Changeset 17861 for misc/runpugs
- Timestamp:
- 09/15/07 20:30:01 (14 months ago)
- Location:
- misc/runpugs/htdocs
- Files:
-
- 3 modified
-
runpugs.css (modified) (9 diffs)
-
runpugs/index.html (modified) (1 diff)
-
runpugs/runpugs.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
misc/runpugs/htdocs/runpugs.css
r17827 r17861 1 BODY {width:100%;margin-left:10%;margin-right:10%; margin-top: 10px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12pt; line-height: normal; background-color:#FFFFFF;} 2 H1 {font-size: 24pt; 1 body { 2 font:14px arial,helvetica,clean,sans-serif; 3 width:100%; 4 margin-left:10%;margin-right:10%; margin-top: 0px; 5 line-height: normal; 6 } 7 H1 { 8 width: 100%; 9 font-size: 24pt; 3 10 font-family: Georgia, Serif, Times; 4 11 font-weight: normal; 5 12 color: white; 6 13 background-color: #204a87; 7 padding: 15px; 8 } 9 H2 { font-weight: bold; font-size: 12pt} 10 11 EM {font-weight: bold; 12 font-style: normal; 13 text-decoration:none;} 14 TT {color: #204a87; 15 font-weight: bold; 16 } 17 14 margin: 5px; 15 padding: 5px; 16 } 17 H2 { font-weight: bold; font-size: 11pt} 18 EM { font-weight: bold; font-style: normal; text-decoration:none;} 19 TT {color: #204a87; font-weight: bold; } 18 20 LABEL {font-weight: normal; } 19 21 FIELDSET {border: solid white 0px} 20 22 LEGEND {font-weight:normal; text-align: left; } 21 23 22 /*23 DL {24 }25 26 DT {27 display:block;28 float: left;29 width: 10ex;30 }31 32 DD {33 display:block ;34 float: left;35 }36 */37 38 24 .copyright {font-size: 9pt} 39 .warning {40 border: solid 2px #204a87;41 padding: 5px;42 }43 25 .tabon { 44 26 font-weight:bold; … … 47 29 padding: 2px; 48 30 padding-bottom: 0px; 49 margin-top: 10px;31 margin-top: 0px; 50 32 51 33 } … … 53 35 font-weight:bold; 54 36 background-color: #c2c2c0; 55 color: gray;37 color: gray; 56 38 border: solid 2px #204a87; 57 39 padding: 2px; 58 40 padding-bottom: 0px; 59 margin-top: 10px;41 margin-top: 0px; 60 42 } 61 43 #mainwindow { 62 width: 85ex; /*750px */ 63 } 64 #hist { 65 width: 100%; /*750px; */ 66 font-family: "Andale Mono", courier, fixed, monospace; 67 font-weight: normal; 68 font-size: 10pt; 69 color: #204a87; 70 border: solid 0px #204a87; 71 background-color: #f2f2f0; 72 padding-bottom: 5px; 44 width:80%; 73 45 } 74 46 .term { … … 80 52 height:40ex; 81 53 } 82 #editorwindow {83 height: 50ex; /*400px;*/84 }85 86 54 #termwindow { 87 height: 45ex; /*400px;*/ 55 height: 100px; 56 display:none; 88 57 background-color: #f2f2f0; 89 58 border: solid 2px #204a87; … … 94 63 font-size: 11pt; 95 64 font-weight: bold; 96 line-height: 1 2pt;65 line-height: 11pt; 97 66 color: #204a87; 98 67 background-color: #f2f2f0; 99 /* border: solid 0px #f2f2f0;*/100 68 } 101 69 .termfont { … … 103 71 font-size: 11pt; 104 72 font-weight: normal; 105 line-height: 1 2pt;73 line-height: 11pt; 106 74 color: #204a87; 107 75 background-color: #f2f2f0; 108 /* border: solid 0px #f2f2f0;*/109 }110 #cmdline {111 width: 90%; /* sadly, Safari would need 92% */112 font-family: "Andale Mono", courier, fixed, monospace;113 font-size: 11pt;114 font-weight: normal;115 line-height: 12pt;116 color: #204a87;117 background-color: #f2f2f0;118 border: solid 0px #f2f2f0;119 76 } 120 77 #output,#script { … … 123 80 font-size: 11pt; 124 81 font-weight: normal; 125 line-height: 1 2pt;82 line-height: 11pt; 126 83 color: #204a87; 127 84 background-color: #f2f2f0; … … 135 92 font-size: 11pt; 136 93 font-weight: normal; 137 line-height: 1 2pt;94 line-height: 11pt; 138 95 color: #204a87; 139 96 background-color: #f2f2f0; 140 97 border: solid 0px #f2f2f0; 141 /* border: solid 2px #204a87;142 padding: 5px;*/143 98 } 144 /* Linkdefinities */145 99 A:link, A.bold:link { text-decoration: underline; color: #660066} 146 100 A:active, A.bold:active { text-decoration: underline; color: #6699FF} … … 148 102 A:hover, A.bold:hover { text-decoration: underline; color: #000099} 149 103 A.taboff:link, A.taboff:active,A.taboff:visited {text-decoration: none; color: #333333} 104 .cc { 105 font-family: 'Courier New', Monaco, Courier, monospace; 106 font-size: 11px; 107 color: white; 108 background-color: black; 109 padding: 5px; 110 width:100%; 111 line-height:1em; 112 height:24em; 113 overflow: auto; 114 border: 1px solid white; 115 } 116 pre { 117 color: white; 118 background-color: black; 119 margin: 0; 120 padding: 0; 121 border: none; 122 display:inline; 123 } 124 pre.wb_theme { 125 color: white; 126 background-color: black; 127 margin: 0; 128 padding: 0; 129 border: none; 130 display:inline; 131 } 132 pre.gb_theme { 133 color: rgb(0,255,0); 134 background-color: black; 135 margin: 0; 136 padding: 0; 137 border: none; 138 display:inline; 139 } 140 pre.ab_theme { 141 color: rgb(255,140,0); 142 background-color: black; 143 margin: 0; 144 padding: 0; 145 border: none; 146 display:inline; 147 } 148 .note { 149 border-style: solid; 150 border-width: 1px; 151 border-color: #F0C000; 152 background-color: #FFFFCE; 153 } 154 span.cursorOn { 155 font-family: 'Courier New', Monaco, Courier, monospace; 156 font-size: 11px; 157 display:inline; 158 background: white; 159 color: white; 160 border:none; 161 } 162 span.cursorOff { 163 font-family: 'Courier New', Monaco, Courier, monospace; 164 font-size: 11px; 165 display:inline; 166 background: black; 167 color: black; 168 border:none; 169 } -
misc/runpugs/htdocs/runpugs/index.html
r17838 r17861 1 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 <html lang="en"><head> 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Run Perl 6 Now -- in your browser!</title> 4 <link rel="stylesheet" type="text/css" href="../runpugs.css"> 5 <script language="javascript" src="jquery-1.2.min.js"></script> 6 <script language="JavaScript" src="runpugs.js"></script> 7 </head> 8 <body> 9 <iframe src="/perl/runpugs.pl" id="scratch" name="scratch" 10 style="visibility:hidden" width="700px" height="1px" 11 onLoad="getreply()"></iframe> 12 <div id="mainwindow"> 13 <h1>Run Perl 6 now -- in your browser!</h1> 14 <form id="term" name="terminal" action="" method="post"> 15 <input name="prompt" value=" " type="hidden"> 16 <input name="sessionid" value="" type="hidden"> 17 <input name="ia" value="1" type="hidden"> 18 <input name="action" value="runpugs" type="hidden"> 19 <input id="rel" value="0" name="reldev" type="radio" 20 onClick="set_version()"><label for="rel">Release version</label> 21 <input id="dev" value="1" name="reldev" checked="checked" type="radio" onClick="set_version()"><label for="dev">Development version</label> 22 <div id="termwindow"> 23 <textarea id="cmd" name="cmd" rows="20" cols="80" wrap="virtual">Please wait while Pugs starts up...</textarea> 24 </div> 25 </form> 26 <script language="JavaScript"> 27 document.terminal.cmd.focus() // _SKIPC_ 28 document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight; // _SKIPC_ 29 nchars=document.terminal.cmd.value.length; 30 </script> 31 <p>This live web terminal runs the <a href="http://www.pugscode.org/">Pugs</a> 32 interpreter for <a href="http://dev.perl.org/perl6/">Perl 6</a>. 33 <!--<p>This is the development version, featuring asynchronous JavaScript, 34 mod_perl and preloaded pugs sessions.</p>--> 35 Please <a href="http://feather.perl6.nl/%7Eandara/runpugs/">read the documentation</a>. 36 </p> 37 <p class="copyright">© Copyright 2006 by Wim.Vanderbauwhede. Contact me @ gmail.com<./p> 38 </div> 39 </body></html> 2 <html lang="en"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <title>Run Perl 6 Now -- in your browser!</title> 6 <link rel="stylesheet" type="text/css" href="../runpugs.css"> 7 <script language="javascript" src="jquery-1.2.min.js"></script> 8 <script language="JavaScript" src="runpugs.js"></script> 9 </head> 10 <body> 11 <iframe src="/perl/runpugs.pl" id="scratch" name="scratch" style="visibility:hidden" 12 width="700px" height="1px" onLoad="getreply()"></iframe> 13 <div id="mainwindow"> 14 <h1 id="logo" style="display:none;"><center>Run Perl 6 now -- in your browser!</center></h1> 15 <strong>Terminal:</strong> 16 <select id="theme"> 17 <option value="wb_theme" selected="selected">White & black</option> 18 <option value="gb_theme">Green</option> 19 <option value="ab_theme">Amber</option> 20 </select> 21 <form id="term" name="terminal" action="" method="post"> 22 <input name="prompt" value=" " type="hidden"> 23 <input name="sessionid" value="" type="hidden"> 24 <input name="ia" value="1" type="hidden"> 25 <input name="action" value="runpugs" type="hidden"> 26 <input id="rel" value="1" name="reldev" type="radio" checked="checked" onClick="set_version()"> 27 <label for="rel"><strong>Release version</strong></label> 28 <input id="dev" value="1" name="reldev" type="radio" onClick="set_version()"> 29 <label for="dev"><strong>Development version</strong></label> 30 <div id="termwindow"> 31 <textarea id="cmd" name="cmd" rows="3" cols="80" wrap="virtual">Please wait while Pugs 32 starts up...</textarea> 33 </div> 34 <div id="termwin" class='cc'> 35 <table id='tt' cellspacing='0' cellpadding='0' border='0' width='100%'> 36 </table> 37 </div> 38 </form> 39 <!--<script language="JavaScript"> 40 //document.terminal.cmd.focus() // _SKIPC_ 41 // document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight; // _SKIPC_ 42 //nchars=document.terminal.cmd.value.length; 43 </script> 44 --> 45 <div class='note' style='padding: 5px'> 46 <p>This live web terminal runs the <a href="http://www.pugscode.org/">Pugs</a> 47 interpreter for <a href="http://dev.perl.org/perl6/">Perl 6</a>. 48 This is the development version, featuring asynchronous jQuery AJAX, 49 mod_perl and preloaded pugs sessions.</p> 50 </p> 51 <h2>Instructions</h2> 52 <p><code>runpugs</code> presents the pugs interactive shell. Only 53 the line typed at the last prompt is sent to pugs.</p> 54 <p><code>runpugs</code>-specific commands:</p> 55 <dl> 56 <dt><code>help</code></dt><dd> displays the Pugs shell help (same as 57 <code>:h</code>)</dd><br> 58 <dt><code>clear</code></dt><dd>clears the web terminal (this command is not sent to the 59 pugs shell).</dd><br> 60 <dt><code>quit</code>, <code>bye</code></dt><dd>quit the Pugs session (same as 61 <code>:q</code>)</dd><br> 62 </dl> 63 <p>Please be considerate and do <em>quit</em> your 64 pugs session before you close the browser window. 65 </p> 66 <h2>Restrictions</h2> 67 <p>Because this is a web terminal, a number of restrictions apply. 68 Please <a href="http://feather.perl6.nl/%7Eandara/runpugs/">read the documentation</a> for more information. 69 70 <p class="copyright">© Copyright 2006 by Wim.Vanderbauwhede. Contact me @ gmail.com</p> 71 </div> 72 </div> 73 </body> 74 </html> -
misc/runpugs/htdocs/runpugs/runpugs.js
r17838 r17861 1 var nchars=0;2 1 var histlist=new Array(); 3 2 var histentry=0; 4 3 var reply=""; 5 4 var sessionid=0; 6 var reldev=1; 5 var reldev=0; 6 7 var curpos=0; 8 var cmd = ""; 9 var prompt = "pugs> "; 10 var cmds = new Array(); 11 var theme = "wb_theme"; 7 12 8 13 $(window).unload(function() { 9 14 //send :q to pugs on onload 10 15 $.ajax({ 11 url: '/perl/runpugs.pl?sessionid='+sessionid+'&reldev=1&ia=1&cmd=%3Aq', 12 async: false 13 }); 16 url: "/perl/runpugs.pl?" + "sessionid=" + sessionid + 17 "&reldev=1&ia=1&cmd=%3Aq", 18 async: true 19 }); 14 20 }); 21 22 function showCursor() { 23 var cursorEl = "#d" + (cmds.length - 1); 24 $(cursorEl).toggleClass('cursorOff'); 25 $(cursorEl).toggleClass('cursorOn'); 26 setTimeout('showCursor()',1000); 27 } 28 29 function updateConsole() { 30 $("#tt").empty(); 31 $.each(cmds,function(i,n) { 32 var l = (n == "") ? " " : n; 33 $("#tt").append( 34 "<tr><td><pre id='c" + i + "' class='"+ theme +"'>" + 35 l + "</pre><span id='d" + i + 36 "' class='cursorOff'> </span></td></tr>" 37 ); 38 }); 39 var lastId = (cmds.length - 1); 40 var cmdEl = "#c" + lastId; 41 var cursorEl = "#d" + lastId; 42 43 var scrollHeight = $("#termwin")[0].scrollHeight; 44 $("#termwin").animate({ scrollTop: scrollHeight }, "fast") 45 } 46 15 47 $(document).ready( function() { 16 48 //document is ready now... 17 $('#cmd').keydown(function(event) { 18 return process_events(event.keyCode); 19 }); 49 $("#tt").empty(); 50 $("#tt").append("<tr><td><pre id='c0' class='wb_theme'>" + 51 "Please wait while Pugs starts up...</pre>"+ 52 "<span class='cursor'> </span></td></tr>"); 53 54 $("#theme").change(function() { 55 $("pre").toggleClass(theme); 56 theme = $("#theme").val(); 57 $("pre").toggleClass(theme); 58 }); 59 $("#logo").slideDown(2000); 60 61 showCursor(); 20 62 }); 21 63 … … 23 65 24 66 25 function getnchars() {26 return document.terminal.cmd.value.length27 }28 67 29 function getcursorpos() { 30 var obj=document.terminal.cmd; 31 if(document.selection) { 32 obj.focus(); 33 var rng=document.selection.createRange(); 34 rng.moveStart('textedit',-1); 35 // rng.moveEnd('character',getnchars()); 36 return rng.text.length; 37 } else if(obj.selectionStart) { // FireFox 38 var start = obj.selectionStart; 39 var end = obj.selectionEnd; 40 if (start<=end) { 41 return start; 42 } else { 43 return end; 44 } 45 } 46 } 68 $(document).keydown(function(event) { 69 var keyCode = event.keyCode; 70 var cmdEl = "#c" + (cmds.length - 1); 47 71 48 function setcursorpos() { 49 var obj=document.terminal.cmd; 50 if(document.selection) { 51 obj.focus(); 52 var rng=document.selection.createRange(); 53 rng.moveStart('character',0); 54 rng.moveEnd('textedit'); 55 // rng.select(); 56 } else if(obj.selectionStart>=0) { // FireFox 57 obj.selectionStart=nchars; 58 obj.selectionEnd=nchars; 59 } 60 } 72 var scrollHeight = $("#termwin")[0].scrollHeight; 73 $("#termwin").animate({ scrollTop: scrollHeight }, "fast"); 61 74 62 function process_events (keycode) { 63 if (keycode == 13) { 64 var cmd=document.terminal.cmd.value; 65 //cmd.replace(/^.*pugs\>\ /, ""); 66 var cmds=cmd.split('pugs> '); 67 var lastCmd=cmds[cmds.length-1]; 68 if($.trim(lastCmd) != "") { 69 histlist.push(lastCmd); 70 } 71 frames['scratch'].document.getElementById("cmd").value=cmd; 75 if(keyCode == 13) { 76 //enter 77 var sessCmds=document.terminal.cmd.value + "\n" + prompt + cmd; 78 var tmpCmds=sessCmds.split('pugs> '); 79 var tmpCmd=tmpCmds[tmpCmds.length-1]; 80 if($.trim(tmpCmd) != "") { 81 histlist.push(tmpCmd); 82 } 83 frames['scratch'].document.getElementById("cmd").value=sessCmds; 72 84 frames['scratch'].document.terminal.submit(); 85 cmd = ""; 73 86 return false; 74 } else if (keycode==38) { 87 } else if(keyCode == 8) { 88 //backspace 89 if(curpos > 0) { 90 curpos -=1 91 cmd = cmd.substring(0,cmd.length-1); 92 $(cmdEl).text(prompt + cmd); 93 } 94 return false; 95 } else if(keyCode == 38) { 96 //up 75 97 hist_next(); 76 setcursorpos();98 77 99 return false; 78 } else if (keycode==40) { 100 } else if(keyCode == 40) { 101 //down 79 102 hist_prev(); 103 $(cmdEl).text(prompt + cmd); 80 104 return false; 81 } else if ((keycode==8)||(keycode==37)||(keycode==46)) { 82 if ((getnchars()>nchars) && (getcursorpos() > nchars)) { 83 return true; 84 } else { 85 setcursorpos(); 86 return false; 105 } /*else if(keyCode == 37) { 106 //left 107 $("#status").text("left not implemented"); 108 return false; 109 } else if(keyCode == 39) { 110 //right 111 $("#status").text("right not implemented"); 112 return false; 113 } else if(keyCode == 36) { 114 //home 115 //curpos = 0; 116 $("#status").text("home not implemented"); 117 return false; 118 119 } else if(keyCode == 35) { 120 //end 121 $("#status").text("end not implemented"); 122 return false; 123 124 } */ 125 126 return true; 127 }); 128 $(document).keypress(function(event) { 129 130 var scrollHeight = $("#termwin")[0].scrollHeight; 131 $("#termwin").animate({ scrollTop: scrollHeight }, "fast"); 132 133 var keyCode = event.keyCode; 134 var cmdEl = "#c" + (cmds.length - 1); 135 if($.browser.msie || $.browser.opera) { 136 var key = String.fromCharCode(keyCode); 137 if(key >= ' ') { 138 if(($.browser.opera && (keyCode < 35 || keyCode > 40)) || $.browser.msie) { 139 cmd += key; 140 $(cmdEl).text(prompt + cmd); 141 curpos++; 142 } 87 143 } 88 } else {89 if(keycode) {90 return true;91 } else {92 144 return false; 93 } 145 }else if($.browser.mozilla && keyCode == 0) { 146 var key = String.fromCharCode(event.charCode ? event.charCode : event.keyCode); 147 cmd += key; 148 $(cmdEl).text(prompt + cmd); 149 curpos++; 150 return false; 94 151 } 95 } 152 return true; 153 }); 154 96 155 97 156 function getreply () { 98 scratchpad=frames['scratch'].document; //.contentDocument;157 scratchpad=frames['scratch'].document; 99 158 reply=scratchpad.getElementById("cmd").value; 100 159 histentry=histlist.length; 101 160 sessionid=scratchpad.terminal.sessionid.value; 102 161 document.terminal.cmd.value=reply; 103 document.terminal.cmd.focus() 104 document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight;105 nchars=document.terminal.cmd.value.length;162 163 cmds = reply.replace(/ /g,' ').split(/\r\n|\n|\r/g); 164 updateConsole(); 106 165 } 107 166 108 167 function hist_next () { 109 168 if (histentry>=1) { 110 histentry-=1; 111 document.terminal.cmd.value=reply+histlist[histentry]; 112 document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight; 169 histentry--; 170 cmd=histlist[histentry]; 171 curpos=cmd.length; 172 var cmdEl = "#c" + (cmds.length - 1); 173 $(cmdEl).text(prompt + cmd); 113 174 } 114 175 return false; … … 117 178 function hist_prev () { 118 179 if (histentry<histlist.length-1) { 119 histentry+=1; 120 document.terminal.cmd.value=reply+histlist[histentry]; 121 document.terminal.cmd.scrollTop =document.terminal.cmd.scrollHeight; 180 histentry++; 181 cmd=histlist[histentry]; 182 curpos=cmd.length; 183 var cmdEl = "#c" + (cmds.length - 1); 184 $(cmdEl).text(prompt + cmd); 122 185 } 123 186 }
