[Slashhack-cvs] slashhack/resources/js/jslib/samples file.xul,NONE,1.1 remotefile.xul,NONE,1.1 socke
Brought to you by:
fletch
|
From: Dave F. <fl...@us...> - 2004-10-21 03:49:26
|
Update of /cvsroot/slashhack/slashhack/resources/js/jslib/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4907/samples Added Files: file.xul remotefile.xul socket.xul test.xul webtop.xul webtop_sample.xul Log Message: Task #106454 - include jslib. --- NEW FILE: socket.xul --- <?xml version="1.0"?> <!DOCTYPE window> <window id="jslib-socket-test" title="jslib Socket Test" style="background-color: #cccccc; width: 500px;" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="initialize();" > <script type="application/x-javascript" src="chrome://slashhack/content/resources/js/jslib/jslib.js" /> <script type="application/x-javascript"> try { // enablePrivilege is required if not running chrome'd // (other tweaks might apply, check out public.mozdev.jslib) netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); include(jslib_socket); } catch( e ) { alert( e ); } var gSocket = new Socket; var hostElement; var portElement; var sendMsg; var socketResults; var statusMsg; function initialize() { hostElement = document.getElementById( "host" ); portElement = document.getElementById( "port" ); sendMsg = document.getElementById( "sendMsg" ); socketResults = document.getElementById( "socketResults" ); statusMsg = document.getElementById( "statusMsg" ); } function closeSocket( theSocket ) { theSocket.close(); statusMsg.value = "socket was closed"; } function openSocket( theSocket ) { if( theSocket.isConnected ) return; var host = hostElement.value; var port = portElement.value; if( theSocket.open( host, port, true ) ) statusMsg.value = "socket was opened...maybe"; else statusMsg.value = "surprise! socket was NOT opened"; } function receiveSocket( theSocket ) { socketData = theSocket.read( theSocket.available() ); socketResults.value = "[" + socketData + "]\nLength: " + socketData.length; } function sendSocket( theSocket ) { theMsg = sendMsg.value; theSocket.write( theMsg ); statusMsg.value = "sent [" + theMsg + "]"; } function testSocket( theSocket ) { availableBytes = theSocket.available(); statusMsg.value = "socket has " + availableBytes + " bytes waiting"; return availableBytes; } </script> <hbox> <vbox flex="1"> <hbox> <label control="host" value="Host:"/> <textbox id="host" value="127.0.0.1" /> </hbox> <hbox> <label control="port" value="Port:"/> <textbox id="port" value="80" /> </hbox> <hbox> <label control="statusMsg" value="Status:"/> <textbox id="statusMsg" value="" flex="1" /> </hbox> <hbox> <label control="sendMsg" value="Send:"/> <textbox id="sendMsg" value="" flex="1" /> </hbox> <hbox> <label control="socketResults" value="Response:"/> <textbox id="socketResults" value="" flex="1" /> </hbox> </vbox> <vbox flex="0" > <spacer flex="1" /> <button label="Open" oncommand="openSocket( gSocket );" /> <button label="Send" oncommand="sendSocket( gSocket );" /> <button label="Receive" oncommand="receiveSocket( gSocket );" /> <button label="Test" oncommand="testSocket( gSocket );" /> <button label="Close" oncommand="closeSocket( gSocket );" /> <spacer flex="1" /> </vbox> </hbox> </window> --- NEW FILE: test.xul --- <?xml version="1.0"?> <!DOCTYPE window> <window id="jslib-test" style="background-color: #cccccc; width: 100px; height: 100px;" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="chrome://slashhack/content/resources/js/jslib/jslib.js" />; <script type="application/x-javascript"> <![CDATA[ /******************************** include (jslib_dir); include (jslib_dirutils); var du = (new DirUtils()).getTmpDir(); var t = new Dir(du); jslibPrint(t.path) var x = t; var y = x.append("test"); jslibPrint(t.path) ****************************/ function test () { /******************************** // a test for windows var d = new Dir("C:\\"); var dirList = d.readDir(); jslibPrint(d.path); jslibPrint(d.exists()); var dirs = new Array(); var files = new Array(); for (var i=0;i<dirList.length;i++) dirList[i].isDir() ? dirs.push(dirList[i]) : files.push(dirList[i]); dirs.sort(); files.sort(); dirList = new Array(); for (i=0;i<dirs.length;i++) dirList.push(dirs[i]); for (i=0;i<files.length;i++) dirList.push(files[i]); for (i=0;i<dirList.length;i++) jslibPrint(dirList[i].path); ********************************/ } ]]> </script> <vbox flex="1" pack="center"> <spacer flex="1" /> <button label="Dir Read" oncommand="alert(window.arguments);" /> <spacer flex="1" /> </vbox> </window> --- NEW FILE: remotefile.xul --- <?xml version="1.0"?> <!DOCTYPE window> <window id="jslib-remotefile-test" style="background-color: #cccccc; width: 200px; height: 100px;" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="chrome://slashhack/content/resources/js/jslib/jslib.js" />; <script type="application/x-javascript"> <![CDATA[ jslibTurnDumpOn(); include (jslib_remotefile); function test () { jslibTurnDumpOn(); var rf = new XMLHttpRequest(); jslibPrint(rf); rf.open("GET", "http://www.mozillazine.org", true); rf.overrideMimeType("text/xml"); function loaded () { jslibPrint("Poll"); if (rf.readyState != 4) return; jslibPrint(rf.responseText); } rf.onreadystatechange = loaded; rf.send(null); /*************** // var url = "http://www.mozilla.org"; var url = "http://downloads.us-east3.mozdev.org/jslib/xpi/jslib_current.xpi"; var rf = new RemoteFile (url); jslibPrint(url+" exists: ["+rf.exists()+"]"); jslibPrint("rf.contentType: ["+rf.contentType+"]"); jslibPrint("rf.nsIURI: ["+rf.nsIURI+"]"); rf.open(); var contents = rf.read(); jslibPrint("********** START CONTENT ************"); jslibPrint(contents); jslibPrint("********** END CONTENT ************"); jslibPrint("["+rf.lastModified+"]"); ****************/ } // jslibTurnDumpOff(); ]]> </script> <vbox flex="1" pack="center"> <spacer flex="1" /> <button label="Test Remote File" oncommand="test();" /> <spacer flex="1" /> <button label="Test GUI" /> <spacer flex="1" /> </vbox> </window> --- NEW FILE: webtop_sample.xul --- <?xml version="1.0"?> <!-- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Mozdev Group, Inc. code. The Initial Developer of the Original Code is Mozdev Group, Inc. Portions created by Mozdev Group, Inc. are Copyright (C) 2003 Mozdev Group, Inc. All Rights Reserved. Original Author: Pete Collins <pe...@mo...> Contributor(s): --> <!-- ***************** STYLE SHEET ****************** --> <!-- <?xml-stylesheet href="chrome://xptk/content/xptk.css" type="text/css"?> --> <!-- ***************** STYLE SHEET ****************** --> <!DOCTYPE window> <window id="webtop-sample" style="background-color: #ffffff;" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="chrome://slashhack/content/resources/js/jslib/jslib.js" /> <script> include (jslib_routines); </script> <toolbox> <toolbar grippyhidden="true"> <label color="black" value="JSLib Web Top" style="margin-left: 10px;" /> <spacer flex="1" /> <button color="black" label="yahoo" oncommand="window.frames[0].location='http://www.yahoo.com';" /> <button color="black" label="google" oncommand="window.frames[0].location='http://www.google.com';" /> <button color="black" label="close" oncommand="close();" /> <button color="black" label="quit" oncommand="quit();" /> </toolbar> </toolbox> <browser id="content" type="content-primary" src="http://jslib.mozdev.org/" flex="1" /> </window> --- NEW FILE: webtop.xul --- <?xml version="1.0"?> <!-- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Mozdev Group, Inc. code. The Initial Developer of the Original Code is Mozdev Group, Inc. Portions created by Mozdev Group, Inc. are Copyright (C) 2003 Mozdev Group, Inc. All Rights Reserved. Original Author: Pete Collins <pe...@mo...> Contributor(s): --> <!-- ***************** STYLE SHEET ****************** --> <!-- <?xml-stylesheet href="chrome://xptk/content/xptk.css" type="text/css"?> --> <!-- ***************** STYLE SHEET ****************** --> <!DOCTYPE window> <window id="webtop mode" style="visibility: collapsed;" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="chrome://slashhack/content/resources/js/jslib/jslib.js" /> <script> include (jslib_window); const URL = 'chrome://slashhack/content/resources/js/jslib/samples/webtop_sample.xul'; var win = new CommonWindow(URL, 640, 480); win.openWebTop(); close(); </script> </window> --- NEW FILE: file.xul --- <?xml version="1.0"?> <!-- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Mozdev Group, Inc. code. The Initial Developer of the Original Code is Mozdev Group, Inc. Portions created by Mozdev Group, Inc. are Copyright (C) 2003 Mozdev Group, Inc. All Rights Reserved. Original Author: Pete Collins <pe...@mo...> Contributor(s): --> <!DOCTYPE window> <window id="file" style="background-color: #cccccc; width: 100px; height: 100px;" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="chrome://slashhack/content/resources/js/jslib/jslib.js" /> <script type="application/x-javascript"> include (jslib_file); // a local file path var localFile = "/tmp/fubar.dat"; var f = new File(localFile); </script> <vbox flex="1" pack="center"> <spacer flex="1" /> <button label="Function List" oncommand="alert(f.help);" /> <button label="exists" oncommand="alert(f.exists());" /> <button label="create file" oncommand="if (!f.exists()) f.create();" /> <spacer flex="1" /> </vbox> </window> |