Changeset 17838 for misc/runpugs

Show
Ignore:
Timestamp:
09/14/07 15:28:27 (15 months ago)
Author:
azawawi
Message:

[runpugs]page load/unload/events is now handled by jquery
[runpugs]page unload sends a :q when page unload is called (browser dependent)
[runpugs]startup script uses port setting from .webtermrc

Location:
misc/runpugs
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • misc/runpugs/bin/termserv.pl

    r16624 r17838  
    1313use Web::Terminal::Server; 
    1414use  Web::Terminal::Settings; 
    15 $Web::Terminal::Settings::port=2059; 
    1615$ENV{PUGS_SAFEMODE}=1; 
    1716my $v=1-$Web::Terminal::Settings::daemon; 
  • misc/runpugs/data/runpugs.html

    r15408 r17838  
    1212<input type="radio" id="rel" value="0" name="reldev" _REL_ > 
    1313<input type="radio" id="dev" value="1" name="reldev" _DEV_ > 
    14 <select name="history" id="hist" > 
    15 <option value="">--- Recent commands ---</option> 
    16 _HIST_ 
    17 </select> 
    1814<textarea id="cmd" name="cmd" rows="20" cols="80"> 
    1915_ALL_ 
  • misc/runpugs/htdocs/runpugs/index.html

    r17830 r17838  
    66<script language="JavaScript" src="runpugs.js"></script> 
    77</head> 
    8 <body onunload="HandleOnUnload(event)"> 
     8<body> 
    99<iframe src="/perl/runpugs.pl" id="scratch" name="scratch" 
    10 style="visibility:hidden" width="700px" height="1px"  onLoad="getreply()"></iframe> 
     10 style="visibility:hidden" width="700px" height="1px"   
     11onLoad="getreply()"></iframe> 
    1112<div id="mainwindow"> 
    1213<h1>Run Perl 6 now -- in your browser!</h1> 
     
    2021<input id="dev" value="1" name="reldev" checked="checked" type="radio" onClick="set_version()"><label for="dev">Development version</label> 
    2122<div id="termwindow"> 
    22 <textarea id="cmd" name="cmd" rows="20" cols="80" wrap="virtual" 
    23 onkeydown="return catch_events(this,event)">Please wait while Pugs starts up...</textarea> 
     23<textarea id="cmd" name="cmd" rows="20" cols="80" wrap="virtual">Please wait while Pugs starts up...</textarea> 
    2424</div> 
    2525</form> 
  • misc/runpugs/htdocs/runpugs/runpugs.js

    r17830 r17838  
    55var sessionid=0; 
    66var reldev=1; 
     7 
     8$(window).unload(function() { 
     9        //send :q to pugs on onload 
     10        $.ajax({ 
     11                url: '/perl/runpugs.pl?sessionid='+sessionid+'&reldev=1&ia=1&cmd=%3Aq', 
     12                async: false 
     13        });                 
     14}); 
     15$(document).ready( function() { 
     16        //document is ready now... 
     17        $('#cmd').keydown(function(event) { 
     18                return process_events(event.keyCode); 
     19        }); 
     20}); 
     21 
     22 
     23 
     24 
    725function getnchars() { 
    826    return document.terminal.cmd.value.length 
     
    4159        } 
    4260} 
    43  
    44 function catch_events(myfield,e) { 
    45     var keycode; 
    46     if (e) { 
    47         keycode = e.which; 
    48         if(keycode) { 
    49         return process_events(keycode); 
    50         } else { 
    51           if (window.event) {      
    52             keycode = window.event.keyCode; 
    53             if(keycode) { 
    54                 return process_events(keycode); 
    55             } else { 
    56                 return true; 
    57             } 
    58         } 
    59     } 
    60 } 
    61 } 
    62  
    6361 
    6462function process_events (keycode) { 
     
    137135} 
    138136 
    139 /* 
    140 <textarea id="cmd" name="cmd" rows="20" cols="80" wrap="virtual" onkeydown="return catch_events(this,event)" > 
    141 Please wait while Pugs starts up... 
    142 </textarea> 
    143 */ 
    144  
    145 /* Courtesy of diakopter */ 
    146 //WV01012007: But it does not send a ':q' on close.  
    147 //in fact, it looks like the handler is completely ignored. 
    148 function HandleOnUnload(evt) 
    149 { 
    150         if ( (navigator.userAgent.toUpperCase().indexOf( "SAFARI" ) == -1) &&  // Exclude Safari. 
    151         ( (document.all && window.screenLeft >= 10004)   // IE moves the window 10000 pixels to the right while closing it 
    152                 || (!document.all && evt.target==null) ) )  // Firefox sets the target of the passed event to null. 
    153         { // The window has been closed.  Submit a logout request to the server. 
    154     var expireSessionUrl='/perl/runpugs.pl?sessionid='+sessionid+'&reldev=1&ia=1&cmd=%3Aq'; 
    155                 var objXMLCloser = null; 
    156                 if ( !document.all && !XMLHttpRequest ) return; 
    157                 if ( document.all ) { objXMLCloser = new ActiveXObject( "Microsoft.XMLHTTP" ) } 
    158                 else if ( XMLHttpRequest ) { objXMLCloser = new XMLHttpRequest(); } 
    159                 if (objXMLCloser) { objXMLCloser.open( 'GET', expireSessionUrl, false ); objXMLCloser.send( null ); } 
    160         } 
    161 } 
    162  
    163 /* usage:  
    164  
    165 This will work in any server-language environment that maintains session state on the server with timeouts.  This will help prevent large accumulation of sessions in memory on the servers. 
    166  
    167 You need to include the javascript file above. 
    168  
    169 Usage: on the page where you want to trap the window close event, add the following to the body tag as follows:  
    170 <body onunload="HandleOnUnload(event)"> 
    171  
    172 */