| 1 | | var debug=0;var histlist=new Array();var histentry=0;var sessionid=0;var reldev=0;var curpos=0;var cmd="";var prompt="pugs> ";var cmds=new Array();var theme="wb_theme";var fixedCharWidth;function showCursor(){var A=cmds.length;var B=(A==0)?"#d0":"#d"+(A-1);$(B).toggleClass("cursorOff");$(B).toggleClass("cursorOn");setTimeout("showCursor()",1000)}function moveCursor(){var B=-(cmd.length-curpos)*fixedCharWidth;var A="#d"+(cmds.length-1);$(A).css("left",B+"px")}function showCmd(){var A="#c"+(cmds.length-1);$(A).text(prompt+cmd)}function updateConsole(){$.each(cmds,function(C,E){if(C==0){$("#tt").empty()}var B=(E=="")?" ":E;var D="<tr><td><pre id='c"+C+"' class='"+theme+"'>"+B+"</pre>";if(C==cmds.length-1){D+="<span id='d"+C+"' class='cursorOff'> </span>"}$("#tt").append(D+"</td></tr>")});var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}$(document).ready(function(){var A="Please wait while Pugs starts up...";$("#tt").empty();$("#tt").append("<tr><td><pre id='c0' class='wb_theme'>"+A+"</pre><span id='d0' class='cursorOff'> </span></td></tr>");fixedCharWidth=($("#c0")[0])?$("#c0")[0].offsetWidth/A.length:8;$("#theme").change(function(){$("pre").toggleClass(theme);theme=$("#theme").val();$("pre").toggleClass(theme)});$("#logo").slideDown(2000);showCursor();$(document).keydown(function(B){return onKeyDown(B)});$(document).keypress(function(B){return onKeyPress(B)});$(window).unload(function(){$.ajax({url:"/perl/runpugs.pl?sessionid="+sessionid+"&reldev=1&ia=1&cmd=%3Aq",async:true})});$("#hidden_iframe").append("<iframe src=\"/perl/runpugs.pl\" id=\"scratch\" name=\"scratch\" style=\"visibility:hidden\" width=\"700px\" height=\"1px\" onLoad=\"getreply()\"></iframe>")});function insert(D,C,E){var B=D.substring(0,E);var A=D.substring(E,D.length);return B+C+A}function focusOnCmd(B){$(B).focus();var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}function onKeyDown(D){if(D.ctrlKey||D.altKey||D.shiftKey){return true}var E=D.keyCode;focusOnCmd("#status");if(E==13){var B=document.terminal.cmd.value+cmd;var G=B.split(prompt);var F=G[G.length-1];if($.trim(F)!=""){histlist.push(F)}if(debug){alert("data to be sent: "+B)}frames["scratch"].document.getElementById("cmd").value=B;frames["scratch"].document.terminal.submit();cmd="";return false}else{if(E==8){if(curpos>0){curpos-=1;var A="";for(var C=0;C<cmd.length;C++){if(C!=curpos){A+=cmd.charAt(C)}}cmd=A;showCmd();debugKeys()}return false}else{if(E==38){hist_next();return false}else{if(E==40){hist_prev();return false}else{if(E==37){if(curpos>0){curpos--;moveCursor()}return false}else{if(E==39){if(curpos<cmd.length){curpos++;moveCursor()}return false}else{if(E==36){curpos=0;moveCursor();return false}else{if(E==35){curpos=cmd.length;moveCursor();return false}else{if(E==46){if(curpos>=0){var A="";for(var C=0;C<cmd.length;C++){if(C!=curpos){A+=cmd.charAt(C)}}cmd=A;showCmd();moveCursor();debugKeys()}return false}}}}}}}}}return true}function toAscii(C){var D="abcdefghijklmnopqrstuvwxyz";var B=" !\"#$%&'()*+'-./0123456789:;<=>?@"+D.toUpperCase()+"[\\]^_`"+D+"{|}~";var E=B.indexOf(C);var A=(E>-1)?(32+E):0;return A}function onKeyPress(B){if(B.ctrlKey||B.altKey){return }var C=B.keyCode;focusOnCmd("#status");if($.browser.msie||$.browser.opera||$.browser.safari){var A=String.fromCharCode(C);if(A>=" "){if(($.browser.opera&&(C<35||C>40))||$.browser.msie||$.browser.safari){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}}return false}else{if($.browser.mozilla&&C==0){var A=String.fromCharCode(B.charCode?B.charCode:B.keyCode);if(A>=" "){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}return false}}return true}function debugKeys(C){if(debug){var A="";for(var B=0;B<cmd.length;B++){var D=toAscii(cmd.charAt(B));A+=D+","}$("#status").text(((C)?("key = '"+C):"")+"', cmd = '"+cmd+"', cmd.length="+cmd.length+", ascii=("+A+")")}}function getreply(){scratchpad=frames["scratch"].document;var B=scratchpad.getElementById("cmd").value;histentry=histlist.length;sessionid=scratchpad.terminal.sessionid.value;document.terminal.cmd.value=B;if(scratchpad.terminal.prompt){var C=scratchpad.terminal.prompt.value;if(C&&C.length=="pugs> ".length){prompt=C}}var A=B.replace(/&/g,"&").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");cmds=A.split(/\r\n|\n|\r/g);if(debug){alert("reply (unescaped): "+B)}updateConsole();cmd="";curpos=0;showCmd()}function hist_next(){if(histentry>=1){histentry--;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}return false}function hist_prev(){if(histentry<histlist.length-1){histentry++;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}}function set_version(){var A=document.terminal.reldev[0].checked;if(A==true){frames["scratch"].document.terminal.reldev[0].checked=true;frames["scratch"].document.terminal.reldev[1].checked=false}else{frames["scratch"].document.terminal.reldev[0].checked=false;frames["scratch"].document.terminal.reldev[1].checked=true}frames["scratch"].document.terminal.submit();$("#rel").blur();$("#dev").blur();focusOnCmd("#tt")} |
| | 1 | var debug=0;var histlist=new Array();var histentry=0;var sessionid=0;var reldev=0;var curpos=0;var cmd="";var prompt="pugs> ";var cmds=new Array();var theme="wb_theme";var fixedCharWidth;var tutorialMode=0;var slide=0;var FIRST_TUTORIAL_SLIDE=2;var slides=new Array("default_info.html","../p6_syntax_highlite/syntax_hilite.html","tutorial/01_helloworld.html","tutorial/02_vars.html","tutorial/03_iteration_array.html","tutorial/04_iteration_hash.html","tutorial/05_iteration_many.html","tutorial/06_conditionals.html","tutorial/07_junctions.html","tutorial/08_junctions_array.html","tutorial/09_chained_comparison.html","tutorial/10_io.html","tutorial/11_io_iteration.html","tutorial/12_io_reading.html","tutorial/13_lists_reduction.html","tutorial/14_lists_hyper.html","tutorial/15_lists_cross.html","tutorial/16_grammar.html","tutorial/17_final.html");function showCursor(){var A=cmds.length;var B=(A==0)?"#d0":"#d"+(A-1);$(B).toggleClass("cursorOff");$(B).toggleClass("cursorOn");setTimeout("showCursor()",1000)}function moveCursor(){var B=-(cmd.length-curpos)*fixedCharWidth;var A="#d"+(cmds.length-1);$(A).css("left",B+"px")}function showCmd(){var A="#c"+(cmds.length-1);$(A).text(prompt+cmd)}function updateConsole(){$.each(cmds,function(C,E){if(C==0){$("#tt").empty()}var B=(E=="")?" ":E;var D="<tr><td><pre id='c"+C+"' class='"+theme+"'>"+B+"</pre>";if(C==cmds.length-1){D+="<span id='d"+C+"' class='cursorOff'> </span>"}$("#tt").append(D+"</td></tr>")});var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}$(document).ready(function(){var A="Please wait while Pugs starts up...";$("#tt").empty();$("#tt").append("<tr><td><pre id='c0' class='wb_theme'>"+A+"</pre><span id='d0' class='cursorOff'> </span></td></tr>");fixedCharWidth=($("#c0")[0])?$("#c0")[0].offsetWidth/A.length:8;$("#theme").change(function(){$("pre").toggleClass(theme);theme=$("#theme").val();$("pre").toggleClass(theme)});$("#logo").slideDown(2000);showCursor();$(document).keydown(function(B){return onKeyDown(B)});$(document).keypress(function(B){return onKeyPress(B)});$(window).unload(function(){$.ajax({url:"/perl/runpugs.pl?sessionid="+sessionid+"&reldev=1&ia=1&cmd=%3Aq",async:true})});loadSlide();$("#hidden_iframe").append("<iframe src=\"/perl/runpugs.pl\" id=\"scratch\" name=\"scratch\" style=\"visibility:hidden\" width=\"700px\" height=\"1px\" onLoad=\"getreply()\"></iframe>")});function loadSlide(){if(debug){alert("slide url to be loaded = '"+slides[slide]+"'")}$("#info").slideUp("fast");$.ajax({url:slides[slide],async:true,success:function(A){if(debug){alert("slide data received: "+A)}$("#info").html(A);$("#info").slideDown("slow")}})}function insert(D,C,E){var B=D.substring(0,E);var A=D.substring(E,D.length);return B+C+A}function focusOnCmd(B){$(B).focus();var A=$("#termwin")[0].scrollHeight;$("#termwin").animate({scrollTop:A},"fast")}function handleEnter(){var A=document.terminal.cmd.value+cmd;var D=A.split(prompt);var C=D[D.length-1];var B=$.trim(C);if(B!=""){histlist.push(C)}if(B==":tutorial"){tutorialMode=!tutorialMode;slide=(tutorialMode)?FIRST_TUTORIAL_SLIDE:0;loadSlide()}else{if(B==":back"||B==":next"){if(tutorialMode){if(B==":back"){slide--;if(slide<FIRST_TUTORIAL_SLIDE){slide=FIRST_TUTORIAL_SLIDE}loadSlide()}else{slide++;if(slide>=slides.length){slide--}loadSlide()}}}else{if(B==":show"){slide=1;loadSlide()}}}if(debug){alert("data to be sent: "+A)}frames["scratch"].document.getElementById("cmd").value=A;frames["scratch"].document.terminal.submit();cmd=""}function onKeyDown(C){if(C.ctrlKey||C.altKey||C.shiftKey){return true}var D=C.keyCode;focusOnCmd("#status");if(D==13){handleEnter();return false}else{if(D==8){if(curpos>0){curpos-=1;var A="";for(var B=0;B<cmd.length;B++){if(B!=curpos){A+=cmd.charAt(B)}}cmd=A;showCmd();debugKeys()}return false}else{if(D==38){hist_next();return false}else{if(D==40){hist_prev();return false}else{if(D==37){if(curpos>0){curpos--;moveCursor()}return false}else{if(D==39){if(curpos<cmd.length){curpos++;moveCursor()}return false}else{if(D==36){curpos=0;moveCursor();return false}else{if(D==35){curpos=cmd.length;moveCursor();return false}else{if(D==46){if(curpos>=0){var A="";for(var B=0;B<cmd.length;B++){if(B!=curpos){A+=cmd.charAt(B)}}cmd=A;showCmd();moveCursor();debugKeys()}return false}}}}}}}}}return true}function toAscii(C){var D="abcdefghijklmnopqrstuvwxyz";var B=" !\"#$%&'()*+'-./0123456789:;<=>?@"+D.toUpperCase()+"[\\]^_`"+D+"{|}~";var E=B.indexOf(C);var A=(E>-1)?(32+E):0;return A}function onKeyPress(B){if(B.ctrlKey||B.altKey){return }var C=B.keyCode;focusOnCmd("#status");if($.browser.msie||$.browser.opera||$.browser.safari){var A=String.fromCharCode(C);if(A>=" "){if(($.browser.opera&&(C<35||C>40))||$.browser.msie||$.browser.safari){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}}return false}else{if($.browser.mozilla&&C==0){var A=String.fromCharCode(B.charCode?B.charCode:B.keyCode);if(A>=" "){cmd=insert(cmd,A,curpos);showCmd();curpos++;debugKeys(A)}return false}}return true}function debugKeys(C){if(debug){var A="";for(var B=0;B<cmd.length;B++){var D=toAscii(cmd.charAt(B));A+=D+","}$("#status").text(((C)?("key = '"+C):"")+"', cmd = '"+cmd+"', cmd.length="+cmd.length+", ascii=("+A+")")}}function getreply(){scratchpad=frames["scratch"].document;var B=scratchpad.getElementById("cmd").value;histentry=histlist.length;sessionid=scratchpad.terminal.sessionid.value;document.terminal.cmd.value=B;if(scratchpad.terminal.prompt){var C=scratchpad.terminal.prompt.value;if(C&&C.length=="pugs> ".length){prompt=C}}var A=B.replace(/&/g,"&").replace(/ /g," ").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");cmds=A.split(/\r\n|\n|\r/g);if(debug){alert("reply (unescaped): "+B)}updateConsole();cmd="";curpos=0;showCmd()}function hist_next(){if(histentry>=1){histentry--;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}return false}function hist_prev(){if(histentry<histlist.length-1){histentry++;cmd=histlist[histentry];curpos=cmd.length;showCmd();moveCursor()}}function set_version(){var A=document.terminal.reldev[0].checked;if(A==true){frames["scratch"].document.terminal.reldev[0].checked=true;frames["scratch"].document.terminal.reldev[1].checked=false}else{frames["scratch"].document.terminal.reldev[0].checked=false;frames["scratch"].document.terminal.reldev[1].checked=true}frames["scratch"].document.terminal.submit();$("#rel").blur();$("#dev").blur();focusOnCmd("#tt")} |