Changeset 17830 for misc/runpugs

Show
Ignore:
Timestamp:
09/14/07 12:25:35 (15 months ago)
Author:
azawawi
Message:

[runpugs] client side command history implemented

Location:
misc/runpugs
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • misc/runpugs/htdocs/runpugs/index.html

    r17145 r17830  
    33<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Run Perl 6 Now -- in your browser!</title> 
    44<link rel="stylesheet" type="text/css" href="../runpugs.css"> 
     5<script language="javascript" src="jquery-1.2.min.js"></script> 
    56<script language="JavaScript" src="runpugs.js"></script> 
    67</head> 
  • misc/runpugs/htdocs/runpugs/runpugs.js

    r15027 r17830  
    11var nchars=0; 
    2 var histlist; 
     2var histlist=new Array(); 
    33var histentry=0; 
    44var reply=""; 
     
    6363 
    6464function process_events (keycode) { 
    65 //    document.terminal.mon.value=keycode; 
    6665    if (keycode == 13) { 
    6766        var cmd=document.terminal.cmd.value; 
    68         //cmd.replace(/^.*pugs\>\ /, ""); 
    69         //cmds=cmd.split('pugs> '); 
    70         //cmd=cmds[cmds.length-1]; 
    71         frames['scratch'].document.getElementById("cmd").value=cmd; 
     67       //cmd.replace(/^.*pugs\>\ /, ""); 
     68        var cmds=cmd.split('pugs> '); 
     69        var lastCmd=cmds[cmds.length-1]; 
     70        if($.trim(lastCmd) != "") { 
     71                histlist.push(lastCmd); 
     72        } 
     73        frames['scratch'].document.getElementById("cmd").value=cmd; 
    7274        frames['scratch'].document.terminal.submit();  
    7375        return false; 
     
    9698 
    9799function getreply () { 
    98     //getElementById("scratch") 
    99100    scratchpad=frames['scratch'].document;//.contentDocument; 
    100101    reply=scratchpad.getElementById("cmd").value; 
    101     histlist=scratchpad.terminal.history.options; 
    102102    histentry=histlist.length; 
    103103    sessionid=scratchpad.terminal.sessionid.value; 
    104     //reldev=scratchpad.terminal.reldev.value; 
    105     //histlist.reverse; 
    106104    document.terminal.cmd.value=reply; 
    107105    document.terminal.cmd.focus()  
     
    111109 
    112110function hist_next () { 
    113     if (histentry>1) { 
     111    if (histentry>=1) { 
    114112        histentry-=1; 
    115         document.terminal.cmd.value=reply+histlist[histentry].value; 
     113        document.terminal.cmd.value=reply+histlist[histentry]; 
    116114        document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight;  
    117115    } 
     
    122120    if (histentry<histlist.length-1) { 
    123121        histentry+=1; 
    124         document.terminal.cmd.value=reply+histlist[histentry].value; 
     122        document.terminal.cmd.value=reply+histlist[histentry]; 
    125123        document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight;  
    126124    } 
     
    154152                || (!document.all && evt.target==null) ) )  // Firefox sets the target of the passed event to null. 
    155153        { // The window has been closed.  Submit a logout request to the server. 
    156     var expireSessionUrl='/perl/runpugs3.pl?sessionid='+sessionid+'&reldev=1&ia=1&cmd=%3Aq'; 
     154    var expireSessionUrl='/perl/runpugs.pl?sessionid='+sessionid+'&reldev=1&ia=1&cmd=%3Aq'; 
    157155                var objXMLCloser = null; 
    158156                if ( !document.all && !XMLHttpRequest ) return; 
  • misc/runpugs/perl/runpugs.pl

    r16055 r17830  
    160160     ($replyw=~/^\s*$/) && ($nrows=1); 
    161161    if ($nrows>20) {$nrows=20;} 
    162     my $historylist="\n"; 
    163     for my $entry (@history) { 
    164         my $entryw=HTML::Entities::encode_entities($entry); 
    165         $historylist.='<option value="'.$entryw.'">'.$entryw.'</option>'."\n"; 
    166     } 
    167162    if($replyw!~/Leaving\ pugs\.$/) { 
    168163        $replyw.=$nprompt; 
     
    171166    open(HTML,"<../data/runpugs.html"); 
    172167    while(<HTML>) { 
    173         /_HIST_/ && do { 
    174             $html.=$historylist; 
    175             next; 
    176         }; 
    177168        s/_DEV_/$devc/; 
    178169        s/_REL_/$relc/;