Staredit Network

Staredit Network -> Computers and Technical -> XUL and Javascript
Report, edit, etc...Posted by Doodle77(MM) on 2006-03-03 at 18:03:23
I am writing a battle.net client in XUL+Javascript+XPCOM, but I am having a problem. look at my code:
XUL:
CODE
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window
   id="findfile-window"
   title="Bnetchat"
   orient="vertical"
   xmlns:html="http://www.w3.org/1999/xhtml"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   onload="login('ub','ug');">
   <script src="bnetchat.js">
   function talk(whattosay) {}
   function login(username,password) {}
   </script>
   <textbox id="chat-area" disabled="true" multiline="true" flex="40" class="cha"/>
   <hbox>
   <textbox id="say-area" flex="1"/>
   <button id="say-button" label="Say!" keycode="VK_ENTER" oncommand="talk(document.getElementById('say-area').value);"/>
   </hbox>
</window>
JS:
CODE

function login(username,password)
{
 var listener = {
   finished : function(data){
     //document.getElementById('chat-area').value = data;
     alert(data);
   }
 }
 readAllFromSocket("useast.battle.net",6112,"\x03"+username+"\r\n\x03"+password+"\r\n",listener,username,password);
 //document.getElementById('say-button').disabled = false
 //document.getElementById('say-area').disabled = false
 // happy.gifhappy.gif Question #1
}
function talk(whattosay) {
 outstream.write(whattosay,whattosay.length);
}

function readAllFromSocket(host,port,outputData,listener)
{
 try {
   var transportService =
     Components.classes["@mozilla.org/network/socket-transport-service;1"]
       .getService(Components.interfaces.nsISocketTransportService);
   var transport = transportService.createTransport(null,0,host,port,null);

   var outstream = transport.openOutputStream(0,0,0);
   outstream.write(outputData,outputData.length);
   var stream = transport.openInputStream(0,0,0);
   var instream = Components.classes["@mozilla.org/scriptableinputstream;1"]
     .createInstance(Components.interfaces.nsIScriptableInputStream);
   instream.init(stream);

   var dataListener = {
     data : "",
     onStartRequest: function(request, context){},
     onStopRequest: function(request, context, status){},
     onDataAvailable: function(request, context, inputStream, offset, count){
       this.data += instream.read(count);
       listener.finished(this.data);
     },
   };

   var pump = Components.
     classes["@mozilla.org/network/input-stream-pump;1"].
       createInstance(Components.interfaces.nsIInputStreamPump);
   pump.init(stream, -1, -1, 0, 0, false);
   pump.asyncRead(dataListener,null);
 } catch (ex){
   return ex;
 }
}

Question #1: How do I disable and enable the button and textbox with javascript.
Question #2: Login doesnt work right now for some reason, it works in an html thing i made.
Report, edit, etc...Posted by O)FaRTy1billion on 2006-03-03 at 23:46:03
say-button.disabled = false; (or true or whatever)
say-area.disabled = false; (or true or whatever)
unless it is randomly different than normal, that should work.
Report, edit, etc...Posted by Doodle77(MM) on 2006-03-05 at 11:46:54
whatever, now I'm using iframes because that way I can scroll them.
Report, edit, etc...Posted by RexyRex on 2006-03-05 at 16:13:09
W3C doesn't like that.
Report, edit, etc...Posted by Doodle77(MM) on 2006-03-06 at 15:51:00
I only test if firefox likes my code, and IE and Konqueror and Safari if its not XUL.
Next Page (1)