All pastes #761624 Raw Edit

Untitled

public text v1 · immutable
·published 2007-11-05 00:32 UTC
rendered paste body
<html>

<head>

  <title>Javascript Hub</title>

  <script type='text/javascript'>

function HUB(author, game) {
    this.author=author;
    this.game=game;
    this.ajaxObj=null;
}

HUB.prototype.HUB_createAjaxObj=HUB_createAjaxObj;
HUB.prototype.HUB_readHub=HUB_readHub;
HUB.prototype.HUB_gotHub=HUB_gotHub;

function HUB_createAjaxObj() {
    try {
        f=this.HUB_gotHub;
        with(this) {
            if(window.XMLHttpRequest) {
                this.xmlObj=new XMLHttpRequest();
            } else if(window.ActiveXObject) {
                this.xmlObj=new ActiveXObject("Microsoft.XMLHTTP");
            }
            //this.xmlObj.onreadystatechange=f;
        }
    } catch(error) {
        alert('HUB_createAjaxObj: '+error);
    }
}

function HUB_readHub() {
    try {
        with(this) {
            this.xmlObj.open('GET', 'http://games.byond.com/hub/'+author+'/'+game+';format=text', true);
            this.xmlObj.send('');
        }
    } catch(error) {
        alert('HUB_readHub: '+error);
    }
}

function HUB_gotHub() {
    //try {
        with(this) {
            if(this.xmlObj.readystate!=4) {
            } else {
                data=this.xmlObj.responseText;
                alert(data);
                return 1;
            }
        }
    //} catch(error) {
    //    alert(error);
    //}
}

function HUB_getHub(hubObj) {
    data=hubObj.HUB_gotHub();
    if(!data) {
        setTimeout('HUB_getHub(hubObj)', 1);
    }
}


function HUB_gotHubRetry(hubObj){
    setTimeout('hubObj.HUB_gotHub()', 100);
}

function test(){
    hub=new HUB('EviOfAu','Chat');
    hub.HUB_createAjaxObj();
    hub.HUB_readHub();
    HUB_getHub(hub);
}
  </script>
  
</head>

<body>

<button onclick='test();'>Test</button>

</body>

</html>