]> gitweb.factorcode.org Git - factor.git/commitdiff
Move web apps to unmaintained/ for now; get more stuff in extra to load
authorSlava Pestov <slava@factorcode.org>
Fri, 7 Mar 2008 22:59:44 +0000 (16:59 -0600)
committerSlava Pestov <slava@factorcode.org>
Fri, 7 Mar 2008 22:59:44 +0000 (16:59 -0600)
76 files changed:
extra/alarms/alarms.factor
extra/http/server/cgi/cgi.factor
extra/logging/insomniac/insomniac.factor
extra/slides/slides.factor
extra/webapps/fjsc/authors.txt [deleted file]
extra/webapps/fjsc/fjsc.factor [deleted file]
extra/webapps/fjsc/head.furnace [deleted file]
extra/webapps/fjsc/repl.furnace [deleted file]
extra/webapps/fjsc/resources/repl.js [deleted file]
extra/webapps/fjsc/resources/termlib/faq.html [deleted file]
extra/webapps/fjsc/resources/termlib/index.html [deleted file]
extra/webapps/fjsc/resources/termlib/multiterm_test.html [deleted file]
extra/webapps/fjsc/resources/termlib/parser_sample.html [deleted file]
extra/webapps/fjsc/resources/termlib/readme.txt [deleted file]
extra/webapps/fjsc/resources/termlib/term_styles.css [deleted file]
extra/webapps/fjsc/resources/termlib/termlib.js [deleted file]
extra/webapps/fjsc/resources/termlib/termlib_parser.js [deleted file]
extra/webapps/fjsc/summary.txt [deleted file]
extra/webapps/fjsc/tags.txt [deleted file]
extra/webapps/help/authors.txt [deleted file]
extra/webapps/help/help.factor [deleted file]
extra/webapps/numbers/authors.txt [deleted file]
extra/webapps/numbers/numbers.factor [deleted file]
extra/webapps/pastebin/annotate-paste.furnace [deleted file]
extra/webapps/pastebin/annotation.furnace [deleted file]
extra/webapps/pastebin/authors.txt [deleted file]
extra/webapps/pastebin/footer.furnace [deleted file]
extra/webapps/pastebin/header.furnace [deleted file]
extra/webapps/pastebin/modes.furnace [deleted file]
extra/webapps/pastebin/new-paste.furnace [deleted file]
extra/webapps/pastebin/paste-list.furnace [deleted file]
extra/webapps/pastebin/paste-summary.furnace [deleted file]
extra/webapps/pastebin/pastebin.factor [deleted file]
extra/webapps/pastebin/show-paste.furnace [deleted file]
extra/webapps/pastebin/style.css [deleted file]
extra/webapps/pastebin/syntax.furnace [deleted file]
extra/webapps/planet/authors.txt [deleted file]
extra/webapps/planet/planet.factor [deleted file]
extra/webapps/planet/planet.furnace [deleted file]
extra/webapps/planet/style.css [deleted file]
unmaintained/webapps/fjsc/authors.txt [new file with mode: 0644]
unmaintained/webapps/fjsc/fjsc.factor [new file with mode: 0755]
unmaintained/webapps/fjsc/head.furnace [new file with mode: 0644]
unmaintained/webapps/fjsc/repl.furnace [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/repl.js [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/faq.html [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/index.html [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/parser_sample.html [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/readme.txt [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/term_styles.css [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/termlib.js [new file with mode: 0644]
unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js [new file with mode: 0644]
unmaintained/webapps/fjsc/summary.txt [new file with mode: 0644]
unmaintained/webapps/fjsc/tags.txt [new file with mode: 0644]
unmaintained/webapps/help/authors.txt [new file with mode: 0755]
unmaintained/webapps/help/help.factor [new file with mode: 0644]
unmaintained/webapps/numbers/authors.txt [new file with mode: 0755]
unmaintained/webapps/numbers/numbers.factor [new file with mode: 0644]
unmaintained/webapps/pastebin/annotate-paste.furnace [new file with mode: 0755]
unmaintained/webapps/pastebin/annotation.furnace [new file with mode: 0755]
unmaintained/webapps/pastebin/authors.txt [new file with mode: 0755]
unmaintained/webapps/pastebin/footer.furnace [new file with mode: 0644]
unmaintained/webapps/pastebin/header.furnace [new file with mode: 0644]
unmaintained/webapps/pastebin/modes.furnace [new file with mode: 0644]
unmaintained/webapps/pastebin/new-paste.furnace [new file with mode: 0755]
unmaintained/webapps/pastebin/paste-list.furnace [new file with mode: 0644]
unmaintained/webapps/pastebin/paste-summary.furnace [new file with mode: 0644]
unmaintained/webapps/pastebin/pastebin.factor [new file with mode: 0755]
unmaintained/webapps/pastebin/show-paste.furnace [new file with mode: 0755]
unmaintained/webapps/pastebin/style.css [new file with mode: 0644]
unmaintained/webapps/pastebin/syntax.furnace [new file with mode: 0755]
unmaintained/webapps/planet/authors.txt [new file with mode: 0755]
unmaintained/webapps/planet/planet.factor [new file with mode: 0755]
unmaintained/webapps/planet/planet.furnace [new file with mode: 0644]
unmaintained/webapps/planet/style.css [new file with mode: 0644]

index 1ccfdcbd3004aa28cfc0a807fae7ab1c7b254ef6..55a66c52318f3d3df1e828bd3107b2b5e04cdfe8 100755 (executable)
@@ -85,5 +85,8 @@ PRIVATE>
 : later ( quot dt -- alarm )
     from-now f add-alarm ;
 
+: every ( quot dt -- alarm )
+    [ from-now ] keep add-alarm ;
+
 : cancel-alarm ( alarm -- )
     alarm-entry [ alarms get-global heap-delete ] if-box? ;
index 9950a9a4a4b120408d428d819383d77d0efc896e..cce3e5402df6e89e62c7e6822a1658028908b530 100755 (executable)
@@ -41,18 +41,17 @@ IN: http.server.cgi
         ] when\r
     ] H{ } make-assoc ;\r
 \r
-: cgi-descriptor ( name -- desc )\r
-    [\r
-        dup 1array +arguments+ set\r
-        cgi-variables +environment+ set\r
-    ] H{ } make-assoc ;\r
+: <cgi-process> ( name -- desc )\r
+    <process>\r
+        over 1array >>command\r
+        swap cgi-variables >>environment ;\r
     \r
 : serve-cgi ( name -- response )\r
     <raw-response>\r
     200 >>code\r
     "CGI output follows" >>message\r
     swap [\r
-        stdio get swap cgi-descriptor <process-stream> [\r
+        stdio get swap <cgi-process> <process-stream> [\r
             post? [\r
                 request get post-data>> write flush\r
             ] when\r
index 0294085eda4fcb793d351c3c6c35408bd9a67779..83339af1c0bd8dc76392a68fd81777836f8d92d4 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: logging.analysis logging.server logging smtp io.sockets\r
-kernel io.files io.streams.string namespaces raptor.cron assocs\r
-io.encodings.utf8 ;\r
+kernel io.files io.streams.string namespaces alarms assocs\r
+io.encodings.utf8 accessors calendar ;\r
 IN: logging.insomniac\r
 \r
 SYMBOL: insomniac-smtp-host\r
@@ -29,13 +29,14 @@ SYMBOL: insomniac-recipients
 \r
 : (email-log-report) ( service word-names -- )\r
     [\r
-        over >r\r
-        ?analyze-log dup [\r
-            r> email-subject\r
-            insomniac-recipients get\r
-            insomniac-sender get\r
-            send-simple-message\r
-        ] [ r> 2drop ] if\r
+        dupd ?analyze-log dup [\r
+            <email>\r
+                swap >>body\r
+                insomniac-recipients get >>to\r
+                insomniac-sender get >>from\r
+                swap email-subject >>subject\r
+            send\r
+        ] [ 2drop ] if\r
     ] with-insomniac-smtp ;\r
 \r
 \ (email-log-report) NOTICE add-error-logging\r
@@ -44,6 +45,5 @@ SYMBOL: insomniac-recipients
     "logging.insomniac" [ (email-log-report) ] with-logging ;\r
 \r
 : schedule-insomniac ( service word-names -- )\r
-    { 25 } { 6 } f f f <when> -rot [\r
-        [ email-log-report ] assoc-each rotate-logs\r
-    ] 2curry schedule ;\r
+    [ [ email-log-report ] assoc-each rotate-logs ] 2curry\r
+    1 days every drop ;\r
index a0065d6fe3d2aade15a97bb478ee4f95902e5d88..b58253381cb1085eac99a0c82ff8818a0d70be11 100755 (executable)
@@ -6,10 +6,14 @@ IN: slides
 
 : stylesheet
     H{
-        { default-style
+        { default-span-style
             H{
                 { font "sans-serif" }
                 { font-size 36 }
+            }
+        }
+        { default-block-style
+            H{
                 { wrap-margin 1000 }
             }
         }
diff --git a/extra/webapps/fjsc/authors.txt b/extra/webapps/fjsc/authors.txt
deleted file mode 100644 (file)
index 44b06f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Chris Double
diff --git a/extra/webapps/fjsc/fjsc.factor b/extra/webapps/fjsc/fjsc.factor
deleted file mode 100755 (executable)
index cf01bf6..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-! Copyright (C) 2006 Chris Double. All Rights Reserved.
-! See http://factorcode.org/license.txt for BSD license.
-!
-USING: kernel furnace fjsc  peg namespaces
-       lazy-lists io io.files furnace.validator sequences
-       http.client http.server http.server.responders
-       webapps.file html ;
-IN: webapps.fjsc
-
-: compile ( code -- )
-  #! Compile the factor code as a string, outputting the http
-  #! response containing the javascript.
-  serving-text
-  'expression' parse parse-result-ast fjsc-compile
-  write flush ;
-
-! The 'compile' action results in an URL that looks like
-! 'responder/fjsc/compile'. It takes one query or post
-! parameter called 'code'. It calls the 'compile' word
-! passing the parameter to it on the stack.
-\ compile {
-  { "code" v-required }
-} define-action
-
-: compile-url ( url -- )
-  #! Compile the factor code at the given url, return the javascript.
-  dup "http:" head? [ "Unable to access remote sites." throw ] when
-  "http://" "host" header-param rot 3append http-get compile "();" write flush ;
-
-\ compile-url {
-  { "url" v-required }
-} define-action
-
-: render-page* ( model body-template head-template -- )
-  [
-      [ render-component ] [ f rot render-component ] html-document 
-  ] serve-html ;
-
-: repl ( -- )
-  #! The main 'repl' page.
-  f "repl" "head" render-page* ;
-
-! An action called 'repl'
-\ repl { } define-action
-
-: fjsc-web-app ( -- )
-  ! Create the web app, providing access
-  ! under '/responder/fjsc' which calls the
-  ! 'repl' action.
-  "fjsc" "repl" "extra/webapps/fjsc" web-app
-
-  ! An URL to the javascript resource files used by
-  ! the 'fjsc' responder.
-  "fjsc-resources" [
-   [
-     "extra/fjsc/resources/" resource-path doc-root set
-     file-responder
-   ] with-scope
-  ] add-simple-responder
-
-  ! An URL to the resource files used by
-  ! 'termlib'.
-  "fjsc-repl-resources" [
-   [
-     "extra/webapps/fjsc/resources/" resource-path doc-root set
-     file-responder
-   ] with-scope
-  ] add-simple-responder ;
-
-MAIN: fjsc-web-app
diff --git a/extra/webapps/fjsc/head.furnace b/extra/webapps/fjsc/head.furnace
deleted file mode 100644 (file)
index 97a3645..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<title>Factor to Javascript REPL</title>\r
-<link rel="stylesheet" type="text/css" href="/responder/fjsc-repl-resources/termlib/term_styles.css"/>\r
-<script type="text/javascript" src="/responder/fjsc-repl-resources/termlib/termlib.js"></script>\r
-<script type="text/javascript" src="/responder/fjsc-resources/jquery.js"></script>\r
-<script type="text/javascript" src="/responder/fjsc-resources/bootstrap.js"></script>\r
-<script type="text/javascript" src="/responder/fjsc-repl-resources/repl.js"></script>\r
-<script type="text/javascript" src="/responder/fjsc/compile-url?url=/responder/fjsc-resources/bootstrap.factor"></script>\r
diff --git a/extra/webapps/fjsc/repl.furnace b/extra/webapps/fjsc/repl.furnace
deleted file mode 100644 (file)
index c67e9d4..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<table border="0">
-<tr><td valign="top">
-<div id="repl" style="position:relative;"></div>
-<p>More information on the Factor to Javascript compiler can be found at these blog posts:
-<ul>
-<li><a href="http://www.bluishcoder.co.nz/2006/12/compiling-factor-to-javascript.html">Factor to Javascript Compiler</a></li>
-<li><a href="http://www.bluishcoder.co.nz/2006/12/factor-to-javascript-compiler-updates.html">Factor to Javascript Compiler Updates</a></li>
-<li><a href="http://www.bluishcoder.co.nz/2006/12/continuations-added-to-fjsc.html">Continuations added to fjsc</a></li>
-<li><a href="http://www.bluishcoder.co.nz/2006/12/cross-domain-json-with-fjsc.html">Cross Domain JSON with fjsc</a></li>
-<li><a href="http://www.bluishcoder.co.nz/2007/02/factor-to-javascript-compiler-makeover.html">Factor to Javascript Compiler Makeover</a></li>
-</ul>
-</p>
-<p>The terminal emulation code for the Factor REPL is provided by the awesome <a href="http://www.masswerk.at/termlib/index.html">termlib</a> library by Norbert Landsteiner. Documentation for termlib is <a href="/responder/fjsc-repl-resources/termlib/">available here</a>. Please note the license of 'termlib':</p>
-<blockquote>This JavaScript-library is free for private and academic use. Please include a readable copyright statement and a backlink to <http://www.masswerk.at> in the web page. The library should always be accompanied by the "readme.txt" and the sample HTML-documents.
-
-The term "private use" includes any personal or non-commercial use, which is not related to commercial activites, but excludes intranet, extranet and/or public net applications that are related to any kind of commercial or profit oriented activity.
-
-For commercial use see <a href="http://www.masswerk.at">http://www.masswerk.at</a> for contact information.</blockquote>
-</td>
-<td valign="top">
-<p><b>Stack</b></p>
-<div id="stack">
-</div>
-<p><b>Playground</b></p>
-<div id="playground">
-</div>
-<h3>Compiled Code</h3>
-<textarea id="compiled" cols="40" rows="10">
-</textarea>
-<p>Some useful words:
-<dl>
-<dt>vocabs ( -- seq )</dt>
-<dd>Return a sequence of available vocabularies</dd>
-<dt>words ( string -- seq )</dt>
-<dd>Return a sequence of words in the given vocabulary</dd>
-<dt>all-words ( -- seq )</dt>
-<dd>Return a sequence of all words</dd>
-</dl>
-</p>
-<p>The contents of <a href="/responder/fjsc-resources/bootstrap.factor">bootstrap.factor</a> have been loaded on startup.</p>
-</td>
-</tr>
-</table>
diff --git a/extra/webapps/fjsc/resources/repl.js b/extra/webapps/fjsc/resources/repl.js
deleted file mode 100644 (file)
index 3bc8bdc..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Copyright (C) 2007 Chris Double. All Rights Reserved.\r
-   See http://factorcode.org/license.txt for BSD license. */\r
-\r
-var fjsc_repl = false;\r
-\r
-function fjsc_repl_handler() {\r
-  var my_term = this;\r
-  this.newLine();\r
-  if(this.lineBuffer != '') {\r
-    factor.server_eval(\r
-      this.lineBuffer, \r
-      function(text, result) { \r
-        document.getElementById("compiled").value = result;\r
-        display_datastack();        \r
-      }, \r
-      function() { my_term.prompt(); });\r
-  }\r
-  else\r
-    my_term.prompt();\r
-}\r
-\r
-function fjsc_init_handler() {\r
-  this.write(\r
-    [\r
-      TermGlobals.center('********************************************************'),\r
-      TermGlobals.center('*                                                      *'),\r
-      TermGlobals.center('*       Factor to Javascript Compiler Example          *'),\r
-      TermGlobals.center('*                                                      *'),\r
-      TermGlobals.center('********************************************************')\r
-    ]);\r
-  \r
-  this.prompt();\r
-}\r
-\r
-function startup() {\r
-  var conf = {\r
-    x: 0,\r
-    y: 0,\r
-    cols: 64,\r
-    rows: 18,\r
-    termDiv: "repl",\r
-    crsrBlinkMode: true,\r
-    ps: "scratchpad ",\r
-    initHandler: fjsc_init_handler,\r
-    handler: fjsc_repl_handler\r
-  };\r
-  fjsc_repl = new Terminal(conf);\r
-  fjsc_repl.open();\r
-}\r
-\r
-function display_datastack() {\r
-   var html=[];\r
-   html.push("<table border='1'>")\r
-   for(var i = 0; i < factor.cont.data_stack.length; ++i) {\r
-      html.push("<tr><td>")\r
-      html.push(factor.cont.data_stack[i])\r
-      html.push("</td></tr>")\r
-   }\r
-   html.push("</table>")\r
-   document.getElementById('stack').innerHTML=html.join("");\r
-}\r
-\r
-jQuery(function() {\r
-  startup();\r
-  display_datastack();\r
-});\r
-\r
-factor.add_word("kernel", ".s", "primitive", function(next) {   \r
-  var stack = factor.cont.data_stack;\r
-  var term = fjsc_repl;\r
-  for(var i=0; i<stack.length; ++i) {\r
-    term.type(""+stack[i]);\r
-    term.newLine();\r
-  }\r
-  factor.call_next(next);\r
-});\r
-\r
-factor.add_word("io", "print", "primitive", function(next) {   \r
-  var stack = factor.cont.data_stack;\r
-  var term = fjsc_repl;\r
-  term.type(""+stack.pop());\r
-  term.newLine();\r
-  factor.call_next(next);\r
-});\r
-\r
-factor.add_word("io", "write", "primitive", function(next) {   \r
-  var stack = factor.cont.data_stack;\r
-  var term = fjsc_repl;\r
-  term.type(""+stack.pop());\r
-  factor.call_next(next);\r
-});\r
-\r
-factor.add_word("io", ".", "primitive", function(next) {   \r
-  var stack = factor.cont.data_stack;\r
-  var term = fjsc_repl;\r
-  term.type(""+stack.pop());\r
-  term.newLine();\r
-  factor.call_next(next);\r
-});\r
diff --git a/extra/webapps/fjsc/resources/termlib/faq.html b/extra/webapps/fjsc/resources/termlib/faq.html
deleted file mode 100644 (file)
index 5adb516..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-<HTML>\r
-<HEAD>\r
-       <TITLE>mass:werk termlib faq</TITLE>\r
-\r
-<STYLE TYPE="text/css">\r
-body,p,a,td {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #cccccc;\r
-}\r
-.lh13 {\r
-       line-height: 13px;\r
-}\r
-.lh15 {\r
-       line-height: 15px;\r
-}\r
-pre {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       color: #ccffaa;\r
-       font-size: 12px;\r
-       line-height: 15px;\r
-}\r
-.prop {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       color: #bbee99;\r
-       font-size: 12px;\r
-       line-height: 15px;\r
-}\r
-h1 {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 16px;\r
-       color: #cccccc;\r
-}\r
-b.quest {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 14px;\r
-       font-weight: bold;\r
-       color: #bbee99;\r
-}\r
-a,a:link,a:visited {\r
-       text-decoration: none;\r
-       color: #77dd11;\r
-}\r
-a:hover {\r
-       text-decoration: underline;\r
-       color: #77dd11;\r
-}\r
-a:active {\r
-       text-decoration: underline;\r
-       color: #dddddd;\r
-}\r
-\r
-@media print {\r
-       body { background-color: #ffffff; }\r
-       body,p,a,td {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 12px;\r
-               color: #000000;\r
-       }\r
-       .lh13 {\r
-               line-height: 13px;\r
-       }\r
-       .lh15 {\r
-               line-height: 15px;\r
-       }\r
-       pre,.prop {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 12px;\r
-               color: #000000;\r
-               line-height: 15px;\r
-       }\r
-       h1 {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 16px;\r
-               color: #000000;\r
-       }\r
-       b.quest {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 14px;\r
-               font-weight: bold;\r
-               color: #000000;\r
-       }\r
-       a,a:link,a:visited {\r
-               text-decoration: none;\r
-               color: #000000;\r
-       }\r
-       a:hover {\r
-               text-decoration: underline;\r
-               color: #000000;\r
-       }\r
-       a:active {\r
-               text-decoration: underline;\r
-               color: #000000;\r
-       }\r
-}\r
-</STYLE>\r
-</HEAD>\r
-\r
-\r
-<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
-TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
-<TR>\r
-       <TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP>faq</TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
-</TR>\r
-</TABLE>\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">\r
-       <TR><TD>\r
-               <H1>frequently asked questions</H1>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-&nbsp;<BR>\r
-       <UL>\r
-       <LI CLASS="lh15"><A HREF="#chrome">Can I add chrome to the terminal? (e.g. a window header, a close box)</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#embed">How can I embed a terminal relative to my HTML layout?</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#syntax">I pasted your sample code and just got an error. - ???</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#keyboard">I can't get any input, but I don't get any erros too.</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#keylock">How can I temporary disable the keyboard handlers?</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#linesranges">How can I set the cusor to the start / the end of the command line?</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#historyunique">How can I limit the command history to unique entries only?</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#rebuild">How can I change my color theme on the fly?</A></LI>\r
-       <LI CLASS="lh15"><A HREF="#connect">How can I connect to a server?</A></LI>\r
-       </UL>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="chrome"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">Can I add chrome to the terminal? (e.g. a window header, a close box)</B><BR><BR>\r
-\r
-Not by the means of the Terminal object's interface (since there are way too many things that you may possibly want to add).<BR>\r
-The Terminal object allows you to specify the background color, the frame color, the frame's width and the font class used. If you want to add more chrome, you must align this in a separate division element.<BR><BR>\r
-\r
-To calculate the dimensions of the terminal use this formula:<BR><BR>\r
-\r
-width:&nbsp; 2 * frameWidth + conf.cols * &lt;width of &nbsp;&gt; + 2 * 2px padding (left and right)<BR>\r
-height: 2 * frameWidth + conf.rows * conf.rowHeight + 2 * 2px padding (top and bottom).<BR><BR>\r
-\r
-Or you could get the empirical values for width and height by calling a terminal's `<SPAN CLASS="prop">getDimensions()</SPAN>' method, once the terminal is open. (see documentation in &quot;readme.txt&quot;).<BR><BR>\r
-\r
-Finnally, you could obviously embed the terminal's division element in your custom chrome layout (see below). [This will not be compatible to Netscape 4.]<BR><BR>\r
-\r
-p.e.:<PRE>\r
-  &lt;div id=&quot;myTerminal1&quot; style=&quot;position:absolute; top:100px; left:100px;&quot;&gt;\r
-     &lt;table class=&quot;termChrome&quot;&gt;\r
-       &lt;tbody&gt;\r
-        &lt;tr&gt;\r
-           &lt;td class=&quot;termTitle&quot;&gt;terminal 1&lt;/td&gt;\r
-        &lt;/tr&gt;\r
-        &lt;tr&gt;\r
-           &lt;td class=&quot;termBody&quot;&gt;&lt;div id=&quot;termDiv1&quot; style=&quot;position:relative&quot;&gt;&lt;/div&gt;&lt;/td&gt;\r
-        &lt;/tr&gt;\r
-       &lt;/tbody&gt;\r
-     &lt;/table&gt;\r
-   &lt;/div&gt;\r
-\r
-   // get a terminal for this\r
-\r
-   var term1 = new Terminal(\r
-                 {\r
-                   x: 0,\r
-                   y: 0,\r
-                   id: 1,\r
-                   termDiv: &quot;termDiv1&quot;,\r
-                   handler: myTermHandler\r
-                 }\r
-              );\r
-   term1.open();\r
-   \r
-   // and this is how to move the chrome and the embedded terminal\r
-\r
-   TermGlobals.setElementXY( &quot;myTerminal1&quot;, 200, 80 );\r
-</PRE>\r
-To keep track of the instance for any widgets use the terminal's `id' property. (You must set this in the configuration object to a unique value for this purpose.)<BR><BR>\r
-\r
-For a demonstration see the <A HREF="chrome_sample.html">Chrome Sample Page</A>.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="embed"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">How can I embed a terminal relative to my HTML layout?</B><BR><BR>\r
-\r
-Define your devision element with attribute &quot;position&quot; set to &quot;relative&quot; and place this inside your layout. Call &quot;new Terminal()&quot; with config-values { x: 0, y: 0 } to leave it at its relative origin.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="syntax"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">I pasted your sample code and just got an error. - ???</B><BR><BR>\r
-\r
-The short examples are kept arbitrarily simple to show the syntax.<BR>\r
-Make sure that your divison element(s) is/are rendered by the browser before `Terminal.open()' is called.<BR><BR>\r
-\r
-Does not work:\r
-<PRE>  &lt;head&gt;\r
-  &lt;script&gt;\r
-    var term = new Terminal();\r
-    term.open();\r
-  &lt;/script&gt;\r
-  &lt;/head&gt;\r
-</PRE>\r
-Does work:\r
-<PRE>  &lt;head&gt;\r
-  &lt;script&gt;\r
-    var term;\r
-    \r
-    function termOpen() {\r
-       // to be called from outside after compile time\r
-       term = new Terminal();\r
-       term.open();\r
-    }\r
-  &lt;/script&gt;\r
-  &lt;/head&gt;\r
-</PRE>\r
-c.f. &quot;readme.txt&quot;<BR>\r
-(Opening a terminal by clicking a link implies also that the page has currently focus.)<BR><BR>\r
-With v.1.01 and higher this doesn't cause an error any more.<BR>`Terminal.prototype.open()' now returns a value for success.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="keyboard"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">I can't get any input, but I don't get any erros too.</B><BR><BR>\r
-\r
-The Terminal object's functionality relies on the browsers ability to generate and handle keyboard events.<BR>\r
-Sadly some browsers lack a full implementation of the event model. (e.g. Konquerer [khtml] and early versions of Apple Safari, which is a descendant of khtml.)\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="keylock"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">How can I temporary disable the keyboard handlers?</B><BR>\r
-<SPAN CLASS="prop">(The terminal is blocking my HTML form fields, etc.)</SPAN><BR><BR>\r
-\r
-With version 1.03 there's a global property `<SPAN CLASS="prop">TermGlobals.keylock</SPAN>'. Set this to `true' to disable the keyboard handlers without altering any other state. Reset it to `false' to continue with your terminal session(s).\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="linesranges"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">How can I set the cusor to the start / the end of the command line?</B><BR><BR>\r
-\r
-In case you need to implement a shortcut (like ^A of some UN*X-shells) to jump to the beginning or the end of the current input line, there are two private instance methods you could utilize:<BR><BR>\r
-`<SPAN CLASS="prop">_getLineEnd(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the last character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>\r
-`<SPAN CLASS="prop">_getLineStart(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the first character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>\r
-Both take a row and a column of a cursor position as arguments.<BR><BR>\r
-\r
-p.e.:\r
-<PRE>\r
-  // jump to the start of the input line\r
-\r
-  myCtrlHandler() {\r
-     // catch ^A and jump to start of the line\r
-     if (this.inputChar == 1) {\r
-        var firstChar = this._getLineStart(this.r, this.c);\r
-        this.cursorSet(firstChar[0], firstChar[1]);\r
-     }\r
-  }</PRE>\r
-(Keep in mind that this is not exactly a good example, since some browser actually don't issue a keyboard event for \r
-&quot;^A&quot;. And other browsers, which do catch such codes, are not very reliable in that.)\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="historyunique"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">How can I limit the command history to unique entries only?</B><BR>\r
-       <SPAN CLASS="prop">(My application effords commands to be commonly repeated.)</SPAN><BR><BR>\r
-\r
-With version 1.05 there is a new configuration and control flag `<SPAN CLASS="prop">historyUnique</SPAN>'. All you need is setting this to `true' in your terminal's configuration object.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="rebuild"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">How can I change my color theme on the fly?</B><BR><BR>\r
-\r
-With version 1.07 there is a new method `<SPAN CLASS="prop">Terminal.rebuild()</SPAN>'.<BR>\r
-This method updates the GUI to current config settings while preserving all other state.<BR><BR>\r
-p.e.:\r
-<PRE>\r
-   // change color settings on the fly\r
-   // here: set bgColor to white and font style to class &quot;termWhite&quot;\r
-   // method rebuild() updates the GUI without side effects\r
-   // assume var term holds a referene to a Terminal object already active\r
-\r
-   term.conf.bgColor = '#ffffff';\r
-   term.conf.fontClass = 'termWhite';\r
-   term.rebuild();</PRE>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13"><A NAME="connect"></A>\r
-&nbsp;<BR>\r
-<B CLASS="quest">How can I connect to a server?</B><BR><BR>\r
-\r
-The Terminal object only provides an interface to handle console input and output.<BR>\r
-External connections have to be handled outside the Terminal object. You could use the XMLHttpRequest-Object (and use a communication model like AJAX or JSON) or connect via a frame or iframe element to a foreign host.<BR><BR>\r
-Handling connections is considered to be out of the realm of the &quot;termlib.js&quot; library.<BR>\r
-The code you need is in fact quite simple:\r
-<PRE>\r
-  function connectToHost(url) {\r
-     if (window.XMLHttpRequest) {\r
-        request = new XMLHttpRequest();\r
-     }\r
-     else if (window.ActiveXObject) {\r
-         request = new ActiveXObject('Microsoft.XMLHTTP');\r
-     }\r
-     if (request) {\r
-         request.onreadystatechange = requestChangeHandler;\r
-         request.open('GET', url);\r
-         request.send('');\r
-     }\r
-     else {\r
-        // XMLHttpRequest not implemented\r
-     }\r
-  }\r
-  \r
-  function requestChangeHandler() {\r
-     if (request.readyState == 4) {\r
-        // readyState 4: complete; now test for server's response status\r
-        if (request.status == 200) {\r
-           // response in request.responseText or request.responseXML if XML-code\r
-           // if it's JS-code we could get this by eval(request.responseText)\r
-           // by this we could import whole functions to be used via the terminal\r
-        }\r
-        else {\r
-           // connection error\r
-           // status code and message in request.status and request.statusText\r
-        }\r
-     }\r
-  }\r
-</PRE>\r
-You should use this only together with a timer (window.setTimeout()) to handle connection timeouts.<BR>\r
-Additionally you would need some syntax to authenticate and tell the server what you want.<BR>\r
-For this purpose you could use the following methods of the XMLHttpRequest object:<BR><BR>\r
-\r
-       <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3">\r
-       <TR VALIGN="top"><TD NOWRAP CLASS="prop">setRequestHeader(&quot;<I>headerLabel</I>&quot;, &quot;<I>value</I>&quot;)</TD><TD>set a HTTP header to be sent to the server</TD></TR>\r
-       <TR VALIGN="top"><TD NOWRAP CLASS="prop">getResponseHeader(&quot;<I>headerLabel</I>&quot;)</TD><TD>get a HTTP header sent from the server</TD></TR>\r
-       <TR VALIGN="top"><TD NOWRAP CLASS="prop">open(<I>method</I>, &quot;<I>url</I>&quot; [, <I>asyncFlag</I> [,<BR>&nbsp; &quot;<I>userid</I>&quot; [, &quot;<I>password</I>&quot;]]])</TD><TD>assign the destination properties to the request.<BR>be aware that userid and password are not encrypted!</TD></TR>\r
-       <TR VALIGN="top"><TD NOWRAP CLASS="prop">send(<I>content</I>)</TD><TD>transmit a message body (post-string or DOM object)</TD></TR>\r
-       <TR VALIGN="top"><TD NOWRAP CLASS="prop">abort()</TD><TD>use this to stop a pending connection</TD></TR>\r
-       </TABLE>\r
-\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;<BR>\r
-       Norbert Landsteiner - August 2005<BR>\r
-       <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;<BR>\r
-               <A HREF="#top">&gt; top of page</A>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;\r
-       </TD></TR>\r
-</TABLE>\r
-\r
-<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
-\r
-</BODY>\r
-</HTML>
\ No newline at end of file
diff --git a/extra/webapps/fjsc/resources/termlib/index.html b/extra/webapps/fjsc/resources/termlib/index.html
deleted file mode 100644 (file)
index 1770b2c..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-<HTML>\r
-<HEAD>\r
-       <TITLE>mass:werk termlib</TITLE>\r
-\r
-<STYLE TYPE="text/css">\r
-body,p,a,td {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #cccccc;\r
-}\r
-.lh13 {\r
-       line-height: 13px;\r
-}\r
-.lh15 {\r
-       line-height: 15px;\r
-}\r
-pre {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #ccffaa;\r
-       line-height: 15px;\r
-}\r
-.prop {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       color: #bbee99;\r
-       font-size: 12px;\r
-       line-height: 15px;\r
-}\r
-h1 {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 16px;\r
-       color: #cccccc;\r
-}\r
-a,a:link,a:visited {\r
-       text-decoration: none;\r
-       color: #77dd11;\r
-}\r
-a:hover {\r
-       text-decoration: underline;\r
-       color: #77dd11;\r
-}\r
-a:active {\r
-       text-decoration: underline;\r
-       color: #dddddd;\r
-}\r
-\r
-@media print {\r
-       body { background-color: #ffffff; }\r
-       body,p,a,td {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 12px;\r
-               color: #000000;\r
-       }\r
-       .lh13 {\r
-               line-height: 13px;\r
-       }\r
-       .lh15 {\r
-               line-height: 15px;\r
-       }\r
-       pre,.prop {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 12px;\r
-               color: #000000;\r
-               line-height: 15px;\r
-       }\r
-       h1 {\r
-               font-family: courier,fixed,swiss,sans-serif;\r
-               font-size: 16px;\r
-               color: #000000;\r
-       }\r
-       a,a:link,a:visited {\r
-               text-decoration: none;\r
-               color: #000000;\r
-       }\r
-       a:hover {\r
-               text-decoration: underline;\r
-               color: #000000;\r
-       }\r
-       a:active {\r
-               text-decoration: underline;\r
-               color: #000000;\r
-       }\r
-}\r
-</STYLE>\r
-</HEAD>\r
-\r
-\r
-<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
-TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
-<TR>\r
-       <TD NOWRAP>termlib.js home</TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="faq.html">faq</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
-</TR>\r
-</TABLE>\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">\r
-       <TR><TD>\r
-               <H1>mass:werk termlib.js</H1>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-               The JavaScript library &quot;termlib.js&quot; provides a `Terminal' object, which\r
-               facillitates a simple and object oriented approach to generate and control a\r
-               terminal-like interface for web services.<BR><BR>\r
-               \r
-               "termlib.js" features direct keyboard input and powerful output methods\r
-               for multiple and simultanious instances of the `Terminal' object.<BR><BR>\r
-               \r
-               The library was written with the aim of simple usage and a maximum of compatibility\r
-               with minimal foot print in the global namespace.<BR><BR><BR>\r
-               \r
-               \r
-               A short example:<BR>\r
-  <PRE>\r
-  var term = new Terminal( {handler: termHandler} );\r
-  term.open();\r
-\r
-  function termHandler() {\r
-     this.newLine();\r
-     var line = this.lineBuffer;\r
-     if (line != &quot;&quot;) {\r
-        this.write(&quot;You typed: &quot;+line);\r
-     }\r
-     this.prompt();\r
-  }\r
-  </PRE>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       <B>License</B><BR><BR>\r
-\r
-       This JavaScript-library is <U>free for private and academic use</U>.\r
-       Please include a readable copyright statement and a backlink to &lt;http://www.masswerk.at&gt; in the\r
-       web page. The library should always be accompanied by the &quot;readme.txt&quot; and the sample HTML-documents.<BR><BR>\r
-\r
-       The term &quot;private use&quot; includes any personal or non-commercial use, which is not related\r
-       to commercial activites, but excludes intranet, extranet and/or public net applications\r
-       that are related to any kind of commercial or profit oriented activity.<BR><BR>\r
-\r
-       For commercial use see &lt;<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>&gt; for contact information.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       <B>Distribution</B><BR><BR>\r
-\r
-       This JavaScript-library may be distributed freely as long it is distributed together with the &quot;readme.txt&quot; and the sample HTML-documents and this document.<BR><BR>\r
-\r
-       Any changes to the library should be commented and be documented in the readme-file.<BR>\r
-       Any changes must be reflected in the `Terminal.version' string as &quot;Version.Subversion&nbsp;(compatibility)&quot;.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       <B>Disclaimer</B><BR><BR>\r
-\r
-       This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY\r
-       WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
-       PURPOSE. The entire risk as to the quality and performance of the product is borne by the\r
-       user. No use of the product is authorized hereunder except under this disclaimer.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       <B>History</B><BR><BR>\r
-\r
-       This library evolved from the terminal script &quot;TermApp&quot; ((c) N. Landsteiner 2003) and is in its\r
-       current form a down scaled spinn-off of the &quot;JS/UIX&quot; project. (JS/UIX is not a free&nbsp;software by now.)\r
-       c.f.: &lt;<A HREF="http://www.masswerk.at/jsuix/" TARGET="_blank">http://www.masswerk.at/jsuix</A>&gt;<BR><BR>\r
-\r
-       For version history: see the <A HREF="readme.txt">readme.txt</A>.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;<BR>\r
-       <B>Download</B><BR><BR>\r
-       Be sure to have read the license information and the disclamer and that you are willing to respect copyrights.<BR><BR>\r
-\r
-       <SPAN CLASS="prop">Download:</SPAN> <A HREF="termlib.zip">termlib.zip</A> (~ 40 KB, incl. docs)<BR><BR>\r
-       Current version is &quot;1.07 (original)&quot;.<BR>\r
-       The files are now provided with line breaks  in format &lt;CRLF&gt;.<BR>\r
-       &nbsp;\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       <B>Author</B><BR><BR>\r
-       &copy; Norbert Landsteiner 2003-2005<BR>\r
-       mass:werk &#150; media environments<BR>\r
-       <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;<BR>\r
-       Author's note:<BR>\r
-       Please do not contact me on questions of simple usage. There is an extensive documentation (readme.txt) including plenty of sample code that should provide all information you need.\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;<BR>\r
-               <A HREF="#top">&gt; top of page</A>\r
-       </TD></TR>\r
-       <TR><TD CLASS="lh13">\r
-       &nbsp;\r
-       </TD></TR>\r
-</TABLE>\r
-\r
-<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
-\r
-</BODY>\r
-</HTML>
\ No newline at end of file
diff --git a/extra/webapps/fjsc/resources/termlib/multiterm_test.html b/extra/webapps/fjsc/resources/termlib/multiterm_test.html
deleted file mode 100644 (file)
index 0a4e1ec..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-<HTML>\r
-<HEAD>\r
-       <TITLE>termlib Multiple Terminal Test</TITLE>\r
-       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>\r
-\r
-<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\r
-<!--\r
-\r
-/*\r
-  multiple terminal test for termlib.js\r
-\r
-  (c) Norbert Landsteiner 2003-2005\r
-  mass:werk - media environments\r
-  <http://www.masswerk.at>\r
-\r
-*/\r
-\r
-var term=new Array();\r
-\r
-var helpPage=[\r
-       '%CS%+r Terminal Help %-r%n',\r
-       '  This is just a tiny test for multiple terminals.',\r
-       '  use one of the following commands:',\r
-       '     clear .... clear the terminal',\r
-       '     exit ..... close the terminal (or <ESC>)',\r
-       '     id ....... show terminal\'s id',\r
-       '     switch ... switch to other terminal',\r
-       '     help ..... show this help page',\r
-       '  other input will be echoed to the terminal.',\r
-       ' '\r
-];\r
-\r
-function termOpen(n) {\r
-       if (!term[n]) {\r
-               var y=(n==1)? 70: 280;\r
-               term[n]=new Terminal(\r
-                       {\r
-                               x: 220,\r
-                               y: y,\r
-                               rows: 12,\r
-                               greeting: '%+r +++ Terminal #'+n+' ready. +++ %-r%nType "help" for help.%n',\r
-                               id: n,\r
-                               termDiv: 'termDiv'+n,\r
-                               crsrBlinkMode: true,\r
-                               handler: termHandler,\r
-                               exitHandler: termExitHandler\r
-                       }\r
-               );\r
-               if (term[n]) term[n].open();\r
-       }\r
-       else if (term[n].closed) {\r
-               term[n].open();\r
-       }\r
-       else {\r
-               term[n].focus();\r
-       }\r
-}\r
-\r
-function termHandler() {\r
-       // called on <CR> or <ENTER>\r
-       this.newLine();\r
-       var cmd=this.lineBuffer;\r
-       if (cmd!='') {\r
-               if (cmd=='switch') {\r
-                       var other=(this.id==1)? 2:1;\r
-                       termOpen(other);\r
-               }\r
-               else if (cmd=='clear') {\r
-                       this.clear();\r
-               }\r
-               else if (cmd=='exit') {\r
-                       this.close();\r
-               }\r
-               else if (cmd=='help') {\r
-                       this.write(helpPage);\r
-               }\r
-               else if (cmd=='id') {\r
-                       this.write('terminal id: '+this.id);\r
-               }\r
-               else {\r
-                       this.type('You typed: '+cmd);\r
-                       this.newLine();\r
-               }\r
-       }\r
-       this.prompt();\r
-}\r
-\r
-function termExitHandler() {\r
-       // optional handler called on exit\r
-       // activate other terminal if open\r
-       var other=(this.id==1)? 2:1;\r
-       if ((term[other]) && (term[other].closed==false)) term[other].focus();\r
-}\r
-\r
-//-->\r
-</SCRIPT>\r
-\r
-<STYLE TYPE="text/css">\r
-body,p,a,td {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #cccccc;\r
-}\r
-.lh15 {\r
-       line-height: 15px;\r
-}\r
-.term {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #33d011;\r
-       background: none;\r
-}\r
-.termReverse {\r
-       color: #111111;\r
-       background: #33d011;\r
-}\r
-a,a:link,a:visited {\r
-       text-decoration: none;\r
-       color: #77dd11;\r
-}\r
-a:hover {\r
-       text-decoration: underline;\r
-       color: #77dd11;\r
-}\r
-a:active {\r
-       text-decoration: underline;\r
-       color: #dddddd;\r
-}\r
-\r
-a.termopen,a.termopen:link,a.termopen:visited {\r
-       text-decoration: none;\r
-       color: #77dd11;\r
-       background: none;\r
-}\r
-a.termopen:hover {\r
-       text-decoration: none;\r
-       color: #222222;\r
-       background: #77dd11;\r
-}\r
-a.termopen:active {\r
-       text-decoration: none;\r
-       color: #222222;\r
-       background: #dddddd;\r
-}\r
-\r
-</STYLE>\r
-</HEAD>\r
-\r
-\r
-<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
-TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
-<TR>\r
-       <TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP>multiple terminal test</TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="faq.html">faq</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
-</TR>\r
-</TABLE>\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">\r
-       <TR><TD NOWRAP>\r
-               Multiple Terminal Test<BR>&nbsp;\r
-       </TD></TR>\r
-       <TR><TD NOWRAP>\r
-               <A HREF="javascript:termOpen(1)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 1 &nbsp;</A>\r
-       </TD></TR>\r
-       <TR><TD NOWRAP>\r
-               <A HREF="javascript:termOpen(2)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 2'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 2 &nbsp;</A>\r
-       </TD></TR>\r
-       <TR><TD NOWRAP CLASS="lh15">\r
-               &nbsp;<BR>\r
-               (c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>\r
-               <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
-       </TD></TR>\r
-</TABLE>\r
-\r
-<DIV ID="termDiv1" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
-<DIV ID="termDiv2" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
-\r
-</BODY>\r
-</HTML>
\ No newline at end of file
diff --git a/extra/webapps/fjsc/resources/termlib/parser_sample.html b/extra/webapps/fjsc/resources/termlib/parser_sample.html
deleted file mode 100644 (file)
index b332af1..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-<HTML>\r
-<HEAD>\r
-       <TITLE>termlib Sample Parser</TITLE>\r
-       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>\r
-       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib_parser.js"></SCRIPT>\r
-\r
-<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\r
-<!--\r
-\r
-/*\r
-  test sample for termlib.js and termlib_parser.js\r
-\r
-  (c) Norbert Landsteiner 2005\r
-  mass:werk - media environments\r
-  <http://www.masswerk.at>\r
-\r
-*/\r
-\r
-var term;\r
-\r
-var helpPage=[\r
-       '%CS%+r Terminal Help %-r%n',\r
-       '  This is just a sample to demonstrate command line parsing.',\r
-       ' ',\r
-       '  Use one of the following commands:',\r
-       '     clear [-a] .......... clear the terminal',\r
-       '                           option "a" also removes the status line',\r
-       '     number -n<value> .... return value of option "n" (test for options)',\r
-       '     repeat -n<value> .... repeats the first argument n times (another test)',\r
-       '     login <username> .... sample login (test for raw mode)',\r
-       '     exit ................ close the terminal (same as <ESC>)',\r
-       '     help ................ show this help page',\r
-       ' ',\r
-       '  other input will be echoed to the terminal as a list of parsed arguments',\r
-       '  in the format <argument index> <quoting level> "<parsed value>".',\r
-       ' '\r
-];\r
-\r
-function termOpen() {\r
-       if (!term) {\r
-               term=new Terminal(\r
-                       {\r
-                               x: 220,\r
-                               y: 70,\r
-                               termDiv: 'termDiv',\r
-                               ps: '[guest]$',\r
-                               initHandler: termInitHandler,\r
-                               handler: commandHandler\r
-                       }\r
-               );\r
-               if (term) term.open();\r
-       }\r
-       else if (term.closed) {\r
-               term.open();\r
-       }\r
-       else {\r
-               term.focus();\r
-       }\r
-}\r
-\r
-function termInitHandler() {\r
-       // output a start up screen\r
-       this.write(\r
-               [\r
-                       TermGlobals.center('####################################################', 80),\r
-                       TermGlobals.center('#                                                  #', 80),\r
-                       TermGlobals.center('#           termlib.js - Sample Parser             #', 80),\r
-                       TermGlobals.center('#  Input is echoed as a list of parsed arguments.  #', 80),\r
-                       TermGlobals.center('#                                                  #', 80),\r
-                       TermGlobals.center('#  Type "help" for commands.                       #', 80),\r
-                       TermGlobals.center('#                                                  #', 80),\r
-                       TermGlobals.center('#  (c) N. Landsteiner 2005;  www.masswerk.at       #', 80),\r
-                       TermGlobals.center('#                                                  #', 80),\r
-                       TermGlobals.center('####################################################', 80),\r
-                       '%n'\r
-               ]\r
-       );\r
-       // set a double status line\r
-       this.statusLine('', 8,2); // just a line of strike\r
-       this.statusLine(' +++ This is just a test sample for command parsing. Type "help" for help. +++');\r
-       this.maxLines -= 2;\r
-       // and leave with prompt\r
-       this.prompt();\r
-}\r
-\r
-function commandHandler() {\r
-       this.newLine();\r
-       // check for raw mode first (should not be parsed)\r
-       if (this.rawMode) {\r
-               if (this.env.getPassword) {\r
-                       // sample password handler (lineBuffer == stored username ?)\r
-                       if (this.lineBuffer == this.env.username) {\r
-                               this.user = this.env.username;\r
-                               this.ps = '['+this.user+']>';\r
-                       }\r
-                       else {\r
-                               this.type('Sorry.');\r
-                       }\r
-                       this.env.username = '';\r
-                       this.env.getPassword = false;\r
-               }\r
-               // leave in normal mode\r
-               this.rawMode = false;\r
-               this.prompt();\r
-               return;\r
-       }\r
-       // normal command parsing\r
-       // just call the termlib_parser with a reference of the calling Terminal instance\r
-       // parsed arguments will be imported in this.argv,\r
-       // quoting levels per argument in this.argQL (quoting character or empty)\r
-       // cursor for arguments is this.argc (used by parserGetopt)\r
-       // => see 'termlib_parse.js' for configuration and details\r
-       parseLine(this);\r
-       if (this.argv.length == 0) {\r
-               // no commmand line input\r
-       }\r
-       else if (this.argQL[0]) {\r
-           // first argument quoted -> error\r
-               this.write("Syntax error: first argument quoted.");\r
-       }\r
-       else {\r
-               var cmd = this.argv[this.argc++];\r
-               /*\r
-                 process commands now\r
-                 1st argument: this.argv[this.argc]\r
-               */\r
-               if (cmd == 'help') {\r
-                       this.write(helpPage);\r
-               }\r
-               else if (cmd == 'clear') {\r
-                       // get options\r
-                       var opts = parserGetopt(this, 'aA');\r
-                       if (opts.a) {\r
-                               // discard status line on opt "a" or "A"\r
-                               this.maxLines = this.conf.rows;\r
-                       }\r
-                       this.clear();\r
-               }\r
-               else if (cmd == 'number') {\r
-                       // test for value options\r
-                       var opts = parserGetopt(this, 'n');\r
-                       if (opts.illegals.length) this.type('illegal option. usage: number -n<value>')\r
-                       else if ((opts.n) && (opts.n.value != -1)) this.type('option value: '+opts.n.value)\r
-                       else this.type('usage: number -n<value>');\r
-               }\r
-               else if (cmd == 'repeat') {\r
-                       // another test for value options\r
-                       var opts = parserGetopt(this, 'n');\r
-                       if (opts.illegals.length) this.type('illegal option. usage: repeat -n<value> <string>')\r
-                       else if ((opts.n) && (opts.n.value != -1)) {\r
-                               // first normal argument is again this.argv[this.argc]\r
-                               var s = this.argv[this.argc];\r
-                               if (typeof s != 'undefined') {\r
-                                       // repeat this string n times\r
-                                       var a = [];\r
-                                       for (var i=0; i<opts.n.value; i++) a[a.length] = s;\r
-                                       this.type(a.join(' '));\r
-                               }\r
-                       }\r
-                       else this.type('usage: repeat -n<value> <string>');\r
-               }\r
-               else if (cmd == 'login') {\r
-                       // sample login (test for raw mode)\r
-                       if ((this.argc == this.argv.length) || (this.argv[this.argc] == '')) {\r
-                               this.type('usage: login <username>');\r
-                       }\r
-                       else {\r
-                               this.env.getPassword = true;\r
-                               this.env.username = this.argv[this.argc];\r
-                               this.write('%+iSample login: repeat username as password.%-i%n');\r
-                               this.type('password: ');\r
-                               // exit in raw mode (blind input)\r
-                               this.rawMode = true;\r
-                               this.lock = false;\r
-                               return;\r
-                       }\r
-               }\r
-               else if (cmd == 'exit') {\r
-                       this.close();\r
-                       return;\r
-               }\r
-               else {\r
-                       // for test purpose just output argv as list\r
-                       // assemble a string of style-escaped lines and output it in more-mode\r
-                       s=' INDEX  QL  ARGUMENT%n';\r
-                       for (var i=0; i<this.argv.length; i++) {\r
-                               s += TermGlobals.stringReplace('%', '%%',\r
-                                               TermGlobals.fillLeft(i, 6) +\r
-                                               TermGlobals.fillLeft((this.argQL[i])? this.argQL[i]:'-', 4) +\r
-                                               '  "' + this.argv[i] + '"'\r
-                                       ) + '%n';\r
-                       }\r
-                       this.write(s, 1);\r
-                       return;\r
-               }\r
-       }\r
-       this.prompt();\r
-}\r
-\r
-\r
-//-->\r
-</SCRIPT>\r
-\r
-<STYLE TYPE="text/css">\r
-body,p,a,td {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #cccccc;\r
-}\r
-.lh15 {\r
-       line-height: 15px;\r
-}\r
-.term {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #33d011;\r
-       background: none;\r
-}\r
-.termReverse {\r
-       color: #111111;\r
-       background: #33d011;\r
-}\r
-a,a:link,a:visited {\r
-       text-decoration: none;\r
-       color: #77dd11;\r
-}\r
-a:hover {\r
-       text-decoration: underline;\r
-       color: #77dd11;\r
-}\r
-a:active {\r
-       text-decoration: underline;\r
-       color: #dddddd;\r
-}\r
-\r
-a.termopen,a.termopen:link,a.termopen:visited {\r
-       text-decoration: none;\r
-       color: #77dd11;\r
-       background: none;\r
-}\r
-a.termopen:hover {\r
-       text-decoration: none;\r
-       color: #222222;\r
-       background: #77dd11;\r
-}\r
-a.termopen:active {\r
-       text-decoration: none;\r
-       color: #222222;\r
-       background: #dddddd;\r
-}\r
-\r
-</STYLE>\r
-</HEAD>\r
-\r
-\r
-<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
-TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
-<TR>\r
-       <TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP>sample parser</TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="faq.html">faq</A></TD>\r
-       <TD>|</TD>\r
-       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
-</TR>\r
-</TABLE>\r
-\r
-<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">\r
-       <TR><TD NOWRAP>\r
-               Sample Parser Test<BR>&nbsp;\r
-       </TD></TR>\r
-       <TR><TD NOWRAP>\r
-               <A HREF="javascript:termOpen()" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal &nbsp;</A>\r
-       </TD></TR>\r
-       <TR><TD NOWRAP>\r
-               &nbsp;\r
-       </TD></TR>\r
-       <TR><TD NOWRAP CLASS="lh15">\r
-               &nbsp;<BR>\r
-               (c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>\r
-               <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
-       </TD></TR>\r
-</TABLE>\r
-\r
-<DIV ID="termDiv" STYLE="position:absolute;"></DIV>\r
-\r
-</BODY>\r
-</HTML>
\ No newline at end of file
diff --git a/extra/webapps/fjsc/resources/termlib/readme.txt b/extra/webapps/fjsc/resources/termlib/readme.txt
deleted file mode 100644 (file)
index 8a92b9c..0000000
+++ /dev/null
@@ -1,1400 +0,0 @@
-****  mass:werk termlib.js - JS-WebTerminal Object v1.07  ****\r
-\r
-  (c) Norbert Landsteiner 2003-2005\r
-  mass:werk - media environments\r
-  <http://www.masswerk.at>\r
-\r
-\r
-\r
-\r
-Contents:\r
-\r
-   1  About\r
-   2  Creating a new Terminal Instance\r
-      2.1 Configuration Values\r
-   3  Using the Terminal\r
-      3.1  The Default Handler\r
-      3.2  Input Modes\r
-           3.2.1  Normal Line Input (Command Line Mode)\r
-                  3.2.1.2 Special Keys (ctrlHandler)\r
-           3.2.2  Raw Mode\r
-           3.2.3  Character Mode\r
-      3.3  Other Handlers\r
-           3.3.1  initHandler\r
-           3.3.2  exitHandler\r
-      3.4  Flags for Behaviour Control\r
-   4  Output Methods\r
-           4.1 Terminal.type()\r
-           4.2 Terminal.write()\r
-           4.3 Terminal.typeAt()\r
-           4.4 Terminal.setChar()\r
-           4.5 Terminal.newLine()\r
-           4.6 Terminal.clear()\r
-           4.7 Terminal.statusLine()\r
-           4.8 Terminal.printRowFromString()\r
-           4.9 Terminal.redraw()\r
-   5  Cursor Methods and Editing\r
-           5.1 Terminal.cursorOn()\r
-           5.2 Terminal.cursorOff()\r
-           5.3 Terminal.cursorSet()\r
-           5.4 Terminal.cursorLeft()\r
-           5.5 Terminal.cursorRight()\r
-           5.6 Terminal.backspace()\r
-           5.7 Terminal.fwdDelete()\r
-           5.8 Terminal.isPrintable()\r
-   6  Other Methods of the Terminal Object\r
-           6.1 Terminal.prompt()\r
-           6.2 Terminal.reset()\r
-           6.3 Terminal.open()\r
-           6.4 Terminal.close()\r
-           6.5 Terminal.focus()\r
-           6.6 Terminal.moveTo()\r
-           6.7 Terminal.resizeTo()\r
-           6.8 Terminal.getDimensions()\r
-           6.9 Terminal.rebuild()\r
-   7  Global Static Methods (TermGlobals)\r
-           7.1 TermGlobals.setFocus()\r
-           7.2 TermGlobals.keylock (Global Locking Flag)\r
-           7.3 TermGlobalsText Methods\r
-               7.3.1 TermGlobals.normalize()\r
-               7.3.2 TermGlobals.fillLeft()\r
-               7.3.3 TermGlobals.center()\r
-               7.3.4 TermGlobals.stringReplace()\r
-   8  Localization\r
-   9  Cross Browser Functions\r
-  10  Architecture, Internals\r
-      10.1  Global Entities\r
-      10.2  I/O Architecture\r
-      10.3  Compatibility\r
-  11  History\r
-  12  Example for a Command Line Parser\r
-  13  License\r
-  14  Disclaimer\r
-  15  References\r
-\r
-\r
-\r
-\r
-1  About\r
-\r
-The Terminal library "termlib.js" provides an object oriented constructor and control\r
-methods for a terminal-like DHTML interface.\r
-\r
-"termlib.js" features direct keyboard input and powerful output methods for multiple\r
-instances of the `Terminal' object (including focus control).\r
-\r
-The library was written with the aim of simple usage and a maximum of compatibility with\r
-minimal foot print in the global namespace.\r
-\r
-\r
-A simple example:\r
-\r
-  // creating a terminal and using it\r
-\r
-  var term = new Terminal( {handler: termHandler} );\r
-  term.open();\r
-\r
-  function termHandler() {\r
-    var line = this.lineBuffer;\r
-    this.newLine();\r
-    if (line == "help") {\r
-      this.write(helpPage)\r
-    }\r
-    else if (line == "exit") {\r
-      this.close();\r
-      return;\r
-    }\r
-    else if (line != "") {\r
-      this.write("You typed: "+line);\r
-    }\r
-    this.prompt();\r
-  }\r
-\r
-  var helpPage = [\r
-    "This is the monstrous help page for my groovy terminal.",\r
-    "Commands available:",\r
-    "   help ... print this monstrous help page",\r
-    "   exit ... leave this groovy terminal",\r
-    " ",\r
-    "Have fun!"\r
-  ];\r
-\r
-\r
-You should provide CSS font definitions for the classes ".term" (normal video) and\r
-".termReverse" (reverse video) in a monospaced font.\r
-A sample stylesheet "term_styles.css" comes with this library.\r
-\r
-See the sample application "multiterm_test.html" for a demo of multiple terminals.\r
-\r
-v.1.01: If you configure to use another font class (see 2.1 Configuration Values),\r
-        you must provide a subclass ".termReverse" for reversed video.\r
-\r
-        p.e.: .myFontClass .termReverse {\r
-                /* your definitions for reverse video here */\r
-              }\r
-        \r
-        With the addition of `conf.fontClass' you can now create multiple\r
-        instances with independend appearences.\r
-\r
-\r
-\r
-\r
-2   Creating a new Terminal Instance\r
-\r
-Use the `new' constructor to create a new instance of the Terminal object. You will want\r
-to supply a configuration object as an argument to the constructor. If the `new'\r
-constructor is called without an object as its first argument, default values are used.\r
-\r
-p.e.:\r
-\r
-  // creating a new instance of Terminal\r
-\r
-  var conf= {\r
-    x: 100,\r
-    y: 100,\r
-    cols: 80,\r
-    rows: 24\r
-  }\r
-\r
-  var term = new Term(conf);\r
-  term.open();\r
-\r
-`Terminal.open()' initializes the terminal and makes it visible to the user.\r
-This is handled in by separate method to allow the re-initilization of instances\r
-previously closed.\r
-\r
-NOTE:\r
-The division element (or NS-layer) that holds the terminal must be present when calling\r
-`Terminal.open()'. So you must not call this method from the header of a HTML-document at\r
-compile time.\r
-\r
-\r
-\r
-2.1 Configuration Values\r
-\r
-Set any of these values in your configuration object to override:\r
-\r
-  \r
-  LABEL                     DEFAULT VALUE    COMMENT\r
-  \r
-  x                                   100    terminal's position x in px\r
-  y                                   100    terminal's position y in px\r
-  divDiv                        'termDiv'    id of terminals CSS division\r
-  bgColor                       '#181818'    background color (HTML hex value)\r
-  frameColor                    '#555555'    frame color (HTML hex value)\r
-  frameWidth                            1    frame border width in px\r
-  fontClass                        'term'    class name of CSS font definition to use\r
-  cols                                 80    number of cols per row\r
-  rows                                 24    number of rows\r
-  rowHeight                            15    a row's line-height in px\r
-  blinkDelay                          500    delay for cursor blinking in milliseconds\r
-  crsrBlinkMode                     false    true for blinking cursor\r
-  crsrBlockMode                      true    true for block-cursor else underscore\r
-  DELisBS                           false    handle <DEL> as <BACKSPACE>\r
-  printTab                           true    handle <TAB> as printable (prints as space)\r
-  printEuro                          true    handle unicode 0x20AC (Euro sign) as printable\r
-  catchCtrlH                         true    handle ^H as <BACKSPACE>\r
-  closeOnESC                         true    close terminal on <ESC>\r
-  historyUnique                     false    prevent consecutive and identical entries in history\r
-  id                                    0    terminal id\r
-  ps                                  '>'    prompt string\r
-  greeting      '%+r Terminal ready. %-r'    string for greeting if no initHandler is used\r
-  handler              termDefaultHandler    reference to handler for command interpretation\r
-  ctrlHandler                        null    reference to handler called on uncatched special keys\r
-  initHandler                        null    reference to handler called at end of init()\r
-  exitHandler                        null    reference to handler called on close()\r
-\r
-\r
-At least you will want to specify `handler' to implement your own command parser.\r
-\r
-Note: While `id' is not used by the Termninal object, it provides an easy way to identify\r
-multiple terminals by the use of "this.id". (e.g.: "if (this.id == 1) startupterm = true;")\r
-\r
-p.e.:\r
-\r
-  // creating two individual Terminal instances\r
-\r
-  var term1 = new Terminal(\r
-    {\r
-      id: 1,\r
-      x: 200,\r
-      y: 10,\r
-      cols: 80,\r
-      rows: 12,\r
-      greeting: "*** This is Terminal 1 ***",\r
-      handler: myTerminalHandler\r
-    }\r
-  );\r
-  term1.open();\r
-\r
-  var term2 = new Terminal(\r
-    {\r
-      id: 2,\r
-      x, 200,\r
-      y: 220,\r
-      cols: 80\r
-      rows: 12,\r
-      greeting: "*** This is Terminal 2 ***",\r
-      handler: myTerminalHandler\r
-    }\r
-  );\r
-  term2.open();\r
-\r
-\r
-\r
-\r
-3   Using the Terminal\r
-\r
-There are 4 different handlers that are called by a Terminal instance to process input and\r
-some flags to control the input mode and behaviour.\r
-\r
-\r
-\r
-3.1 The Default Handler (a simlple example for input handling)\r
-\r
-If no handlers are defined in the configuration object, a default handler is called to\r
-handle a line of user input. The default command line handler `termDefaultHandler' just\r
-closes the command line with a new line and echos the input back to the user:\r
-\r
-  function termDefaultHandler() {\r
-    this.newLine();\r
-    if (this.lineBuffer != '') {\r
-      this.type('You typed: '+this.lineBuffer);\r
-      this.newLine();\r
-    }\r
-    this.prompt();\r
-  }\r
-\r
-First you may note that the instance is refered to as `this'. So you need not worry about\r
-which Terminal instance is calling your handler. As the handler is entered, the terminal\r
-is locked for user input and the cursor is off. The current input is available as a string\r
-value in `this.lineBuffer'.\r
-\r
-The method `type(<text>)' just does what it says and types a string at the current cursor\r
-position to the terminal screen.\r
-\r
-`newLine()' moves the cursor to a new line.\r
-\r
-The method `prompt()' adds a new line if the cursor isn't at the start of a line, outputs\r
-the prompt string (as specified in the configuration), activates the cursor, and unlocks\r
-the terminal for further input. While you're doing normal command line processing, always\r
-call `prompt()' when leaving your handler.\r
-\r
-In fact this is all you need to create your own terminal application. Please see at least\r
-the method `write()' for a more powerful output method.\r
-\r
-Below we will refer to all methods of the Terminal object as `Terminal.<method>()'.\r
-You can call them as `this.<method>()' in a handler or as methods of your named instance\r
-in other context (e.g.: "myTerminal.close()").\r
-\r
-[In technical terms these methods are methods of the Terminal's prototype object, while\r
-the properties are properties of a Termninal instance. Since this doesn't make any\r
-difference to your script, we'll refer to both as `Terminal.<method-or-property>'.]\r
-\r
-\r
-\r
-3.2 Input Modes\r
-\r
-3.2.1 Normal Line Input (Command Line Mode)\r
-\r
-By default the terminal is in normal input mode. Any printable characters in the range of\r
-ASCII 0x20 - 0xff are echoed to the terminal and may be edited with the use of the cursor\r
-keys and the <BACKSPACE> key.\r
-The cursor keys UP and DOWN let the user browse in the command line history (the list of\r
-all commands issued previously in this Terminal instance).\r
-\r
-If the user presses <CR> or <ENTER>, the line is read from the terminal buffer, converted\r
-to a string, and placed in `Terminal.lineBuffer' (-> `this.lineBuffer') for further use.\r
-The terminal is then locked for further input and the specified handler\r
-(`Terminal.handler') is called.\r
-\r
-\r
-3.2.1.2 Special Keys (ctrlHandler)\r
-\r
-If a special character (ASCII<0x20) or an according combination of <CTRL> and a key is\r
-pressed, which is not caught for editing or "enter", and a handler for `ctrlHandler' is\r
-specified, this handler is called.\r
-The ASCII value of the special character is available in `Terminal.inputChar'. Please note\r
-that the terminal is neither locked, nor is the cursor off - all further actions have to\r
-be controlled by `ctrlHandler'. (The tracking of <CTRL>-<key> combinations as "^C" usually\r
-works but cannot be taken for granted.)\r
-\r
-A named reference of the special control values in POSIX form (as well as the values of\r
-the cursor keys [LEFT, RIGHT, UP, DOWN]) is available in the `termKey' object.\r
-\r
-p.e.:\r
-\r
-  // a simple ctrlHandler\r
-\r
-  function myCtrlHandler() {\r
-    if (this.inputChar == termKey.ETX) {\r
-      // exit on ^C (^C == ASCII 0x03 == <ETX>)\r
-      this.close();\r
-    }\r
-  }\r
-\r
-If no `ctrlHandler' is specified, control keys are ignored (default).\r
-\r
-\r
-3.2.2 Raw Mode\r
-\r
-If the flag `Terminal.rawMode' is set to a value evaluating to `true', no special keys are\r
-tracked but <CR> and <ENTER> (and <ESC>, if the flag `Terminal.closeOnESC' is set).\r
-The input is NOT echoed to the terminal. All printable key values [0x20-0xff] are\r
-transformed to characters and added to `Terminal.lineBuffer' sequentially. The command\r
-line input is NOT added to the history.\r
-\r
-This mode is especially suitable for password input.\r
-\r
-p.e.:\r
-\r
-  // using raw mode for password input\r
-\r
-  function myTermHandler() {\r
-    this.newLine();\r
-    // we stored a flag in Terminal.env to track the status\r
-    if (this.env.getpassword) {\r
-      // leave raw mode\r
-      this.rawMode = false;\r
-      if (passwords[this.env.user] == this.lineBuffer) {\r
-        // matched\r
-        this.type('Welcome '+this.env.user);\r
-        this.env.loggedin = true;\r
-      }\r
-      else {\r
-        this.type('Sorry.');\r
-      }\r
-      this.env.getpassword = false;\r
-    }\r
-    else {\r
-      // simple parsing\r
-      var args = this.lineBuffer.split(' ');\r
-      var cmd = args[0];\r
-      if (cmd == 'login') {\r
-        var user = args[1];\r
-        if (!user) {\r
-          this.type('usage: login <username>');\r
-        }\r
-        else {\r
-          this.env.user = user;\r
-          this.env.getpassword = true;\r
-          this.type('password? ');\r
-          // enter raw mode\r
-          this.rawMode = true;\r
-          // leave without prompt so we must unlock first\r
-          this.lock = false;\r
-          return;\r
-        }\r
-      }\r
-      /*\r
-        other actions ...\r
-      */\r
-    }\r
-    this.prompt();\r
-  }\r
-\r
-In this example a handler is set up to process the command "login <username>" and ask for\r
-a password for the given user name in raw mode. Note the use of the object `Terminal.env'\r
-which is just an empty object set up at the creation of the Terminal instance. Its only\r
-purpose is to provide an individual namespace for private data to be stored by a Terminal\r
-instance.\r
-\r
-NOTE: The flag `Terminal.lock' is used to control the keyboard locking. If we would not\r
-set this to `false' before leaving in raw mode, we would be caught in dead-lock, since no\r
-input could be entered and our handler wouldn't be called again. - A dreadful end of our\r
-terminal session.\r
-\r
-NOTE: Raw mode utilizes the property `Terminal.lastLine' to collect the input string.\r
-This is normally emty, when a handler is called. This is not the case if your script left\r
-the input process on a call of ctrlHandler. You should clear `Terminal.lastLine' in such\r
-a case, if you're going to enter raw mode immediatly after this.\r
-\r
-\r
-3.2.3 Character Mode\r
-\r
-If the flag `Terminal.charMode' is set to a value evaluating to `true', the terminal is in\r
-character mode. In this mode the numeric ASCII value of the next key typed is stored in\r
-`Terminal.inputChar'. The input is NOT echoed to the terminal. NO locking or cursor\r
-control is performed and left to the handler.\r
-You can use this mode to implement your editor or a console game.\r
-`Terminal.charMode' takes precedence over `Terminal.rawMode'.\r
-\r
-p.e.: \r
-\r
-  // using char mode\r
-\r
-  function myTermHandler() {\r
-    // this is the normal handler\r
-    this.newLine();\r
-    // simple parsing\r
-    var args = this.lineBuffer.split(' ');\r
-    var cmd = args[0];\r
-    if (cmd == 'edit') {\r
-      // init the editor\r
-      myEditor(this);\r
-      // redirect the handler to editor\r
-      this.handler = myEditor;\r
-      // leave in char mode\r
-      this.charMode = true;\r
-      // show cursor\r
-      this.cursorOn();\r
-      // don't forget unlocking\r
-      this.lock = false;\r
-      return;\r
-    }\r
-    /*\r
-      other actions ...\r
-    */\r
-    this.prompt();\r
-  }\r
-\r
-  function myEditor(initterm) {\r
-    // our dummy editor (featuring modal behaviour)\r
-    if (initterm) {\r
-      // perform initialization tasks\r
-      initterm.clear();\r
-      initterm.write('this is a simple test editor; leave with <ESC> then "q"%n%n');\r
-      initterm.env.mode = '';\r
-      // store a reference of the calling handler\r
-      initterm.env.handler = initterm.handler;\r
-      return;\r
-    }\r
-    // called as handler -> lock first\r
-    this.lock=true;\r
-    // hide cursor\r
-    this.cursorOff();\r
-    var key = this.inputChar;\r
-    if (this.env.mode == 'ctrl') {\r
-      // control mode\r
-      if (key == 113) {\r
-        // "q" => quit\r
-        // leave charMode and reset the handler to normal\r
-        this.charMode = false;\r
-        this.handler = this.env.handler;\r
-        // clear the screen\r
-        this.clear();\r
-        // prompt and return\r
-        this.prompt();\r
-        return;\r
-      }\r
-      else {\r
-        // leave control mode\r
-        this.env.mode = '';\r
-      }\r
-    }\r
-    else {\r
-      // edit mode\r
-      if (key == termKey.ESC) {\r
-        // enter control mode\r
-        // we'd better indicate this in a status line ...\r
-        this.env.mode = 'ctrl';\r
-      }\r
-      else if (key == termKey.LEFT) {\r
-        // cursor left\r
-      }\r
-      else if (key == termKey.RIGHT) {\r
-        // cursor right\r
-      }\r
-      if (key == termKey.UP) {\r
-        // cursor up\r
-      }\r
-      else if (key == termKey.DOWN) {\r
-        // cursor down\r
-      }\r
-      else if (key == termKey.CR) {\r
-        // cr or enter\r
-      }\r
-      else if (key == termKey.BS) {\r
-        // backspace\r
-      }\r
-      else if (key == termKey.DEL) {\r
-        // fwd delete\r
-        // conf.DELisBS is not evaluated in charMode!\r
-      }\r
-      else if (this.isPrintable(key)) {\r
-        // printable char - just type it\r
-        var ch = String.fromCharCode(key);\r
-        this.type(ch);\r
-      }\r
-    }\r
-    // leave unlocked with cursor\r
-    this.lock = false;\r
-    this.cursorOn();\r
-  }\r
-\r
-\r
-Note the redirecting of the input handler to replace the command line handler by the\r
-editor. The method `Terminal.clear()' clears the terminal.\r
-`Terminal.cursorOn()' and `Terminal.cursorOff()' are used to show and hide the cursor.\r
-\r
-\r
-\r
-3.3 Other Handlers\r
-\r
-There are two more handlers that can be specified in the configuration object:\r
-\r
-\r
-3.3.1 initHandler\r
-\r
-`initHandler' is called at the end of the initialization triggered by `Terminal.open()'.\r
-The default action - if no `initHandler' is specified - is:\r
-\r
-  // default initilization\r
-\r
-  this.write(this.conf.greeting);\r
-  this.newLine();\r
-  this.prompt();\r
-\r
-Use `initHandler' to perform your own start up tasks (e.g. show a start up screen). Keep\r
-in mind that you should unlock the terminal and possibly show a cursor to give the\r
-impression of a usable terminal.\r
-\r
-\r
-3.3.2  exitHandler\r
-\r
-`exitHandler' is called by `Terminal.close()' just before hiding the terminal. You can use\r
-this handler to implement any tasks to be performed on exit. Note that this handler is\r
-called even if the terminal is closed on <ESC> outside of your inputHandlers control.\r
-\r
-See the file "multiterm_test.html" for an example.\r
-\r
-\r
-\r
-3.4   Overview: Flags for Behaviour Control\r
-\r
-These falgs are accessible as `Terminal.<flag>' at runtime. If not stated else, the\r
-initial value may be specified in the configuration object.\r
-The configuration object and its properties are accessible at runtime via `Terminal.conf'.\r
-\r
-\r
-  NAME                      DEFAULT VALUE    MEANING\r
-\r
-  blink_delay                         500    delay for cursor blinking in milliseconds.\r
-\r
-  crsrBlinkMode                     false    true for blinking cursor.\r
-                                             if false, cursor is static.\r
-  \r
-  crsrBlockMode                      true    true for block-cursor else underscore.\r
-\r
-  DELisBS                           false    handle <DEL> as <BACKSPACE>.\r
-\r
-  printTab                           true    handle <TAB> as printable (prints as space)\r
-                                             if false <TAB> is handled as a control character\r
-\r
-  printEuro                          true    handle the euro sign as valid input char.\r
-                                             if false char 0x20AC is printed, but not accepted\r
-                                             in the command line\r
-\r
-  catchCtrlH                         true    handle ^H as <BACKSPACE>.\r
-                                             if false, ^H must be tracked by a custom\r
-                                             ctrlHandler.\r
-\r
-  closeOnESC                         true    close terminal on <ESC>.\r
-                                             if true, <ESC> is not available for ctrHandler.\r
-\r
-\r
-  historyUnique                     false    unique history entries.\r
-                                             if true, entries that are identical to the last\r
-                                             entry in the user history will not be added.\r
-\r
-  charMode                          false    terminal in character mode (tracks next key-code).\r
-                                             (runtime only)\r
\r
-  rawMode                           false    terminal in raw mode (no echo, no editing).\r
-                                             (runtime only)\r
-\r
-\r
-Not exactly a flag but useful:\r
-\r
-  ps                                  '>'    prompt string.\r
-\r
-\r
-\r
-\r
-4  Output Methods\r
-\r
-Please note that any output to the terminal implies an advance of the cursor. This means,\r
-that if your output reaches the last column of your terminal, the cursor is advanced and\r
-a new line is opened automatically. This procedure may include scrolling to make room for\r
-the new line. While this is not of much interest for most purposes, please note that, if\r
-you output a string of length 80 to a 80-columns-terminal, and a new line, and another\r
-string, this will result in an empty line between the two strings.\r
-\r
-\r
-4.1  Terminal.type( <text> [,<stylevector>] )\r
-\r
-Types the string <text> at the current cursor position to the terminal. Long lines are\r
-broken where the last column of the terminal is reached and continued in the next line.\r
-`Terminal.write()' does not support any kind of arbitrary line breaks. (This is just a\r
-basic output routine. See `Terminal.write()' for a more powerful output method.)\r
-\r
-A bitvector may be supplied as an optional second argument to represent a style or a\r
-combination of styles. The meanings of the bits set are interpreted as follows:\r
-\r
-<stylevector>:\r
-\r
-   1 ... reverse    (2 power 0)\r
-   2 ... underline  (2 power 1)\r
-   4 ... italics    (2 power 2)\r
-   8 ... strike     (2 power 3)\r
-\r
-So "Terminal.type( 'text', 5 )" types "text" in italics and reverse video.\r
-\r
-Note:\r
-There is no bold, for most monospaced fonts (including Courier) tend to render wider in\r
-bold. Since this would bring the terminal's layout out of balance, we just can't use bold\r
-as a style. - Sorry.\r
-\r
-The HTML-representation of this styles are defined in "TermGlobals.termStyleOpen" and\r
-"TermGlobals.termStyleClose".\r
-\r
-\r
-4.2  Terminal.write( <text> [,<usemore>] )\r
-\r
-Writes a text with markup to the terminal. If an optional second argument evaluates to\r
-true, a UN*X-style utility like `more' is used to page the text. The text may be supplied\r
-as a single string (with newline character "\n") or as an array of lines. Any other input\r
-is transformed to a string value before output.\r
-\r
-4.2.1 Mark-up:\r
-\r
-`Terminal.write()' employs a simple mark-up with the following syntax:\r
-\r
-<markup>: %([+|-]<style>|n|CS|%)\r
-   \r
-   where "+" and '-' are used to switch on and off a style, where\r
-   \r
-   <style>:\r
-   \r
-      "i" ... italics\r
-      "r" ... reverse\r
-      "s" ... strike\r
-      "u" ... underline\r
-      \r
-      "p" ... reset to plain ("%+p" == "%-p")\r
-    \r
-   styles may be combined and may overlap. (e.g. "This is %+rREVERSE%-r, %+uUNDER%+iSCORE%-u%-i.")\r
-   \r
-   "%n"  represents a new line (in fact "\n" is translated to "%n" before processing)\r
-   \r
-   "%CS" clears the terminal screen\r
-   \r
-   "%%"  represents the percent character ('%')\r
-\r
-\r
-4.2.2 Buffering:\r
-\r
-`Terminal.write()' writes via buffered output to the terminal. This means that the\r
-provided text is rendered to a buffer first and then only the visible parts are transfered\r
-to the terminal display buffers. This avoids scrolling delays for long output.\r
-\r
-4.2.3 UseMore Mode:\r
-\r
-The buffering of `Terminal.write()' allows for pagewise output, which may be specified by\r
-a second boolean argument. If <usemore> evaluates to `true' and the output exceeds the\r
-range of empty rows on the terminal screen, `Terminal.write()' performs like the UN*X\r
-utility `more'. The next page may be accessed by hitting <SPACE> while <q> terminates\r
-paging and returns with the prompt (-> `Terminal.prompt()').\r
-\r
-To use this facillity make sure to return immediatly after calling `Terminal.write()' in\r
-order to allow the more-routine to track the user input.\r
-The terminal is set to "charMode == false" afterwards.\r
-\r
-p.e.:\r
-\r
-  // using Terminal.write as a pager\r
-\r
-  function myTermHandler() {\r
-    this.newLine();\r
-    var args = this.lineBuffer.split(' ');\r
-    var cmd = args[0];\r
-    if (cmd == 'more') {\r
-      var page = args[1];\r
-      if (myPages[page]) {\r
-        // Terminal.write as a pager\r
-        this.write(myPages[page], true);\r
-        return;\r
-      }\r
-      else {\r
-        // Terminal.write for simple output\r
-        this.write('no such page.');\r
-      }\r
-    }\r
-    /*\r
-      other actions ...\r
-    */\r
-    this.prompt();\r
-  }\r
-\r
-\r
-4.3  Terminal.typeAt( <r>, <c>, <text> [,<stylevector>] )\r
-\r
-Output the string <text> at row <r>, col <c>.\r
-For <stylevector> see `Terminal.type()'.\r
-`Terminal.typeAt()' does not move the cursor.\r
-\r
-\r
-4.4  Terminal.setChar( <charcode>, <r>, <c> [,<stylevector>] )\r
-\r
-Output a single character represented by the ASCII value of <charcode> at row <r>, col <c>.\r
-For <stylevector> see `Terminal.type()'.\r
-\r
-\r
-4.5  Terminal.newLine()\r
-\r
-Moves the cursor to the first column of the next line and performs scrolling, if needed.\r
-\r
-\r
-4.6  Terminal.clear()\r
-\r
-Clears the terminal screen. (Returns with cursor off.)\r
-\r
-\r
-4.7  Terminal.statusLine( <text> [,<stylevector> [,<lineoffset>]] )\r
-\r
-All output acts on a logical screen with the origin at row 0 / col 0. While the origin is\r
-fixed, the logical width and height of the terminal are defined by `Terminal.maxCols' and\r
-`Terminal.maxLines'. These are set to the configuration dimensions at initilization and by\r
-`Terminal.reset()', but may be altered at any moment. Please note that there are no bounds\r
-checked, so make sure that `Terminal.maxCols' and `Terminal.maxLines' are less or equal\r
-to the configuration dimensions.\r
-\r
-You may want to decrement `Terminal.maxLines' to keep space for a reserved status line.\r
-`Terminal.statusLine( <text>, <style> )' offers a simple way to type a text to the last\r
-line of the screen as defined by the configuration dimensions.\r
-\r
-  // using statusLine()\r
-\r
-  function myHandler() {\r
-    // ...\r
-    // reserve last line\r
-    this.maxLines = term.conf.rows-1;\r
-    // print to status line in reverse video\r
-    this.statusLine("Status: <none>", 1);\r
-    // ...\r
-  }\r
-\r
-For multiple status lines the optional argument <lineoffset> specifies the addressed row,\r
-where 1 is the line closest to the bottom, 2 the second line from the bottom and so on.\r
-(default: 1)\r
-\r
-\r
-4.8  Terminal.printRowFromString( <r> , <text> [,<stylevector>] )\r
-\r
-Outputs the string <text> to row <r> in the style of an optional <stylevector>.\r
-If the string's length exceeds the length of the row  (up to `Terminal.conf.cols'), extra\r
-characteres are ignored, else any extra space is filled with character code 0 (prints as\r
-<SPACE>).\r
-The valid range for <row> is: 0 >= <row> < `Terminal.maxLines'.\r
-`Terminal.printRowFromString()' does not set the cursor.\r
-\r
-You could, for example, use this method to output a line of a text editor's buffer.\r
-\r
-p.e.:\r
-\r
-  // page refresh function of a text editor\r
-\r
-  function myEditorRefresh(termref, topline) {\r
-    // termref: reference to Terminal instance\r
-    // topline: index of first line to print\r
-    // lines of text are stored in termref.env.lines\r
-    for (var r=0; r<termref.maxLines; r++) {\r
-      var i = topline + r;\r
-      if (i < termref.env.lines.length) {\r
-        // output stored line\r
-        termref.printRowFromString(r, termref.env.lines[i]);\r
-      }\r
-      else {\r
-        // output <tilde> for empty line\r
-        termref.printRowFromString(r, '~');\r
-      }\r
-    }\r
-    // set cursor to origin\r
-    termref.r = termref.c = 0; // same as termref.cursorSet(0, 0);\r
-  }\r
-\r
-\r
-4.9  Terminal.redraw( <row> )\r
-\r
-Basic function to redraw a terminal row <row> according to screen buffer values.\r
-For hackers only. (e.g.: for a console game, hack screen buffers first and redraw all\r
-changed rows at once.)\r
-\r
-\r
-\r
-\r
-5  Cursor Methods and Editing\r
-\r
-\r
-5.1  Terminal.cursorOn()\r
-\r
-Show the cursor.\r
-\r
-\r
-5.2  Terminal.cursorOff()\r
-\r
-Hide the cursor.\r
-\r
-\r
-5.3  Terminal.cursorSet( <r>, <c> )\r
-\r
-Set the cursor position to row <r> column <c>.\r
-`Terminal.cursorSet()' preserves the cursor's active state (on/off).\r
-\r
-\r
-5.4  Terminal.cursorLeft()\r
-\r
-Move the cursor left. (Movement is restricted to the logical input line.)\r
-`Terminal.cursorLeft()' preserves the cursor's active state (on/off).\r
-\r
-\r
-5.5  Terminal.cursorRight()\r
-\r
-Move the cursor right. (Movement is restricted to the logical input line.)\r
-`Terminal.cursorRight()' preserves the cursor's active state (on/off).\r
-\r
-\r
-5.6  Terminal.backspace()\r
-\r
-Delete the character left from the cursor, if the cursor is not in first position of the\r
-logical input line.\r
-`Terminal.backspace()' preserves the cursor's active state (on/off).\r
-\r
-\r
-5.7  Terminal.fwdDelete()\r
-\r
-Delete the character under the cursor.\r
-`Terminal.fwdDelete()' preserves the cursor's active state (on/off).\r
-\r
-\r
-5.8  Terminal.isPrintable( <key code> [,<unicode page 1 only>] )\r
-\r
-Returns `true' if the character represented by <key code> is printable with the current\r
-settings. An optional second argument <unicode page 1 only> limits the range of valid\r
-values to 255 with the exception of the Euro sign, if the flag `Terminal.printEuro' is set.\r
-(This second flag is used for input methods but not for output methods. So you may only\r
-enter portable characters, but you may print others to the terminals screen.)\r
-\r
-\r
-\r
-\r
-6  Other Methods of the Terminal Object\r
-\r
-6.1  Terminal.prompt()\r
-\r
-Performes the following actions:\r
-\r
-  * advance the cursor to a new line, if the cursor is not at 1st column\r
-  * type the prompt string (as specified in the configuaration object)\r
-  * show the cursor\r
-  * unlock the terminal\r
-\r
-(The value of the prompt string can be accessed and changed in `Terminal.ps'.)\r
-\r
-\r
-6.2  Terminal.reset()\r
-\r
-Resets the terminal to sane values and clears the terminal screen.\r
-\r
-\r
-6.3  Terminal.open()\r
-\r
-Opens the terminal. If this is a fresh instance, the HTML code for the terminal is\r
-generated. On re-entry the terminal's visibility is set to `true'. Initialization tasks\r
-are performed and the optional initHandler called. If no initHandler is specified in the\r
-configuration object, the greeting (configuration or default value) is shown and the user\r
-is prompted for input.\r
-\r
-v.1.01: `Terminal.open()' now checks for the existence of the DHTML element as defined in\r
-        `Terminal.conf.termDiv' and returns success.\r
-\r
-\r
-6.4  Terminal.close()\r
-\r
-Closes the terminal and hides its visibility. An optional exitHandler (specified in the\r
-configuration object) is called, and finally the flag `Terminal.closed' is set to true. So\r
-you can check for existing terminal instances as you would check for a `window' object\r
-created by `window.open()'.\r
-\r
-p.e.:\r
-\r
-  // check for a terminals state\r
-  // let array "term" hold references to terminals\r
-\r
-  if (term[n]) {\r
-    if (term[n].closed) {\r
-      // terminal exists and is closed\r
-      // re-enter via "term[n].open()"\r
-    }\r
-    else {\r
-      // terminal exists and is currently open\r
-    }\r
-  }\r
-  else {\r
-    // no such terminal\r
-    // create it via "term[n] = new Terminal()"\r
-  }\r
-\r
-\r
-6.5  Terminal.focus()\r
-\r
-Set the keyboard focus to this instance of Terminal. (As `window.focus()'.)\r
-\r
-\r
-6.6  Terminal.moveTo( <x>, <y> )\r
-\r
-Move the terminal to position <x>/<y> in px.\r
-(As `window.moveTo()', but inside the HTML page.)\r
-\r
-\r
-6.7  Terminal.resizeTo( <x>, <y> )\r
-\r
-Resize the terminal to dimensions <x> cols and <y> rows.\r
-<x> must be at least 4, <y> at least 2.\r
-`Terminal.resizeTo()' resets `Terminal.conf.rows', `Terminal.conf.cols',\r
-`Terminal.maxLines', and `Terminal.maxCols' to <y> and <x>, but leaves the instance' state\r
-else unchanged. Clears the terminal's screen and returns success.\r
-\r
-(A bit like `window.resizeTo()', but with rows and cols instead of px.)\r
-\r
-\r
-6.8  Terminal.getDimensions()\r
-\r
-Returns an object with properties "width" and "height" with numeric values for the\r
-terminal's outer dimensions in px. Values are zero (0) if the element is not present or\r
-if the method fails otherwise.\r
-\r
-\r
-6.9  Terminal.rebuild()\r
-\r
-Rebuilds the Terminal object's GUI preserving its state and content.\r
-Use this to change the color theme on the fly.\r
-\r
-p.e.:\r
-\r
-   // change color settings on the fly\r
-   // here: set bgColor to white and font style to "termWhite"\r
-   // method rebuild() updates the GUI without side effects\r
-\r
-   term.conf.bgColor = '#ffffff';\r
-   term.conf.fontClass = 'termWhite';\r
-   term.rebuild();\r
-\r
-\r
-\r
-\r
-7   Global Static Methods (TermGlobals)\r
-\r
-\r
-7.1  TermGlobals.setFocus( <termref> )\r
-\r
-Sets the keyboard focus to the instance referenced by <termref>.\r
-The focus is controlled by `TermGlobals.activeTerm' which may be accessed directly.\r
-See also: `Terminal.focus()'\r
-\r
-\r
-7.2  TermGlobals.keylock (Global Locking Flag)\r
-\r
-The global flag `TermGlobals.keylock' allows temporary keyboard locking without any\r
-other change of state. Use this to free the keyboard for any other resources.\r
-(added in v.1.03)\r
-\r
-\r
-7.3  TermGlobals Text Methods\r
-\r
-There is a small set of methods for common terminal related string tasks:\r
-\r
-\r
-7.3.1  TermGlobals.normalize( <n>, <fieldlength> )\r
-\r
-Converts a number to a string, which is filled at its left with zeros ("0") to the total\r
-length of <filedlength>. (e.g.: "TermGlobals.normalize(1, 2)" => "01")\r
-\r
-\r
-7.3.2  TermGlobals.fillLeft( <value>, <fieldlength> )\r
-\r
-Converts a value to a string and fills it to the left with blanks to <fieldlength>.\r
-\r
-\r
-7.3.3  TermGlobals.center( <text>, <length> )\r
-\r
-Adds blanks at the left of the string <text> until the text would be centered at a line\r
-of length <length>. (No blanks are added to the the right.)\r
-\r
-\r
-7.3.4  TermGlobals.stringReplace( <string1>, <string2>, <text> )\r
-\r
-Replaces all occurences of the string <string1> in <text> with <string2>.\r
-This is just a tiny work around for browsers with no support of RegExp.\r
-\r
-\r
-\r
-\r
-8   Localization\r
-\r
-The strings and key-codes used by the more utility of `Terminal.write()' are the only\r
-properties of "termlib.js" that may need localization. These properties are defined in\r
-`TermGlobals'. You may override them as needed:\r
-\r
-PROPERTY                                      STANDARD VALUE                 COMMENT\r
-\r
-TermGlobals.lcMorePrompt1                                    ' -- MORE -- '  1st string\r
-TermGlobals.lcMorePromtp1Style                                            1  reverse\r
-TermGlobals.lcMorePrompt2       ' (Type: space to continue, \'q\' to quit)'  appended string\r
-TermGlobals.lcMorePrompt2Style                                            0  plain\r
-TermGlobals.lcMoreKeyAbort                                              113  (key-code: q)\r
-TermGlobals.lcMoreKeyContinue                                            32  (key-code <SPACE>)\r
-\r
-\r
-As "TermGlobals.lcMorePrompt2" is appended to "TermGlobals.lcMorePrompt1" make sure that\r
-the length of the combined strings does not exceed `Terminal.conf.cols'.\r
-\r
-\r
-\r
-\r
-9   Cross Browser Functions\r
-\r
-For DHTML rendering some methods - as needed by the Terminal library - are provided.\r
-These may also be accessed for other purposes.\r
-\r
-\r
-9.1  TermGlobals.writeElement( <element id>, <text> [,<NS4 parent document>] )\r
-\r
-Writes <text> to the DHTML element with id/name <element id>. \r
-<NS4 parent document> is used for NS4 only and specifies an optional reference to a parent\r
-document (default `window.document').\r
-\r
-9.2  TermGlobals.setElementXY( <element id>, <x>, <y> )\r
-\r
-Sets the DHTML element with id/name <element id> to position <x>/<y>.\r
-For NS4 works only with children of the top document (window.document).\r
-\r
-\r
-9.3  TermGlobals.setVisible( <element id>, <value> )\r
-\r
-If <value> evaluates to `true' show DHTML element with id/name <element id> else hide it.\r
-For NS4 works only with children of the top document (window.document).\r
-\r
-\r
-9.4  Custom Fixes for Missing String Methods\r
-\r
-Although `String.fromCharCode' and `String.prototype.charCodeAt' are defined by ECMA-262-2\r
-specifications, a few number of browsers lack them in their JavaScript implementation. At\r
-compile time custom methods are installed to fix this. Please note that they work only\r
-with ASCII characters and values in the range of [0x20-0xff].\r
-\r
-\r
-9.5  TermGlobals.setDisplay( <element id>, <value> )\r
-\r
-Sets the style.display property of the element with id/name <element id> to the given\r
-<value>. (added with v. 1.06)\r
-\r
-\r
-\r
-\r
-10   Architecture, Internals\r
-\r
-10.1  Global Entities\r
-\r
-The library is designed to leave only a small foot print in the namespace while providing\r
-suitable usability:\r
-\r
-  Globals defined in this library:\r
-\r
-    Terminal           (Terminal object, `new' constructor and prototype methods)\r
-    TerminalDefaults   (default configuration, static object)\r
-    termDefaultHandler (default command line handler, static function)\r
-    TermGlobals        (common vars and code for all instances, static object and methods)\r
-    termKey            (named mappings for special keys, static object)\r
-    termDomKeyRef      (special key mapping for DOM key constants, static object)\r
-\r
-\r
-  Globals defined for fixing String methods, if missing\r
-  (String.fromCharCode, String.prototype.charCodeAt):\r
-\r
-    termString_keyref, termString_keycoderef, termString_makeKeyref\r
-\r
-  \r
-  Required CSS classes for font definitions: ".term", ".termReverse".\r
-\r
-\r
-\r
-10.2  I/O Architecture\r
-\r
-The Terminal object renders keyboard input from keyCodes to a line buffer and/or to a\r
-special keyCode buffer. In normal input mode printable input is echoed to the screen\r
-buffers. Special characters like <LEFT>, <RIGHT>, <BACKSPACE> are processed for command\r
-line editing by the internal key-handler `TermGlobals.keyHandler' and act directly on the\r
-screen buffers. On <CR> or <ENTER> the start and end positions of the current line are\r
-evaluated (terminated by ASCII 0x01 at the beginning which separates the prompt from the\r
-user input, and any value less than ASCII 0x20 (<SPACE>) at the right end). Then the\r
-character representation for the buffer values in this range are evaluated and\r
-concatenated to a string stored in `Terminal.lineBuffer'. As this involves some\r
-ASCII-to-String-transformations, the range of valid printable input characters is limited\r
-to the first page of unicode characters (0x0020-0x00ff).\r
-\r
-There are two screen buffers for output, one for character codes (ASCII values) and one\r
-for style codes. Style codes represent combination of styles as a bitvector (see\r
-`Terminal.type' for bit values.) The method `Terminal.redraw(<row>)' finally renders the\r
-buffers values to a string of HTML code, which is written to the HTML entity holding the\r
-according terminal row. The character buffer is a 2 dimensional array\r
-`Terminal.charBuf[<row>][<col>]' with ranges for <row> from 0 to less than\r
-`Terminal.conf.rows' and for <col> from 0 to less than `Terminal.conf.cols'. The style\r
-buffer is a 2 dimensional array `Terminal.styleBuf[<row>][<col>]' with according ranges.\r
-\r
-So every single character is represented by a ASCII code in `Terminal.charBuf' and a\r
-style-vector in `Terminal.styleBuf'. The range of printable character codes is unlimitted\r
-but should be kept to the first page of unicode characters (0x0020-0x00ff) for\r
-compatibility purpose. (c.f. 8.4)\r
-\r
-Keyboard input is first handled on the `KEYDOWN' event by the handler `TermGlobals.keyFix'\r
-to remap the keyCodes of cursor keys to consistent values. (To make them distinctable from\r
-any other possibly printable values, the values of POSIX <IS4> to <IS1> where chosen.)\r
-The mapping of the cursor keys is stored in the properties LEFT, RIGHT, UP, and DOWN of\r
-the global static object `termKey'.\r
-\r
-The main keyboard handler `TermGlobals.keyHandler' (invoked on `KEYPRESS' or by\r
-`TermGlobals.keyFix') does some final mapping first. Then the input is evaluated as\r
-controlled by the flags `Terminal.rawMode' and `Terminal.charMode' with precedence of the\r
-latter. In dependancy of the mode defined and the handlers currently defined, the input\r
-either is ignored, or is internally processed for command line editing, or one of the\r
-handlers is called.\r
-\r
-In the case of the simultanous presecence of two instances of Terminal, the keyboard focus\r
-is controlled via a reference stored in `TermGlobals.activeTerm'. This reference is also\r
-used to evaluate the `this'-context of the key handlers which are methods of the static\r
-Object `TermGlobals'.\r
-\r
-A terminal's screen consists of a HTML-table element residing in the HTML/CSS division\r
-spcified in `Terminal.conf.termDiv'. Any output is handled on a per row bases. The\r
-individual rows are either nested sub-divisions of the main divisions (used for NS4 or\r
-browsers not compatible to the "Gecko" engine) or the indiviual table data elements (<TD>)\r
-of the terminal's inner table (used for browsers employing the "Gecko" engine).\r
-(This implementation was chosen for rendering speed and in order to minimize any screen\r
-flicker.) Any output or change of state in a raw results in the inner HTML contents of a\r
-row's HTML element to be rewritten. Please note that as a result of this a blinking cursor\r
-may cause a flicker in the line containing the cursor's position while displayed by a\r
-browser, which employs the "Gecko" engine.\r
-\r
-\r
-\r
-10.3  Compatibility\r
-\r
-Standard web browsers with a JavaScript implementation compliant to ECMA-262 2nd edition\r
-[ECMA262-2] and support for the anonymous array and object constructs and the anonymous\r
-function construct in the form of "myfunc = function(x) {}" (c.f. ECMA-262 3rd edion\r
-[ECMA262-3] for details). This comprises almost all current browsers but Konquerer (khtml)\r
-and versions of Apple Safari for Mac OS 10.0-10.28 (Safari < 1.1) which lack support for\r
-keyboard events.\r
-\r
-To provide a maximum of compatibilty the extend of language keywords used was kept to a\r
-minimum and does not exceed the lexical conventions of ECMA-262-2. Especially there is no\r
-use of the `switch' statement or the `RegExp' method of the global object. Also the use of\r
-advanced Array methods like `push', `shift', `splice' was avoided.\r
-\r
-\r
-\r
-\r
-11   History\r
-\r
-This library evolved from the terminal script "TermApp" ((c) N. Landsteiner 2003) and is\r
-in its current form a down scaled spinn-off of the "JS/UIX" project [JS/UIX] (evolution\r
-"JS/UIX v0.5"). c.f.: <http://www.masswerk.at/jsuix>\r
-\r
-v 1.01: added Terminal.prototype.resizeTo(x,y)\r
-        added Terminal.conf.fontClass (=> configureable class name)\r
-        Terminal.prototype.open() now checks for element conf.termDiv in advance\r
-          and returns success.\r
-\r
-v 1.02: added support for <TAB> and Euro sign\r
-          Terminal.conf.printTab\r
-          Terminal.conf.printEuro\r
-        and method Terminal.prototype.isPrintable(keycode)\r
-        added support for getopt to sample parser ("parser_sample.html")\r
-\r
-\r
-v 1.03: added global keyboard locking (TermGlobals.keylock)\r
-        modified Terminal.prototype.redraw for speed (use of locals)\r
-\r
-\r
-v 1.04: modified the key handler to fix a bug with MSIE5/Mac\r
-        fixed a bug in TermGlobals.setVisible with older MSIE-alike browsers without\r
-        DOM support.\r
-        moved the script of the sample parser to an individual document\r
-        => "termlib_parser.js" (HTML document is "parser_sample.html" as before)\r
-\r
-v 1.05: added config flag historyUnique.\r
-\r
-v 1.06: fixed CTRl+ALT (Windows alt gr) isn't CTRL any more\r
-        -> better support for international keyboards with MSIE/Win.\r
-        fixed double backspace bug for Safari;\r
-        added TermGlobals.setDisplay for setting style.display props\r
-        termlib.js now outputs lower case html (xhtml compatibility)\r
-        (date: 12'2006)\r
-\r
-v 1.07: added method Terminal.rebuild() to rebuild the GUI with new color settings.\r
-        (date: 01'2007)\r
-\r
-\r
-\r
-\r
-12  Example for a Command Line Parser\r
-\r
-  // parser example, splits command line to args with quoting and escape\r
-  // for use as `Terminal.handler'\r
-  \r
-  function commandHandler() {\r
-    this.newLine();\r
-    var argv = [''];     // arguments vector\r
-    var argQL = [''];    // quoting level\r
-    var argc = 0;        // arguments cursor\r
-    var escape = false ; // escape flag\r
-    for (var i=0; i<this.lineBuffer.length; i++) {\r
-      var ch= this.lineBuffer.charAt(i);\r
-      if (escape) {\r
-        argv[argc] += ch;\r
-        escape = false;\r
-      }\r
-      else if ((ch == '"') || (ch == "'") || (ch == "`")) {\r
-        if (argQL[argc]) {\r
-          if (argQL[argc] == ch) {\r
-            argc ++;\r
-            argv[argc] = argQL[argc] = '';\r
-          }\r
-          else {\r
-            argv[argc] += ch;\r
-          }\r
-        }\r
-        else {\r
-          if (argv[argc] != '') {\r
-            argc ++;\r
-            argv[argc] = '';\r
-            argQL[argc] = ch;\r
-          }\r
-          else {\r
-            argQL[argc] = ch;\r
-          }\r
-        }\r
-      }\r
-      else if ((ch == ' ') || (ch == '\t')) {\r
-        if (argQL[argc]) {\r
-          argv[argc] += ch;\r
-        }\r
-        else if (argv[argc] != '') {\r
-          argc++;\r
-          argv[argc] = argQL[argc] = '';\r
-        }\r
-      }\r
-      else if (ch == '\\') {\r
-        escape = true;\r
-      }\r
-      else {\r
-        argv[argc] += ch;\r
-      }\r
-    }\r
-    if ((argv[argc] == '') && (!argQL[argc])) {\r
-      argv.length--;\r
-      argQL.length--;\r
-    }\r
-    if (argv.length == 0) {\r
-      // no commmand line input\r
-    }\r
-    else if (argQL[0]) {\r
-      // first argument quoted -> error\r
-      this.write("Error: first argument quoted by "+argQL[0]);\r
-    }\r
-    else {\r
-      argc = 0;\r
-      var cmd = argv[argc++];\r
-      /*\r
-        parse commands\r
-        1st argument is argv[argc]\r
-        arguments' quoting levels in argQL[argc] are of (<empty> | ' | " | `)\r
-      */\r
-      if (cmd == 'help') {\r
-        this.write(helpPage);\r
-      }\r
-      else if (cmd == 'clear') {\r
-        this.clear();\r
-      }\r
-      else if (cmd == 'exit') {\r
-        this.close();\r
-        return;\r
-      }\r
-      else {\r
-        // for test purpose just output argv as list\r
-        // assemple a string of style-escaped lines and output it in more-mode\r
-        s='   ARG  QL  VALUE%n';\r
-        for (var i=0; i<argv.length; i++) {\r
-          s += TermGlobals.stringReplace('%', '%%',\r
-                 TermGlobals.fillLeft(i, 6) +\r
-                 TermGlobals.fillLeft((argQL[i])? argQL[i]:'-', 4) +\r
-                 '  "' + argv[i] + '"'\r
-            ) + '%n';\r
-        }\r
-        this.write(s, 1);\r
-        return;\r
-      }\r
-    }\r
-    this.prompt();\r
-  }\r
-\r
-\r
-The file "parser_sample.html" features a stand-alone parser ("termlib_parser.js") very\r
-much like this. You are free to use it according to the termlib-license (see sect. 13).\r
-It provides configurable values for quotes and esape characters and imports the parsed\r
-argument list into a Terminal instance's namespace. ("parser_sample.html" and\r
-"termlib_parser.js" should accompany this file.)\r
-\r
-\r
-\r
-\r
-13   License\r
-\r
-This JavaScript-library is free for private and academic use.\r
-Please include a readable copyright statement and a backlink to <http://www.masswerk.at>\r
-in the web page. The library should always be accompanied by the 'readme.txt' and the\r
-sample HTML-documents.\r
-\r
-The term "private use" includes any personal or non-commercial use, which is not related\r
-to commercial activites, but excludes intranet, extranet and/or public net applications\r
-that are related to any kind of commercial or profit oriented activity.\r
-\r
-For commercial use see <http://www.masswerk.at> for contact information.\r
-\r
-Any changes to the library should be commented and be documented in the readme-file.\r
-Any changes must be reflected in the `Terminal.version' string as\r
-"Version.Subversion (compatibility)".\r
-\r
-\r
-\r
-\r
-14   Disclaimer\r
-\r
-This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY\r
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
-PURPOSE. The entire risk as to the quality and performance of the product is borne by the\r
-user. No use of the product is authorized hereunder except under this disclaimer.\r
-\r
-\r
-\r
-\r
-15   References\r
-\r
-[ECMA262-2] "ECMAScript Language Specification" Standard ECMA-262 2nd Edition\r
-            August 1998 (ISO/IEC 16262 - April 1998)\r
-\r
-[ECMA262-3] "ECMAScript Language Specification" Standard ECMA-262 3rd Edition Final\r
-            24 March 2000\r
-\r
-[JS/UIX]     JS/UIX - JavaScript Uniplexed Interface eXtension\r
-             <http://www.masswerk.at/jsuix>\r
-\r
-\r
-\r
-\r
-\r
-Norbert Landsteiner / Vienna, August 2005\r
-mass:werk - media environments\r
-<http://www.masswerk.at>\r
-See web site for contact information.\r
diff --git a/extra/webapps/fjsc/resources/termlib/term_styles.css b/extra/webapps/fjsc/resources/termlib/term_styles.css
deleted file mode 100644 (file)
index 4971709..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-.term {\r
-       font-family: courier,fixed,swiss,sans-serif;\r
-       font-size: 12px;\r
-       color: #33d011;\r
-       background: none;\r
-}\r
-\r
-.termReverse {\r
-       color: #111111;\r
-       background: #33d011;\r
-}\r
diff --git a/extra/webapps/fjsc/resources/termlib/termlib.js b/extra/webapps/fjsc/resources/termlib/termlib.js
deleted file mode 100644 (file)
index 195e11f..0000000
+++ /dev/null
@@ -1,1633 +0,0 @@
-/*\r
-  termlib.js - JS-WebTerminal Object v1.07\r
-\r
-  (c) Norbert Landsteiner 2003-2005\r
-  mass:werk - media environments\r
-  <http://www.masswerk.at>\r
-\r
-  Creates [multiple] Terminal instances.\r
-\r
-  Synopsis:\r
-\r
-  myTerminal = new Terminal(<config object>);\r
-  myTerminal.open();\r
-\r
-  <config object> overrides any values of object `TerminalDefaults'.\r
-  individual values of `id' must be supplied for multiple terminals.\r
-  `handler' specifies a function to be called for input handling.\r
-  (see `Terminal.prototype.termDefaultHandler()' and documentation.)\r
-\r
-  globals defined in this library:\r
-       Terminal           (Terminal object)\r
-    TerminalDefaults   (default configuration)\r
-    termDefaultHandler (default command line handler)\r
-    TermGlobals        (common vars and code for all instances)\r
-    termKey            (named mappings for special keys)\r
-    termDomKeyRef      (special key mapping for DOM constants)\r
-\r
-  globals defined for fixing String methods, if missing\r
-  (String.fromCharCode, String.prototype.charCodeAt):\r
-    termString_keyref, termString_keycoderef, termString_makeKeyref\r
-\r
-  required CSS classes for font definitions: ".term", ".termReverse".\r
-\r
-  Compatibilty:\r
-  Standard web browsers with a JavaScript implementation compliant to\r
-  ECMA-262 2nd edition and support for the anonymous array and object\r
-  constructs and the anonymous function construct in the form of\r
-  "myfunc=function(x) {}" (c.f. ECMA-262 3rd edion for details).\r
-  This comprises almost all current browsers but Konquerer (khtml) and\r
-  versions of Apple Safari for Mac OS 10.0-10.28 (Safari 1.0) which\r
-  lack support for keyboard events.\r
-\r
-  License:\r
-  This JavaScript-library is free for private and academic use.\r
-  Please include a readable copyright statement and a backlink to\r
-  <http://www.masswerk.at> in the web page.\r
-  The library should always be accompanied by the 'readme.txt' and the\r
-  sample HTML-documents.\r
-  \r
-  The term "private use" includes any personal or non-commercial use, which\r
-  is not related to commercial activites, but excludes intranet, extranet\r
-  and/or public net applications that are related to any kind of commercial\r
-  or profit oriented activity.\r
-\r
-  For commercial use see <http://www.masswerk.at> for contact information.\r
-  \r
-  Any changes should be commented and must be reflected in `Terminal.version'\r
-  in the format: "Version.Subversion (compatibility)".\r
-\r
-  Disclaimer:\r
-  This software is distributed AS IS and in the hope that it will be useful,\r
-  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The entire risk as to\r
-  the quality and performance of the product is borne by the user. No use of\r
-  the product is authorized hereunder except under this disclaimer.\r
-\r
-  ### The sections above must not be removed. ###\r
-  \r
-  version 1.01: added Terminal.prototype.resizeTo(x,y)\r
-                added Terminal.conf.fontClass (=> configureable class name)\r
-                Terminal.prototype.open() now checks for element conf.termDiv\r
-                in advance and returns success.\r
-\r
-  version 1.02: added support for <TAB> and Euro sign\r
-                (Terminal.conf.printTab, Terminal.conf.printEuro)\r
-                and a method to evaluate printable chars:\r
-                Terminal.prototype.isPrintable(keycode)\r
-\r
-  version 1.03: added global keyboard locking (TermGlobals.keylock)\r
-                modified Terminal.prototype.redraw for speed (use of locals)\r
-\r
-  version 1.04: modified the key handler to fix a bug with MSIE5/Mac\r
-                fixed a bug in TermGlobals.setVisible with older MSIE-alike\r
-                browsers without DOM support.\r
-\r
-  version 1.05: added config flag historyUnique.\r
\r
-  version 1.06: fixed CTRl+ALT (Windows alt gr) isn't CTRL any more\r
-                fixed double backspace bug for Safari;\r
-                added TermGlobals.setDisplay for setting style.display props\r
-                termlib.js now outputs lower case html (xhtml compatibility)\r
-\r
-  version 1.07: added method rebuild() to rebuild with new color settings.\r
-\r
-*/\r
-\r
-var TerminalDefaults = {\r
-       // dimensions\r
-       cols:80,\r
-       rows:24,\r
-       // appearance\r
-       x:100,\r
-       y:100,\r
-       termDiv:'termDiv',\r
-       bgColor:'#181818',\r
-       frameColor:'#555555',\r
-       frameWidth:1,\r
-       rowHeight:15,\r
-       blinkDelay:500,\r
-       // css class\r
-       fontClass:'term',\r
-       // initial cursor mode\r
-       crsrBlinkMode:false,\r
-       crsrBlockMode:true,\r
-       // key mapping\r
-       DELisBS:false,\r
-       printTab:true,\r
-       printEuro:true,\r
-       catchCtrlH:true,\r
-       closeOnESC:true,\r
-       // prevent consecutive history doublets\r
-       historyUnique:false,\r
-       // optional id\r
-       id:0,\r
-       // strings\r
-       ps:'>',\r
-       greeting:'%+r Terminal ready. %-r',\r
-       // handlers\r
-       handler:termDefaultHandler,\r
-       ctrlHandler:null,\r
-       initHandler:null,\r
-       exitHandler:null\r
-}\r
-\r
-var Terminal = function(conf) {\r
-       if (typeof conf != 'object') conf=new Object();\r
-       else {\r
-               for (var i in TerminalDefaults) {\r
-                       if (typeof conf[i] == 'undefined') conf[i]=TerminalDefaults[i];\r
-               }\r
-       }\r
-       this.conf=conf;\r
-       this.version='1.07 (original)';\r
-       this.isSafari= (navigator.userAgent.indexOf('Safari')>=0)? true:false;\r
-       this.setInitValues();\r
-}\r
-\r
-Terminal.prototype.setInitValues=function() {\r
-       this.id=this.conf.id;\r
-       this.maxLines=this.conf.rows;\r
-       this.maxCols=this.conf.cols;\r
-       this.termDiv=this.conf.termDiv;\r
-       this.crsrBlinkMode=this.conf.crsrBlinkMode;\r
-       this.crsrBlockMode=this.conf.crsrBlockMode;\r
-       this.blinkDelay=this.conf.blinkDelay;\r
-       this.DELisBS=this.conf.DELisBS;\r
-       this.printTab=this.conf.printTab;\r
-       this.printEuro=this.conf.printEuro;\r
-       this.catchCtrlH=this.conf.catchCtrlH;\r
-       this.closeOnESC=this.conf.closeOnESC;\r
-       this.historyUnique=this.conf.historyUnique;\r
-       this.ps=this.conf.ps;\r
-       this.closed=false;\r
-       this.r;\r
-       this.c;\r
-       this.charBuf=new Array();\r
-       this.styleBuf=new Array();\r
-       this.scrollBuf=null;\r
-       this.blinkBuffer=0;\r
-       this.blinkTimer;\r
-       this.cursoractive=false;\r
-       this.lock=true;\r
-       this.insert=false;\r
-       this.charMode=false;\r
-       this.rawMode=false;\r
-       this.lineBuffer='';\r
-       this.inputChar=0;\r
-       this.lastLine='';\r
-       this.guiCounter=0;\r
-       this.history=new Array();\r
-       this.histPtr=0;\r
-       this.env=new Object();\r
-       this.ns4ParentDoc=null;\r
-       this.handler=this.conf.handler;\r
-       this.ctrlHandler=this.conf.ctrlHandler;\r
-       this.initHandler=this.conf.initHandler;\r
-       this.exitHandler=this.conf.exitHandler;\r
-}\r
-\r
-function termDefaultHandler() {\r
-       this.newLine();\r
-       if (this.lineBuffer != '') {\r
-               this.type('You typed: '+this.lineBuffer);\r
-               this.newLine();\r
-       }\r
-       this.prompt();\r
-}\r
-\r
-Terminal.prototype.open=function() {\r
-       if (this.termDivReady()) {\r
-               if (!this.closed) this._makeTerm();\r
-               this.init();\r
-               return true;\r
-       }\r
-       else return false;\r
-}\r
-\r
-Terminal.prototype.close=function() {\r
-       this.lock=true;\r
-       this.cursorOff();\r
-       if (this.exitHandler) this.exitHandler();\r
-       TermGlobals.setVisible(this.termDiv,0);\r
-       this.closed=true;\r
-}\r
-\r
-Terminal.prototype.init=function() {\r
-       // wait for gui\r
-       if (this.guiReady()) {\r
-               this.guiCounter=0;\r
-               // clean up at re-entry\r
-               if (this.closed) {\r
-                       this.setInitValues();\r
-               }\r
-               this.clear();\r
-               TermGlobals.setVisible(this.termDiv,1);\r
-               TermGlobals.enableKeyboard(this);\r
-               if (this.initHandler) {\r
-                       this.initHandler();\r
-               }\r
-               else {\r
-                       this.write(this.conf.greeting);\r
-                       this.newLine();\r
-                       this.prompt();\r
-               }\r
-       }\r
-       else {\r
-               this.guiCounter++;\r
-               if (this.guiCounter>18000) {\r
-                       if (confirm('Terminal:\nYour browser hasn\'t responded for more than 2 minutes.\nRetry?')) this.guiCounter=0\r
-                       else return;\r
-               };\r
-               TermGlobals.termToInitialze=this;\r
-               window.setTimeout('TermGlobals.termToInitialze.init()',200);\r
-       }\r
-}\r
-\r
-Terminal.prototype.getRowArray=function(l,v) {\r
-       var a=new Array();\r
-       for (var i=0; i<l; i++) a[i]=v;\r
-       return a;\r
-}\r
-\r
-Terminal.prototype.type=function(text,style) {\r
-       for (var i=0; i<text.length; i++) {\r
-               var ch=text.charCodeAt(i);\r
-               if (!this.isPrintable(ch)) ch=94;\r
-               this.charBuf[this.r][this.c]=ch;\r
-               this.styleBuf[this.r][this.c]=(style)? style:0;\r
-               var last_r=this.r;\r
-               this._incCol();\r
-               if (this.r!=last_r) this.redraw(last_r);\r
-       }\r
-       this.redraw(this.r)\r
-}\r
-\r
-Terminal.prototype.write=function(text,usemore) {\r
-       // write to scroll buffer with markup\r
-       // new line = '%n' prepare any strings or arrys first\r
-       if (typeof text != 'object') {\r
-               if (typeof text!='string') text=''+text;\r
-               if (text.indexOf('\n')>=0) {\r
-                       var ta=text.split('\n');\r
-                       text=ta.join('%n');\r
-               }\r
-       }\r
-       else {\r
-               if (text.join) text=text.join('%n')\r
-               else text=''+text;\r
-       }\r
-       this._sbInit(usemore);\r
-       var chunks=text.split('%');\r
-       var esc=(text.charAt(0)!='%');\r
-       var style=0;\r
-       for (var i=0; i<chunks.length; i++) {\r
-               if (esc) {\r
-                       if (chunks[i].length>0) this._sbType(chunks[i],style)\r
-                       else if (i>0) this._sbType('%', style);\r
-                       esc=false;\r
-               }\r
-               else {\r
-                       var func=chunks[i].charAt(0);\r
-                       if ((chunks[i].length==0) && (i>0)) {\r
-                               this._sbType("%",style);\r
-                               esc=true;\r
-                       }\r
-                       else if (func=='n') {\r
-                               this._sbNewLine();\r
-                               if (chunks[i].length>1) this._sbType(chunks[i].substring(1),style);\r
-                       }\r
-                       else if (func=='+') {\r
-                               var opt=chunks[i].charAt(1);\r
-                               opt=opt.toLowerCase();\r
-                               if (opt=='p') style=0\r
-                               else if (opt=='r') style|=1\r
-                               else if (opt=='u') style|=2\r
-                               else if (opt=='i') style|=4\r
-                               else if (opt=='s') style|=8;\r
-                               if (chunks[i].length>2) this._sbType(chunks[i].substring(2),style);\r
-                       }\r
-                       else if (func=='-') {\r
-                               var opt=chunks[i].charAt(1);\r
-                               opt=opt.toLowerCase();\r
-                               if (opt=='p') style|=0\r
-                               else if (opt=='r') style&=~1\r
-                               else if (opt=='u') style&=~2\r
-                               else if (opt=='i') style&=~4\r
-                               else if (opt=='s') style&=~8;\r
-                               if (chunks[i].length>2) this._sbType(chunks[i].substring(2),style);\r
-                       }\r
-                       else if ((chunks[i].length>1) && (chunks[i].charAt(0)=='C') && (chunks[i].charAt(1)=='S')) {\r
-                               this.clear();\r
-                               this._sbInit();\r
-                               if (chunks[i].length>2) this._sbType(chunks[i].substring(2),style);\r
-                       }\r
-                       else {\r
-                               if (chunks[i].length>0) this._sbType(chunks[i],style);\r
-                       }\r
-               }\r
-       }\r
-       this._sbOut();\r
-}\r
-\r
-Terminal.prototype._sbType=function(text,style) {\r
-       // type to scroll buffer\r
-       var sb=this.scrollBuf;\r
-       for (var i=0; i<text.length; i++) {\r
-               var ch=text.charCodeAt(i);\r
-               if (!this.isPrintable(ch)) ch=94;\r
-               sb.lines[sb.r][sb.c]=ch;\r
-               sb.styles[sb.r][sb.c]=(style)? style:0;\r
-               sb.c++;\r
-               if (sb.c>=this.maxCols) this._sbNewLine();\r
-       }\r
-}\r
-\r
-Terminal.prototype._sbNewLine=function() {\r
-       var sb=this.scrollBuf;\r
-       sb.r++;\r
-       sb.c=0;\r
-       sb.lines[sb.r]=this.getRowArray(this.conf.cols,0);\r
-       sb.styles[sb.r]=this.getRowArray(this.conf.cols,0);\r
-}\r
-\r
-\r
-Terminal.prototype._sbInit=function(usemore) {\r
-       var sb=this.scrollBuf=new Object();\r
-       var sbl=sb.lines=new Array();\r
-       var sbs=sb.styles=new Array();\r
-       sb.more=usemore;\r
-       sb.line=0;\r
-       sb.status=0;\r
-       sb.r=0;\r
-       sb.c=this.c;\r
-       sbl[0]=this.getRowArray(this.conf.cols,0);\r
-       sbs[0]=this.getRowArray(this.conf.cols,0);\r
-       for (var i=0; i<this.c; i++) {\r
-               sbl[0][i]=this.charBuf[this.r][i];\r
-               sbs[0][i]=this.styleBuf[this.r][i];\r
-       }\r
-}\r
-\r
-Terminal.prototype._sbOut=function() {\r
-       var sb=this.scrollBuf;\r
-       var sbl=sb.lines;\r
-       var sbs=sb.styles;\r
-       var tcb=this.charBuf;\r
-       var tsb=this.styleBuf;\r
-       var ml=this.maxLines;\r
-       var buflen=sbl.length;\r
-       if (sb.more) {\r
-               if (sb.status) {\r
-                       if (this.inputChar==TermGlobals.lcMoreKeyAbort) {\r
-                               this.r=ml-1;\r
-                               this.c=0;\r
-                               tcb[this.r]=this.getRowArray(this.maxLines,0);\r
-                               tsb[this.r]=this.getRowArray(this.maxLines,0);\r
-                               this.redraw(this.r);\r
-                               this.handler=sb.handler;\r
-                               this.charMode=false;\r
-                               this.inputChar=0;\r
-                               this.scrollBuf=null;\r
-                               this.prompt();\r
-                               return;\r
-                       }\r
-                       else if (this.inputChar==TermGlobals.lcMoreKeyContinue) {\r
-                               this.clear();\r
-                       }\r
-                       else {\r
-                               return;\r
-                       }\r
-               }\r
-               else {\r
-                       if (this.r>=ml-1) this.clear();\r
-               }\r
-       }\r
-       if (this.r+buflen-sb.line<=ml) {\r
-               for (var i=sb.line; i<buflen; i++) {\r
-                       var r=this.r+i-sb.line;\r
-                       tcb[r]=sbl[i];\r
-                       tsb[r]=sbs[i];\r
-                       this.redraw(r);\r
-               }\r
-               this.r+=sb.r-sb.line;\r
-               this.c=sb.c;\r
-               if (sb.more) {\r
-                       if (sb.status) this.handler=sb.handler;\r
-                       this.charMode=false;\r
-                       this.inputChar=0;\r
-                       this.scrollBuf=null;\r
-                       this.prompt();\r
-                       return;\r
-               }\r
-       }\r
-       else if (sb.more) {\r
-               ml--;\r
-               if (sb.status==0) {\r
-                       sb.handler=this.handler;\r
-                       this.handler=this._sbOut;\r
-                       this.charMode=true;\r
-                       sb.status=1;\r
-               }\r
-               if (this.r) {\r
-                       var ofs=ml-this.r;\r
-                       for (var i=sb.line; i<ofs; i++) {\r
-                               var r=this.r+i-sb.line;\r
-                               tcb[r]=sbl[i];\r
-                               tsb[r]=sbs[i];\r
-                               this.redraw(r);\r
-                       }\r
-               }\r
-               else {\r
-                       var ofs=sb.line+ml;\r
-                       for (var i=sb.line; i<ofs; i++) {\r
-                               var r=this.r+i-sb.line;\r
-                               tcb[r]=sbl[i];\r
-                               tsb[r]=sbs[i];\r
-                               this.redraw(r);\r
-                       }\r
-               }\r
-               sb.line=ofs;\r
-               this.r=ml;\r
-               this.c=0;\r
-               this.type(TermGlobals.lcMorePrompt1, TermGlobals.lcMorePromtp1Style);\r
-               this.type(TermGlobals.lcMorePrompt2, TermGlobals.lcMorePrompt2Style);\r
-               this.lock=false;\r
-               return;\r
-       }\r
-       else if (buflen>=ml) {\r
-               var ofs=buflen-ml;\r
-               for (var i=0; i<ml; i++) {\r
-                       var r=ofs+i;\r
-                       tcb[i]=sbl[r];\r
-                       tsb[i]=sbs[r];\r
-                       this.redraw(i);\r
-               }\r
-               this.r=ml-1;\r
-               this.c=sb.c;\r
-       }\r
-       else {\r
-               var dr=ml-buflen;\r
-               var ofs=this.r-dr;\r
-               for (var i=0; i<dr; i++) {\r
-                       var r=ofs+i;\r
-                       for (var c=0; c<this.maxCols; c++) {\r
-                               tcb[i][c]=tcb[r][c];\r
-                               tsb[i][c]=tsb[r][c];\r
-                       }\r
-                       this.redraw(i);\r
-               }\r
-               for (var i=0; i<buflen; i++) {\r
-                       var r=dr+i;\r
-                       tcb[r]=sbl[i];\r
-                       tsb[r]=sbs[i];\r
-                       this.redraw(r);\r
-               }\r
-               this.r=ml-1;\r
-               this.c=sb.c;\r
-       }\r
-       this.scrollBuf=null;\r
-}\r
-\r
-// basic console output\r
-\r
-Terminal.prototype.typeAt=function(r,c,text,style) {\r
-       var tr1=this.r;\r
-       var tc1=this.c;\r
-       this.cursorSet(r,c);\r
-       for (var i=0; i<text.length; i++) {\r
-               var ch=text.charCodeAt(i);\r
-               if (!this.isPrintable(ch)) ch=94;\r
-               this.charBuf[this.r][this.c]=ch;\r
-               this.styleBuf[this.r][this.c]=(style)? style:0;\r
-               var last_r=this.r;\r
-               this._incCol();\r
-               if (this.r!=last_r) this.redraw(last_r);\r
-       }\r
-       this.redraw(this.r);\r
-       this.r=tr1;\r
-       this.c=tc1;\r
-}\r
-\r
-Terminal.prototype.statusLine = function(text,style,offset) {\r
-       var ch,r;\r
-       style=((style) && (!isNaN(style)))? parseInt(style)&15:0;\r
-       if ((offset) && (offset>0)) r=this.conf.rows-offset\r
-       else r=this.conf.rows-1;\r
-       for (var i=0; i<this.conf.cols; i++) {\r
-               if (i<text.length) {\r
-                       ch=text.charCodeAt(i);\r
-                       if (!this.isPrintable(ch)) ch = 94;\r
-               }\r
-               else ch=0;\r
-               this.charBuf[r][i]=ch;\r
-               this.styleBuf[r][i]=style;\r
-       }\r
-       this.redraw(r);\r
-}\r
-\r
-Terminal.prototype.printRowFromString = function(r,text,style) {\r
-       var ch;\r
-       style=((style) && (!isNaN(style)))? parseInt(style)&15:0;\r
-       if ((r>=0) && (r<this.maxLines)) {\r
-               if (typeof text != 'string') text=''+text;\r
-               for (var i=0; i<this.conf.cols; i++) {\r
-                       if (i<text.length) {\r
-                               ch=text.charCodeAt(i);\r
-                               if (!this.isPrintable(ch)) ch = 94;\r
-                       }\r
-                       else ch=0;\r
-                       this.charBuf[r][i]=ch;\r
-                       this.styleBuf[r][i]=style;\r
-               }\r
-               this.redraw(r);\r
-       }\r
-}\r
-\r
-Terminal.prototype.setChar=function(ch,r,c,style) {\r
-       this.charBuf[r][c]=ch;\r
-       this.styleBuf[this.r][this.c]=(style)? style:0;\r
-       this.redraw(r);\r
-}\r
-\r
-Terminal.prototype._charOut=function(ch, style) {\r
-       this.charBuf[this.r][this.c]=ch;\r
-       this.styleBuf[this.r][this.c]=(style)? style:0;\r
-       this.redraw(this.r);\r
-       this._incCol();\r
-}\r
-\r
-Terminal.prototype._incCol=function() {\r
-       this.c++;\r
-       if (this.c>=this.maxCols) {\r
-               this.c=0;\r
-               this._incRow();\r
-       }\r
-}\r
-\r
-Terminal.prototype._incRow=function() {\r
-       this.r++;\r
-       if (this.r>=this.maxLines) {\r
-               this._scrollLines(0,this.maxLines);\r
-               this.r=this.maxLines-1;\r
-       }\r
-}\r
-\r
-Terminal.prototype._scrollLines=function(start, end) {\r
-       window.status='Scrolling lines ...';\r
-       start++;\r
-       for (var ri=start; ri<end; ri++) {\r
-               var rt=ri-1;\r
-               this.charBuf[rt]=this.charBuf[ri];\r
-               this.styleBuf[rt]=this.styleBuf[ri];\r
-       }\r
-       // clear last line\r
-       var rt=end-1;\r
-       this.charBuf[rt]=this.getRowArray(this.conf.cols,0);\r
-       this.styleBuf[rt]=this.getRowArray(this.conf.cols,0);\r
-       this.redraw(rt);\r
-       for (var r=end-1; r>=start; r--) this.redraw(r-1);\r
-       window.status='';\r
-}\r
-\r
-Terminal.prototype.newLine=function() {\r
-       this.c=0;\r
-       this._incRow();\r
-}\r
-\r
-Terminal.prototype.clear=function() {\r
-       window.status='Clearing display ...';\r
-       this.cursorOff();\r
-       this.insert=false;\r
-       for (var ri=0; ri<this.maxLines; ri++) {\r
-               this.charBuf[ri]=this.getRowArray(this.conf.cols,0);\r
-               this.styleBuf[ri]=this.getRowArray(this.conf.cols,0);\r
-               this.redraw(ri);\r
-       }\r
-       this.r=0;\r
-       this.c=0;\r
-       window.status='';\r
-}\r
-\r
-Terminal.prototype.reset=function() {\r
-       if (this.lock) return;\r
-       this.lock=true;\r
-       this.rawMode=false;\r
-       this.charMode=false;\r
-       this.maxLines=this.conf.rows;\r
-       this.maxCols=this.conf.cols;\r
-       this.lastLine='';\r
-       this.lineBuffer='';\r
-       this.inputChar=0;\r
-       this.clear();\r
-}\r
-\r
-Terminal.prototype.cursorSet=function(r,c) {\r
-       var crsron=this.cursoractive;\r
-       if (crsron) this.cursorOff();\r
-       this.r=r%this.maxLines;\r
-       this.c=c%this.maxCols;\r
-       this._cursorReset(crsron);\r
-}\r
-\r
-Terminal.prototype._cursorReset=function(crsron) {\r
-       if (crsron) this.cursorOn()\r
-       else {\r
-               this.blinkBuffer=this.styleBuf[this.r][this.c];\r
-       }\r
-}\r
-\r
-Terminal.prototype.cursorOn=function() {\r
-       if (this.blinkTimer) clearTimeout(this.blinkTimer);\r
-       this.blinkBuffer=this.styleBuf[this.r][this.c];\r
-       this._cursorBlink();\r
-       this.cursoractive=true;\r
-}\r
-\r
-Terminal.prototype.cursorOff=function() {\r
-       if (this.blinkTimer) clearTimeout(this.blinkTimer);\r
-       if (this.cursoractive) {\r
-               this.styleBuf[this.r][this.c]=this.blinkBuffer;\r
-               this.redraw(this.r);\r
-               this.cursoractive=false;\r
-       }\r
-}\r
-\r
-Terminal.prototype._cursorBlink=function() {\r
-       if (this.blinkTimer) clearTimeout(this.blinkTimer);\r
-       if (this == TermGlobals.activeTerm) {\r
-               if (this.crsrBlockMode) {\r
-                       this.styleBuf[this.r][this.c]=(this.styleBuf[this.r][this.c]&1)?\r
-                               this.styleBuf[this.r][this.c]&254:this.styleBuf[this.r][this.c]|1;\r
-               }\r
-               else {\r
-                       this.styleBuf[this.r][this.c]=(this.styleBuf[this.r][this.c]&2)?\r
-                               this.styleBuf[this.r][this.c]&253:this.styleBuf[this.r][this.c]|2;\r
-               }\r
-               this.redraw(this.r);\r
-       }\r
-       if (this.crsrBlinkMode) this.blinkTimer=setTimeout('TermGlobals.activeTerm._cursorBlink()', this.blinkDelay);\r
-}\r
-\r
-Terminal.prototype.cursorLeft=function() {\r
-       var crsron=this.cursoractive;\r
-       if (crsron) this.cursorOff();\r
-       var r=this.r;\r
-       var c=this.c;\r
-       if (c>0) c--\r
-       else if (r>0) {\r
-               c=this.maxCols-1;\r
-               r--;\r
-       }\r
-       if (this.isPrintable(this.charBuf[r][c])) {\r
-               this.r=r;\r
-               this.c=c;\r
-       }\r
-       this.insert=true;\r
-       this._cursorReset(crsron);\r
-}\r
-\r
-Terminal.prototype.cursorRight=function() {\r
-       var crsron=this.cursoractive;\r
-       if (crsron) this.cursorOff();\r
-       var r=this.r;\r
-       var c=this.c;\r
-       if (c<this.maxCols-1) c++\r
-       else if (r<this.maxLines-1) {\r
-               c=0;\r
-               r++;\r
-       }\r
-       if (!this.isPrintable(this.charBuf[r][c])) {\r
-               this.insert=false;\r
-       }\r
-       if (this.isPrintable(this.charBuf[this.r][this.c])) {\r
-               this.r=r;\r
-               this.c=c;\r
-       }\r
-       this._cursorReset(crsron);\r
-}\r
-\r
-Terminal.prototype.backspace=function() {\r
-       var crsron=this.cursoractive;\r
-       if (crsron) this.cursorOff();\r
-       var r=this.r;\r
-       var c=this.c;\r
-       if (c>0) c--\r
-       else if (r>0) {\r
-               c=this.maxCols-1;\r
-               r--;\r
-       };\r
-       if (this.isPrintable(this.charBuf[r][c])) {\r
-               this._scrollLeft(r, c);\r
-               this.r=r;\r
-               this.c=c;\r
-       };      \r
-       this._cursorReset(crsron);\r
-}\r
-\r
-Terminal.prototype.fwdDelete=function() {\r
-       var crsron=this.cursoractive;\r
-       if (crsron) this.cursorOff();\r
-       if (this.isPrintable(this.charBuf[this.r][this.c])) {\r
-               this._scrollLeft(this.r,this.c);\r
-               if (!this.isPrintable(this.charBuf[this.r][this.c])) this.insert=false;\r
-       }\r
-       this._cursorReset(crsron);\r
-}\r
-\r
-Terminal.prototype.prompt=function() {\r
-       this.lock=true;\r
-       if (this.c>0) this.newLine();\r
-       this.type(this.ps);\r
-       this._charOut(1);\r
-       this.lock=false;\r
-       this.cursorOn();\r
-}\r
-\r
-Terminal.prototype._scrollLeft=function(r,c) {\r
-       var rows=new Array();\r
-       rows[0]=r;\r
-       while (this.isPrintable(this.charBuf[r][c])) {\r
-               var ri=r;\r
-               var ci=c+1;\r
-               if (ci==this.maxCols) {\r
-                       if (ri<this.maxLines-1) {\r
-                               ci=0;\r
-                               ri++;\r
-                               rows[rows.length]=ri;\r
-                       }\r
-                       else {\r
-                               break;\r
-                       }\r
-               }\r
-               this.charBuf[r][c]=this.charBuf[ri][ci];\r
-               this.styleBuf[r][c]=this.styleBuf[ri][ci];\r
-               c=ci;\r
-               r=ri;\r
-       }\r
-       if (this.charBuf[r][c]!=0) this.charBuf[r][c]=0;\r
-       for (var i=0; i<rows.length; i++) this.redraw(rows[i]);\r
-}\r
-\r
-Terminal.prototype._scrollRight=function(r,c) {\r
-       var rows=new Array();\r
-       var end=this._getLineEnd(r,c);\r
-       var ri=end[0];\r
-       var ci=end[1];\r
-       if ((ci==this.maxCols-1) && (ri==this.maxLines-1)) {\r
-               if (r==0) return;\r
-               this._scrollLines(0,this.maxLines);\r
-               this.r--;\r
-               r--;\r
-               ri--;\r
-       }\r
-       rows[r]=1;\r
-       while (this.isPrintable(this.charBuf[ri][ci])) {\r
-               var rt=ri;\r
-               var ct=ci+1;\r
-               if (ct==this.maxCols) {\r
-                       ct=0;\r
-                       rt++;\r
-                       rows[rt]=1;\r
-               }\r
-               this.charBuf[rt][ct]=this.charBuf[ri][ci];\r
-               this.styleBuf[rt][ct]=this.styleBuf[ri][ci];\r
-               if ((ri==r) && (ci==c)) break;\r
-               ci--;\r
-               if (ci<0) {\r
-                       ci=this.maxCols-1;\r
-                       ri--;\r
-                       rows[ri]=1;\r
-               }\r
-       }\r
-       for (var i=r; i<this.maxLines; i++) {\r
-               if (rows[i]) this.redraw(i);\r
-       }\r
-}\r
-\r
-Terminal.prototype._getLineEnd=function(r,c) {\r
-       if (!this.isPrintable(this.charBuf[r][c])) {\r
-               c--;\r
-               if (c<0) {\r
-                       if (r>0) {\r
-                               r--;\r
-                               c=this.maxCols-1;\r
-                       }\r
-                       else {\r
-                               c=0;\r
-                       }\r
-               }\r
-       }\r
-       if (this.isPrintable(this.charBuf[r][c])) {\r
-               while (true) {\r
-                       var ri=r;\r
-                       var ci=c+1;\r
-                       if (ci==this.maxCols) {\r
-                               if (ri<this.maxLines-1) {\r
-                                       ri++;\r
-                                       ci=0;\r
-                               }\r
-                               else {\r
-                                       break;\r
-                               }\r
-                       }\r
-                       if (!this.isPrintable(this.charBuf[ri][ci])) break;\r
-                       c=ci;\r
-                       r=ri;\r
-               }\r
-       }\r
-       return [r,c];\r
-}\r
-\r
-Terminal.prototype._getLineStart=function(r,c) {\r
-       // not used by now, just in case anyone needs this ...\r
-       var ci, ri;\r
-       if (!this.isPrintable(this.charBuf[r][c])) {\r
-               ci=c-1;\r
-               ri=r;\r
-               if (ci<0) {\r
-                       if (ri==0) return [0,0];\r
-                       ci=this.maxCols-1;\r
-                       ri--;\r
-               }\r
-               if (!this.isPrintable(this.charBuf[ri][ci])) return [r,c]\r
-               else {\r
-                       r=ri;\r
-                       c=ci;\r
-               }\r
-       }\r
-       while (true) {\r
-               var ri=r;\r
-               var ci=c-1;\r
-               if (ci<0) {\r
-                       if (ri==0) break;\r
-                       ci=this.maxCols-1;\r
-                       ri--;\r
-               }\r
-               if (!this.isPrintable(this.charBuf[ri][ci])) break;;\r
-               r=ri;\r
-               c=ci;\r
-       }\r
-       return [r,c];\r
-}\r
-\r
-Terminal.prototype._getLine=function() {\r
-       var end=this._getLineEnd(this.r,this.c);\r
-       var r=end[0];\r
-       var c=end[1];\r
-       var line=new Array();\r
-       while (this.isPrintable(this.charBuf[r][c])) {\r
-               line[line.length]=String.fromCharCode(this.charBuf[r][c]);\r
-               if (c>0) c--\r
-               else if (r>0) {\r
-                       c=this.maxCols-1;\r
-                       r--;\r
-               }\r
-               else break;\r
-       }\r
-       line.reverse();\r
-       return line.join('');\r
-}\r
-\r
-Terminal.prototype._clearLine=function() {\r
-       var end=this._getLineEnd(this.r,this.c);\r
-       var r=end[0];\r
-       var c=end[1];\r
-       var line='';\r
-       while (this.isPrintable(this.charBuf[r][c])) {\r
-               this.charBuf[r][c]=0;\r
-               if (c>0) {\r
-                       c--;\r
-               }\r
-               else if (r>0) {\r
-                       this.redraw(r);\r
-                       c=this.maxCols-1;\r
-                       r--;\r
-               }\r
-               else break;\r
-       }\r
-       if (r!=end[0]) this.redraw(r);\r
-       c++;\r
-       this.cursorSet(r,c);\r
-       this.insert=false;\r
-}\r
-\r
-Terminal.prototype.isPrintable=function(ch, unicodePage1only) {\r
-       if ((unicodePage1only) && (ch>255)) {\r
-               return ((ch==termKey.EURO) && (this.printEuro))? true:false;\r
-       }\r
-       return (\r
-               ((ch>=32) && (ch!=termKey.DEL)) ||\r
-               ((this.printTab) && (ch==termKey.TAB))\r
-       );\r
-}\r
-\r
-// keyboard focus\r
-\r
-Terminal.prototype.focus=function() {\r
-       TermGlobals.activeTerm=this;\r
-}\r
-\r
-// global store and functions\r
-\r
-var TermGlobals={\r
-       termToInitialze:null,\r
-       activeTerm:null,\r
-       kbdEnabled:false,\r
-       keylock:false,\r
-       lcMorePrompt1: ' -- MORE -- ',\r
-       lcMorePromtp1Style: 1,\r
-       lcMorePrompt2: ' (Type: space to continue, \'q\' to quit)',\r
-       lcMorePrompt2Style: 0,\r
-       lcMoreKeyAbort: 113,\r
-       lcMoreKeyContinue: 32\r
-};\r
-\r
-// keybard focus\r
-\r
-TermGlobals.setFocus=function(termref) {\r
-       TermGlobals.activeTerm=termref;\r
-}\r
-\r
-// text related\r
-\r
-TermGlobals.normalize=function(n,m) {\r
-       var s=''+n;\r
-       while (s.length<m) s='0'+s;\r
-       return s;\r
-}\r
-\r
-TermGlobals.fillLeft=function(t,n) {\r
-       if (typeof t != 'string') t=''+t;\r
-       while (t.length<n) t=' '+t;\r
-       return t;\r
-}\r
-\r
-TermGlobals.center=function(t,l) {\r
-       var s='';\r
-       for (var i=t.length; i<l; i+=2) s+=' ';\r
-       return s+t;\r
-}\r
-\r
-TermGlobals.stringReplace=function(s1,s2,t) {\r
-       var l1=s1.length;\r
-       var l2=s2.length;\r
-       var ofs=t.indexOf(s1);\r
-       while (ofs>=0) {\r
-               t=t.substring(0,ofs)+s2+t.substring(ofs+l1);\r
-               ofs=t.indexOf(s1,ofs+l2);\r
-       }\r
-       return t;\r
-}\r
-\r
-// keyboard\r
-\r
-var termKey= {\r
-       // special key codes\r
-       'NUL': 0x00,\r
-       'SOH': 0x01,\r
-       'STX': 0x02,\r
-       'ETX': 0x03,\r
-       'EOT': 0x04,\r
-       'ENQ': 0x05,\r
-       'ACK': 0x06,\r
-       'BEL': 0x07,\r
-       'BS': 0x08,\r
-       'HT': 0x09,\r
-       'TAB': 0x09,\r
-       'LF': 0x0A,\r
-       'VT': 0x0B,\r
-       'FF': 0x0C,\r
-       'CR': 0x0D,\r
-       'SO': 0x0E,\r
-       'SI': 0x0F,\r
-       'DLE': 0x10,\r
-       'DC1': 0x11,\r
-       'DC2': 0x12,\r
-       'DC3': 0x13,\r
-       'DC4': 0x14,\r
-       'NAK': 0x15,\r
-       'SYN': 0x16,\r
-       'ETB': 0x17,\r
-       'CAN': 0x18,\r
-       'EM': 0x19,\r
-       'SUB': 0x1A,\r
-       'ESC': 0x1B,\r
-       'IS4': 0x1C,\r
-       'IS3': 0x1D,\r
-       'IS2': 0x1E,\r
-       'IS1': 0x1F,\r
-       'DEL': 0x7F,\r
-       // other specials\r
-       'EURO': 0x20AC,\r
-       // cursor mapping\r
-       'LEFT': 0x1C,\r
-       'RIGHT': 0x1D,\r
-       'UP': 0x1E,\r
-       'DOWN': 0x1F\r
-};\r
-\r
-var termDomKeyRef = {\r
-       DOM_VK_LEFT: termKey.LEFT,\r
-       DOM_VK_RIGHT: termKey.RIGHT,\r
-       DOM_VK_UP: termKey.UP,\r
-       DOM_VK_DOWN: termKey.DOWN,\r
-       DOM_VK_BACK_SPACE: termKey.BS,\r
-       DOM_VK_RETURN: termKey.CR,\r
-       DOM_VK_ENTER: termKey.CR,\r
-       DOM_VK_ESCAPE: termKey.ESC,\r
-       DOM_VK_DELETE: termKey.DEL,\r
-       DOM_VK_TAB: termKey.TAB\r
-};\r
-\r
-TermGlobals.enableKeyboard=function(term) {\r
-       if (!this.kbdEnabled) {\r
-               if (document.addEventListener) document.addEventListener("keypress", this.keyHandler, true)\r
-               else {\r
-                       if ((self.Event) && (self.Event.KEYPRESS)) document.captureEvents(Event.KEYPRESS);\r
-                       document.onkeypress = this.keyHandler;\r
-               }\r
-               window.document.onkeydown=this.keyFix;\r
-               this.kbdEnabled=true;\r
-       }\r
-       this.activeTerm=term;\r
-}\r
-\r
-TermGlobals.keyFix=function(e) {\r
-       var term=TermGlobals.activeTerm;\r
-       if ((TermGlobals.keylock) || (term.lock)) return true;\r
-       if (window.event) {\r
-               var ch=window.event.keyCode;\r
-               if  (!e) e=window.event;\r
-               if (e.DOM_VK_UP) {\r
-                       for (var i in termDomKeyRef) {\r
-                               if ((e[i]) && (ch == e[i])) {\r
-                                       this.keyHandler({which:termDomKeyRef[i],_remapped:true});\r
-                                       if (e.preventDefault) e.preventDefault();\r
-                                       if (e.stopPropagation) e.stopPropagation();\r
-                                       e.cancleBubble=true;\r
-                                       return false;\r
-                               }\r
-                       }\r
-                       e.cancleBubble=false;\r
-                       return true;\r
-               }\r
-               else {\r
-                       // no DOM support\r
-                       if ((ch==8) && (!term.isSafari)) TermGlobals.keyHandler({which:termKey.BS,_remapped:true})\r
-                       else if (ch==9) TermGlobals.keyHandler({which:termKey.TAB,_remapped:true})\r
-                       else if (ch==37) TermGlobals.keyHandler({which:termKey.LEFT,_remapped:true})\r
-                       else if (ch==39) TermGlobals.keyHandler({which:termKey.RIGHT,_remapped:true})\r
-                       else if (ch==38) TermGlobals.keyHandler({which:termKey.UP,_remapped:true})\r
-                       else if (ch==40) TermGlobals.keyHandler({which:termKey.DOWN,_remapped:true})\r
-                       else if (ch==127) TermGlobals.keyHandler({which:termKey.DEL,_remapped:true})\r
-                       else if ((ch>=57373) && (ch<=57376)) {\r
-                               if (ch==57373) TermGlobals.keyHandler({which:termKey.UP,_remapped:true})\r
-                               else if (ch==57374) TermGlobals.keyHandler({which:termKey.DOWN,_remapped:true})\r
-                               else if (ch==57375) TermGlobals.keyHandler({which:termKey.LEFT,_remapped:true})\r
-                               else if (ch==57376) TermGlobals.keyHandler({which:termKey.RIGHT,_remapped:true});\r
-                       }\r
-                       else {\r
-                               e.cancleBubble=false;\r
-                               return true;\r
-                       }\r
-                       if (e.preventDefault) e.preventDefault();\r
-                       if (e.stopPropagation) e.stopPropagation();\r
-                       e.cancleBubble=true;\r
-                       return false;\r
-               }\r
-       }\r
-}\r
-\r
-TermGlobals.keyHandler=function(e) {\r
-       var term=TermGlobals.activeTerm;\r
-       if ((TermGlobals.keylock) || (term.lock)) return true;\r
-       if ((window.event) && (window.event.preventDefault)) window.event.preventDefault()\r
-       else if ((e) && (e.preventDefault)) e.preventDefault();\r
-       if ((window.event) && (window.event.stopPropagation)) window.event.stopPropagation()\r
-       else if ((e) && (e.stopPropagation)) e.stopPropagation();\r
-       var ch;\r
-       var ctrl=false;\r
-       var shft=false;\r
-       var remapped=false;\r
-       if (e) {\r
-               ch=e.which;\r
-               ctrl=(((e.ctrlKey) && (e.altKey)) || (e.modifiers==2));\r
-               shft=((e.shiftKey) || (e.modifiers==4));\r
-               if (e._remapped) {\r
-                       remapped=true;\r
-                       if (window.event) {\r
-                               //ctrl=((ctrl) || (window.event.ctrlKey));\r
-                               ctrl=((ctrl) || ((window.event.ctrlKey) && (!window.event.altKey)));\r
-                               shft=((shft) || (window.event.shiftKey));\r
-                       }\r
-               }\r
-       }\r
-       else if (window.event) {\r
-               ch=window.event.keyCode;\r
-               //ctrl=(window.event.ctrlKey);\r
-               ctrl=((window.event.ctrlKey) && (!window.event.altKey)); // allow alt gr == ctrl alts\r
-               shft=(window.event.shiftKey);\r
-       }\r
-       else {\r
-               return true;\r
-       }\r
-       if ((ch=='') && (remapped==false)) {\r
-               // map specials\r
-               if (e==null) e=window.event;\r
-               if ((e.charCode==0) && (e.keyCode)) {\r
-                       if (e.DOM_VK_UP) {\r
-                               for (var i in termDomKeyRef) {\r
-                                       if ((e[i]) && (e.keyCode == e[i])) {\r
-                                               ch=termDomKeyRef[i];\r
-                                               break;\r
-                                       }\r
-                               }\r
-                       }\r
-                       else {\r
-                               // NS4\r
-                               if (e.keyCode==28) ch=termKey.LEFT\r
-                               else if (e.keyCode==29) ch=termKey.RIGHT\r
-                               else if (e.keyCode==30) ch=termKey.UP\r
-                               else if (e.keyCode==31) ch=termKey.DOWN\r
-                               // Mozilla alike but no DOM support\r
-                               else if (e.keyCode==37) ch=termKey.LEFT\r
-                               else if (e.keyCode==39) ch=termKey.RIGHT\r
-                               else if (e.keyCode==38) ch=termKey.UP\r
-                               else if (e.keyCode==40) ch=termKey.DOWN\r
-                               // just to have the TAB mapping here too\r
-                               else if (e.keyCode==9) ch=termKey.TAB;\r
-                       }\r
-               }\r
-       }\r
-       // key actions\r
-       if (term.charMode) {\r
-               term.insert=false;\r
-               term.inputChar=ch;\r
-               term.lineBuffer='';\r
-               term.handler();\r
-               if ((ch<=32) && (window.event)) window.event.cancleBubble=true;\r
-               return false;\r
-       }\r
-       if (!ctrl) {\r
-               // special keys\r
-               if (ch==termKey.CR) {\r
-                       term.lock=true;\r
-                       term.cursorOff();\r
-                       term.insert=false;\r
-                       if (term.rawMode) {\r
-                               term.lineBuffer=term.lastLine;\r
-                       }\r
-                       else {\r
-                               term.lineBuffer=term._getLine();\r
-                               if (\r
-                                   (term.lineBuffer!='') && ((!term.historyUnique) ||\r
-                                   (term.history.length==0) ||\r
-                                   (term.lineBuffer!=term.history[term.history.length-1]))\r
-                                  ) {\r
-                                       term.history[term.history.length]=term.lineBuffer;\r
-                               }\r
-                               term.histPtr=term.history.length;\r
-                       }\r
-                       term.lastLine='';\r
-                       term.inputChar=0;\r
-                       term.handler();\r
-                       if (window.event) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-               else if (ch==termKey.ESC) {\r
-                       if (term.conf.closeOnESC) term.close();\r
-                       if (window.event) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-               if ((ch<32) && (term.rawMode)) {\r
-                       if (window.event) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-               else {\r
-                       if (ch==termKey.LEFT) {\r
-                               term.cursorLeft();\r
-                               if (window.event) window.event.cancleBubble=true;\r
-                               return false;\r
-                       }\r
-                       else if (ch==termKey.RIGHT) {\r
-                               term.cursorRight();\r
-                               if (window.event) window.event.cancleBubble=true;\r
-                               return false;\r
-                       }\r
-                       else if (ch==termKey.UP) {\r
-                               term.cursorOff();\r
-                               if (term.histPtr==term.history.length) term.lastLine=term._getLine();\r
-                               term._clearLine();\r
-                               if ((term.history.length) && (term.histPtr>=0)) {\r
-                                       if (term.histPtr>0) term.histPtr--;\r
-                                       term.type(term.history[term.histPtr]);\r
-                               }\r
-                               else if (term.lastLine) term.type(term.lastLine);\r
-                               term.cursorOn();\r
-                               if (window.event) window.event.cancleBubble=true;\r
-                               return false;\r
-                       }\r
-                       else if (ch==termKey.DOWN) {\r
-                               term.cursorOff();\r
-                               if (term.histPtr==term.history.length) term.lastLine=term._getLine();\r
-                               term._clearLine();\r
-                               if ((term.history.length) && (term.histPtr<=term.history.length)) {\r
-                                       if (term.histPtr<term.history.length) term.histPtr++;\r
-                                       if (term.histPtr<term.history.length) term.type(term.history[term.histPtr])\r
-                                       else if (term.lastLine) term.type(term.lastLine);\r
-                               }\r
-                               else if (term.lastLine) term.type(term.lastLine);\r
-                               term.cursorOn();\r
-                               if (window.event) window.event.cancleBubble=true;\r
-                               return false;\r
-                       }\r
-                       else if (ch==termKey.BS) {\r
-                               term.backspace();\r
-                               if (window.event) window.event.cancleBubble=true;\r
-                               return false;\r
-                       }\r
-                       else if (ch==termKey.DEL) {\r
-                               if (term.DELisBS) term.backspace()\r
-                               else term.fwdDelete();\r
-                               if (window.event) window.event.cancleBubble=true;\r
-                               return false;\r
-                       }\r
-               }\r
-       }\r
-       if (term.rawMode) {\r
-               if (term.isPrintable(ch)) {\r
-                       term.lastLine+=String.fromCharCode(ch);\r
-               }\r
-               if ((ch==32) && (window.event)) window.event.cancleBubble=true\r
-               else if ((window.opera) && (window.event)) window.event.cancleBubble=true;\r
-               return false;\r
-       }\r
-       else {\r
-               if ((term.conf.catchCtrlH) && ((ch==termKey.BS) || ((ctrl) && (ch==72)))) {\r
-                       // catch ^H\r
-                       term.backspace();\r
-                       if (window.event) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-               else if ((term.ctrlHandler) && ((ch<32) || ((ctrl) && (term.isPrintable(ch,true))))) {\r
-                       if (((ch>=65) && (ch<=96)) || (ch==63)) {\r
-                               // remap canonical\r
-                               if (ch==63) ch=31\r
-                               else ch-=64;\r
-                       }\r
-                       term.inputChar=ch;\r
-                       term.ctrlHandler();\r
-                       if (window.event) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-               else if ((ctrl) || (!term.isPrintable(ch,true))) {\r
-                       if (window.event) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-               else if (term.isPrintable(ch,true)) {\r
-                       if (term.blinkTimer) clearTimeout(term.blinkTimer);\r
-                       if (term.insert) {\r
-                               term.cursorOff();\r
-                               term._scrollRight(term.r,term.c);\r
-                       }\r
-                       term._charOut(ch);\r
-                       term.cursorOn();\r
-                       if ((ch==32) && (window.event)) window.event.cancleBubble=true\r
-                       else if ((window.opera) && (window.event)) window.event.cancleBubble=true;\r
-                       return false;\r
-               }\r
-       }\r
-       return true;\r
-}\r
-\r
-// term gui\r
-\r
-TermGlobals.hasSubDivs=false;\r
-TermGlobals.hasLayers=false;\r
-TermGlobals.termStringStart='';\r
-TermGlobals.termStringEnd='';\r
-\r
-TermGlobals.termSpecials=new Array();\r
-TermGlobals.termSpecials[0]='&nbsp;';\r
-TermGlobals.termSpecials[1]='&nbsp;';\r
-TermGlobals.termSpecials[9]='&nbsp;';\r
-TermGlobals.termSpecials[32]='&nbsp;';\r
-TermGlobals.termSpecials[34]='&quot;';\r
-TermGlobals.termSpecials[38]='&amp;';\r
-TermGlobals.termSpecials[60]='&lt;';\r
-TermGlobals.termSpecials[62]='&gt;';\r
-TermGlobals.termSpecials[127]='&loz;';\r
-TermGlobals.termSpecials[0x20AC]='&euro;';\r
-\r
-TermGlobals.termStyles=new Array(1,2,4,8);\r
-TermGlobals.termStyleOpen=new Array();\r
-TermGlobals.termStyleClose=new Array();\r
-TermGlobals.termStyleOpen[1]='<span class="termReverse">';\r
-TermGlobals.termStyleClose[1]='<\/span>';\r
-TermGlobals.termStyleOpen[2]='<u>';\r
-TermGlobals.termStyleClose[2]='<\/u>';\r
-TermGlobals.termStyleOpen[4]='<i>';\r
-TermGlobals.termStyleClose[4]='<\/i>';\r
-TermGlobals.termStyleOpen[8]='<strike>';\r
-TermGlobals.termStyleClose[8]='<\/strike>';\r
-\r
-Terminal.prototype._makeTerm=function(rebuild) {\r
-       window.status='Building terminal ...';\r
-       TermGlobals.hasLayers=(document.layers)? true:false;\r
-       TermGlobals.hasSubDivs=(navigator.userAgent.indexOf('Gecko')<0);\r
-       var divPrefix=this.termDiv+'_r';\r
-       var s='';\r
-       s+='<table border="0" cellspacing="0" cellpadding="'+this.conf.frameWidth+'">\n';\r
-       s+='<tr><td bgcolor="'+this.conf.frameColor+'"><table border="0" cellspacing="0" cellpadding="2"><tr><td  bgcolor="'+this.conf.bgColor+'"><table border="0" cellspacing="0" cellpadding="0">\n';\r
-       var rstr='';\r
-       for (var c=0; c<this.conf.cols; c++) rstr+='&nbsp;';\r
-       for (var r=0; r<this.conf.rows; r++) {\r
-               var termid=((TermGlobals.hasLayers) || (TermGlobals.hasSubDivs))? '' : ' id="'+divPrefix+r+'"';\r
-               s+='<tr><td nowrap height="'+this.conf.rowHeight+'"'+termid+' class="'+this.conf.fontClass+'">'+rstr+'<\/td><\/tr>\n';\r
-       }\r
-       s+='<\/table><\/td><\/tr>\n';\r
-       s+='<\/table><\/td><\/tr>\n';\r
-       s+='<\/table>\n';\r
-       var termOffset=2+this.conf.frameWidth;\r
-       if (TermGlobals.hasLayers) {\r
-               for (var r=0; r<this.conf.rows; r++) {\r
-                       s+='<layer name="'+divPrefix+r+'" top="'+(termOffset+r*this.conf.rowHeight)+'" left="'+termOffset+'" class="'+this.conf.fontClass+'"><\/layer>\n';\r
-               }\r
-               this.ns4ParentDoc=document.layers[this.termDiv].document;\r
-               TermGlobals.termStringStart='<table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap height="'+this.conf.rowHeight+'" class="'+this.conf.fontClass+'">';\r
-               TermGlobals.termStringEnd='<\/td><\/tr><\/table>';\r
-       }\r
-       else if (TermGlobals.hasSubDivs) {\r
-               for (var r=0; r<this.conf.rows; r++) {\r
-                       s+='<div id="'+divPrefix+r+'" style="position:absolute; top:'+(termOffset+r*this.conf.rowHeight)+'px; left: '+termOffset+'px;" class="'+this.conf.fontClass+'"><\/div>\n';\r
-               }\r
-               TermGlobals.termStringStart='<table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap height="'+this.conf.rowHeight+'" class="'+this.conf.fontClass+'">';\r
-               TermGlobals.termStringEnd='<\/td><\/tr><\/table>';\r
-       }\r
-       TermGlobals.writeElement(this.termDiv,s);\r
-       if (!rebuild) {\r
-               TermGlobals.setElementXY(this.termDiv,this.conf.x,this.conf.y);\r
-               TermGlobals.setVisible(this.termDiv,1);\r
-       }\r
-       window.status='';\r
-}\r
-\r
-Terminal.prototype.rebuild=function() {\r
-       // check for bounds and array lengths\r
-       var rl=this.conf.rows;\r
-       var cl=this.conf.cols;\r
-       for (var r=0; r<rl; r++) {\r
-               var cbr=this.charBuf[r];\r
-               if (!cbr) {\r
-                       this.charBuf[r]=this.getRowArray(cl,0);\r
-                       this.styleBuf[r]=this.getRowArray(cl,0);\r
-               }\r
-               else if (cbr.length<cl) {\r
-                       for (var c=cbr.length; c<cl; c++) {\r
-                               this.charBuf[r][c]=0;\r
-                               this.styleBuf[r][c]=0;\r
-                       }\r
-               }\r
-       }\r
-       var resetcrsr=false;\r
-       if (this.r>=rl) {\r
-               r=rl-1;\r
-               resetcrsr=true;\r
-       }\r
-       if (this.c>=cl) {\r
-               c=cl-1;\r
-               resetcrsr=true;\r
-       }\r
-       if ((resetcrsr) && (this.cursoractive)) this.cursorOn();\r
-       // and actually rebuild\r
-       this._makeTerm(true);\r
-       for (var r=0; r<rl; r++) {\r
-               this.redraw(r);\r
-       }\r
-}\r
-\r
-Terminal.prototype.moveTo=function(x,y) {\r
-       TermGlobals.setElementXY(this.termDiv,x,y);\r
-}\r
-\r
-Terminal.prototype.resizeTo=function(x,y) {\r
-       if (this.termDivReady()) {\r
-               x=parseInt(x,10);\r
-               y=parseInt(y,10);\r
-               if ((isNaN(x)) || (isNaN(y)) || (x<4) || (y<2)) return false;\r
-               this.maxCols=this.conf.cols=x;\r
-               this.maxLines=this.conf.rows=y;\r
-               this._makeTerm();\r
-               this.clear();\r
-               return true;\r
-       }\r
-       else return false;\r
-}\r
-\r
-Terminal.prototype.redraw=function(r) {\r
-       var s=TermGlobals.termStringStart;\r
-       var curStyle=0;\r
-       var tstls=TermGlobals.termStyles;\r
-       var tscls=TermGlobals.termStyleClose;\r
-       var tsopn=TermGlobals.termStyleOpen;\r
-       var tspcl=TermGlobals.termSpecials;\r
-       var t_cb=this.charBuf;\r
-       var t_sb=this.styleBuf;\r
-       for (var i=0; i<this.conf.cols; i++) {\r
-               var c=t_cb[r][i];\r
-               var cs=t_sb[r][i];\r
-               if (cs!=curStyle) {\r
-                       if (curStyle) {\r
-                               for (var k=tstls.length-1; k>=0; k--) {\r
-                                       var st=tstls[k];\r
-                                       if (curStyle&st) s+=tscls[st];\r
-                               }\r
-                       }\r
-                       curStyle=cs;\r
-                       for (var k=0; k<tstls.length; k++) {\r
-                               var st=tstls[k];\r
-                               if (curStyle&st) s+=tsopn[st];\r
-                       }\r
-               }\r
-               s+= (tspcl[c])? tspcl[c] : String.fromCharCode(c);\r
-       }\r
-       if (curStyle>0) {\r
-               for (var k=tstls.length-1; k>=0; k--) {\r
-                       var st=tstls[k];\r
-                       if (curStyle&st) s+=tscls[st];\r
-               }\r
-       }\r
-       s+=TermGlobals.termStringEnd;\r
-       TermGlobals.writeElement(this.termDiv+'_r'+r,s,this.ns4ParentDoc);\r
-}\r
-\r
-Terminal.prototype.guiReady=function() {\r
-       ready=true;\r
-       if (TermGlobals.guiElementsReady(this.termDiv, self.document)) {\r
-               for (var r=0; r<this.conf.rows; r++) {\r
-                       if (TermGlobals.guiElementsReady(this.termDiv+'_r'+r,this.ns4ParentDoc)==false) {\r
-                               ready=false;\r
-                               break;\r
-                       }\r
-               }\r
-       }\r
-       else ready=false;\r
-       return ready;\r
-}\r
-\r
-Terminal.prototype.termDivReady=function() {\r
-       if (document.layers) {\r
-               return (document.layers[this.termDiv])? true:false;\r
-       }\r
-       else if (document.getElementById) {\r
-               return (document.getElementById(this.termDiv))? true:false;\r
-       }\r
-       else if (document.all) {\r
-               return (document.all[this.termDiv])? true:false;\r
-       }\r
-       else {\r
-               return false;\r
-       }\r
-}\r
-\r
-Terminal.prototype.getDimensions=function() {\r
-       var w=0;\r
-       var h=0;\r
-       var d=this.termDiv;\r
-       if (document.layers) {\r
-               if (document.layers[d]) {\r
-                       w=document.layers[d].clip.right;\r
-                       h=document.layers[d].clip.bottom;\r
-               }\r
-       }\r
-       else if (document.getElementById) {\r
-               var obj=document.getElementById(d);\r
-               if ((obj) && (obj.firstChild)) {\r
-                       w=parseInt(obj.firstChild.offsetWidth,10);\r
-                       h=parseInt(obj.firstChild.offsetHeight,10);\r
-        }\r
-               else if ((obj) && (obj.children) && (obj.children[0])) {\r
-                       w=parseInt(obj.children[0].offsetWidth,10);\r
-                       h=parseInt(obj.children[0].offsetHeight,10);\r
-        }\r
-       }\r
-       else if (document.all) {\r
-               var obj=document.all[d];\r
-               if ((obj) && (obj.children) && (obj.children[0])) {\r
-                       w=parseInt(obj.children[0].offsetWidth,10);\r
-                       h=parseInt(obj.children[0].offsetHeight,10);\r
-        }\r
-       }\r
-       return { width: w, height: h };\r
-}\r
-\r
-// basic dynamics\r
-\r
-TermGlobals.writeElement=function(e,t,d) {\r
-       if (document.layers) {\r
-               var doc=(d)? d : self.document;\r
-               doc.layers[e].document.open();\r
-               doc.layers[e].document.write(t);\r
-               doc.layers[e].document.close();\r
-       }\r
-       else if (document.getElementById) {\r
-               var obj=document.getElementById(e);\r
-               obj.innerHTML=t;\r
-       }\r
-       else if (document.all) {\r
-               document.all[e].innerHTML=t;\r
-       }\r
-}\r
-\r
-TermGlobals.setElementXY=function(d,x,y) {\r
-       if (document.layers) {\r
-               document.layers[d].moveTo(x,y);\r
-       }\r
-       else if (document.getElementById) {\r
-               var obj=document.getElementById(d);\r
-               obj.style.left=x+'px';\r
-               obj.style.top=y+'px';\r
-       }\r
-       else if (document.all) {\r
-               document.all[d].style.left=x+'px';\r
-               document.all[d].style.top=y+'px';\r
-       }\r
-}\r
-\r
-TermGlobals.setVisible=function(d,v) {\r
-       if (document.layers) {\r
-               document.layers[d].visibility= (v)? 'show':'hide';\r
-       }\r
-       else if (document.getElementById) {\r
-               var obj=document.getElementById(d);\r
-               obj.style.visibility= (v)? 'visible':'hidden';\r
-       }\r
-       else if (document.all) {\r
-               document.all[d].style.visibility= (v)? 'visible':'hidden';\r
-       }\r
-}\r
-\r
-TermGlobals.setDisplay=function(d,v) {\r
-       if (document.getElementById) {\r
-               var obj=document.getElementById(d);\r
-               obj.style.display=v;\r
-       }\r
-       else if (document.all) {\r
-               document.all[d].style.display=v;\r
-       }\r
-}\r
-\r
-TermGlobals.guiElementsReady=function(e,d) {\r
-       if (document.layers) {\r
-               var doc=(d)? d : self.document;\r
-               return ((doc) && (doc.layers[e]))? true:false;\r
-       }\r
-       else if (document.getElementById) {\r
-               return (document.getElementById(e))? true:false;\r
-       }\r
-       else if (document.all) {\r
-               return (document.all[e])? true:false;\r
-       }\r
-       else return false;\r
-}\r
-\r
-\r
-// constructor mods (ie4 fix)\r
-\r
-var termString_keyref;\r
-var termString_keycoderef;\r
-\r
-function termString_makeKeyref() {\r
-       termString_keyref= new Array();\r
-       termString_keycoderef= new Array();\r
-       var hex= new Array('A','B','C','D','E','F');\r
-       for (var i=0; i<=15; i++) {\r
-               var high=(i<10)? i:hex[i-10];\r
-               for (var k=0; k<=15; k++) {\r
-                       var low=(k<10)? k:hex[k-10];\r
-                       var cc=i*16+k;\r
-                       if (cc>=32) {\r
-                               var cs=unescape("%"+high+low);\r
-                               termString_keyref[cc]=cs;\r
-                               termString_keycoderef[cs]=cc;\r
-                       }\r
-               }\r
-       }\r
-}\r
-\r
-if (!String.fromCharCode) {\r
-       termString_makeKeyref();\r
-       String.fromCharCode=function(cc) {\r
-               return (cc!=null)? termString_keyref[cc] : '';\r
-       };\r
-}\r
-if (!String.prototype.charCodeAt) {\r
-       if (!termString_keycoderef) termString_makeKeyref();\r
-       String.prototype.charCodeAt=function(n) {\r
-               cs=this.charAt(n);\r
-               return (termString_keycoderef[cs])? termString_keycoderef[cs] : 0;\r
-       };\r
-}\r
-\r
-// eof
\ No newline at end of file
diff --git a/extra/webapps/fjsc/resources/termlib/termlib_parser.js b/extra/webapps/fjsc/resources/termlib/termlib_parser.js
deleted file mode 100644 (file)
index 27c0c5f..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-/*\r
-  termlib_parser.js  v.1.0\r
-  command line parser for termlib.js\r
-  (c) Norbert Landsteiner 2005\r
-  mass:werk - media environments\r
-  <http://www.masswerk.at>\r
-\r
-  you are free to use this parser under the "termlib.js" license.\r
-\r
-  usage:  call "parseLine(this)" from your Terminal handler\r
-          parsed args in this.argv\r
-          quoting levels per arg in this.argQL (value: quote char)\r
-          this.argc: pointer to this.argv and this.argQL (used by parserGetopt)\r
-          call parseretopt(this, "<options>") from your handler to get opts\r
-          (returns an object with properties for every option flag. any float\r
-          values are stored in Object.<flag>.value; illegal opts in array\r
-          Object.illegals)\r
-\r
-  configuration: you may want to overide the follow objects (or add properties):\r
-          parserWhiteSpace: chars to be parsed as whitespace\r
-          parserQuoteChars: chars to be parsed as quotes\r
-          parserSingleEscapes: chars to escape a quote or escape expression\r
-          parserOptionChars: chars that start an option\r
-          parserEscapeExpressions: chars that start escape expressions\r
-*/\r
-\r
-// chars to be parsed as white space\r
-var parserWhiteSpace = {\r
-       ' ': true,\r
-       '\t': true\r
-}\r
-\r
-// chars to be parsed as quotes\r
-var parserQuoteChars = {\r
-       '"': true,\r
-       "'": true,\r
-       '`': true\r
-};\r
-\r
-// chars to be parsed as escape char\r
-var parserSingleEscapes = {\r
-       '\\': true\r
-};\r
-\r
-// chars that mark the start of an option-expression\r
-// for use with parserGetopt\r
-var parserOptionChars = {\r
-       '-': true\r
-}\r
-\r
-// chars that start escape expressions (value = handler)\r
-// plugin handlers for ascii escapes or variable substitution\r
-var parserEscapeExpressions = {\r
-       '%': parserHexExpression\r
-}\r
-\r
-function parserHexExpression(termref, pointer, echar, quotelevel) {\r
-       /* example for parserEscapeExpressions\r
-          params:\r
-            termref: ref to Terminal instance\r
-            pointer: position in termref.lineBuffer (echar)\r
-            echar:   escape character found\r
-            quotelevel: current quoting level (quote char or empty)\r
-          char under pointer will be ignored\r
-          the return value is added to the current argument\r
-       */\r
-       // convert hex values to chars (e.g. %20 => <SPACE>)\r
-       if (termref.lineBuffer.length > pointer+2) {\r
-               // get next 2 chars\r
-               var hi = termref.lineBuffer.charAt(pointer+1);\r
-               var lo = termref.lineBuffer.charAt(pointer+2);\r
-               lo = lo.toUpperCase();\r
-               hi = hi.toUpperCase();\r
-               // check for valid hex digits\r
-               if ((((hi>='0') && (hi<='9')) || ((hi>='A') && ((hi<='F')))) &&\r
-                   (((lo>='0') && (lo<='9')) || ((lo>='A') && ((lo<='F'))))) {\r
-                       // next 2 chars are valid hex, so strip them from lineBuffer\r
-                       parserEscExprStrip(termref, pointer+1, pointer+3);\r
-                       // and return the char\r
-                       return String.fromCharCode(parseInt(hi+lo, 16));\r
-               }\r
-       }\r
-       // if not handled return the escape character (=> no conversion)\r
-       return echar;\r
-}\r
-\r
-function parserEscExprStrip(termref, from, to) {\r
-       // strip characters from termref.lineBuffer (for use with escape expressions)\r
-       termref.lineBuffer =\r
-               termref.lineBuffer.substring(0, from) +\r
-               termref.lineBuffer.substring(to);\r
-}\r
-\r
-function parserGetopt(termref, optsstring) {\r
-    // scans argv form current position of argc for opts\r
-    // arguments in argv must not be quoted\r
-       // returns an object with a property for every option flag found\r
-       // option values (absolute floats) are stored in Object.<opt>.value (default -1)\r
-       // the property "illegals" contains an array of  all flags found but not in optstring\r
-       // argc is set to first argument that is not an option\r
-       var opts = { 'illegals':[] };\r
-       while ((termref.argc < termref.argv.length) && (termref.argQL[termref.argc]==''))  {\r
-               var a = termref.argv[termref.argc];\r
-               if ((a.length>0) && (parserOptionChars[a.charAt(0)])) {\r
-                       var i = 1;\r
-                       while (i<a.length) {\r
-                               var c=a.charAt(i);\r
-                               var v = '';\r
-                               while (i<a.length-1) {\r
-                                       var nc=a.charAt(i+1);\r
-                                       if ((nc=='.') || ((nc>='0') && (nc<='9'))) {\r
-                                               v += nc;\r
-                                               i++;\r
-                                       }\r
-                                       else break;\r
-                               }\r
-                               if (optsstring.indexOf(c)>=0) {\r
-                                       opts[c] = (v == '')? {value:-1} : (isNaN(v))? {value:0} : {value:parseFloat(v)};\r
-                               }\r
-                               else {\r
-                                       opts.illegals[opts.illegals.length]=c;\r
-                               }\r
-                               i++;\r
-                       }\r
-                       termref.argc++;\r
-               }\r
-               else break;\r
-       }\r
-       return opts;\r
-}\r
-\r
-function parseLine(termref) {\r
-       // stand-alone parser, takes a Terminal instance as argument\r
-       // parses the command line and stores results as instance properties\r
-       //   argv:  list of parsed arguments\r
-       //   argQL: argument's quoting level (<empty> or quote character)\r
-       //   argc:  cursur for argv, set initinally to zero (0)\r
-       // open quote strings are not an error but automatically closed.\r
-       var argv = [''];     // arguments vector\r
-       var argQL = [''];    // quoting level\r
-       var argc = 0;        // arguments cursor\r
-       var escape = false ; // escape flag\r
-       for (var i=0; i<termref.lineBuffer.length; i++) {\r
-               var ch= termref.lineBuffer.charAt(i);\r
-               if (escape) {\r
-                       argv[argc] += ch;\r
-                       escape = false;\r
-               }\r
-               else if (parserEscapeExpressions[ch]) {\r
-                       var v = parserEscapeExpressions[ch](termref, i, ch, argQL[argc]);\r
-                       if (typeof v != 'undefined') argv[argc] += v;\r
-               }\r
-               else if (parserQuoteChars[ch]) {\r
-                       if (argQL[argc]) {\r
-                               if (argQL[argc] == ch) {\r
-                                       argc ++;\r
-                                       argv[argc] = argQL[argc] = '';\r
-                               }\r
-                               else {\r
-                                       argv[argc] += ch;\r
-                               }\r
-                       }\r
-                       else {\r
-                               if (argv[argc] != '') {\r
-                                       argc ++;\r
-                                       argv[argc] = '';\r
-                                       argQL[argc] = ch;\r
-                               }\r
-                               else {\r
-                                       argQL[argc] = ch;\r
-                               }\r
-                       }\r
-               }\r
-               else if (parserWhiteSpace[ch]) {\r
-                       if (argQL[argc]) {\r
-                               argv[argc] += ch;\r
-                       }\r
-                       else if (argv[argc] != '') {\r
-                               argc++;\r
-                               argv[argc] = argQL[argc] = '';\r
-                       }\r
-               }\r
-               else if (parserSingleEscapes[ch]) {\r
-                       escape = true;\r
-               }\r
-               else {\r
-                       argv[argc] += ch;\r
-               }\r
-       }\r
-       if ((argv[argc] == '') && (!argQL[argc])) {\r
-               argv.length--;\r
-               argQL.length--;\r
-       }\r
-       termref.argv = argv;\r
-       termref.argQL = argQL;\r
-       termref.argc = 0;\r
-}\r
-\r
-// eof
\ No newline at end of file
diff --git a/extra/webapps/fjsc/summary.txt b/extra/webapps/fjsc/summary.txt
deleted file mode 100644 (file)
index 74e8bbb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Web interface for Factor to Javascript compiler
diff --git a/extra/webapps/fjsc/tags.txt b/extra/webapps/fjsc/tags.txt
deleted file mode 100644 (file)
index 1b93c9e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-webapp
diff --git a/extra/webapps/help/authors.txt b/extra/webapps/help/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/webapps/help/help.factor b/extra/webapps/help/help.factor
deleted file mode 100644 (file)
index 28d7360..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel furnace furnace.validator http.server.responders
-       help help.topics html splitting sequences words strings 
-       quotations macros vocabs tools.browser combinators
-       arrays io.files ;
-IN: webapps.help 
-
-! : string>topic ( string -- topic )
-    ! " " split dup length 1 = [ first ] when ;
-
-: show-help ( topic -- )
-    serving-html
-    dup article-title [
-        [ help ] with-html-stream
-    ] simple-html-document ;
-
-\ show-help {
-    { "topic" }
-} define-action
-\ show-help { { "topic" "handbook" } } default-values
-
-M: link browser-link-href
-    link-name
-    dup word? over f eq? or [
-        browser-link-href
-    ] [
-        dup array? [ " " join ] when
-        [ show-help ] curry quot-link
-    ] if ;
-
-: show-word ( word vocab -- )
-    lookup show-help ;
-
-\ show-word {
-    { "word" }
-    { "vocab" }
-} define-action
-\ show-word { { "word" "call" } { "vocab" "kernel" } } default-values
-
-M: f browser-link-href
-    drop \ f browser-link-href ;
-
-M: word browser-link-href
-    dup word-name swap word-vocabulary
-    [ show-word ] 2curry quot-link ;
-
-: show-vocab ( vocab -- )
-    f >vocab-link show-help ;
-
-\ show-vocab {
-    { "vocab" }
-} define-action
-
-\ show-vocab { { "vocab" "kernel" } } default-values
-
-M: vocab-spec browser-link-href
-    vocab-name [ show-vocab ] curry quot-link ;
-
-: show-vocabs-tagged ( tag -- )
-    <vocab-tag> show-help ;
-
-\ show-vocabs-tagged {
-    { "tag" }
-} define-action
-
-M: vocab-tag browser-link-href
-    vocab-tag-name [ show-vocabs-tagged ] curry quot-link ;
-
-: show-vocabs-by ( author -- )
-    <vocab-author> show-help ;
-
-\ show-vocabs-by {
-    { "author" }
-} define-action
-
-M: vocab-author browser-link-href
-    vocab-author-name [ show-vocabs-by ] curry quot-link ;
-
-"help" "show-help" "extra/webapps/help" web-app
-
-! Hard-coding for factorcode.org
-PREDICATE: pathname resource-pathname
-    pathname-string "resource:" head? ;
-
-M: resource-pathname browser-link-href
-    pathname-string
-    "resource:" ?head drop
-    "/responder/source/" swap append ;
diff --git a/extra/webapps/numbers/authors.txt b/extra/webapps/numbers/authors.txt
deleted file mode 100755 (executable)
index 44b06f9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Chris Double
diff --git a/extra/webapps/numbers/numbers.factor b/extra/webapps/numbers/numbers.factor
deleted file mode 100644 (file)
index 59247e9..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-! cont-number-guess
-!
-! Copyright (C) 2004 Chris Double.
-! 
-! Redistribution and use in source and binary forms, with or without
-! modification, are permitted provided that the following conditions are met:
-! 
-! 1. Redistributions of source code must retain the above copyright notice,
-!    this list of conditions and the following disclaimer.
-! 
-! 2. Redistributions in binary form must reproduce the above copyright notice,
-!    this list of conditions and the following disclaimer in the documentation
-!    and/or other materials provided with the distribution.
-! 
-! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
-! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
-! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-!
-! This example modifies the console based 'numbers-game' example
-! in a very minimal way to demonstrate conversion of a console
-! program to a web based application.
-!
-! All that was required was changing the input and output functions
-! to use HTML. The remaining code was untouched. 
-!
-! The result is not that pretty but it shows the basic idea.
-USING: kernel math parser html html.elements io namespaces
-math.parser random webapps.continuation ;
-
-IN: webapps.numbers
-
-: web-print ( str -- )
-  #! Display the string in a web page.
-  [
-    swap dup
-    <html>
-      <head> <title> write </title> </head>
-      <body>
-        <p> write </p>
-        <p> <a =href a> "Press to continue" write </a> </p>
-      </body>
-    </html>
-  ] show 2drop ;
-
-: read-number ( -- )
-  [
-    <html>
-      <head> <title> "Enter a number" write </title> </head>
-      <body>
-        <form =action "post" =method form>
-          <p> 
-            "Enter a number:" write
-            <input "text" =type "num" =name "20" =size input/>
-            <input "submit" =type "Press to continue" =value input/>
-          </p>
-        </form>
-      </body>
-    </html>
-  ] show [ "num" get ] bind string>number ;
-
-: guess-banner
-  "I'm thinking of a number between 0 and 100." web-print ;
-: guess-prompt  ;
-: too-high "Too high" web-print ;
-: too-low "Too low" web-print ;
-: correct "Correct - you win!" web-print ;
-: inexact-guess ( actual guess -- )
-     < [ too-high ] [ too-low ] if ;
-
-: judge-guess ( actual guess -- ? )
-    2dup = [
-        2drop correct f
-    ] [
-        inexact-guess t
-    ] if ;
-
-: number-to-guess ( -- n ) 100 random ;
-
-: numbers-game-loop ( actual -- )
-    dup guess-prompt read-number judge-guess [
-        numbers-game-loop
-    ] [
-        drop
-    ] if ;
-
-: numbers-game number-to-guess numbers-game-loop ;
-
-"numbers-game" [ numbers-game ] install-cont-responder
diff --git a/extra/webapps/pastebin/annotate-paste.furnace b/extra/webapps/pastebin/annotate-paste.furnace
deleted file mode 100755 (executable)
index 14a424f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<% USING: io math math.parser namespaces furnace ; %>
-
-<h1>Annotate</h1>
-
-<form method="POST" action="/responder/pastebin/annotate-paste">
-
-<table>
-
-<tr>
-<th align="right">Summary:</th>
-<td><input type="TEXT" name="summary" value="<% "summary" render %>" /></td>
-<td align="left" class="error"><% "summary" "*Required" render-error %></td>
-</tr>
-
-<tr>
-<th align="right">Your name:</th>
-<td><input type="TEXT" name="author" value="<% "author" render  %>" /></td>
-<td class="error"><% "author" "*Required" render-error %></td>
-</tr>
-
-<tr>
-<th align="right">File type:</th>
-<td><% "modes" render-template %></td>
-</tr>
-
-<!--
-<tr>
-<th align="right">Channel:</th>
-<td><input type="TEXT" name="channel" value="#concatenative" /></td>
-</tr>
--->
-
-<tr>
-<td></td>
-<td colspan="2" class="error" align="left"><% "contents" "*Required" render-error %></td>
-</tr>
-
-<tr>
-<th align="right" valign="top">Content:</th>
-<td colspan="2"><textarea rows="24" cols="60" name="contents"><% "contents" render %></textarea></td>
-</tr>
-</table>
-
-<input type="hidden" name="n" value="<% "n" get number>string write %>" />
-<input type="hidden" name="furnace-form-submitted" value="annotate-paste"/>
-<input type="SUBMIT" value="Annotate" />
-</form>
diff --git a/extra/webapps/pastebin/annotation.furnace b/extra/webapps/pastebin/annotation.furnace
deleted file mode 100755 (executable)
index e59db32..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<% USING: namespaces io furnace calendar ; %>
-
-<h2>Annotation: <% "summary" get write %></h2>
-
-<table>
-<tr><th align="right">Annotation by:</th><td><% "author" get write %></td></tr>
-<tr><th align="right">File type:</th><td><% "mode" get write %></td></tr>
-<tr><th align="right">Created:</th><td><% "date" get timestamp>string write %></td></tr>
-</table>
-
-<% "syntax" render-template %>
diff --git a/extra/webapps/pastebin/authors.txt b/extra/webapps/pastebin/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/webapps/pastebin/footer.furnace b/extra/webapps/pastebin/footer.furnace
deleted file mode 100644 (file)
index 15b9011..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-</body>
-
-</html>
diff --git a/extra/webapps/pastebin/header.furnace b/extra/webapps/pastebin/header.furnace
deleted file mode 100644 (file)
index 2c8e79a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<% USING: namespaces io furnace sequences xmode.code2html webapps.pastebin ; %>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
-       <title><% "title" get write %></title>
-       <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
-       <% default-stylesheet %>
-    <link rel="alternate" type="application/atom+xml" title="Pastebin - Atom" href="feed.xml" />
-</head>
-
-<body id="index">
-
-    <div class="navbar">
-        <% [ paste-list ] "Paste list" render-link %> |
-        <% [ new-paste ] "New paste" render-link %> |
-        <% [ feed.xml ] "Syndicate" render-link %>
-    </div>
-    <h1 class="pastebin-title"><% "title" get write %></h1>
diff --git a/extra/webapps/pastebin/modes.furnace b/extra/webapps/pastebin/modes.furnace
deleted file mode 100644 (file)
index 18bbec1..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<% USING: furnace xmode.catalog sequences kernel html.elements assocs io sorting continuations ; %>
-
-<select name="mode">
-    <% modes keys natural-sort [
-        <option dup "mode" session-var = [ "true" =selected ] when option> write </option>
-    ] each %>
-</select>
diff --git a/extra/webapps/pastebin/new-paste.furnace b/extra/webapps/pastebin/new-paste.furnace
deleted file mode 100755 (executable)
index b21e197..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<% USING: continuations furnace namespaces ; %>
-
-<%
-    "New paste" "title" set
-    "header" render-template
-%>
-
-<form method="POST" action="/responder/pastebin/submit-paste">
-
-<table>
-
-<tr>
-<th align="right">Summary:</th>
-<td><input type="TEXT" name="summary" value="<% "summary" render %>" /></td>
-<td align="left" class="error"><% "summary" "*Required" render-error %></td>
-</tr>
-
-<tr>
-<th align="right">Your name:</th>
-<td><input type="TEXT" name="author" value="<% "author" render  %>" /></td>
-<td class="error"><% "author" "*Required" render-error %></td>
-</tr>
-
-<tr>
-<th align="right">File type:</th>
-<td><% "modes" render-template %></td>
-</tr>
-
-<!--
-<tr>
-<th align="right">Channel:</th>
-<td><input type="TEXT" name="channel" value="#concatenative" /></td>
-</tr>
--->
-
-<tr>
-<td></td>
-<td colspan="2" class="error" align="left"><% "contents" "*Required" render-error %></td>
-</tr>
-
-<tr>
-<th align="right" valign="top">Content:</th>
-<td colspan="2"><textarea rows="24" cols="60" name="contents"><% "contents" render %></textarea></td>
-</tr>
-</table>
-
-<input type="hidden" name="furnace-form-submitted" value="new-paste"/>
-<input type="SUBMIT" value="Submit paste" />
-</form>
-
-<% "footer" render-template %>
diff --git a/extra/webapps/pastebin/paste-list.furnace b/extra/webapps/pastebin/paste-list.furnace
deleted file mode 100644 (file)
index 51813ec..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<% USING: namespaces furnace sequences ; %>
-
-<%
-    "Pastebin" "title" set
-    "header" render-template
-%>
-
-<table width="100%" cellspacing="10">
-    <tr>
-        <td valign="top">
-            <table width="100%">
-                <tr align="left" class="pastebin-headings">
-                    <th width="50%">Summary:</th>
-                    <th width="100">Paste by:</th>
-                    <th width="200">Date:</th>
-                </tr>
-                <% "pastes" get <reversed> [ "paste-summary" render-component ] each %>
-            </table>
-        </td>
-        <td valign="top" width="25%">
-            <div class="infobox">
-                <p>This pastebin is written in <a href="http://factorcode.org/">Factor</a>. It is inspired by <a href="http://paste.lisp.org">lisppaste</a>.
-                </p>
-                <p>It can be used for collaborative development over IRC. You can post code for review, and annotate other people's code. Syntax highlighting for over a hundred file types is supported.
-                </p>
-                <p>
-                <% "webapps.pastebin" browse-webapp-source %></p>
-            </div>
-        </td>
-    </tr>
-</table>
-
-<% "footer" render-template %>
diff --git a/extra/webapps/pastebin/paste-summary.furnace b/extra/webapps/pastebin/paste-summary.furnace
deleted file mode 100644 (file)
index dc25fe1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<% USING: continuations namespaces io kernel math math.parser
-furnace webapps.pastebin calendar sequences ; %>
-
-<tr>
-    <td>
-        <a href="<% model get paste-link write %>">
-        <% "summary" get write %>
-        </a>
-    </td>
-    <td><% "author" get write %></td>
-    <td><% "date" get timestamp>string write %></td>
-</tr>
diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor
deleted file mode 100755 (executable)
index 36a7279..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-USING: calendar furnace furnace.validator io.files kernel
-namespaces sequences http.server.responders html math.parser rss
-xml.writer xmode.code2html math calendar.format ;
-IN: webapps.pastebin
-
-TUPLE: pastebin pastes ;
-
-: <pastebin> ( -- pastebin )
-    V{ } clone pastebin construct-boa ;
-
-<pastebin> pastebin set-global
-
-TUPLE: paste
-summary author channel mode contents date
-annotations n ;
-
-: <paste> ( summary author channel mode contents -- paste )
-    f V{ } clone f paste construct-boa ;
-
-TUPLE: annotation summary author mode contents ;
-
-C: <annotation> annotation
-
-: get-paste ( n -- paste )
-    pastebin get pastebin-pastes nth ;
-
-: show-paste ( n -- )
-    serving-html
-    get-paste
-    [ "show-paste" render-component ] with-html-stream ;
-
-\ show-paste { { "n" v-number } } define-action
-
-: new-paste ( -- )
-    serving-html
-    [ "new-paste" render-template ] with-html-stream ;
-
-\ new-paste { } define-action
-
-: paste-list ( -- )
-    serving-html
-    [
-        [ show-paste ] "show-paste-quot" set
-        [ new-paste ] "new-paste-quot" set
-        pastebin get "paste-list" render-component
-    ] with-html-stream ;
-
-\ paste-list { } define-action
-
-: paste-link ( paste -- link )
-    paste-n number>string [ show-paste ] curry quot-link ;
-
-: safe-head ( seq n -- seq' )
-    over length min head ;
-
-: paste-feed ( -- entries )
-    pastebin get pastebin-pastes <reversed> 20 safe-head [
-        {
-            paste-summary
-            paste-link
-            paste-date
-        } get-slots timestamp>rfc3339 f swap <entry>
-    ] map ;
-
-: feed.xml ( -- )
-    "text/xml" serving-content
-    "pastebin"
-    "http://pastebin.factorcode.org"
-    paste-feed <feed> feed>xml write-xml ;
-
-\ feed.xml { } define-action
-
-: add-paste ( paste pastebin -- )
-    >r now over set-paste-date r>
-    pastebin-pastes 2dup length swap set-paste-n push ;
-
-: submit-paste ( summary author channel mode contents -- )
-    <paste> [ pastebin get add-paste ] keep
-    paste-link permanent-redirect ;
-
-\ new-paste
-\ submit-paste {
-    { "summary" v-required }
-    { "author" v-required }
-    { "channel" }
-    { "mode" v-required }
-    { "contents" v-required }
-} define-form
-
-\ new-paste {
-    { "channel" "#concatenative" }
-    { "mode" "factor" }
-} default-values
-
-: annotate-paste ( n summary author mode contents -- )
-    <annotation> swap get-paste
-    [ paste-annotations push ] keep
-    paste-link permanent-redirect ;
-
-[ "n" show-paste ]
-\ annotate-paste {
-    { "n" v-required v-number }
-    { "summary" v-required }
-    { "author" v-required }
-    { "mode" v-required }
-    { "contents" v-required }
-} define-form
-
-\ show-paste {
-    { "mode" "factor" }
-} default-values
-
-: style.css ( -- )
-    "text/css" serving-content
-    "style.css" send-resource ;
-
-\ style.css { } define-action
-
-"pastebin" "paste-list" "extra/webapps/pastebin" web-app
diff --git a/extra/webapps/pastebin/show-paste.furnace b/extra/webapps/pastebin/show-paste.furnace
deleted file mode 100755 (executable)
index 30129ed..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<% USING: namespaces io furnace sequences xmode.code2html calendar ; %>
-
-<%
-    "Paste: " "summary" get append "title" set
-    "header" render-template
-%>
-
-<table>
-<tr><th>Paste by:</th><td><% "author" get write %></td></tr>
-<!-- <tr><th>Channel:</th><td><% "channel" get write %></td></tr> -->
-<tr><th>Created:</th><td><% "date" get timestamp>string write %></td></tr>
-<tr><th>File type:</th><td><% "mode" get write %></td></tr>
-</table>
-
-<% "syntax" render-template %>
-
-<% "annotations" get [ "annotation" render-component ] each %>
-
-<% model get "annotate-paste" render-component %>
-
-<% "footer" render-template %>
diff --git a/extra/webapps/pastebin/style.css b/extra/webapps/pastebin/style.css
deleted file mode 100644 (file)
index 4a469f9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-body {
-       font:75%/1.6em "Lucida Grande", "Lucida Sans Unicode", verdana, geneva, sans-serif;
-       color:#888;
-}
-
-h1.pastebin-title {
-       font-size:300%;
-}
-
-a {
-       color:#222;
-       border-bottom:1px dotted #ccc;
-       text-decoration:none;
-}
-
-a:hover {
-       border-bottom:1px solid #ccc;
-}
-
-pre.code {
-       border:1px dashed #ccc;
-       background-color:#f5f5f5;
-       padding:5px;
-       font-size:150%;
-       color:#000000;
-}
-
-.navbar {
-       background-color:#eeeeee;
-       padding:5px;
-       border:1px solid #ccc;
-}
-
-.infobox {
-       border: 1px solid #C1DAD7;
-       padding: 10px;
-}
-
-.error {
-       color: red;
-}
diff --git a/extra/webapps/pastebin/syntax.furnace b/extra/webapps/pastebin/syntax.furnace
deleted file mode 100755 (executable)
index 17b64b9..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<% USING: xmode.code2html splitting namespaces ; %>
-
-<pre class="code"><% "contents" get string-lines "mode" get htmlize-lines %></pre>
diff --git a/extra/webapps/planet/authors.txt b/extra/webapps/planet/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/webapps/planet/planet.factor b/extra/webapps/planet/planet.factor
deleted file mode 100755 (executable)
index 9a5f8ee..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-USING: sequences rss arrays concurrency.combinators kernel
-sorting html.elements io assocs namespaces math threads vocabs
-html furnace http.server.templating calendar math.parser
-splitting continuations debugger system http.server.responders
-xml.writer prettyprint logging calendar.format ;
-IN: webapps.planet
-
-: print-posting-summary ( posting -- )
-    <p "news" =class p>
-        <b> dup entry-title write </b> <br/>
-        <a entry-link =href "more" =class a>
-            "Read More..." write
-        </a>
-    </p> ;
-
-: print-posting-summaries ( postings -- )
-    [ print-posting-summary ] each ;
-
-: print-blogroll ( blogroll -- )
-    <ul "description" =class ul>
-        [
-            <li> <a dup third =href a> first write </a> </li>
-        ] each
-    </ul> ;
-
-: format-date ( date -- string )
-    rfc3339>timestamp timestamp>string ;
-
-: print-posting ( posting -- )
-    <h2 "posting-title" =class h2>
-        <a dup entry-link =href a>
-            dup entry-title write-html
-        </a>
-    </h2>
-    <p "posting-body" =class p>
-        dup entry-description write-html
-    </p>
-    <p "posting-date" =class p>
-        entry-pub-date format-date write
-    </p> ;
-
-: print-postings ( postings -- )
-    [ print-posting ] each ;
-
-SYMBOL: default-blogroll
-SYMBOL: cached-postings
-
-: safe-head ( seq n -- seq' )
-    over length min head ;
-
-: mini-planet-factor ( -- )
-    cached-postings get 4 safe-head print-posting-summaries ;
-
-: planet-factor ( -- )
-    serving-html [ "planet" render-template ] with-html-stream ;
-
-\ planet-factor { } define-action
-
-: planet-feed ( -- feed )
-    "[ planet-factor ]"
-    "http://planet.factorcode.org"
-    cached-postings get 30 safe-head <feed> ;
-
-: feed.xml ( -- )
-    "text/xml" serving-content
-    planet-feed feed>xml write-xml ;
-
-\ feed.xml { } define-action
-
-: style.css ( -- )
-    "text/css" serving-content
-    "style.css" send-resource ;
-
-\ style.css { } define-action
-
-SYMBOL: last-update
-
-: <posting> ( author entry -- entry' )
-    clone
-    [ ": " swap entry-title 3append ] keep
-    [ set-entry-title ] keep ;
-
-: fetch-feed ( url -- feed )
-    download-feed feed-entries ;
-
-\ fetch-feed DEBUG add-error-logging
-
-: fetch-blogroll ( blogroll -- entries )
-    dup 0 <column> swap 1 <column>
-    [ fetch-feed ] parallel-map
-    [ [ <posting> ] with map ] 2map concat ;
-
-: sort-entries ( entries -- entries' )
-    [ [ entry-pub-date ] compare ] sort <reversed> ;
-
-: update-cached-postings ( -- )
-    default-blogroll get
-    fetch-blogroll sort-entries
-    cached-postings set-global ;
-
-: update-thread ( -- )
-    millis last-update set-global
-    [ update-cached-postings ] "RSS feed update slave" spawn drop
-    10 60 * 1000 * sleep
-    update-thread ;
-
-: start-update-thread ( -- )
-    [
-        "webapps.planet" [
-            update-thread
-        ] with-logging
-    ] "RSS feed update master" spawn drop ;
-
-"planet" "planet-factor" "extra/webapps/planet" web-app
-
-{
-    { "Berlin Brown" "http://factorlang-fornovices.blogspot.com/feeds/posts/default" "http://factorlang-fornovices.blogspot.com" }
-    { "Chris Double" "http://www.blogger.com/feeds/18561009/posts/full/-/factor" "http://www.bluishcoder.co.nz/" }
-    { "Elie Chaftari" "http://fun-factor.blogspot.com/feeds/posts/default" "http://fun-factor.blogspot.com/" }
-    { "Doug Coleman" "http://code-factor.blogspot.com/feeds/posts/default" "http://code-factor.blogspot.com/" }
-    { "Daniel Ehrenberg" "http://useless-factor.blogspot.com/feeds/posts/default" "http://useless-factor.blogspot.com/" }
-    { "Gavin Harrison" "http://gmh33.blogspot.com/feeds/posts/default" "http://gmh33.blogspot.com/" }
-    { "Kio M. Smallwood"
-    "http://sekenre.wordpress.com/feed/atom/"
-    "http://sekenre.wordpress.com/" }
-    { "Phil Dawes" "http://www.phildawes.net/blog/category/factor/feed/atom" "http://www.phildawes.net/blog/" }
-    { "Samuel Tardieu" "http://www.rfc1149.net/blog/tag/factor/feed/atom/" "http://www.rfc1149.net/blog/tag/factor/" }
-    { "Slava Pestov" "http://factor-language.blogspot.com/atom.xml" "http://factor-language.blogspot.com/" }
-} default-blogroll set-global
diff --git a/extra/webapps/planet/planet.furnace b/extra/webapps/planet/planet.furnace
deleted file mode 100644 (file)
index 4c6676c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<% USING: namespaces html.elements webapps.planet sequences
-furnace ; %>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
-
-       <title>planet-factor</title>
-       <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
-    <link rel="alternate" type="application/atom+xml" title="Planet Factor - Atom" href="feed.xml" />
-</head>
-
-<body id="index">
-    <h1 class="planet-title">[ planet-factor ]</h1>
-    <table width="100%" cellpadding="10">
-        <tr>
-            <td> <% cached-postings get 20 safe-head print-postings %> </td>
-            <td valign="top" width="25%" class="infobox">
-                <p>
-                    <b>planet-factor</b> is an Atom/RSS aggregator that collects the
-                    contents of <a href="http://factorcode.org/">Factor</a>-related blogs. It is inspired by
-                    <a href="http://planet.lisp.org">Planet Lisp</a>.
-                </p>
-                <p>
-                    <img src="http://planet.lisp.org/feed-icon-14x14.png" />
-                    <a href="feed.xml"> Syndicate </a>
-                </p>
-                <p>
-                    This webapp is written in <a href="http://factorcode.org/">Factor</a>.<br/>
-                    <% "webapps.planet" browse-webapp-source %>
-                </p>
-                <h2 class="blogroll-title">Blogroll</h2>
-                <% default-blogroll get print-blogroll %>
-                <p>
-                    If you want your weblog added to the blogroll, <a href="http://factorcode.org/gethelp.fhtml">just ask</a>.
-                </p>
-            </td>
-        </tr>
-    </table>
-</body>
-
-</html>
diff --git a/extra/webapps/planet/style.css b/extra/webapps/planet/style.css
deleted file mode 100644 (file)
index 7a66d8d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-body {
-       font:75%/1.6em "Lucida Grande", "Lucida Sans Unicode", verdana, geneva, sans-serif;
-       color:#888;
-}
-
-h1.planet-title {
-       font-size:300%;
-}
-
-a {
-       color:#222;
-       border-bottom:1px dotted #ccc;
-       text-decoration:none;
-}
-
-a:hover {
-       border-bottom:1px solid #ccc;
-}
-
-.posting-title {
-       background-color:#f5f5f5;
-}
-
-pre, code {
-       color:#000000;
-       font-size:120%;
-}
-
-.infobox {
-       border-left: 1px solid #C1DAD7;
-}
-
-.posting-date {
-       text-align: right;
-       font-size:90%;
-}
-
-a.more {
-       display:block;
-       padding:0 0 5px 0;
-       color:#333;
-       text-decoration:none;
-       text-align:right;
-       border:none;
-}
diff --git a/unmaintained/webapps/fjsc/authors.txt b/unmaintained/webapps/fjsc/authors.txt
new file mode 100644 (file)
index 0000000..44b06f9
--- /dev/null
@@ -0,0 +1 @@
+Chris Double
diff --git a/unmaintained/webapps/fjsc/fjsc.factor b/unmaintained/webapps/fjsc/fjsc.factor
new file mode 100755 (executable)
index 0000000..cf01bf6
--- /dev/null
@@ -0,0 +1,70 @@
+! Copyright (C) 2006 Chris Double. All Rights Reserved.
+! See http://factorcode.org/license.txt for BSD license.
+!
+USING: kernel furnace fjsc  peg namespaces
+       lazy-lists io io.files furnace.validator sequences
+       http.client http.server http.server.responders
+       webapps.file html ;
+IN: webapps.fjsc
+
+: compile ( code -- )
+  #! Compile the factor code as a string, outputting the http
+  #! response containing the javascript.
+  serving-text
+  'expression' parse parse-result-ast fjsc-compile
+  write flush ;
+
+! The 'compile' action results in an URL that looks like
+! 'responder/fjsc/compile'. It takes one query or post
+! parameter called 'code'. It calls the 'compile' word
+! passing the parameter to it on the stack.
+\ compile {
+  { "code" v-required }
+} define-action
+
+: compile-url ( url -- )
+  #! Compile the factor code at the given url, return the javascript.
+  dup "http:" head? [ "Unable to access remote sites." throw ] when
+  "http://" "host" header-param rot 3append http-get compile "();" write flush ;
+
+\ compile-url {
+  { "url" v-required }
+} define-action
+
+: render-page* ( model body-template head-template -- )
+  [
+      [ render-component ] [ f rot render-component ] html-document 
+  ] serve-html ;
+
+: repl ( -- )
+  #! The main 'repl' page.
+  f "repl" "head" render-page* ;
+
+! An action called 'repl'
+\ repl { } define-action
+
+: fjsc-web-app ( -- )
+  ! Create the web app, providing access
+  ! under '/responder/fjsc' which calls the
+  ! 'repl' action.
+  "fjsc" "repl" "extra/webapps/fjsc" web-app
+
+  ! An URL to the javascript resource files used by
+  ! the 'fjsc' responder.
+  "fjsc-resources" [
+   [
+     "extra/fjsc/resources/" resource-path doc-root set
+     file-responder
+   ] with-scope
+  ] add-simple-responder
+
+  ! An URL to the resource files used by
+  ! 'termlib'.
+  "fjsc-repl-resources" [
+   [
+     "extra/webapps/fjsc/resources/" resource-path doc-root set
+     file-responder
+   ] with-scope
+  ] add-simple-responder ;
+
+MAIN: fjsc-web-app
diff --git a/unmaintained/webapps/fjsc/head.furnace b/unmaintained/webapps/fjsc/head.furnace
new file mode 100644 (file)
index 0000000..97a3645
--- /dev/null
@@ -0,0 +1,7 @@
+<title>Factor to Javascript REPL</title>\r
+<link rel="stylesheet" type="text/css" href="/responder/fjsc-repl-resources/termlib/term_styles.css"/>\r
+<script type="text/javascript" src="/responder/fjsc-repl-resources/termlib/termlib.js"></script>\r
+<script type="text/javascript" src="/responder/fjsc-resources/jquery.js"></script>\r
+<script type="text/javascript" src="/responder/fjsc-resources/bootstrap.js"></script>\r
+<script type="text/javascript" src="/responder/fjsc-repl-resources/repl.js"></script>\r
+<script type="text/javascript" src="/responder/fjsc/compile-url?url=/responder/fjsc-resources/bootstrap.factor"></script>\r
diff --git a/unmaintained/webapps/fjsc/repl.furnace b/unmaintained/webapps/fjsc/repl.furnace
new file mode 100644 (file)
index 0000000..c67e9d4
--- /dev/null
@@ -0,0 +1,43 @@
+<table border="0">
+<tr><td valign="top">
+<div id="repl" style="position:relative;"></div>
+<p>More information on the Factor to Javascript compiler can be found at these blog posts:
+<ul>
+<li><a href="http://www.bluishcoder.co.nz/2006/12/compiling-factor-to-javascript.html">Factor to Javascript Compiler</a></li>
+<li><a href="http://www.bluishcoder.co.nz/2006/12/factor-to-javascript-compiler-updates.html">Factor to Javascript Compiler Updates</a></li>
+<li><a href="http://www.bluishcoder.co.nz/2006/12/continuations-added-to-fjsc.html">Continuations added to fjsc</a></li>
+<li><a href="http://www.bluishcoder.co.nz/2006/12/cross-domain-json-with-fjsc.html">Cross Domain JSON with fjsc</a></li>
+<li><a href="http://www.bluishcoder.co.nz/2007/02/factor-to-javascript-compiler-makeover.html">Factor to Javascript Compiler Makeover</a></li>
+</ul>
+</p>
+<p>The terminal emulation code for the Factor REPL is provided by the awesome <a href="http://www.masswerk.at/termlib/index.html">termlib</a> library by Norbert Landsteiner. Documentation for termlib is <a href="/responder/fjsc-repl-resources/termlib/">available here</a>. Please note the license of 'termlib':</p>
+<blockquote>This JavaScript-library is free for private and academic use. Please include a readable copyright statement and a backlink to <http://www.masswerk.at> in the web page. The library should always be accompanied by the "readme.txt" and the sample HTML-documents.
+
+The term "private use" includes any personal or non-commercial use, which is not related to commercial activites, but excludes intranet, extranet and/or public net applications that are related to any kind of commercial or profit oriented activity.
+
+For commercial use see <a href="http://www.masswerk.at">http://www.masswerk.at</a> for contact information.</blockquote>
+</td>
+<td valign="top">
+<p><b>Stack</b></p>
+<div id="stack">
+</div>
+<p><b>Playground</b></p>
+<div id="playground">
+</div>
+<h3>Compiled Code</h3>
+<textarea id="compiled" cols="40" rows="10">
+</textarea>
+<p>Some useful words:
+<dl>
+<dt>vocabs ( -- seq )</dt>
+<dd>Return a sequence of available vocabularies</dd>
+<dt>words ( string -- seq )</dt>
+<dd>Return a sequence of words in the given vocabulary</dd>
+<dt>all-words ( -- seq )</dt>
+<dd>Return a sequence of all words</dd>
+</dl>
+</p>
+<p>The contents of <a href="/responder/fjsc-resources/bootstrap.factor">bootstrap.factor</a> have been loaded on startup.</p>
+</td>
+</tr>
+</table>
diff --git a/unmaintained/webapps/fjsc/resources/repl.js b/unmaintained/webapps/fjsc/resources/repl.js
new file mode 100644 (file)
index 0000000..3bc8bdc
--- /dev/null
@@ -0,0 +1,99 @@
+/* Copyright (C) 2007 Chris Double. All Rights Reserved.\r
+   See http://factorcode.org/license.txt for BSD license. */\r
+\r
+var fjsc_repl = false;\r
+\r
+function fjsc_repl_handler() {\r
+  var my_term = this;\r
+  this.newLine();\r
+  if(this.lineBuffer != '') {\r
+    factor.server_eval(\r
+      this.lineBuffer, \r
+      function(text, result) { \r
+        document.getElementById("compiled").value = result;\r
+        display_datastack();        \r
+      }, \r
+      function() { my_term.prompt(); });\r
+  }\r
+  else\r
+    my_term.prompt();\r
+}\r
+\r
+function fjsc_init_handler() {\r
+  this.write(\r
+    [\r
+      TermGlobals.center('********************************************************'),\r
+      TermGlobals.center('*                                                      *'),\r
+      TermGlobals.center('*       Factor to Javascript Compiler Example          *'),\r
+      TermGlobals.center('*                                                      *'),\r
+      TermGlobals.center('********************************************************')\r
+    ]);\r
+  \r
+  this.prompt();\r
+}\r
+\r
+function startup() {\r
+  var conf = {\r
+    x: 0,\r
+    y: 0,\r
+    cols: 64,\r
+    rows: 18,\r
+    termDiv: "repl",\r
+    crsrBlinkMode: true,\r
+    ps: "scratchpad ",\r
+    initHandler: fjsc_init_handler,\r
+    handler: fjsc_repl_handler\r
+  };\r
+  fjsc_repl = new Terminal(conf);\r
+  fjsc_repl.open();\r
+}\r
+\r
+function display_datastack() {\r
+   var html=[];\r
+   html.push("<table border='1'>")\r
+   for(var i = 0; i < factor.cont.data_stack.length; ++i) {\r
+      html.push("<tr><td>")\r
+      html.push(factor.cont.data_stack[i])\r
+      html.push("</td></tr>")\r
+   }\r
+   html.push("</table>")\r
+   document.getElementById('stack').innerHTML=html.join("");\r
+}\r
+\r
+jQuery(function() {\r
+  startup();\r
+  display_datastack();\r
+});\r
+\r
+factor.add_word("kernel", ".s", "primitive", function(next) {   \r
+  var stack = factor.cont.data_stack;\r
+  var term = fjsc_repl;\r
+  for(var i=0; i<stack.length; ++i) {\r
+    term.type(""+stack[i]);\r
+    term.newLine();\r
+  }\r
+  factor.call_next(next);\r
+});\r
+\r
+factor.add_word("io", "print", "primitive", function(next) {   \r
+  var stack = factor.cont.data_stack;\r
+  var term = fjsc_repl;\r
+  term.type(""+stack.pop());\r
+  term.newLine();\r
+  factor.call_next(next);\r
+});\r
+\r
+factor.add_word("io", "write", "primitive", function(next) {   \r
+  var stack = factor.cont.data_stack;\r
+  var term = fjsc_repl;\r
+  term.type(""+stack.pop());\r
+  factor.call_next(next);\r
+});\r
+\r
+factor.add_word("io", ".", "primitive", function(next) {   \r
+  var stack = factor.cont.data_stack;\r
+  var term = fjsc_repl;\r
+  term.type(""+stack.pop());\r
+  term.newLine();\r
+  factor.call_next(next);\r
+});\r
diff --git a/unmaintained/webapps/fjsc/resources/termlib/faq.html b/unmaintained/webapps/fjsc/resources/termlib/faq.html
new file mode 100644 (file)
index 0000000..5adb516
--- /dev/null
@@ -0,0 +1,356 @@
+<HTML>\r
+<HEAD>\r
+       <TITLE>mass:werk termlib faq</TITLE>\r
+\r
+<STYLE TYPE="text/css">\r
+body,p,a,td {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #cccccc;\r
+}\r
+.lh13 {\r
+       line-height: 13px;\r
+}\r
+.lh15 {\r
+       line-height: 15px;\r
+}\r
+pre {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       color: #ccffaa;\r
+       font-size: 12px;\r
+       line-height: 15px;\r
+}\r
+.prop {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       color: #bbee99;\r
+       font-size: 12px;\r
+       line-height: 15px;\r
+}\r
+h1 {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 16px;\r
+       color: #cccccc;\r
+}\r
+b.quest {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 14px;\r
+       font-weight: bold;\r
+       color: #bbee99;\r
+}\r
+a,a:link,a:visited {\r
+       text-decoration: none;\r
+       color: #77dd11;\r
+}\r
+a:hover {\r
+       text-decoration: underline;\r
+       color: #77dd11;\r
+}\r
+a:active {\r
+       text-decoration: underline;\r
+       color: #dddddd;\r
+}\r
+\r
+@media print {\r
+       body { background-color: #ffffff; }\r
+       body,p,a,td {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 12px;\r
+               color: #000000;\r
+       }\r
+       .lh13 {\r
+               line-height: 13px;\r
+       }\r
+       .lh15 {\r
+               line-height: 15px;\r
+       }\r
+       pre,.prop {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 12px;\r
+               color: #000000;\r
+               line-height: 15px;\r
+       }\r
+       h1 {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 16px;\r
+               color: #000000;\r
+       }\r
+       b.quest {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 14px;\r
+               font-weight: bold;\r
+               color: #000000;\r
+       }\r
+       a,a:link,a:visited {\r
+               text-decoration: none;\r
+               color: #000000;\r
+       }\r
+       a:hover {\r
+               text-decoration: underline;\r
+               color: #000000;\r
+       }\r
+       a:active {\r
+               text-decoration: underline;\r
+               color: #000000;\r
+       }\r
+}\r
+</STYLE>\r
+</HEAD>\r
+\r
+\r
+<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
+TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
+<TR>\r
+       <TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP>faq</TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
+</TR>\r
+</TABLE>\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">\r
+       <TR><TD>\r
+               <H1>frequently asked questions</H1>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+&nbsp;<BR>\r
+       <UL>\r
+       <LI CLASS="lh15"><A HREF="#chrome">Can I add chrome to the terminal? (e.g. a window header, a close box)</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#embed">How can I embed a terminal relative to my HTML layout?</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#syntax">I pasted your sample code and just got an error. - ???</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#keyboard">I can't get any input, but I don't get any erros too.</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#keylock">How can I temporary disable the keyboard handlers?</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#linesranges">How can I set the cusor to the start / the end of the command line?</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#historyunique">How can I limit the command history to unique entries only?</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#rebuild">How can I change my color theme on the fly?</A></LI>\r
+       <LI CLASS="lh15"><A HREF="#connect">How can I connect to a server?</A></LI>\r
+       </UL>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="chrome"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">Can I add chrome to the terminal? (e.g. a window header, a close box)</B><BR><BR>\r
+\r
+Not by the means of the Terminal object's interface (since there are way too many things that you may possibly want to add).<BR>\r
+The Terminal object allows you to specify the background color, the frame color, the frame's width and the font class used. If you want to add more chrome, you must align this in a separate division element.<BR><BR>\r
+\r
+To calculate the dimensions of the terminal use this formula:<BR><BR>\r
+\r
+width:&nbsp; 2 * frameWidth + conf.cols * &lt;width of &nbsp;&gt; + 2 * 2px padding (left and right)<BR>\r
+height: 2 * frameWidth + conf.rows * conf.rowHeight + 2 * 2px padding (top and bottom).<BR><BR>\r
+\r
+Or you could get the empirical values for width and height by calling a terminal's `<SPAN CLASS="prop">getDimensions()</SPAN>' method, once the terminal is open. (see documentation in &quot;readme.txt&quot;).<BR><BR>\r
+\r
+Finnally, you could obviously embed the terminal's division element in your custom chrome layout (see below). [This will not be compatible to Netscape 4.]<BR><BR>\r
+\r
+p.e.:<PRE>\r
+  &lt;div id=&quot;myTerminal1&quot; style=&quot;position:absolute; top:100px; left:100px;&quot;&gt;\r
+     &lt;table class=&quot;termChrome&quot;&gt;\r
+       &lt;tbody&gt;\r
+        &lt;tr&gt;\r
+           &lt;td class=&quot;termTitle&quot;&gt;terminal 1&lt;/td&gt;\r
+        &lt;/tr&gt;\r
+        &lt;tr&gt;\r
+           &lt;td class=&quot;termBody&quot;&gt;&lt;div id=&quot;termDiv1&quot; style=&quot;position:relative&quot;&gt;&lt;/div&gt;&lt;/td&gt;\r
+        &lt;/tr&gt;\r
+       &lt;/tbody&gt;\r
+     &lt;/table&gt;\r
+   &lt;/div&gt;\r
+\r
+   // get a terminal for this\r
+\r
+   var term1 = new Terminal(\r
+                 {\r
+                   x: 0,\r
+                   y: 0,\r
+                   id: 1,\r
+                   termDiv: &quot;termDiv1&quot;,\r
+                   handler: myTermHandler\r
+                 }\r
+              );\r
+   term1.open();\r
+   \r
+   // and this is how to move the chrome and the embedded terminal\r
+\r
+   TermGlobals.setElementXY( &quot;myTerminal1&quot;, 200, 80 );\r
+</PRE>\r
+To keep track of the instance for any widgets use the terminal's `id' property. (You must set this in the configuration object to a unique value for this purpose.)<BR><BR>\r
+\r
+For a demonstration see the <A HREF="chrome_sample.html">Chrome Sample Page</A>.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="embed"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">How can I embed a terminal relative to my HTML layout?</B><BR><BR>\r
+\r
+Define your devision element with attribute &quot;position&quot; set to &quot;relative&quot; and place this inside your layout. Call &quot;new Terminal()&quot; with config-values { x: 0, y: 0 } to leave it at its relative origin.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="syntax"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">I pasted your sample code and just got an error. - ???</B><BR><BR>\r
+\r
+The short examples are kept arbitrarily simple to show the syntax.<BR>\r
+Make sure that your divison element(s) is/are rendered by the browser before `Terminal.open()' is called.<BR><BR>\r
+\r
+Does not work:\r
+<PRE>  &lt;head&gt;\r
+  &lt;script&gt;\r
+    var term = new Terminal();\r
+    term.open();\r
+  &lt;/script&gt;\r
+  &lt;/head&gt;\r
+</PRE>\r
+Does work:\r
+<PRE>  &lt;head&gt;\r
+  &lt;script&gt;\r
+    var term;\r
+    \r
+    function termOpen() {\r
+       // to be called from outside after compile time\r
+       term = new Terminal();\r
+       term.open();\r
+    }\r
+  &lt;/script&gt;\r
+  &lt;/head&gt;\r
+</PRE>\r
+c.f. &quot;readme.txt&quot;<BR>\r
+(Opening a terminal by clicking a link implies also that the page has currently focus.)<BR><BR>\r
+With v.1.01 and higher this doesn't cause an error any more.<BR>`Terminal.prototype.open()' now returns a value for success.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="keyboard"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">I can't get any input, but I don't get any erros too.</B><BR><BR>\r
+\r
+The Terminal object's functionality relies on the browsers ability to generate and handle keyboard events.<BR>\r
+Sadly some browsers lack a full implementation of the event model. (e.g. Konquerer [khtml] and early versions of Apple Safari, which is a descendant of khtml.)\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="keylock"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">How can I temporary disable the keyboard handlers?</B><BR>\r
+<SPAN CLASS="prop">(The terminal is blocking my HTML form fields, etc.)</SPAN><BR><BR>\r
+\r
+With version 1.03 there's a global property `<SPAN CLASS="prop">TermGlobals.keylock</SPAN>'. Set this to `true' to disable the keyboard handlers without altering any other state. Reset it to `false' to continue with your terminal session(s).\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="linesranges"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">How can I set the cusor to the start / the end of the command line?</B><BR><BR>\r
+\r
+In case you need to implement a shortcut (like ^A of some UN*X-shells) to jump to the beginning or the end of the current input line, there are two private instance methods you could utilize:<BR><BR>\r
+`<SPAN CLASS="prop">_getLineEnd(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the last character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>\r
+`<SPAN CLASS="prop">_getLineStart(&lt;row&gt;, &lt;col&gt;)</SPAN>' returns an array [&lt;row&gt;, &lt;col&gt;] with the position of the first character in the logical input line with ASCII value &gt;= 32 (0x20).<BR><BR>\r
+Both take a row and a column of a cursor position as arguments.<BR><BR>\r
+\r
+p.e.:\r
+<PRE>\r
+  // jump to the start of the input line\r
+\r
+  myCtrlHandler() {\r
+     // catch ^A and jump to start of the line\r
+     if (this.inputChar == 1) {\r
+        var firstChar = this._getLineStart(this.r, this.c);\r
+        this.cursorSet(firstChar[0], firstChar[1]);\r
+     }\r
+  }</PRE>\r
+(Keep in mind that this is not exactly a good example, since some browser actually don't issue a keyboard event for \r
+&quot;^A&quot;. And other browsers, which do catch such codes, are not very reliable in that.)\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="historyunique"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">How can I limit the command history to unique entries only?</B><BR>\r
+       <SPAN CLASS="prop">(My application effords commands to be commonly repeated.)</SPAN><BR><BR>\r
+\r
+With version 1.05 there is a new configuration and control flag `<SPAN CLASS="prop">historyUnique</SPAN>'. All you need is setting this to `true' in your terminal's configuration object.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="rebuild"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">How can I change my color theme on the fly?</B><BR><BR>\r
+\r
+With version 1.07 there is a new method `<SPAN CLASS="prop">Terminal.rebuild()</SPAN>'.<BR>\r
+This method updates the GUI to current config settings while preserving all other state.<BR><BR>\r
+p.e.:\r
+<PRE>\r
+   // change color settings on the fly\r
+   // here: set bgColor to white and font style to class &quot;termWhite&quot;\r
+   // method rebuild() updates the GUI without side effects\r
+   // assume var term holds a referene to a Terminal object already active\r
+\r
+   term.conf.bgColor = '#ffffff';\r
+   term.conf.fontClass = 'termWhite';\r
+   term.rebuild();</PRE>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13"><A NAME="connect"></A>\r
+&nbsp;<BR>\r
+<B CLASS="quest">How can I connect to a server?</B><BR><BR>\r
+\r
+The Terminal object only provides an interface to handle console input and output.<BR>\r
+External connections have to be handled outside the Terminal object. You could use the XMLHttpRequest-Object (and use a communication model like AJAX or JSON) or connect via a frame or iframe element to a foreign host.<BR><BR>\r
+Handling connections is considered to be out of the realm of the &quot;termlib.js&quot; library.<BR>\r
+The code you need is in fact quite simple:\r
+<PRE>\r
+  function connectToHost(url) {\r
+     if (window.XMLHttpRequest) {\r
+        request = new XMLHttpRequest();\r
+     }\r
+     else if (window.ActiveXObject) {\r
+         request = new ActiveXObject('Microsoft.XMLHTTP');\r
+     }\r
+     if (request) {\r
+         request.onreadystatechange = requestChangeHandler;\r
+         request.open('GET', url);\r
+         request.send('');\r
+     }\r
+     else {\r
+        // XMLHttpRequest not implemented\r
+     }\r
+  }\r
+  \r
+  function requestChangeHandler() {\r
+     if (request.readyState == 4) {\r
+        // readyState 4: complete; now test for server's response status\r
+        if (request.status == 200) {\r
+           // response in request.responseText or request.responseXML if XML-code\r
+           // if it's JS-code we could get this by eval(request.responseText)\r
+           // by this we could import whole functions to be used via the terminal\r
+        }\r
+        else {\r
+           // connection error\r
+           // status code and message in request.status and request.statusText\r
+        }\r
+     }\r
+  }\r
+</PRE>\r
+You should use this only together with a timer (window.setTimeout()) to handle connection timeouts.<BR>\r
+Additionally you would need some syntax to authenticate and tell the server what you want.<BR>\r
+For this purpose you could use the following methods of the XMLHttpRequest object:<BR><BR>\r
+\r
+       <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3">\r
+       <TR VALIGN="top"><TD NOWRAP CLASS="prop">setRequestHeader(&quot;<I>headerLabel</I>&quot;, &quot;<I>value</I>&quot;)</TD><TD>set a HTTP header to be sent to the server</TD></TR>\r
+       <TR VALIGN="top"><TD NOWRAP CLASS="prop">getResponseHeader(&quot;<I>headerLabel</I>&quot;)</TD><TD>get a HTTP header sent from the server</TD></TR>\r
+       <TR VALIGN="top"><TD NOWRAP CLASS="prop">open(<I>method</I>, &quot;<I>url</I>&quot; [, <I>asyncFlag</I> [,<BR>&nbsp; &quot;<I>userid</I>&quot; [, &quot;<I>password</I>&quot;]]])</TD><TD>assign the destination properties to the request.<BR>be aware that userid and password are not encrypted!</TD></TR>\r
+       <TR VALIGN="top"><TD NOWRAP CLASS="prop">send(<I>content</I>)</TD><TD>transmit a message body (post-string or DOM object)</TD></TR>\r
+       <TR VALIGN="top"><TD NOWRAP CLASS="prop">abort()</TD><TD>use this to stop a pending connection</TD></TR>\r
+       </TABLE>\r
+\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;<BR>\r
+       Norbert Landsteiner - August 2005<BR>\r
+       <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;<BR>\r
+               <A HREF="#top">&gt; top of page</A>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;\r
+       </TD></TR>\r
+</TABLE>\r
+\r
+<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
+\r
+</BODY>\r
+</HTML>
\ No newline at end of file
diff --git a/unmaintained/webapps/fjsc/resources/termlib/index.html b/unmaintained/webapps/fjsc/resources/termlib/index.html
new file mode 100644 (file)
index 0000000..1770b2c
--- /dev/null
@@ -0,0 +1,207 @@
+<HTML>\r
+<HEAD>\r
+       <TITLE>mass:werk termlib</TITLE>\r
+\r
+<STYLE TYPE="text/css">\r
+body,p,a,td {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #cccccc;\r
+}\r
+.lh13 {\r
+       line-height: 13px;\r
+}\r
+.lh15 {\r
+       line-height: 15px;\r
+}\r
+pre {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #ccffaa;\r
+       line-height: 15px;\r
+}\r
+.prop {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       color: #bbee99;\r
+       font-size: 12px;\r
+       line-height: 15px;\r
+}\r
+h1 {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 16px;\r
+       color: #cccccc;\r
+}\r
+a,a:link,a:visited {\r
+       text-decoration: none;\r
+       color: #77dd11;\r
+}\r
+a:hover {\r
+       text-decoration: underline;\r
+       color: #77dd11;\r
+}\r
+a:active {\r
+       text-decoration: underline;\r
+       color: #dddddd;\r
+}\r
+\r
+@media print {\r
+       body { background-color: #ffffff; }\r
+       body,p,a,td {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 12px;\r
+               color: #000000;\r
+       }\r
+       .lh13 {\r
+               line-height: 13px;\r
+       }\r
+       .lh15 {\r
+               line-height: 15px;\r
+       }\r
+       pre,.prop {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 12px;\r
+               color: #000000;\r
+               line-height: 15px;\r
+       }\r
+       h1 {\r
+               font-family: courier,fixed,swiss,sans-serif;\r
+               font-size: 16px;\r
+               color: #000000;\r
+       }\r
+       a,a:link,a:visited {\r
+               text-decoration: none;\r
+               color: #000000;\r
+       }\r
+       a:hover {\r
+               text-decoration: underline;\r
+               color: #000000;\r
+       }\r
+       a:active {\r
+               text-decoration: underline;\r
+               color: #000000;\r
+       }\r
+}\r
+</STYLE>\r
+</HEAD>\r
+\r
+\r
+<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
+TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"><A NAME="top"></A>\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
+<TR>\r
+       <TD NOWRAP>termlib.js home</TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="faq.html">faq</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
+</TR>\r
+</TABLE>\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" WIDTH="700" ALIGN="center">\r
+       <TR><TD>\r
+               <H1>mass:werk termlib.js</H1>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+               The JavaScript library &quot;termlib.js&quot; provides a `Terminal' object, which\r
+               facillitates a simple and object oriented approach to generate and control a\r
+               terminal-like interface for web services.<BR><BR>\r
+               \r
+               "termlib.js" features direct keyboard input and powerful output methods\r
+               for multiple and simultanious instances of the `Terminal' object.<BR><BR>\r
+               \r
+               The library was written with the aim of simple usage and a maximum of compatibility\r
+               with minimal foot print in the global namespace.<BR><BR><BR>\r
+               \r
+               \r
+               A short example:<BR>\r
+  <PRE>\r
+  var term = new Terminal( {handler: termHandler} );\r
+  term.open();\r
+\r
+  function termHandler() {\r
+     this.newLine();\r
+     var line = this.lineBuffer;\r
+     if (line != &quot;&quot;) {\r
+        this.write(&quot;You typed: &quot;+line);\r
+     }\r
+     this.prompt();\r
+  }\r
+  </PRE>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       <B>License</B><BR><BR>\r
+\r
+       This JavaScript-library is <U>free for private and academic use</U>.\r
+       Please include a readable copyright statement and a backlink to &lt;http://www.masswerk.at&gt; in the\r
+       web page. The library should always be accompanied by the &quot;readme.txt&quot; and the sample HTML-documents.<BR><BR>\r
+\r
+       The term &quot;private use&quot; includes any personal or non-commercial use, which is not related\r
+       to commercial activites, but excludes intranet, extranet and/or public net applications\r
+       that are related to any kind of commercial or profit oriented activity.<BR><BR>\r
+\r
+       For commercial use see &lt;<A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>&gt; for contact information.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       <B>Distribution</B><BR><BR>\r
+\r
+       This JavaScript-library may be distributed freely as long it is distributed together with the &quot;readme.txt&quot; and the sample HTML-documents and this document.<BR><BR>\r
+\r
+       Any changes to the library should be commented and be documented in the readme-file.<BR>\r
+       Any changes must be reflected in the `Terminal.version' string as &quot;Version.Subversion&nbsp;(compatibility)&quot;.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       <B>Disclaimer</B><BR><BR>\r
+\r
+       This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY\r
+       WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
+       PURPOSE. The entire risk as to the quality and performance of the product is borne by the\r
+       user. No use of the product is authorized hereunder except under this disclaimer.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       <B>History</B><BR><BR>\r
+\r
+       This library evolved from the terminal script &quot;TermApp&quot; ((c) N. Landsteiner 2003) and is in its\r
+       current form a down scaled spinn-off of the &quot;JS/UIX&quot; project. (JS/UIX is not a free&nbsp;software by now.)\r
+       c.f.: &lt;<A HREF="http://www.masswerk.at/jsuix/" TARGET="_blank">http://www.masswerk.at/jsuix</A>&gt;<BR><BR>\r
+\r
+       For version history: see the <A HREF="readme.txt">readme.txt</A>.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;<BR>\r
+       <B>Download</B><BR><BR>\r
+       Be sure to have read the license information and the disclamer and that you are willing to respect copyrights.<BR><BR>\r
+\r
+       <SPAN CLASS="prop">Download:</SPAN> <A HREF="termlib.zip">termlib.zip</A> (~ 40 KB, incl. docs)<BR><BR>\r
+       Current version is &quot;1.07 (original)&quot;.<BR>\r
+       The files are now provided with line breaks  in format &lt;CRLF&gt;.<BR>\r
+       &nbsp;\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       <B>Author</B><BR><BR>\r
+       &copy; Norbert Landsteiner 2003-2005<BR>\r
+       mass:werk &#150; media environments<BR>\r
+       <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;<BR>\r
+       Author's note:<BR>\r
+       Please do not contact me on questions of simple usage. There is an extensive documentation (readme.txt) including plenty of sample code that should provide all information you need.\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;<BR>\r
+               <A HREF="#top">&gt; top of page</A>\r
+       </TD></TR>\r
+       <TR><TD CLASS="lh13">\r
+       &nbsp;\r
+       </TD></TR>\r
+</TABLE>\r
+\r
+<DIV ID="termDiv" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
+\r
+</BODY>\r
+</HTML>
\ No newline at end of file
diff --git a/unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html b/unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html
new file mode 100644 (file)
index 0000000..0a4e1ec
--- /dev/null
@@ -0,0 +1,188 @@
+<HTML>\r
+<HEAD>\r
+       <TITLE>termlib Multiple Terminal Test</TITLE>\r
+       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>\r
+\r
+<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\r
+<!--\r
+\r
+/*\r
+  multiple terminal test for termlib.js\r
+\r
+  (c) Norbert Landsteiner 2003-2005\r
+  mass:werk - media environments\r
+  <http://www.masswerk.at>\r
+\r
+*/\r
+\r
+var term=new Array();\r
+\r
+var helpPage=[\r
+       '%CS%+r Terminal Help %-r%n',\r
+       '  This is just a tiny test for multiple terminals.',\r
+       '  use one of the following commands:',\r
+       '     clear .... clear the terminal',\r
+       '     exit ..... close the terminal (or <ESC>)',\r
+       '     id ....... show terminal\'s id',\r
+       '     switch ... switch to other terminal',\r
+       '     help ..... show this help page',\r
+       '  other input will be echoed to the terminal.',\r
+       ' '\r
+];\r
+\r
+function termOpen(n) {\r
+       if (!term[n]) {\r
+               var y=(n==1)? 70: 280;\r
+               term[n]=new Terminal(\r
+                       {\r
+                               x: 220,\r
+                               y: y,\r
+                               rows: 12,\r
+                               greeting: '%+r +++ Terminal #'+n+' ready. +++ %-r%nType "help" for help.%n',\r
+                               id: n,\r
+                               termDiv: 'termDiv'+n,\r
+                               crsrBlinkMode: true,\r
+                               handler: termHandler,\r
+                               exitHandler: termExitHandler\r
+                       }\r
+               );\r
+               if (term[n]) term[n].open();\r
+       }\r
+       else if (term[n].closed) {\r
+               term[n].open();\r
+       }\r
+       else {\r
+               term[n].focus();\r
+       }\r
+}\r
+\r
+function termHandler() {\r
+       // called on <CR> or <ENTER>\r
+       this.newLine();\r
+       var cmd=this.lineBuffer;\r
+       if (cmd!='') {\r
+               if (cmd=='switch') {\r
+                       var other=(this.id==1)? 2:1;\r
+                       termOpen(other);\r
+               }\r
+               else if (cmd=='clear') {\r
+                       this.clear();\r
+               }\r
+               else if (cmd=='exit') {\r
+                       this.close();\r
+               }\r
+               else if (cmd=='help') {\r
+                       this.write(helpPage);\r
+               }\r
+               else if (cmd=='id') {\r
+                       this.write('terminal id: '+this.id);\r
+               }\r
+               else {\r
+                       this.type('You typed: '+cmd);\r
+                       this.newLine();\r
+               }\r
+       }\r
+       this.prompt();\r
+}\r
+\r
+function termExitHandler() {\r
+       // optional handler called on exit\r
+       // activate other terminal if open\r
+       var other=(this.id==1)? 2:1;\r
+       if ((term[other]) && (term[other].closed==false)) term[other].focus();\r
+}\r
+\r
+//-->\r
+</SCRIPT>\r
+\r
+<STYLE TYPE="text/css">\r
+body,p,a,td {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #cccccc;\r
+}\r
+.lh15 {\r
+       line-height: 15px;\r
+}\r
+.term {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #33d011;\r
+       background: none;\r
+}\r
+.termReverse {\r
+       color: #111111;\r
+       background: #33d011;\r
+}\r
+a,a:link,a:visited {\r
+       text-decoration: none;\r
+       color: #77dd11;\r
+}\r
+a:hover {\r
+       text-decoration: underline;\r
+       color: #77dd11;\r
+}\r
+a:active {\r
+       text-decoration: underline;\r
+       color: #dddddd;\r
+}\r
+\r
+a.termopen,a.termopen:link,a.termopen:visited {\r
+       text-decoration: none;\r
+       color: #77dd11;\r
+       background: none;\r
+}\r
+a.termopen:hover {\r
+       text-decoration: none;\r
+       color: #222222;\r
+       background: #77dd11;\r
+}\r
+a.termopen:active {\r
+       text-decoration: none;\r
+       color: #222222;\r
+       background: #dddddd;\r
+}\r
+\r
+</STYLE>\r
+</HEAD>\r
+\r
+\r
+<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
+TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
+<TR>\r
+       <TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP>multiple terminal test</TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="parser_sample.html">sample parser</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="faq.html">faq</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
+</TR>\r
+</TABLE>\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">\r
+       <TR><TD NOWRAP>\r
+               Multiple Terminal Test<BR>&nbsp;\r
+       </TD></TR>\r
+       <TR><TD NOWRAP>\r
+               <A HREF="javascript:termOpen(1)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 1 &nbsp;</A>\r
+       </TD></TR>\r
+       <TR><TD NOWRAP>\r
+               <A HREF="javascript:termOpen(2)" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 2'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal 2 &nbsp;</A>\r
+       </TD></TR>\r
+       <TR><TD NOWRAP CLASS="lh15">\r
+               &nbsp;<BR>\r
+               (c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>\r
+               <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
+       </TD></TR>\r
+</TABLE>\r
+\r
+<DIV ID="termDiv1" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
+<DIV ID="termDiv2" STYLE="position:absolute; top:20px; left:100px;"></DIV>\r
+\r
+</BODY>\r
+</HTML>
\ No newline at end of file
diff --git a/unmaintained/webapps/fjsc/resources/termlib/parser_sample.html b/unmaintained/webapps/fjsc/resources/termlib/parser_sample.html
new file mode 100644 (file)
index 0000000..b332af1
--- /dev/null
@@ -0,0 +1,293 @@
+<HTML>\r
+<HEAD>\r
+       <TITLE>termlib Sample Parser</TITLE>\r
+       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib.js"></SCRIPT>\r
+       <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="termlib_parser.js"></SCRIPT>\r
+\r
+<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\r
+<!--\r
+\r
+/*\r
+  test sample for termlib.js and termlib_parser.js\r
+\r
+  (c) Norbert Landsteiner 2005\r
+  mass:werk - media environments\r
+  <http://www.masswerk.at>\r
+\r
+*/\r
+\r
+var term;\r
+\r
+var helpPage=[\r
+       '%CS%+r Terminal Help %-r%n',\r
+       '  This is just a sample to demonstrate command line parsing.',\r
+       ' ',\r
+       '  Use one of the following commands:',\r
+       '     clear [-a] .......... clear the terminal',\r
+       '                           option "a" also removes the status line',\r
+       '     number -n<value> .... return value of option "n" (test for options)',\r
+       '     repeat -n<value> .... repeats the first argument n times (another test)',\r
+       '     login <username> .... sample login (test for raw mode)',\r
+       '     exit ................ close the terminal (same as <ESC>)',\r
+       '     help ................ show this help page',\r
+       ' ',\r
+       '  other input will be echoed to the terminal as a list of parsed arguments',\r
+       '  in the format <argument index> <quoting level> "<parsed value>".',\r
+       ' '\r
+];\r
+\r
+function termOpen() {\r
+       if (!term) {\r
+               term=new Terminal(\r
+                       {\r
+                               x: 220,\r
+                               y: 70,\r
+                               termDiv: 'termDiv',\r
+                               ps: '[guest]$',\r
+                               initHandler: termInitHandler,\r
+                               handler: commandHandler\r
+                       }\r
+               );\r
+               if (term) term.open();\r
+       }\r
+       else if (term.closed) {\r
+               term.open();\r
+       }\r
+       else {\r
+               term.focus();\r
+       }\r
+}\r
+\r
+function termInitHandler() {\r
+       // output a start up screen\r
+       this.write(\r
+               [\r
+                       TermGlobals.center('####################################################', 80),\r
+                       TermGlobals.center('#                                                  #', 80),\r
+                       TermGlobals.center('#           termlib.js - Sample Parser             #', 80),\r
+                       TermGlobals.center('#  Input is echoed as a list of parsed arguments.  #', 80),\r
+                       TermGlobals.center('#                                                  #', 80),\r
+                       TermGlobals.center('#  Type "help" for commands.                       #', 80),\r
+                       TermGlobals.center('#                                                  #', 80),\r
+                       TermGlobals.center('#  (c) N. Landsteiner 2005;  www.masswerk.at       #', 80),\r
+                       TermGlobals.center('#                                                  #', 80),\r
+                       TermGlobals.center('####################################################', 80),\r
+                       '%n'\r
+               ]\r
+       );\r
+       // set a double status line\r
+       this.statusLine('', 8,2); // just a line of strike\r
+       this.statusLine(' +++ This is just a test sample for command parsing. Type "help" for help. +++');\r
+       this.maxLines -= 2;\r
+       // and leave with prompt\r
+       this.prompt();\r
+}\r
+\r
+function commandHandler() {\r
+       this.newLine();\r
+       // check for raw mode first (should not be parsed)\r
+       if (this.rawMode) {\r
+               if (this.env.getPassword) {\r
+                       // sample password handler (lineBuffer == stored username ?)\r
+                       if (this.lineBuffer == this.env.username) {\r
+                               this.user = this.env.username;\r
+                               this.ps = '['+this.user+']>';\r
+                       }\r
+                       else {\r
+                               this.type('Sorry.');\r
+                       }\r
+                       this.env.username = '';\r
+                       this.env.getPassword = false;\r
+               }\r
+               // leave in normal mode\r
+               this.rawMode = false;\r
+               this.prompt();\r
+               return;\r
+       }\r
+       // normal command parsing\r
+       // just call the termlib_parser with a reference of the calling Terminal instance\r
+       // parsed arguments will be imported in this.argv,\r
+       // quoting levels per argument in this.argQL (quoting character or empty)\r
+       // cursor for arguments is this.argc (used by parserGetopt)\r
+       // => see 'termlib_parse.js' for configuration and details\r
+       parseLine(this);\r
+       if (this.argv.length == 0) {\r
+               // no commmand line input\r
+       }\r
+       else if (this.argQL[0]) {\r
+           // first argument quoted -> error\r
+               this.write("Syntax error: first argument quoted.");\r
+       }\r
+       else {\r
+               var cmd = this.argv[this.argc++];\r
+               /*\r
+                 process commands now\r
+                 1st argument: this.argv[this.argc]\r
+               */\r
+               if (cmd == 'help') {\r
+                       this.write(helpPage);\r
+               }\r
+               else if (cmd == 'clear') {\r
+                       // get options\r
+                       var opts = parserGetopt(this, 'aA');\r
+                       if (opts.a) {\r
+                               // discard status line on opt "a" or "A"\r
+                               this.maxLines = this.conf.rows;\r
+                       }\r
+                       this.clear();\r
+               }\r
+               else if (cmd == 'number') {\r
+                       // test for value options\r
+                       var opts = parserGetopt(this, 'n');\r
+                       if (opts.illegals.length) this.type('illegal option. usage: number -n<value>')\r
+                       else if ((opts.n) && (opts.n.value != -1)) this.type('option value: '+opts.n.value)\r
+                       else this.type('usage: number -n<value>');\r
+               }\r
+               else if (cmd == 'repeat') {\r
+                       // another test for value options\r
+                       var opts = parserGetopt(this, 'n');\r
+                       if (opts.illegals.length) this.type('illegal option. usage: repeat -n<value> <string>')\r
+                       else if ((opts.n) && (opts.n.value != -1)) {\r
+                               // first normal argument is again this.argv[this.argc]\r
+                               var s = this.argv[this.argc];\r
+                               if (typeof s != 'undefined') {\r
+                                       // repeat this string n times\r
+                                       var a = [];\r
+                                       for (var i=0; i<opts.n.value; i++) a[a.length] = s;\r
+                                       this.type(a.join(' '));\r
+                               }\r
+                       }\r
+                       else this.type('usage: repeat -n<value> <string>');\r
+               }\r
+               else if (cmd == 'login') {\r
+                       // sample login (test for raw mode)\r
+                       if ((this.argc == this.argv.length) || (this.argv[this.argc] == '')) {\r
+                               this.type('usage: login <username>');\r
+                       }\r
+                       else {\r
+                               this.env.getPassword = true;\r
+                               this.env.username = this.argv[this.argc];\r
+                               this.write('%+iSample login: repeat username as password.%-i%n');\r
+                               this.type('password: ');\r
+                               // exit in raw mode (blind input)\r
+                               this.rawMode = true;\r
+                               this.lock = false;\r
+                               return;\r
+                       }\r
+               }\r
+               else if (cmd == 'exit') {\r
+                       this.close();\r
+                       return;\r
+               }\r
+               else {\r
+                       // for test purpose just output argv as list\r
+                       // assemble a string of style-escaped lines and output it in more-mode\r
+                       s=' INDEX  QL  ARGUMENT%n';\r
+                       for (var i=0; i<this.argv.length; i++) {\r
+                               s += TermGlobals.stringReplace('%', '%%',\r
+                                               TermGlobals.fillLeft(i, 6) +\r
+                                               TermGlobals.fillLeft((this.argQL[i])? this.argQL[i]:'-', 4) +\r
+                                               '  "' + this.argv[i] + '"'\r
+                                       ) + '%n';\r
+                       }\r
+                       this.write(s, 1);\r
+                       return;\r
+               }\r
+       }\r
+       this.prompt();\r
+}\r
+\r
+\r
+//-->\r
+</SCRIPT>\r
+\r
+<STYLE TYPE="text/css">\r
+body,p,a,td {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #cccccc;\r
+}\r
+.lh15 {\r
+       line-height: 15px;\r
+}\r
+.term {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #33d011;\r
+       background: none;\r
+}\r
+.termReverse {\r
+       color: #111111;\r
+       background: #33d011;\r
+}\r
+a,a:link,a:visited {\r
+       text-decoration: none;\r
+       color: #77dd11;\r
+}\r
+a:hover {\r
+       text-decoration: underline;\r
+       color: #77dd11;\r
+}\r
+a:active {\r
+       text-decoration: underline;\r
+       color: #dddddd;\r
+}\r
+\r
+a.termopen,a.termopen:link,a.termopen:visited {\r
+       text-decoration: none;\r
+       color: #77dd11;\r
+       background: none;\r
+}\r
+a.termopen:hover {\r
+       text-decoration: none;\r
+       color: #222222;\r
+       background: #77dd11;\r
+}\r
+a.termopen:active {\r
+       text-decoration: none;\r
+       color: #222222;\r
+       background: #dddddd;\r
+}\r
+\r
+</STYLE>\r
+</HEAD>\r
+\r
+\r
+<BODY BGCOLOR="#222222" LINK="#77dd11" TEXT="#cccccc" ALINK="#dddddd" VLINK="#77dd11"\r
+TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0">\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0" ALIGN="center">\r
+<TR>\r
+       <TD NOWRAP><A HREF="index.html">termlib.js home</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="multiterm_test.html">multiple terminal test</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP>sample parser</TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="faq.html">faq</A></TD>\r
+       <TD>|</TD>\r
+       <TD NOWRAP><A HREF="readme.txt" TITLE="readme.txt (text/plain)">documentation</A></TD>\r
+</TR>\r
+</TABLE>\r
+\r
+<TABLE BORDER="0" CELLSPACING="20" CELLPADDING="0">\r
+       <TR><TD NOWRAP>\r
+               Sample Parser Test<BR>&nbsp;\r
+       </TD></TR>\r
+       <TR><TD NOWRAP>\r
+               <A HREF="javascript:termOpen()" onfocus="if(this.blur)this.blur();" onmouseover="window.status='terminal 1'; return true" onmouseout="window.status=''; return true" CLASS="termopen">&gt; open terminal &nbsp;</A>\r
+       </TD></TR>\r
+       <TR><TD NOWRAP>\r
+               &nbsp;\r
+       </TD></TR>\r
+       <TR><TD NOWRAP CLASS="lh15">\r
+               &nbsp;<BR>\r
+               (c) mass:werk,<BR>N. Landsteiner 2003-2005<BR>\r
+               <A HREF="http://www.masswerk.at/" TARGET="_blank">http://www.masswerk.at</A>\r
+       </TD></TR>\r
+</TABLE>\r
+\r
+<DIV ID="termDiv" STYLE="position:absolute;"></DIV>\r
+\r
+</BODY>\r
+</HTML>
\ No newline at end of file
diff --git a/unmaintained/webapps/fjsc/resources/termlib/readme.txt b/unmaintained/webapps/fjsc/resources/termlib/readme.txt
new file mode 100644 (file)
index 0000000..8a92b9c
--- /dev/null
@@ -0,0 +1,1400 @@
+****  mass:werk termlib.js - JS-WebTerminal Object v1.07  ****\r
+\r
+  (c) Norbert Landsteiner 2003-2005\r
+  mass:werk - media environments\r
+  <http://www.masswerk.at>\r
+\r
+\r
+\r
+\r
+Contents:\r
+\r
+   1  About\r
+   2  Creating a new Terminal Instance\r
+      2.1 Configuration Values\r
+   3  Using the Terminal\r
+      3.1  The Default Handler\r
+      3.2  Input Modes\r
+           3.2.1  Normal Line Input (Command Line Mode)\r
+                  3.2.1.2 Special Keys (ctrlHandler)\r
+           3.2.2  Raw Mode\r
+           3.2.3  Character Mode\r
+      3.3  Other Handlers\r
+           3.3.1  initHandler\r
+           3.3.2  exitHandler\r
+      3.4  Flags for Behaviour Control\r
+   4  Output Methods\r
+           4.1 Terminal.type()\r
+           4.2 Terminal.write()\r
+           4.3 Terminal.typeAt()\r
+           4.4 Terminal.setChar()\r
+           4.5 Terminal.newLine()\r
+           4.6 Terminal.clear()\r
+           4.7 Terminal.statusLine()\r
+           4.8 Terminal.printRowFromString()\r
+           4.9 Terminal.redraw()\r
+   5  Cursor Methods and Editing\r
+           5.1 Terminal.cursorOn()\r
+           5.2 Terminal.cursorOff()\r
+           5.3 Terminal.cursorSet()\r
+           5.4 Terminal.cursorLeft()\r
+           5.5 Terminal.cursorRight()\r
+           5.6 Terminal.backspace()\r
+           5.7 Terminal.fwdDelete()\r
+           5.8 Terminal.isPrintable()\r
+   6  Other Methods of the Terminal Object\r
+           6.1 Terminal.prompt()\r
+           6.2 Terminal.reset()\r
+           6.3 Terminal.open()\r
+           6.4 Terminal.close()\r
+           6.5 Terminal.focus()\r
+           6.6 Terminal.moveTo()\r
+           6.7 Terminal.resizeTo()\r
+           6.8 Terminal.getDimensions()\r
+           6.9 Terminal.rebuild()\r
+   7  Global Static Methods (TermGlobals)\r
+           7.1 TermGlobals.setFocus()\r
+           7.2 TermGlobals.keylock (Global Locking Flag)\r
+           7.3 TermGlobalsText Methods\r
+               7.3.1 TermGlobals.normalize()\r
+               7.3.2 TermGlobals.fillLeft()\r
+               7.3.3 TermGlobals.center()\r
+               7.3.4 TermGlobals.stringReplace()\r
+   8  Localization\r
+   9  Cross Browser Functions\r
+  10  Architecture, Internals\r
+      10.1  Global Entities\r
+      10.2  I/O Architecture\r
+      10.3  Compatibility\r
+  11  History\r
+  12  Example for a Command Line Parser\r
+  13  License\r
+  14  Disclaimer\r
+  15  References\r
+\r
+\r
+\r
+\r
+1  About\r
+\r
+The Terminal library "termlib.js" provides an object oriented constructor and control\r
+methods for a terminal-like DHTML interface.\r
+\r
+"termlib.js" features direct keyboard input and powerful output methods for multiple\r
+instances of the `Terminal' object (including focus control).\r
+\r
+The library was written with the aim of simple usage and a maximum of compatibility with\r
+minimal foot print in the global namespace.\r
+\r
+\r
+A simple example:\r
+\r
+  // creating a terminal and using it\r
+\r
+  var term = new Terminal( {handler: termHandler} );\r
+  term.open();\r
+\r
+  function termHandler() {\r
+    var line = this.lineBuffer;\r
+    this.newLine();\r
+    if (line == "help") {\r
+      this.write(helpPage)\r
+    }\r
+    else if (line == "exit") {\r
+      this.close();\r
+      return;\r
+    }\r
+    else if (line != "") {\r
+      this.write("You typed: "+line);\r
+    }\r
+    this.prompt();\r
+  }\r
+\r
+  var helpPage = [\r
+    "This is the monstrous help page for my groovy terminal.",\r
+    "Commands available:",\r
+    "   help ... print this monstrous help page",\r
+    "   exit ... leave this groovy terminal",\r
+    " ",\r
+    "Have fun!"\r
+  ];\r
+\r
+\r
+You should provide CSS font definitions for the classes ".term" (normal video) and\r
+".termReverse" (reverse video) in a monospaced font.\r
+A sample stylesheet "term_styles.css" comes with this library.\r
+\r
+See the sample application "multiterm_test.html" for a demo of multiple terminals.\r
+\r
+v.1.01: If you configure to use another font class (see 2.1 Configuration Values),\r
+        you must provide a subclass ".termReverse" for reversed video.\r
+\r
+        p.e.: .myFontClass .termReverse {\r
+                /* your definitions for reverse video here */\r
+              }\r
+        \r
+        With the addition of `conf.fontClass' you can now create multiple\r
+        instances with independend appearences.\r
+\r
+\r
+\r
+\r
+2   Creating a new Terminal Instance\r
+\r
+Use the `new' constructor to create a new instance of the Terminal object. You will want\r
+to supply a configuration object as an argument to the constructor. If the `new'\r
+constructor is called without an object as its first argument, default values are used.\r
+\r
+p.e.:\r
+\r
+  // creating a new instance of Terminal\r
+\r
+  var conf= {\r
+    x: 100,\r
+    y: 100,\r
+    cols: 80,\r
+    rows: 24\r
+  }\r
+\r
+  var term = new Term(conf);\r
+  term.open();\r
+\r
+`Terminal.open()' initializes the terminal and makes it visible to the user.\r
+This is handled in by separate method to allow the re-initilization of instances\r
+previously closed.\r
+\r
+NOTE:\r
+The division element (or NS-layer) that holds the terminal must be present when calling\r
+`Terminal.open()'. So you must not call this method from the header of a HTML-document at\r
+compile time.\r
+\r
+\r
+\r
+2.1 Configuration Values\r
+\r
+Set any of these values in your configuration object to override:\r
+\r
+  \r
+  LABEL                     DEFAULT VALUE    COMMENT\r
+  \r
+  x                                   100    terminal's position x in px\r
+  y                                   100    terminal's position y in px\r
+  divDiv                        'termDiv'    id of terminals CSS division\r
+  bgColor                       '#181818'    background color (HTML hex value)\r
+  frameColor                    '#555555'    frame color (HTML hex value)\r
+  frameWidth                            1    frame border width in px\r
+  fontClass                        'term'    class name of CSS font definition to use\r
+  cols                                 80    number of cols per row\r
+  rows                                 24    number of rows\r
+  rowHeight                            15    a row's line-height in px\r
+  blinkDelay                          500    delay for cursor blinking in milliseconds\r
+  crsrBlinkMode                     false    true for blinking cursor\r
+  crsrBlockMode                      true    true for block-cursor else underscore\r
+  DELisBS                           false    handle <DEL> as <BACKSPACE>\r
+  printTab                           true    handle <TAB> as printable (prints as space)\r
+  printEuro                          true    handle unicode 0x20AC (Euro sign) as printable\r
+  catchCtrlH                         true    handle ^H as <BACKSPACE>\r
+  closeOnESC                         true    close terminal on <ESC>\r
+  historyUnique                     false    prevent consecutive and identical entries in history\r
+  id                                    0    terminal id\r
+  ps                                  '>'    prompt string\r
+  greeting      '%+r Terminal ready. %-r'    string for greeting if no initHandler is used\r
+  handler              termDefaultHandler    reference to handler for command interpretation\r
+  ctrlHandler                        null    reference to handler called on uncatched special keys\r
+  initHandler                        null    reference to handler called at end of init()\r
+  exitHandler                        null    reference to handler called on close()\r
+\r
+\r
+At least you will want to specify `handler' to implement your own command parser.\r
+\r
+Note: While `id' is not used by the Termninal object, it provides an easy way to identify\r
+multiple terminals by the use of "this.id". (e.g.: "if (this.id == 1) startupterm = true;")\r
+\r
+p.e.:\r
+\r
+  // creating two individual Terminal instances\r
+\r
+  var term1 = new Terminal(\r
+    {\r
+      id: 1,\r
+      x: 200,\r
+      y: 10,\r
+      cols: 80,\r
+      rows: 12,\r
+      greeting: "*** This is Terminal 1 ***",\r
+      handler: myTerminalHandler\r
+    }\r
+  );\r
+  term1.open();\r
+\r
+  var term2 = new Terminal(\r
+    {\r
+      id: 2,\r
+      x, 200,\r
+      y: 220,\r
+      cols: 80\r
+      rows: 12,\r
+      greeting: "*** This is Terminal 2 ***",\r
+      handler: myTerminalHandler\r
+    }\r
+  );\r
+  term2.open();\r
+\r
+\r
+\r
+\r
+3   Using the Terminal\r
+\r
+There are 4 different handlers that are called by a Terminal instance to process input and\r
+some flags to control the input mode and behaviour.\r
+\r
+\r
+\r
+3.1 The Default Handler (a simlple example for input handling)\r
+\r
+If no handlers are defined in the configuration object, a default handler is called to\r
+handle a line of user input. The default command line handler `termDefaultHandler' just\r
+closes the command line with a new line and echos the input back to the user:\r
+\r
+  function termDefaultHandler() {\r
+    this.newLine();\r
+    if (this.lineBuffer != '') {\r
+      this.type('You typed: '+this.lineBuffer);\r
+      this.newLine();\r
+    }\r
+    this.prompt();\r
+  }\r
+\r
+First you may note that the instance is refered to as `this'. So you need not worry about\r
+which Terminal instance is calling your handler. As the handler is entered, the terminal\r
+is locked for user input and the cursor is off. The current input is available as a string\r
+value in `this.lineBuffer'.\r
+\r
+The method `type(<text>)' just does what it says and types a string at the current cursor\r
+position to the terminal screen.\r
+\r
+`newLine()' moves the cursor to a new line.\r
+\r
+The method `prompt()' adds a new line if the cursor isn't at the start of a line, outputs\r
+the prompt string (as specified in the configuration), activates the cursor, and unlocks\r
+the terminal for further input. While you're doing normal command line processing, always\r
+call `prompt()' when leaving your handler.\r
+\r
+In fact this is all you need to create your own terminal application. Please see at least\r
+the method `write()' for a more powerful output method.\r
+\r
+Below we will refer to all methods of the Terminal object as `Terminal.<method>()'.\r
+You can call them as `this.<method>()' in a handler or as methods of your named instance\r
+in other context (e.g.: "myTerminal.close()").\r
+\r
+[In technical terms these methods are methods of the Terminal's prototype object, while\r
+the properties are properties of a Termninal instance. Since this doesn't make any\r
+difference to your script, we'll refer to both as `Terminal.<method-or-property>'.]\r
+\r
+\r
+\r
+3.2 Input Modes\r
+\r
+3.2.1 Normal Line Input (Command Line Mode)\r
+\r
+By default the terminal is in normal input mode. Any printable characters in the range of\r
+ASCII 0x20 - 0xff are echoed to the terminal and may be edited with the use of the cursor\r
+keys and the <BACKSPACE> key.\r
+The cursor keys UP and DOWN let the user browse in the command line history (the list of\r
+all commands issued previously in this Terminal instance).\r
+\r
+If the user presses <CR> or <ENTER>, the line is read from the terminal buffer, converted\r
+to a string, and placed in `Terminal.lineBuffer' (-> `this.lineBuffer') for further use.\r
+The terminal is then locked for further input and the specified handler\r
+(`Terminal.handler') is called.\r
+\r
+\r
+3.2.1.2 Special Keys (ctrlHandler)\r
+\r
+If a special character (ASCII<0x20) or an according combination of <CTRL> and a key is\r
+pressed, which is not caught for editing or "enter", and a handler for `ctrlHandler' is\r
+specified, this handler is called.\r
+The ASCII value of the special character is available in `Terminal.inputChar'. Please note\r
+that the terminal is neither locked, nor is the cursor off - all further actions have to\r
+be controlled by `ctrlHandler'. (The tracking of <CTRL>-<key> combinations as "^C" usually\r
+works but cannot be taken for granted.)\r
+\r
+A named reference of the special control values in POSIX form (as well as the values of\r
+the cursor keys [LEFT, RIGHT, UP, DOWN]) is available in the `termKey' object.\r
+\r
+p.e.:\r
+\r
+  // a simple ctrlHandler\r
+\r
+  function myCtrlHandler() {\r
+    if (this.inputChar == termKey.ETX) {\r
+      // exit on ^C (^C == ASCII 0x03 == <ETX>)\r
+      this.close();\r
+    }\r
+  }\r
+\r
+If no `ctrlHandler' is specified, control keys are ignored (default).\r
+\r
+\r
+3.2.2 Raw Mode\r
+\r
+If the flag `Terminal.rawMode' is set to a value evaluating to `true', no special keys are\r
+tracked but <CR> and <ENTER> (and <ESC>, if the flag `Terminal.closeOnESC' is set).\r
+The input is NOT echoed to the terminal. All printable key values [0x20-0xff] are\r
+transformed to characters and added to `Terminal.lineBuffer' sequentially. The command\r
+line input is NOT added to the history.\r
+\r
+This mode is especially suitable for password input.\r
+\r
+p.e.:\r
+\r
+  // using raw mode for password input\r
+\r
+  function myTermHandler() {\r
+    this.newLine();\r
+    // we stored a flag in Terminal.env to track the status\r
+    if (this.env.getpassword) {\r
+      // leave raw mode\r
+      this.rawMode = false;\r
+      if (passwords[this.env.user] == this.lineBuffer) {\r
+        // matched\r
+        this.type('Welcome '+this.env.user);\r
+        this.env.loggedin = true;\r
+      }\r
+      else {\r
+        this.type('Sorry.');\r
+      }\r
+      this.env.getpassword = false;\r
+    }\r
+    else {\r
+      // simple parsing\r
+      var args = this.lineBuffer.split(' ');\r
+      var cmd = args[0];\r
+      if (cmd == 'login') {\r
+        var user = args[1];\r
+        if (!user) {\r
+          this.type('usage: login <username>');\r
+        }\r
+        else {\r
+          this.env.user = user;\r
+          this.env.getpassword = true;\r
+          this.type('password? ');\r
+          // enter raw mode\r
+          this.rawMode = true;\r
+          // leave without prompt so we must unlock first\r
+          this.lock = false;\r
+          return;\r
+        }\r
+      }\r
+      /*\r
+        other actions ...\r
+      */\r
+    }\r
+    this.prompt();\r
+  }\r
+\r
+In this example a handler is set up to process the command "login <username>" and ask for\r
+a password for the given user name in raw mode. Note the use of the object `Terminal.env'\r
+which is just an empty object set up at the creation of the Terminal instance. Its only\r
+purpose is to provide an individual namespace for private data to be stored by a Terminal\r
+instance.\r
+\r
+NOTE: The flag `Terminal.lock' is used to control the keyboard locking. If we would not\r
+set this to `false' before leaving in raw mode, we would be caught in dead-lock, since no\r
+input could be entered and our handler wouldn't be called again. - A dreadful end of our\r
+terminal session.\r
+\r
+NOTE: Raw mode utilizes the property `Terminal.lastLine' to collect the input string.\r
+This is normally emty, when a handler is called. This is not the case if your script left\r
+the input process on a call of ctrlHandler. You should clear `Terminal.lastLine' in such\r
+a case, if you're going to enter raw mode immediatly after this.\r
+\r
+\r
+3.2.3 Character Mode\r
+\r
+If the flag `Terminal.charMode' is set to a value evaluating to `true', the terminal is in\r
+character mode. In this mode the numeric ASCII value of the next key typed is stored in\r
+`Terminal.inputChar'. The input is NOT echoed to the terminal. NO locking or cursor\r
+control is performed and left to the handler.\r
+You can use this mode to implement your editor or a console game.\r
+`Terminal.charMode' takes precedence over `Terminal.rawMode'.\r
+\r
+p.e.: \r
+\r
+  // using char mode\r
+\r
+  function myTermHandler() {\r
+    // this is the normal handler\r
+    this.newLine();\r
+    // simple parsing\r
+    var args = this.lineBuffer.split(' ');\r
+    var cmd = args[0];\r
+    if (cmd == 'edit') {\r
+      // init the editor\r
+      myEditor(this);\r
+      // redirect the handler to editor\r
+      this.handler = myEditor;\r
+      // leave in char mode\r
+      this.charMode = true;\r
+      // show cursor\r
+      this.cursorOn();\r
+      // don't forget unlocking\r
+      this.lock = false;\r
+      return;\r
+    }\r
+    /*\r
+      other actions ...\r
+    */\r
+    this.prompt();\r
+  }\r
+\r
+  function myEditor(initterm) {\r
+    // our dummy editor (featuring modal behaviour)\r
+    if (initterm) {\r
+      // perform initialization tasks\r
+      initterm.clear();\r
+      initterm.write('this is a simple test editor; leave with <ESC> then "q"%n%n');\r
+      initterm.env.mode = '';\r
+      // store a reference of the calling handler\r
+      initterm.env.handler = initterm.handler;\r
+      return;\r
+    }\r
+    // called as handler -> lock first\r
+    this.lock=true;\r
+    // hide cursor\r
+    this.cursorOff();\r
+    var key = this.inputChar;\r
+    if (this.env.mode == 'ctrl') {\r
+      // control mode\r
+      if (key == 113) {\r
+        // "q" => quit\r
+        // leave charMode and reset the handler to normal\r
+        this.charMode = false;\r
+        this.handler = this.env.handler;\r
+        // clear the screen\r
+        this.clear();\r
+        // prompt and return\r
+        this.prompt();\r
+        return;\r
+      }\r
+      else {\r
+        // leave control mode\r
+        this.env.mode = '';\r
+      }\r
+    }\r
+    else {\r
+      // edit mode\r
+      if (key == termKey.ESC) {\r
+        // enter control mode\r
+        // we'd better indicate this in a status line ...\r
+        this.env.mode = 'ctrl';\r
+      }\r
+      else if (key == termKey.LEFT) {\r
+        // cursor left\r
+      }\r
+      else if (key == termKey.RIGHT) {\r
+        // cursor right\r
+      }\r
+      if (key == termKey.UP) {\r
+        // cursor up\r
+      }\r
+      else if (key == termKey.DOWN) {\r
+        // cursor down\r
+      }\r
+      else if (key == termKey.CR) {\r
+        // cr or enter\r
+      }\r
+      else if (key == termKey.BS) {\r
+        // backspace\r
+      }\r
+      else if (key == termKey.DEL) {\r
+        // fwd delete\r
+        // conf.DELisBS is not evaluated in charMode!\r
+      }\r
+      else if (this.isPrintable(key)) {\r
+        // printable char - just type it\r
+        var ch = String.fromCharCode(key);\r
+        this.type(ch);\r
+      }\r
+    }\r
+    // leave unlocked with cursor\r
+    this.lock = false;\r
+    this.cursorOn();\r
+  }\r
+\r
+\r
+Note the redirecting of the input handler to replace the command line handler by the\r
+editor. The method `Terminal.clear()' clears the terminal.\r
+`Terminal.cursorOn()' and `Terminal.cursorOff()' are used to show and hide the cursor.\r
+\r
+\r
+\r
+3.3 Other Handlers\r
+\r
+There are two more handlers that can be specified in the configuration object:\r
+\r
+\r
+3.3.1 initHandler\r
+\r
+`initHandler' is called at the end of the initialization triggered by `Terminal.open()'.\r
+The default action - if no `initHandler' is specified - is:\r
+\r
+  // default initilization\r
+\r
+  this.write(this.conf.greeting);\r
+  this.newLine();\r
+  this.prompt();\r
+\r
+Use `initHandler' to perform your own start up tasks (e.g. show a start up screen). Keep\r
+in mind that you should unlock the terminal and possibly show a cursor to give the\r
+impression of a usable terminal.\r
+\r
+\r
+3.3.2  exitHandler\r
+\r
+`exitHandler' is called by `Terminal.close()' just before hiding the terminal. You can use\r
+this handler to implement any tasks to be performed on exit. Note that this handler is\r
+called even if the terminal is closed on <ESC> outside of your inputHandlers control.\r
+\r
+See the file "multiterm_test.html" for an example.\r
+\r
+\r
+\r
+3.4   Overview: Flags for Behaviour Control\r
+\r
+These falgs are accessible as `Terminal.<flag>' at runtime. If not stated else, the\r
+initial value may be specified in the configuration object.\r
+The configuration object and its properties are accessible at runtime via `Terminal.conf'.\r
+\r
+\r
+  NAME                      DEFAULT VALUE    MEANING\r
+\r
+  blink_delay                         500    delay for cursor blinking in milliseconds.\r
+\r
+  crsrBlinkMode                     false    true for blinking cursor.\r
+                                             if false, cursor is static.\r
+  \r
+  crsrBlockMode                      true    true for block-cursor else underscore.\r
+\r
+  DELisBS                           false    handle <DEL> as <BACKSPACE>.\r
+\r
+  printTab                           true    handle <TAB> as printable (prints as space)\r
+                                             if false <TAB> is handled as a control character\r
+\r
+  printEuro                          true    handle the euro sign as valid input char.\r
+                                             if false char 0x20AC is printed, but not accepted\r
+                                             in the command line\r
+\r
+  catchCtrlH                         true    handle ^H as <BACKSPACE>.\r
+                                             if false, ^H must be tracked by a custom\r
+                                             ctrlHandler.\r
+\r
+  closeOnESC                         true    close terminal on <ESC>.\r
+                                             if true, <ESC> is not available for ctrHandler.\r
+\r
+\r
+  historyUnique                     false    unique history entries.\r
+                                             if true, entries that are identical to the last\r
+                                             entry in the user history will not be added.\r
+\r
+  charMode                          false    terminal in character mode (tracks next key-code).\r
+                                             (runtime only)\r
\r
+  rawMode                           false    terminal in raw mode (no echo, no editing).\r
+                                             (runtime only)\r
+\r
+\r
+Not exactly a flag but useful:\r
+\r
+  ps                                  '>'    prompt string.\r
+\r
+\r
+\r
+\r
+4  Output Methods\r
+\r
+Please note that any output to the terminal implies an advance of the cursor. This means,\r
+that if your output reaches the last column of your terminal, the cursor is advanced and\r
+a new line is opened automatically. This procedure may include scrolling to make room for\r
+the new line. While this is not of much interest for most purposes, please note that, if\r
+you output a string of length 80 to a 80-columns-terminal, and a new line, and another\r
+string, this will result in an empty line between the two strings.\r
+\r
+\r
+4.1  Terminal.type( <text> [,<stylevector>] )\r
+\r
+Types the string <text> at the current cursor position to the terminal. Long lines are\r
+broken where the last column of the terminal is reached and continued in the next line.\r
+`Terminal.write()' does not support any kind of arbitrary line breaks. (This is just a\r
+basic output routine. See `Terminal.write()' for a more powerful output method.)\r
+\r
+A bitvector may be supplied as an optional second argument to represent a style or a\r
+combination of styles. The meanings of the bits set are interpreted as follows:\r
+\r
+<stylevector>:\r
+\r
+   1 ... reverse    (2 power 0)\r
+   2 ... underline  (2 power 1)\r
+   4 ... italics    (2 power 2)\r
+   8 ... strike     (2 power 3)\r
+\r
+So "Terminal.type( 'text', 5 )" types "text" in italics and reverse video.\r
+\r
+Note:\r
+There is no bold, for most monospaced fonts (including Courier) tend to render wider in\r
+bold. Since this would bring the terminal's layout out of balance, we just can't use bold\r
+as a style. - Sorry.\r
+\r
+The HTML-representation of this styles are defined in "TermGlobals.termStyleOpen" and\r
+"TermGlobals.termStyleClose".\r
+\r
+\r
+4.2  Terminal.write( <text> [,<usemore>] )\r
+\r
+Writes a text with markup to the terminal. If an optional second argument evaluates to\r
+true, a UN*X-style utility like `more' is used to page the text. The text may be supplied\r
+as a single string (with newline character "\n") or as an array of lines. Any other input\r
+is transformed to a string value before output.\r
+\r
+4.2.1 Mark-up:\r
+\r
+`Terminal.write()' employs a simple mark-up with the following syntax:\r
+\r
+<markup>: %([+|-]<style>|n|CS|%)\r
+   \r
+   where "+" and '-' are used to switch on and off a style, where\r
+   \r
+   <style>:\r
+   \r
+      "i" ... italics\r
+      "r" ... reverse\r
+      "s" ... strike\r
+      "u" ... underline\r
+      \r
+      "p" ... reset to plain ("%+p" == "%-p")\r
+    \r
+   styles may be combined and may overlap. (e.g. "This is %+rREVERSE%-r, %+uUNDER%+iSCORE%-u%-i.")\r
+   \r
+   "%n"  represents a new line (in fact "\n" is translated to "%n" before processing)\r
+   \r
+   "%CS" clears the terminal screen\r
+   \r
+   "%%"  represents the percent character ('%')\r
+\r
+\r
+4.2.2 Buffering:\r
+\r
+`Terminal.write()' writes via buffered output to the terminal. This means that the\r
+provided text is rendered to a buffer first and then only the visible parts are transfered\r
+to the terminal display buffers. This avoids scrolling delays for long output.\r
+\r
+4.2.3 UseMore Mode:\r
+\r
+The buffering of `Terminal.write()' allows for pagewise output, which may be specified by\r
+a second boolean argument. If <usemore> evaluates to `true' and the output exceeds the\r
+range of empty rows on the terminal screen, `Terminal.write()' performs like the UN*X\r
+utility `more'. The next page may be accessed by hitting <SPACE> while <q> terminates\r
+paging and returns with the prompt (-> `Terminal.prompt()').\r
+\r
+To use this facillity make sure to return immediatly after calling `Terminal.write()' in\r
+order to allow the more-routine to track the user input.\r
+The terminal is set to "charMode == false" afterwards.\r
+\r
+p.e.:\r
+\r
+  // using Terminal.write as a pager\r
+\r
+  function myTermHandler() {\r
+    this.newLine();\r
+    var args = this.lineBuffer.split(' ');\r
+    var cmd = args[0];\r
+    if (cmd == 'more') {\r
+      var page = args[1];\r
+      if (myPages[page]) {\r
+        // Terminal.write as a pager\r
+        this.write(myPages[page], true);\r
+        return;\r
+      }\r
+      else {\r
+        // Terminal.write for simple output\r
+        this.write('no such page.');\r
+      }\r
+    }\r
+    /*\r
+      other actions ...\r
+    */\r
+    this.prompt();\r
+  }\r
+\r
+\r
+4.3  Terminal.typeAt( <r>, <c>, <text> [,<stylevector>] )\r
+\r
+Output the string <text> at row <r>, col <c>.\r
+For <stylevector> see `Terminal.type()'.\r
+`Terminal.typeAt()' does not move the cursor.\r
+\r
+\r
+4.4  Terminal.setChar( <charcode>, <r>, <c> [,<stylevector>] )\r
+\r
+Output a single character represented by the ASCII value of <charcode> at row <r>, col <c>.\r
+For <stylevector> see `Terminal.type()'.\r
+\r
+\r
+4.5  Terminal.newLine()\r
+\r
+Moves the cursor to the first column of the next line and performs scrolling, if needed.\r
+\r
+\r
+4.6  Terminal.clear()\r
+\r
+Clears the terminal screen. (Returns with cursor off.)\r
+\r
+\r
+4.7  Terminal.statusLine( <text> [,<stylevector> [,<lineoffset>]] )\r
+\r
+All output acts on a logical screen with the origin at row 0 / col 0. While the origin is\r
+fixed, the logical width and height of the terminal are defined by `Terminal.maxCols' and\r
+`Terminal.maxLines'. These are set to the configuration dimensions at initilization and by\r
+`Terminal.reset()', but may be altered at any moment. Please note that there are no bounds\r
+checked, so make sure that `Terminal.maxCols' and `Terminal.maxLines' are less or equal\r
+to the configuration dimensions.\r
+\r
+You may want to decrement `Terminal.maxLines' to keep space for a reserved status line.\r
+`Terminal.statusLine( <text>, <style> )' offers a simple way to type a text to the last\r
+line of the screen as defined by the configuration dimensions.\r
+\r
+  // using statusLine()\r
+\r
+  function myHandler() {\r
+    // ...\r
+    // reserve last line\r
+    this.maxLines = term.conf.rows-1;\r
+    // print to status line in reverse video\r
+    this.statusLine("Status: <none>", 1);\r
+    // ...\r
+  }\r
+\r
+For multiple status lines the optional argument <lineoffset> specifies the addressed row,\r
+where 1 is the line closest to the bottom, 2 the second line from the bottom and so on.\r
+(default: 1)\r
+\r
+\r
+4.8  Terminal.printRowFromString( <r> , <text> [,<stylevector>] )\r
+\r
+Outputs the string <text> to row <r> in the style of an optional <stylevector>.\r
+If the string's length exceeds the length of the row  (up to `Terminal.conf.cols'), extra\r
+characteres are ignored, else any extra space is filled with character code 0 (prints as\r
+<SPACE>).\r
+The valid range for <row> is: 0 >= <row> < `Terminal.maxLines'.\r
+`Terminal.printRowFromString()' does not set the cursor.\r
+\r
+You could, for example, use this method to output a line of a text editor's buffer.\r
+\r
+p.e.:\r
+\r
+  // page refresh function of a text editor\r
+\r
+  function myEditorRefresh(termref, topline) {\r
+    // termref: reference to Terminal instance\r
+    // topline: index of first line to print\r
+    // lines of text are stored in termref.env.lines\r
+    for (var r=0; r<termref.maxLines; r++) {\r
+      var i = topline + r;\r
+      if (i < termref.env.lines.length) {\r
+        // output stored line\r
+        termref.printRowFromString(r, termref.env.lines[i]);\r
+      }\r
+      else {\r
+        // output <tilde> for empty line\r
+        termref.printRowFromString(r, '~');\r
+      }\r
+    }\r
+    // set cursor to origin\r
+    termref.r = termref.c = 0; // same as termref.cursorSet(0, 0);\r
+  }\r
+\r
+\r
+4.9  Terminal.redraw( <row> )\r
+\r
+Basic function to redraw a terminal row <row> according to screen buffer values.\r
+For hackers only. (e.g.: for a console game, hack screen buffers first and redraw all\r
+changed rows at once.)\r
+\r
+\r
+\r
+\r
+5  Cursor Methods and Editing\r
+\r
+\r
+5.1  Terminal.cursorOn()\r
+\r
+Show the cursor.\r
+\r
+\r
+5.2  Terminal.cursorOff()\r
+\r
+Hide the cursor.\r
+\r
+\r
+5.3  Terminal.cursorSet( <r>, <c> )\r
+\r
+Set the cursor position to row <r> column <c>.\r
+`Terminal.cursorSet()' preserves the cursor's active state (on/off).\r
+\r
+\r
+5.4  Terminal.cursorLeft()\r
+\r
+Move the cursor left. (Movement is restricted to the logical input line.)\r
+`Terminal.cursorLeft()' preserves the cursor's active state (on/off).\r
+\r
+\r
+5.5  Terminal.cursorRight()\r
+\r
+Move the cursor right. (Movement is restricted to the logical input line.)\r
+`Terminal.cursorRight()' preserves the cursor's active state (on/off).\r
+\r
+\r
+5.6  Terminal.backspace()\r
+\r
+Delete the character left from the cursor, if the cursor is not in first position of the\r
+logical input line.\r
+`Terminal.backspace()' preserves the cursor's active state (on/off).\r
+\r
+\r
+5.7  Terminal.fwdDelete()\r
+\r
+Delete the character under the cursor.\r
+`Terminal.fwdDelete()' preserves the cursor's active state (on/off).\r
+\r
+\r
+5.8  Terminal.isPrintable( <key code> [,<unicode page 1 only>] )\r
+\r
+Returns `true' if the character represented by <key code> is printable with the current\r
+settings. An optional second argument <unicode page 1 only> limits the range of valid\r
+values to 255 with the exception of the Euro sign, if the flag `Terminal.printEuro' is set.\r
+(This second flag is used for input methods but not for output methods. So you may only\r
+enter portable characters, but you may print others to the terminals screen.)\r
+\r
+\r
+\r
+\r
+6  Other Methods of the Terminal Object\r
+\r
+6.1  Terminal.prompt()\r
+\r
+Performes the following actions:\r
+\r
+  * advance the cursor to a new line, if the cursor is not at 1st column\r
+  * type the prompt string (as specified in the configuaration object)\r
+  * show the cursor\r
+  * unlock the terminal\r
+\r
+(The value of the prompt string can be accessed and changed in `Terminal.ps'.)\r
+\r
+\r
+6.2  Terminal.reset()\r
+\r
+Resets the terminal to sane values and clears the terminal screen.\r
+\r
+\r
+6.3  Terminal.open()\r
+\r
+Opens the terminal. If this is a fresh instance, the HTML code for the terminal is\r
+generated. On re-entry the terminal's visibility is set to `true'. Initialization tasks\r
+are performed and the optional initHandler called. If no initHandler is specified in the\r
+configuration object, the greeting (configuration or default value) is shown and the user\r
+is prompted for input.\r
+\r
+v.1.01: `Terminal.open()' now checks for the existence of the DHTML element as defined in\r
+        `Terminal.conf.termDiv' and returns success.\r
+\r
+\r
+6.4  Terminal.close()\r
+\r
+Closes the terminal and hides its visibility. An optional exitHandler (specified in the\r
+configuration object) is called, and finally the flag `Terminal.closed' is set to true. So\r
+you can check for existing terminal instances as you would check for a `window' object\r
+created by `window.open()'.\r
+\r
+p.e.:\r
+\r
+  // check for a terminals state\r
+  // let array "term" hold references to terminals\r
+\r
+  if (term[n]) {\r
+    if (term[n].closed) {\r
+      // terminal exists and is closed\r
+      // re-enter via "term[n].open()"\r
+    }\r
+    else {\r
+      // terminal exists and is currently open\r
+    }\r
+  }\r
+  else {\r
+    // no such terminal\r
+    // create it via "term[n] = new Terminal()"\r
+  }\r
+\r
+\r
+6.5  Terminal.focus()\r
+\r
+Set the keyboard focus to this instance of Terminal. (As `window.focus()'.)\r
+\r
+\r
+6.6  Terminal.moveTo( <x>, <y> )\r
+\r
+Move the terminal to position <x>/<y> in px.\r
+(As `window.moveTo()', but inside the HTML page.)\r
+\r
+\r
+6.7  Terminal.resizeTo( <x>, <y> )\r
+\r
+Resize the terminal to dimensions <x> cols and <y> rows.\r
+<x> must be at least 4, <y> at least 2.\r
+`Terminal.resizeTo()' resets `Terminal.conf.rows', `Terminal.conf.cols',\r
+`Terminal.maxLines', and `Terminal.maxCols' to <y> and <x>, but leaves the instance' state\r
+else unchanged. Clears the terminal's screen and returns success.\r
+\r
+(A bit like `window.resizeTo()', but with rows and cols instead of px.)\r
+\r
+\r
+6.8  Terminal.getDimensions()\r
+\r
+Returns an object with properties "width" and "height" with numeric values for the\r
+terminal's outer dimensions in px. Values are zero (0) if the element is not present or\r
+if the method fails otherwise.\r
+\r
+\r
+6.9  Terminal.rebuild()\r
+\r
+Rebuilds the Terminal object's GUI preserving its state and content.\r
+Use this to change the color theme on the fly.\r
+\r
+p.e.:\r
+\r
+   // change color settings on the fly\r
+   // here: set bgColor to white and font style to "termWhite"\r
+   // method rebuild() updates the GUI without side effects\r
+\r
+   term.conf.bgColor = '#ffffff';\r
+   term.conf.fontClass = 'termWhite';\r
+   term.rebuild();\r
+\r
+\r
+\r
+\r
+7   Global Static Methods (TermGlobals)\r
+\r
+\r
+7.1  TermGlobals.setFocus( <termref> )\r
+\r
+Sets the keyboard focus to the instance referenced by <termref>.\r
+The focus is controlled by `TermGlobals.activeTerm' which may be accessed directly.\r
+See also: `Terminal.focus()'\r
+\r
+\r
+7.2  TermGlobals.keylock (Global Locking Flag)\r
+\r
+The global flag `TermGlobals.keylock' allows temporary keyboard locking without any\r
+other change of state. Use this to free the keyboard for any other resources.\r
+(added in v.1.03)\r
+\r
+\r
+7.3  TermGlobals Text Methods\r
+\r
+There is a small set of methods for common terminal related string tasks:\r
+\r
+\r
+7.3.1  TermGlobals.normalize( <n>, <fieldlength> )\r
+\r
+Converts a number to a string, which is filled at its left with zeros ("0") to the total\r
+length of <filedlength>. (e.g.: "TermGlobals.normalize(1, 2)" => "01")\r
+\r
+\r
+7.3.2  TermGlobals.fillLeft( <value>, <fieldlength> )\r
+\r
+Converts a value to a string and fills it to the left with blanks to <fieldlength>.\r
+\r
+\r
+7.3.3  TermGlobals.center( <text>, <length> )\r
+\r
+Adds blanks at the left of the string <text> until the text would be centered at a line\r
+of length <length>. (No blanks are added to the the right.)\r
+\r
+\r
+7.3.4  TermGlobals.stringReplace( <string1>, <string2>, <text> )\r
+\r
+Replaces all occurences of the string <string1> in <text> with <string2>.\r
+This is just a tiny work around for browsers with no support of RegExp.\r
+\r
+\r
+\r
+\r
+8   Localization\r
+\r
+The strings and key-codes used by the more utility of `Terminal.write()' are the only\r
+properties of "termlib.js" that may need localization. These properties are defined in\r
+`TermGlobals'. You may override them as needed:\r
+\r
+PROPERTY                                      STANDARD VALUE                 COMMENT\r
+\r
+TermGlobals.lcMorePrompt1                                    ' -- MORE -- '  1st string\r
+TermGlobals.lcMorePromtp1Style                                            1  reverse\r
+TermGlobals.lcMorePrompt2       ' (Type: space to continue, \'q\' to quit)'  appended string\r
+TermGlobals.lcMorePrompt2Style                                            0  plain\r
+TermGlobals.lcMoreKeyAbort                                              113  (key-code: q)\r
+TermGlobals.lcMoreKeyContinue                                            32  (key-code <SPACE>)\r
+\r
+\r
+As "TermGlobals.lcMorePrompt2" is appended to "TermGlobals.lcMorePrompt1" make sure that\r
+the length of the combined strings does not exceed `Terminal.conf.cols'.\r
+\r
+\r
+\r
+\r
+9   Cross Browser Functions\r
+\r
+For DHTML rendering some methods - as needed by the Terminal library - are provided.\r
+These may also be accessed for other purposes.\r
+\r
+\r
+9.1  TermGlobals.writeElement( <element id>, <text> [,<NS4 parent document>] )\r
+\r
+Writes <text> to the DHTML element with id/name <element id>. \r
+<NS4 parent document> is used for NS4 only and specifies an optional reference to a parent\r
+document (default `window.document').\r
+\r
+9.2  TermGlobals.setElementXY( <element id>, <x>, <y> )\r
+\r
+Sets the DHTML element with id/name <element id> to position <x>/<y>.\r
+For NS4 works only with children of the top document (window.document).\r
+\r
+\r
+9.3  TermGlobals.setVisible( <element id>, <value> )\r
+\r
+If <value> evaluates to `true' show DHTML element with id/name <element id> else hide it.\r
+For NS4 works only with children of the top document (window.document).\r
+\r
+\r
+9.4  Custom Fixes for Missing String Methods\r
+\r
+Although `String.fromCharCode' and `String.prototype.charCodeAt' are defined by ECMA-262-2\r
+specifications, a few number of browsers lack them in their JavaScript implementation. At\r
+compile time custom methods are installed to fix this. Please note that they work only\r
+with ASCII characters and values in the range of [0x20-0xff].\r
+\r
+\r
+9.5  TermGlobals.setDisplay( <element id>, <value> )\r
+\r
+Sets the style.display property of the element with id/name <element id> to the given\r
+<value>. (added with v. 1.06)\r
+\r
+\r
+\r
+\r
+10   Architecture, Internals\r
+\r
+10.1  Global Entities\r
+\r
+The library is designed to leave only a small foot print in the namespace while providing\r
+suitable usability:\r
+\r
+  Globals defined in this library:\r
+\r
+    Terminal           (Terminal object, `new' constructor and prototype methods)\r
+    TerminalDefaults   (default configuration, static object)\r
+    termDefaultHandler (default command line handler, static function)\r
+    TermGlobals        (common vars and code for all instances, static object and methods)\r
+    termKey            (named mappings for special keys, static object)\r
+    termDomKeyRef      (special key mapping for DOM key constants, static object)\r
+\r
+\r
+  Globals defined for fixing String methods, if missing\r
+  (String.fromCharCode, String.prototype.charCodeAt):\r
+\r
+    termString_keyref, termString_keycoderef, termString_makeKeyref\r
+\r
+  \r
+  Required CSS classes for font definitions: ".term", ".termReverse".\r
+\r
+\r
+\r
+10.2  I/O Architecture\r
+\r
+The Terminal object renders keyboard input from keyCodes to a line buffer and/or to a\r
+special keyCode buffer. In normal input mode printable input is echoed to the screen\r
+buffers. Special characters like <LEFT>, <RIGHT>, <BACKSPACE> are processed for command\r
+line editing by the internal key-handler `TermGlobals.keyHandler' and act directly on the\r
+screen buffers. On <CR> or <ENTER> the start and end positions of the current line are\r
+evaluated (terminated by ASCII 0x01 at the beginning which separates the prompt from the\r
+user input, and any value less than ASCII 0x20 (<SPACE>) at the right end). Then the\r
+character representation for the buffer values in this range are evaluated and\r
+concatenated to a string stored in `Terminal.lineBuffer'. As this involves some\r
+ASCII-to-String-transformations, the range of valid printable input characters is limited\r
+to the first page of unicode characters (0x0020-0x00ff).\r
+\r
+There are two screen buffers for output, one for character codes (ASCII values) and one\r
+for style codes. Style codes represent combination of styles as a bitvector (see\r
+`Terminal.type' for bit values.) The method `Terminal.redraw(<row>)' finally renders the\r
+buffers values to a string of HTML code, which is written to the HTML entity holding the\r
+according terminal row. The character buffer is a 2 dimensional array\r
+`Terminal.charBuf[<row>][<col>]' with ranges for <row> from 0 to less than\r
+`Terminal.conf.rows' and for <col> from 0 to less than `Terminal.conf.cols'. The style\r
+buffer is a 2 dimensional array `Terminal.styleBuf[<row>][<col>]' with according ranges.\r
+\r
+So every single character is represented by a ASCII code in `Terminal.charBuf' and a\r
+style-vector in `Terminal.styleBuf'. The range of printable character codes is unlimitted\r
+but should be kept to the first page of unicode characters (0x0020-0x00ff) for\r
+compatibility purpose. (c.f. 8.4)\r
+\r
+Keyboard input is first handled on the `KEYDOWN' event by the handler `TermGlobals.keyFix'\r
+to remap the keyCodes of cursor keys to consistent values. (To make them distinctable from\r
+any other possibly printable values, the values of POSIX <IS4> to <IS1> where chosen.)\r
+The mapping of the cursor keys is stored in the properties LEFT, RIGHT, UP, and DOWN of\r
+the global static object `termKey'.\r
+\r
+The main keyboard handler `TermGlobals.keyHandler' (invoked on `KEYPRESS' or by\r
+`TermGlobals.keyFix') does some final mapping first. Then the input is evaluated as\r
+controlled by the flags `Terminal.rawMode' and `Terminal.charMode' with precedence of the\r
+latter. In dependancy of the mode defined and the handlers currently defined, the input\r
+either is ignored, or is internally processed for command line editing, or one of the\r
+handlers is called.\r
+\r
+In the case of the simultanous presecence of two instances of Terminal, the keyboard focus\r
+is controlled via a reference stored in `TermGlobals.activeTerm'. This reference is also\r
+used to evaluate the `this'-context of the key handlers which are methods of the static\r
+Object `TermGlobals'.\r
+\r
+A terminal's screen consists of a HTML-table element residing in the HTML/CSS division\r
+spcified in `Terminal.conf.termDiv'. Any output is handled on a per row bases. The\r
+individual rows are either nested sub-divisions of the main divisions (used for NS4 or\r
+browsers not compatible to the "Gecko" engine) or the indiviual table data elements (<TD>)\r
+of the terminal's inner table (used for browsers employing the "Gecko" engine).\r
+(This implementation was chosen for rendering speed and in order to minimize any screen\r
+flicker.) Any output or change of state in a raw results in the inner HTML contents of a\r
+row's HTML element to be rewritten. Please note that as a result of this a blinking cursor\r
+may cause a flicker in the line containing the cursor's position while displayed by a\r
+browser, which employs the "Gecko" engine.\r
+\r
+\r
+\r
+10.3  Compatibility\r
+\r
+Standard web browsers with a JavaScript implementation compliant to ECMA-262 2nd edition\r
+[ECMA262-2] and support for the anonymous array and object constructs and the anonymous\r
+function construct in the form of "myfunc = function(x) {}" (c.f. ECMA-262 3rd edion\r
+[ECMA262-3] for details). This comprises almost all current browsers but Konquerer (khtml)\r
+and versions of Apple Safari for Mac OS 10.0-10.28 (Safari < 1.1) which lack support for\r
+keyboard events.\r
+\r
+To provide a maximum of compatibilty the extend of language keywords used was kept to a\r
+minimum and does not exceed the lexical conventions of ECMA-262-2. Especially there is no\r
+use of the `switch' statement or the `RegExp' method of the global object. Also the use of\r
+advanced Array methods like `push', `shift', `splice' was avoided.\r
+\r
+\r
+\r
+\r
+11   History\r
+\r
+This library evolved from the terminal script "TermApp" ((c) N. Landsteiner 2003) and is\r
+in its current form a down scaled spinn-off of the "JS/UIX" project [JS/UIX] (evolution\r
+"JS/UIX v0.5"). c.f.: <http://www.masswerk.at/jsuix>\r
+\r
+v 1.01: added Terminal.prototype.resizeTo(x,y)\r
+        added Terminal.conf.fontClass (=> configureable class name)\r
+        Terminal.prototype.open() now checks for element conf.termDiv in advance\r
+          and returns success.\r
+\r
+v 1.02: added support for <TAB> and Euro sign\r
+          Terminal.conf.printTab\r
+          Terminal.conf.printEuro\r
+        and method Terminal.prototype.isPrintable(keycode)\r
+        added support for getopt to sample parser ("parser_sample.html")\r
+\r
+\r
+v 1.03: added global keyboard locking (TermGlobals.keylock)\r
+        modified Terminal.prototype.redraw for speed (use of locals)\r
+\r
+\r
+v 1.04: modified the key handler to fix a bug with MSIE5/Mac\r
+        fixed a bug in TermGlobals.setVisible with older MSIE-alike browsers without\r
+        DOM support.\r
+        moved the script of the sample parser to an individual document\r
+        => "termlib_parser.js" (HTML document is "parser_sample.html" as before)\r
+\r
+v 1.05: added config flag historyUnique.\r
+\r
+v 1.06: fixed CTRl+ALT (Windows alt gr) isn't CTRL any more\r
+        -> better support for international keyboards with MSIE/Win.\r
+        fixed double backspace bug for Safari;\r
+        added TermGlobals.setDisplay for setting style.display props\r
+        termlib.js now outputs lower case html (xhtml compatibility)\r
+        (date: 12'2006)\r
+\r
+v 1.07: added method Terminal.rebuild() to rebuild the GUI with new color settings.\r
+        (date: 01'2007)\r
+\r
+\r
+\r
+\r
+12  Example for a Command Line Parser\r
+\r
+  // parser example, splits command line to args with quoting and escape\r
+  // for use as `Terminal.handler'\r
+  \r
+  function commandHandler() {\r
+    this.newLine();\r
+    var argv = [''];     // arguments vector\r
+    var argQL = [''];    // quoting level\r
+    var argc = 0;        // arguments cursor\r
+    var escape = false ; // escape flag\r
+    for (var i=0; i<this.lineBuffer.length; i++) {\r
+      var ch= this.lineBuffer.charAt(i);\r
+      if (escape) {\r
+        argv[argc] += ch;\r
+        escape = false;\r
+      }\r
+      else if ((ch == '"') || (ch == "'") || (ch == "`")) {\r
+        if (argQL[argc]) {\r
+          if (argQL[argc] == ch) {\r
+            argc ++;\r
+            argv[argc] = argQL[argc] = '';\r
+          }\r
+          else {\r
+            argv[argc] += ch;\r
+          }\r
+        }\r
+        else {\r
+          if (argv[argc] != '') {\r
+            argc ++;\r
+            argv[argc] = '';\r
+            argQL[argc] = ch;\r
+          }\r
+          else {\r
+            argQL[argc] = ch;\r
+          }\r
+        }\r
+      }\r
+      else if ((ch == ' ') || (ch == '\t')) {\r
+        if (argQL[argc]) {\r
+          argv[argc] += ch;\r
+        }\r
+        else if (argv[argc] != '') {\r
+          argc++;\r
+          argv[argc] = argQL[argc] = '';\r
+        }\r
+      }\r
+      else if (ch == '\\') {\r
+        escape = true;\r
+      }\r
+      else {\r
+        argv[argc] += ch;\r
+      }\r
+    }\r
+    if ((argv[argc] == '') && (!argQL[argc])) {\r
+      argv.length--;\r
+      argQL.length--;\r
+    }\r
+    if (argv.length == 0) {\r
+      // no commmand line input\r
+    }\r
+    else if (argQL[0]) {\r
+      // first argument quoted -> error\r
+      this.write("Error: first argument quoted by "+argQL[0]);\r
+    }\r
+    else {\r
+      argc = 0;\r
+      var cmd = argv[argc++];\r
+      /*\r
+        parse commands\r
+        1st argument is argv[argc]\r
+        arguments' quoting levels in argQL[argc] are of (<empty> | ' | " | `)\r
+      */\r
+      if (cmd == 'help') {\r
+        this.write(helpPage);\r
+      }\r
+      else if (cmd == 'clear') {\r
+        this.clear();\r
+      }\r
+      else if (cmd == 'exit') {\r
+        this.close();\r
+        return;\r
+      }\r
+      else {\r
+        // for test purpose just output argv as list\r
+        // assemple a string of style-escaped lines and output it in more-mode\r
+        s='   ARG  QL  VALUE%n';\r
+        for (var i=0; i<argv.length; i++) {\r
+          s += TermGlobals.stringReplace('%', '%%',\r
+                 TermGlobals.fillLeft(i, 6) +\r
+                 TermGlobals.fillLeft((argQL[i])? argQL[i]:'-', 4) +\r
+                 '  "' + argv[i] + '"'\r
+            ) + '%n';\r
+        }\r
+        this.write(s, 1);\r
+        return;\r
+      }\r
+    }\r
+    this.prompt();\r
+  }\r
+\r
+\r
+The file "parser_sample.html" features a stand-alone parser ("termlib_parser.js") very\r
+much like this. You are free to use it according to the termlib-license (see sect. 13).\r
+It provides configurable values for quotes and esape characters and imports the parsed\r
+argument list into a Terminal instance's namespace. ("parser_sample.html" and\r
+"termlib_parser.js" should accompany this file.)\r
+\r
+\r
+\r
+\r
+13   License\r
+\r
+This JavaScript-library is free for private and academic use.\r
+Please include a readable copyright statement and a backlink to <http://www.masswerk.at>\r
+in the web page. The library should always be accompanied by the 'readme.txt' and the\r
+sample HTML-documents.\r
+\r
+The term "private use" includes any personal or non-commercial use, which is not related\r
+to commercial activites, but excludes intranet, extranet and/or public net applications\r
+that are related to any kind of commercial or profit oriented activity.\r
+\r
+For commercial use see <http://www.masswerk.at> for contact information.\r
+\r
+Any changes to the library should be commented and be documented in the readme-file.\r
+Any changes must be reflected in the `Terminal.version' string as\r
+"Version.Subversion (compatibility)".\r
+\r
+\r
+\r
+\r
+14   Disclaimer\r
+\r
+This software is distributed AS IS and in the hope that it will be useful, but WITHOUT ANY\r
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\r
+PURPOSE. The entire risk as to the quality and performance of the product is borne by the\r
+user. No use of the product is authorized hereunder except under this disclaimer.\r
+\r
+\r
+\r
+\r
+15   References\r
+\r
+[ECMA262-2] "ECMAScript Language Specification" Standard ECMA-262 2nd Edition\r
+            August 1998 (ISO/IEC 16262 - April 1998)\r
+\r
+[ECMA262-3] "ECMAScript Language Specification" Standard ECMA-262 3rd Edition Final\r
+            24 March 2000\r
+\r
+[JS/UIX]     JS/UIX - JavaScript Uniplexed Interface eXtension\r
+             <http://www.masswerk.at/jsuix>\r
+\r
+\r
+\r
+\r
+\r
+Norbert Landsteiner / Vienna, August 2005\r
+mass:werk - media environments\r
+<http://www.masswerk.at>\r
+See web site for contact information.\r
diff --git a/unmaintained/webapps/fjsc/resources/termlib/term_styles.css b/unmaintained/webapps/fjsc/resources/termlib/term_styles.css
new file mode 100644 (file)
index 0000000..4971709
--- /dev/null
@@ -0,0 +1,11 @@
+.term {\r
+       font-family: courier,fixed,swiss,sans-serif;\r
+       font-size: 12px;\r
+       color: #33d011;\r
+       background: none;\r
+}\r
+\r
+.termReverse {\r
+       color: #111111;\r
+       background: #33d011;\r
+}\r
diff --git a/unmaintained/webapps/fjsc/resources/termlib/termlib.js b/unmaintained/webapps/fjsc/resources/termlib/termlib.js
new file mode 100644 (file)
index 0000000..195e11f
--- /dev/null
@@ -0,0 +1,1633 @@
+/*\r
+  termlib.js - JS-WebTerminal Object v1.07\r
+\r
+  (c) Norbert Landsteiner 2003-2005\r
+  mass:werk - media environments\r
+  <http://www.masswerk.at>\r
+\r
+  Creates [multiple] Terminal instances.\r
+\r
+  Synopsis:\r
+\r
+  myTerminal = new Terminal(<config object>);\r
+  myTerminal.open();\r
+\r
+  <config object> overrides any values of object `TerminalDefaults'.\r
+  individual values of `id' must be supplied for multiple terminals.\r
+  `handler' specifies a function to be called for input handling.\r
+  (see `Terminal.prototype.termDefaultHandler()' and documentation.)\r
+\r
+  globals defined in this library:\r
+       Terminal           (Terminal object)\r
+    TerminalDefaults   (default configuration)\r
+    termDefaultHandler (default command line handler)\r
+    TermGlobals        (common vars and code for all instances)\r
+    termKey            (named mappings for special keys)\r
+    termDomKeyRef      (special key mapping for DOM constants)\r
+\r
+  globals defined for fixing String methods, if missing\r
+  (String.fromCharCode, String.prototype.charCodeAt):\r
+    termString_keyref, termString_keycoderef, termString_makeKeyref\r
+\r
+  required CSS classes for font definitions: ".term", ".termReverse".\r
+\r
+  Compatibilty:\r
+  Standard web browsers with a JavaScript implementation compliant to\r
+  ECMA-262 2nd edition and support for the anonymous array and object\r
+  constructs and the anonymous function construct in the form of\r
+  "myfunc=function(x) {}" (c.f. ECMA-262 3rd edion for details).\r
+  This comprises almost all current browsers but Konquerer (khtml) and\r
+  versions of Apple Safari for Mac OS 10.0-10.28 (Safari 1.0) which\r
+  lack support for keyboard events.\r
+\r
+  License:\r
+  This JavaScript-library is free for private and academic use.\r
+  Please include a readable copyright statement and a backlink to\r
+  <http://www.masswerk.at> in the web page.\r
+  The library should always be accompanied by the 'readme.txt' and the\r
+  sample HTML-documents.\r
+  \r
+  The term "private use" includes any personal or non-commercial use, which\r
+  is not related to commercial activites, but excludes intranet, extranet\r
+  and/or public net applications that are related to any kind of commercial\r
+  or profit oriented activity.\r
+\r
+  For commercial use see <http://www.masswerk.at> for contact information.\r
+  \r
+  Any changes should be commented and must be reflected in `Terminal.version'\r
+  in the format: "Version.Subversion (compatibility)".\r
+\r
+  Disclaimer:\r
+  This software is distributed AS IS and in the hope that it will be useful,\r
+  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The entire risk as to\r
+  the quality and performance of the product is borne by the user. No use of\r
+  the product is authorized hereunder except under this disclaimer.\r
+\r
+  ### The sections above must not be removed. ###\r
+  \r
+  version 1.01: added Terminal.prototype.resizeTo(x,y)\r
+                added Terminal.conf.fontClass (=> configureable class name)\r
+                Terminal.prototype.open() now checks for element conf.termDiv\r
+                in advance and returns success.\r
+\r
+  version 1.02: added support for <TAB> and Euro sign\r
+                (Terminal.conf.printTab, Terminal.conf.printEuro)\r
+                and a method to evaluate printable chars:\r
+                Terminal.prototype.isPrintable(keycode)\r
+\r
+  version 1.03: added global keyboard locking (TermGlobals.keylock)\r
+                modified Terminal.prototype.redraw for speed (use of locals)\r
+\r
+  version 1.04: modified the key handler to fix a bug with MSIE5/Mac\r
+                fixed a bug in TermGlobals.setVisible with older MSIE-alike\r
+                browsers without DOM support.\r
+\r
+  version 1.05: added config flag historyUnique.\r
\r
+  version 1.06: fixed CTRl+ALT (Windows alt gr) isn't CTRL any more\r
+                fixed double backspace bug for Safari;\r
+                added TermGlobals.setDisplay for setting style.display props\r
+                termlib.js now outputs lower case html (xhtml compatibility)\r
+\r
+  version 1.07: added method rebuild() to rebuild with new color settings.\r
+\r
+*/\r
+\r
+var TerminalDefaults = {\r
+       // dimensions\r
+       cols:80,\r
+       rows:24,\r
+       // appearance\r
+       x:100,\r
+       y:100,\r
+       termDiv:'termDiv',\r
+       bgColor:'#181818',\r
+       frameColor:'#555555',\r
+       frameWidth:1,\r
+       rowHeight:15,\r
+       blinkDelay:500,\r
+       // css class\r
+       fontClass:'term',\r
+       // initial cursor mode\r
+       crsrBlinkMode:false,\r
+       crsrBlockMode:true,\r
+       // key mapping\r
+       DELisBS:false,\r
+       printTab:true,\r
+       printEuro:true,\r
+       catchCtrlH:true,\r
+       closeOnESC:true,\r
+       // prevent consecutive history doublets\r
+       historyUnique:false,\r
+       // optional id\r
+       id:0,\r
+       // strings\r
+       ps:'>',\r
+       greeting:'%+r Terminal ready. %-r',\r
+       // handlers\r
+       handler:termDefaultHandler,\r
+       ctrlHandler:null,\r
+       initHandler:null,\r
+       exitHandler:null\r
+}\r
+\r
+var Terminal = function(conf) {\r
+       if (typeof conf != 'object') conf=new Object();\r
+       else {\r
+               for (var i in TerminalDefaults) {\r
+                       if (typeof conf[i] == 'undefined') conf[i]=TerminalDefaults[i];\r
+               }\r
+       }\r
+       this.conf=conf;\r
+       this.version='1.07 (original)';\r
+       this.isSafari= (navigator.userAgent.indexOf('Safari')>=0)? true:false;\r
+       this.setInitValues();\r
+}\r
+\r
+Terminal.prototype.setInitValues=function() {\r
+       this.id=this.conf.id;\r
+       this.maxLines=this.conf.rows;\r
+       this.maxCols=this.conf.cols;\r
+       this.termDiv=this.conf.termDiv;\r
+       this.crsrBlinkMode=this.conf.crsrBlinkMode;\r
+       this.crsrBlockMode=this.conf.crsrBlockMode;\r
+       this.blinkDelay=this.conf.blinkDelay;\r
+       this.DELisBS=this.conf.DELisBS;\r
+       this.printTab=this.conf.printTab;\r
+       this.printEuro=this.conf.printEuro;\r
+       this.catchCtrlH=this.conf.catchCtrlH;\r
+       this.closeOnESC=this.conf.closeOnESC;\r
+       this.historyUnique=this.conf.historyUnique;\r
+       this.ps=this.conf.ps;\r
+       this.closed=false;\r
+       this.r;\r
+       this.c;\r
+       this.charBuf=new Array();\r
+       this.styleBuf=new Array();\r
+       this.scrollBuf=null;\r
+       this.blinkBuffer=0;\r
+       this.blinkTimer;\r
+       this.cursoractive=false;\r
+       this.lock=true;\r
+       this.insert=false;\r
+       this.charMode=false;\r
+       this.rawMode=false;\r
+       this.lineBuffer='';\r
+       this.inputChar=0;\r
+       this.lastLine='';\r
+       this.guiCounter=0;\r
+       this.history=new Array();\r
+       this.histPtr=0;\r
+       this.env=new Object();\r
+       this.ns4ParentDoc=null;\r
+       this.handler=this.conf.handler;\r
+       this.ctrlHandler=this.conf.ctrlHandler;\r
+       this.initHandler=this.conf.initHandler;\r
+       this.exitHandler=this.conf.exitHandler;\r
+}\r
+\r
+function termDefaultHandler() {\r
+       this.newLine();\r
+       if (this.lineBuffer != '') {\r
+               this.type('You typed: '+this.lineBuffer);\r
+               this.newLine();\r
+       }\r
+       this.prompt();\r
+}\r
+\r
+Terminal.prototype.open=function() {\r
+       if (this.termDivReady()) {\r
+               if (!this.closed) this._makeTerm();\r
+               this.init();\r
+               return true;\r
+       }\r
+       else return false;\r
+}\r
+\r
+Terminal.prototype.close=function() {\r
+       this.lock=true;\r
+       this.cursorOff();\r
+       if (this.exitHandler) this.exitHandler();\r
+       TermGlobals.setVisible(this.termDiv,0);\r
+       this.closed=true;\r
+}\r
+\r
+Terminal.prototype.init=function() {\r
+       // wait for gui\r
+       if (this.guiReady()) {\r
+               this.guiCounter=0;\r
+               // clean up at re-entry\r
+               if (this.closed) {\r
+                       this.setInitValues();\r
+               }\r
+               this.clear();\r
+               TermGlobals.setVisible(this.termDiv,1);\r
+               TermGlobals.enableKeyboard(this);\r
+               if (this.initHandler) {\r
+                       this.initHandler();\r
+               }\r
+               else {\r
+                       this.write(this.conf.greeting);\r
+                       this.newLine();\r
+                       this.prompt();\r
+               }\r
+       }\r
+       else {\r
+               this.guiCounter++;\r
+               if (this.guiCounter>18000) {\r
+                       if (confirm('Terminal:\nYour browser hasn\'t responded for more than 2 minutes.\nRetry?')) this.guiCounter=0\r
+                       else return;\r
+               };\r
+               TermGlobals.termToInitialze=this;\r
+               window.setTimeout('TermGlobals.termToInitialze.init()',200);\r
+       }\r
+}\r
+\r
+Terminal.prototype.getRowArray=function(l,v) {\r
+       var a=new Array();\r
+       for (var i=0; i<l; i++) a[i]=v;\r
+       return a;\r
+}\r
+\r
+Terminal.prototype.type=function(text,style) {\r
+       for (var i=0; i<text.length; i++) {\r
+               var ch=text.charCodeAt(i);\r
+               if (!this.isPrintable(ch)) ch=94;\r
+               this.charBuf[this.r][this.c]=ch;\r
+               this.styleBuf[this.r][this.c]=(style)? style:0;\r
+               var last_r=this.r;\r
+               this._incCol();\r
+               if (this.r!=last_r) this.redraw(last_r);\r
+       }\r
+       this.redraw(this.r)\r
+}\r
+\r
+Terminal.prototype.write=function(text,usemore) {\r
+       // write to scroll buffer with markup\r
+       // new line = '%n' prepare any strings or arrys first\r
+       if (typeof text != 'object') {\r
+               if (typeof text!='string') text=''+text;\r
+               if (text.indexOf('\n')>=0) {\r
+                       var ta=text.split('\n');\r
+                       text=ta.join('%n');\r
+               }\r
+       }\r
+       else {\r
+               if (text.join) text=text.join('%n')\r
+               else text=''+text;\r
+       }\r
+       this._sbInit(usemore);\r
+       var chunks=text.split('%');\r
+       var esc=(text.charAt(0)!='%');\r
+       var style=0;\r
+       for (var i=0; i<chunks.length; i++) {\r
+               if (esc) {\r
+                       if (chunks[i].length>0) this._sbType(chunks[i],style)\r
+                       else if (i>0) this._sbType('%', style);\r
+                       esc=false;\r
+               }\r
+               else {\r
+                       var func=chunks[i].charAt(0);\r
+                       if ((chunks[i].length==0) && (i>0)) {\r
+                               this._sbType("%",style);\r
+                               esc=true;\r
+                       }\r
+                       else if (func=='n') {\r
+                               this._sbNewLine();\r
+                               if (chunks[i].length>1) this._sbType(chunks[i].substring(1),style);\r
+                       }\r
+                       else if (func=='+') {\r
+                               var opt=chunks[i].charAt(1);\r
+                               opt=opt.toLowerCase();\r
+                               if (opt=='p') style=0\r
+                               else if (opt=='r') style|=1\r
+                               else if (opt=='u') style|=2\r
+                               else if (opt=='i') style|=4\r
+                               else if (opt=='s') style|=8;\r
+                               if (chunks[i].length>2) this._sbType(chunks[i].substring(2),style);\r
+                       }\r
+                       else if (func=='-') {\r
+                               var opt=chunks[i].charAt(1);\r
+                               opt=opt.toLowerCase();\r
+                               if (opt=='p') style|=0\r
+                               else if (opt=='r') style&=~1\r
+                               else if (opt=='u') style&=~2\r
+                               else if (opt=='i') style&=~4\r
+                               else if (opt=='s') style&=~8;\r
+                               if (chunks[i].length>2) this._sbType(chunks[i].substring(2),style);\r
+                       }\r
+                       else if ((chunks[i].length>1) && (chunks[i].charAt(0)=='C') && (chunks[i].charAt(1)=='S')) {\r
+                               this.clear();\r
+                               this._sbInit();\r
+                               if (chunks[i].length>2) this._sbType(chunks[i].substring(2),style);\r
+                       }\r
+                       else {\r
+                               if (chunks[i].length>0) this._sbType(chunks[i],style);\r
+                       }\r
+               }\r
+       }\r
+       this._sbOut();\r
+}\r
+\r
+Terminal.prototype._sbType=function(text,style) {\r
+       // type to scroll buffer\r
+       var sb=this.scrollBuf;\r
+       for (var i=0; i<text.length; i++) {\r
+               var ch=text.charCodeAt(i);\r
+               if (!this.isPrintable(ch)) ch=94;\r
+               sb.lines[sb.r][sb.c]=ch;\r
+               sb.styles[sb.r][sb.c]=(style)? style:0;\r
+               sb.c++;\r
+               if (sb.c>=this.maxCols) this._sbNewLine();\r
+       }\r
+}\r
+\r
+Terminal.prototype._sbNewLine=function() {\r
+       var sb=this.scrollBuf;\r
+       sb.r++;\r
+       sb.c=0;\r
+       sb.lines[sb.r]=this.getRowArray(this.conf.cols,0);\r
+       sb.styles[sb.r]=this.getRowArray(this.conf.cols,0);\r
+}\r
+\r
+\r
+Terminal.prototype._sbInit=function(usemore) {\r
+       var sb=this.scrollBuf=new Object();\r
+       var sbl=sb.lines=new Array();\r
+       var sbs=sb.styles=new Array();\r
+       sb.more=usemore;\r
+       sb.line=0;\r
+       sb.status=0;\r
+       sb.r=0;\r
+       sb.c=this.c;\r
+       sbl[0]=this.getRowArray(this.conf.cols,0);\r
+       sbs[0]=this.getRowArray(this.conf.cols,0);\r
+       for (var i=0; i<this.c; i++) {\r
+               sbl[0][i]=this.charBuf[this.r][i];\r
+               sbs[0][i]=this.styleBuf[this.r][i];\r
+       }\r
+}\r
+\r
+Terminal.prototype._sbOut=function() {\r
+       var sb=this.scrollBuf;\r
+       var sbl=sb.lines;\r
+       var sbs=sb.styles;\r
+       var tcb=this.charBuf;\r
+       var tsb=this.styleBuf;\r
+       var ml=this.maxLines;\r
+       var buflen=sbl.length;\r
+       if (sb.more) {\r
+               if (sb.status) {\r
+                       if (this.inputChar==TermGlobals.lcMoreKeyAbort) {\r
+                               this.r=ml-1;\r
+                               this.c=0;\r
+                               tcb[this.r]=this.getRowArray(this.maxLines,0);\r
+                               tsb[this.r]=this.getRowArray(this.maxLines,0);\r
+                               this.redraw(this.r);\r
+                               this.handler=sb.handler;\r
+                               this.charMode=false;\r
+                               this.inputChar=0;\r
+                               this.scrollBuf=null;\r
+                               this.prompt();\r
+                               return;\r
+                       }\r
+                       else if (this.inputChar==TermGlobals.lcMoreKeyContinue) {\r
+                               this.clear();\r
+                       }\r
+                       else {\r
+                               return;\r
+                       }\r
+               }\r
+               else {\r
+                       if (this.r>=ml-1) this.clear();\r
+               }\r
+       }\r
+       if (this.r+buflen-sb.line<=ml) {\r
+               for (var i=sb.line; i<buflen; i++) {\r
+                       var r=this.r+i-sb.line;\r
+                       tcb[r]=sbl[i];\r
+                       tsb[r]=sbs[i];\r
+                       this.redraw(r);\r
+               }\r
+               this.r+=sb.r-sb.line;\r
+               this.c=sb.c;\r
+               if (sb.more) {\r
+                       if (sb.status) this.handler=sb.handler;\r
+                       this.charMode=false;\r
+                       this.inputChar=0;\r
+                       this.scrollBuf=null;\r
+                       this.prompt();\r
+                       return;\r
+               }\r
+       }\r
+       else if (sb.more) {\r
+               ml--;\r
+               if (sb.status==0) {\r
+                       sb.handler=this.handler;\r
+                       this.handler=this._sbOut;\r
+                       this.charMode=true;\r
+                       sb.status=1;\r
+               }\r
+               if (this.r) {\r
+                       var ofs=ml-this.r;\r
+                       for (var i=sb.line; i<ofs; i++) {\r
+                               var r=this.r+i-sb.line;\r
+                               tcb[r]=sbl[i];\r
+                               tsb[r]=sbs[i];\r
+                               this.redraw(r);\r
+                       }\r
+               }\r
+               else {\r
+                       var ofs=sb.line+ml;\r
+                       for (var i=sb.line; i<ofs; i++) {\r
+                               var r=this.r+i-sb.line;\r
+                               tcb[r]=sbl[i];\r
+                               tsb[r]=sbs[i];\r
+                               this.redraw(r);\r
+                       }\r
+               }\r
+               sb.line=ofs;\r
+               this.r=ml;\r
+               this.c=0;\r
+               this.type(TermGlobals.lcMorePrompt1, TermGlobals.lcMorePromtp1Style);\r
+               this.type(TermGlobals.lcMorePrompt2, TermGlobals.lcMorePrompt2Style);\r
+               this.lock=false;\r
+               return;\r
+       }\r
+       else if (buflen>=ml) {\r
+               var ofs=buflen-ml;\r
+               for (var i=0; i<ml; i++) {\r
+                       var r=ofs+i;\r
+                       tcb[i]=sbl[r];\r
+                       tsb[i]=sbs[r];\r
+                       this.redraw(i);\r
+               }\r
+               this.r=ml-1;\r
+               this.c=sb.c;\r
+       }\r
+       else {\r
+               var dr=ml-buflen;\r
+               var ofs=this.r-dr;\r
+               for (var i=0; i<dr; i++) {\r
+                       var r=ofs+i;\r
+                       for (var c=0; c<this.maxCols; c++) {\r
+                               tcb[i][c]=tcb[r][c];\r
+                               tsb[i][c]=tsb[r][c];\r
+                       }\r
+                       this.redraw(i);\r
+               }\r
+               for (var i=0; i<buflen; i++) {\r
+                       var r=dr+i;\r
+                       tcb[r]=sbl[i];\r
+                       tsb[r]=sbs[i];\r
+                       this.redraw(r);\r
+               }\r
+               this.r=ml-1;\r
+               this.c=sb.c;\r
+       }\r
+       this.scrollBuf=null;\r
+}\r
+\r
+// basic console output\r
+\r
+Terminal.prototype.typeAt=function(r,c,text,style) {\r
+       var tr1=this.r;\r
+       var tc1=this.c;\r
+       this.cursorSet(r,c);\r
+       for (var i=0; i<text.length; i++) {\r
+               var ch=text.charCodeAt(i);\r
+               if (!this.isPrintable(ch)) ch=94;\r
+               this.charBuf[this.r][this.c]=ch;\r
+               this.styleBuf[this.r][this.c]=(style)? style:0;\r
+               var last_r=this.r;\r
+               this._incCol();\r
+               if (this.r!=last_r) this.redraw(last_r);\r
+       }\r
+       this.redraw(this.r);\r
+       this.r=tr1;\r
+       this.c=tc1;\r
+}\r
+\r
+Terminal.prototype.statusLine = function(text,style,offset) {\r
+       var ch,r;\r
+       style=((style) && (!isNaN(style)))? parseInt(style)&15:0;\r
+       if ((offset) && (offset>0)) r=this.conf.rows-offset\r
+       else r=this.conf.rows-1;\r
+       for (var i=0; i<this.conf.cols; i++) {\r
+               if (i<text.length) {\r
+                       ch=text.charCodeAt(i);\r
+                       if (!this.isPrintable(ch)) ch = 94;\r
+               }\r
+               else ch=0;\r
+               this.charBuf[r][i]=ch;\r
+               this.styleBuf[r][i]=style;\r
+       }\r
+       this.redraw(r);\r
+}\r
+\r
+Terminal.prototype.printRowFromString = function(r,text,style) {\r
+       var ch;\r
+       style=((style) && (!isNaN(style)))? parseInt(style)&15:0;\r
+       if ((r>=0) && (r<this.maxLines)) {\r
+               if (typeof text != 'string') text=''+text;\r
+               for (var i=0; i<this.conf.cols; i++) {\r
+                       if (i<text.length) {\r
+                               ch=text.charCodeAt(i);\r
+                               if (!this.isPrintable(ch)) ch = 94;\r
+                       }\r
+                       else ch=0;\r
+                       this.charBuf[r][i]=ch;\r
+                       this.styleBuf[r][i]=style;\r
+               }\r
+               this.redraw(r);\r
+       }\r
+}\r
+\r
+Terminal.prototype.setChar=function(ch,r,c,style) {\r
+       this.charBuf[r][c]=ch;\r
+       this.styleBuf[this.r][this.c]=(style)? style:0;\r
+       this.redraw(r);\r
+}\r
+\r
+Terminal.prototype._charOut=function(ch, style) {\r
+       this.charBuf[this.r][this.c]=ch;\r
+       this.styleBuf[this.r][this.c]=(style)? style:0;\r
+       this.redraw(this.r);\r
+       this._incCol();\r
+}\r
+\r
+Terminal.prototype._incCol=function() {\r
+       this.c++;\r
+       if (this.c>=this.maxCols) {\r
+               this.c=0;\r
+               this._incRow();\r
+       }\r
+}\r
+\r
+Terminal.prototype._incRow=function() {\r
+       this.r++;\r
+       if (this.r>=this.maxLines) {\r
+               this._scrollLines(0,this.maxLines);\r
+               this.r=this.maxLines-1;\r
+       }\r
+}\r
+\r
+Terminal.prototype._scrollLines=function(start, end) {\r
+       window.status='Scrolling lines ...';\r
+       start++;\r
+       for (var ri=start; ri<end; ri++) {\r
+               var rt=ri-1;\r
+               this.charBuf[rt]=this.charBuf[ri];\r
+               this.styleBuf[rt]=this.styleBuf[ri];\r
+       }\r
+       // clear last line\r
+       var rt=end-1;\r
+       this.charBuf[rt]=this.getRowArray(this.conf.cols,0);\r
+       this.styleBuf[rt]=this.getRowArray(this.conf.cols,0);\r
+       this.redraw(rt);\r
+       for (var r=end-1; r>=start; r--) this.redraw(r-1);\r
+       window.status='';\r
+}\r
+\r
+Terminal.prototype.newLine=function() {\r
+       this.c=0;\r
+       this._incRow();\r
+}\r
+\r
+Terminal.prototype.clear=function() {\r
+       window.status='Clearing display ...';\r
+       this.cursorOff();\r
+       this.insert=false;\r
+       for (var ri=0; ri<this.maxLines; ri++) {\r
+               this.charBuf[ri]=this.getRowArray(this.conf.cols,0);\r
+               this.styleBuf[ri]=this.getRowArray(this.conf.cols,0);\r
+               this.redraw(ri);\r
+       }\r
+       this.r=0;\r
+       this.c=0;\r
+       window.status='';\r
+}\r
+\r
+Terminal.prototype.reset=function() {\r
+       if (this.lock) return;\r
+       this.lock=true;\r
+       this.rawMode=false;\r
+       this.charMode=false;\r
+       this.maxLines=this.conf.rows;\r
+       this.maxCols=this.conf.cols;\r
+       this.lastLine='';\r
+       this.lineBuffer='';\r
+       this.inputChar=0;\r
+       this.clear();\r
+}\r
+\r
+Terminal.prototype.cursorSet=function(r,c) {\r
+       var crsron=this.cursoractive;\r
+       if (crsron) this.cursorOff();\r
+       this.r=r%this.maxLines;\r
+       this.c=c%this.maxCols;\r
+       this._cursorReset(crsron);\r
+}\r
+\r
+Terminal.prototype._cursorReset=function(crsron) {\r
+       if (crsron) this.cursorOn()\r
+       else {\r
+               this.blinkBuffer=this.styleBuf[this.r][this.c];\r
+       }\r
+}\r
+\r
+Terminal.prototype.cursorOn=function() {\r
+       if (this.blinkTimer) clearTimeout(this.blinkTimer);\r
+       this.blinkBuffer=this.styleBuf[this.r][this.c];\r
+       this._cursorBlink();\r
+       this.cursoractive=true;\r
+}\r
+\r
+Terminal.prototype.cursorOff=function() {\r
+       if (this.blinkTimer) clearTimeout(this.blinkTimer);\r
+       if (this.cursoractive) {\r
+               this.styleBuf[this.r][this.c]=this.blinkBuffer;\r
+               this.redraw(this.r);\r
+               this.cursoractive=false;\r
+       }\r
+}\r
+\r
+Terminal.prototype._cursorBlink=function() {\r
+       if (this.blinkTimer) clearTimeout(this.blinkTimer);\r
+       if (this == TermGlobals.activeTerm) {\r
+               if (this.crsrBlockMode) {\r
+                       this.styleBuf[this.r][this.c]=(this.styleBuf[this.r][this.c]&1)?\r
+                               this.styleBuf[this.r][this.c]&254:this.styleBuf[this.r][this.c]|1;\r
+               }\r
+               else {\r
+                       this.styleBuf[this.r][this.c]=(this.styleBuf[this.r][this.c]&2)?\r
+                               this.styleBuf[this.r][this.c]&253:this.styleBuf[this.r][this.c]|2;\r
+               }\r
+               this.redraw(this.r);\r
+       }\r
+       if (this.crsrBlinkMode) this.blinkTimer=setTimeout('TermGlobals.activeTerm._cursorBlink()', this.blinkDelay);\r
+}\r
+\r
+Terminal.prototype.cursorLeft=function() {\r
+       var crsron=this.cursoractive;\r
+       if (crsron) this.cursorOff();\r
+       var r=this.r;\r
+       var c=this.c;\r
+       if (c>0) c--\r
+       else if (r>0) {\r
+               c=this.maxCols-1;\r
+               r--;\r
+       }\r
+       if (this.isPrintable(this.charBuf[r][c])) {\r
+               this.r=r;\r
+               this.c=c;\r
+       }\r
+       this.insert=true;\r
+       this._cursorReset(crsron);\r
+}\r
+\r
+Terminal.prototype.cursorRight=function() {\r
+       var crsron=this.cursoractive;\r
+       if (crsron) this.cursorOff();\r
+       var r=this.r;\r
+       var c=this.c;\r
+       if (c<this.maxCols-1) c++\r
+       else if (r<this.maxLines-1) {\r
+               c=0;\r
+               r++;\r
+       }\r
+       if (!this.isPrintable(this.charBuf[r][c])) {\r
+               this.insert=false;\r
+       }\r
+       if (this.isPrintable(this.charBuf[this.r][this.c])) {\r
+               this.r=r;\r
+               this.c=c;\r
+       }\r
+       this._cursorReset(crsron);\r
+}\r
+\r
+Terminal.prototype.backspace=function() {\r
+       var crsron=this.cursoractive;\r
+       if (crsron) this.cursorOff();\r
+       var r=this.r;\r
+       var c=this.c;\r
+       if (c>0) c--\r
+       else if (r>0) {\r
+               c=this.maxCols-1;\r
+               r--;\r
+       };\r
+       if (this.isPrintable(this.charBuf[r][c])) {\r
+               this._scrollLeft(r, c);\r
+               this.r=r;\r
+               this.c=c;\r
+       };      \r
+       this._cursorReset(crsron);\r
+}\r
+\r
+Terminal.prototype.fwdDelete=function() {\r
+       var crsron=this.cursoractive;\r
+       if (crsron) this.cursorOff();\r
+       if (this.isPrintable(this.charBuf[this.r][this.c])) {\r
+               this._scrollLeft(this.r,this.c);\r
+               if (!this.isPrintable(this.charBuf[this.r][this.c])) this.insert=false;\r
+       }\r
+       this._cursorReset(crsron);\r
+}\r
+\r
+Terminal.prototype.prompt=function() {\r
+       this.lock=true;\r
+       if (this.c>0) this.newLine();\r
+       this.type(this.ps);\r
+       this._charOut(1);\r
+       this.lock=false;\r
+       this.cursorOn();\r
+}\r
+\r
+Terminal.prototype._scrollLeft=function(r,c) {\r
+       var rows=new Array();\r
+       rows[0]=r;\r
+       while (this.isPrintable(this.charBuf[r][c])) {\r
+               var ri=r;\r
+               var ci=c+1;\r
+               if (ci==this.maxCols) {\r
+                       if (ri<this.maxLines-1) {\r
+                               ci=0;\r
+                               ri++;\r
+                               rows[rows.length]=ri;\r
+                       }\r
+                       else {\r
+                               break;\r
+                       }\r
+               }\r
+               this.charBuf[r][c]=this.charBuf[ri][ci];\r
+               this.styleBuf[r][c]=this.styleBuf[ri][ci];\r
+               c=ci;\r
+               r=ri;\r
+       }\r
+       if (this.charBuf[r][c]!=0) this.charBuf[r][c]=0;\r
+       for (var i=0; i<rows.length; i++) this.redraw(rows[i]);\r
+}\r
+\r
+Terminal.prototype._scrollRight=function(r,c) {\r
+       var rows=new Array();\r
+       var end=this._getLineEnd(r,c);\r
+       var ri=end[0];\r
+       var ci=end[1];\r
+       if ((ci==this.maxCols-1) && (ri==this.maxLines-1)) {\r
+               if (r==0) return;\r
+               this._scrollLines(0,this.maxLines);\r
+               this.r--;\r
+               r--;\r
+               ri--;\r
+       }\r
+       rows[r]=1;\r
+       while (this.isPrintable(this.charBuf[ri][ci])) {\r
+               var rt=ri;\r
+               var ct=ci+1;\r
+               if (ct==this.maxCols) {\r
+                       ct=0;\r
+                       rt++;\r
+                       rows[rt]=1;\r
+               }\r
+               this.charBuf[rt][ct]=this.charBuf[ri][ci];\r
+               this.styleBuf[rt][ct]=this.styleBuf[ri][ci];\r
+               if ((ri==r) && (ci==c)) break;\r
+               ci--;\r
+               if (ci<0) {\r
+                       ci=this.maxCols-1;\r
+                       ri--;\r
+                       rows[ri]=1;\r
+               }\r
+       }\r
+       for (var i=r; i<this.maxLines; i++) {\r
+               if (rows[i]) this.redraw(i);\r
+       }\r
+}\r
+\r
+Terminal.prototype._getLineEnd=function(r,c) {\r
+       if (!this.isPrintable(this.charBuf[r][c])) {\r
+               c--;\r
+               if (c<0) {\r
+                       if (r>0) {\r
+                               r--;\r
+                               c=this.maxCols-1;\r
+                       }\r
+                       else {\r
+                               c=0;\r
+                       }\r
+               }\r
+       }\r
+       if (this.isPrintable(this.charBuf[r][c])) {\r
+               while (true) {\r
+                       var ri=r;\r
+                       var ci=c+1;\r
+                       if (ci==this.maxCols) {\r
+                               if (ri<this.maxLines-1) {\r
+                                       ri++;\r
+                                       ci=0;\r
+                               }\r
+                               else {\r
+                                       break;\r
+                               }\r
+                       }\r
+                       if (!this.isPrintable(this.charBuf[ri][ci])) break;\r
+                       c=ci;\r
+                       r=ri;\r
+               }\r
+       }\r
+       return [r,c];\r
+}\r
+\r
+Terminal.prototype._getLineStart=function(r,c) {\r
+       // not used by now, just in case anyone needs this ...\r
+       var ci, ri;\r
+       if (!this.isPrintable(this.charBuf[r][c])) {\r
+               ci=c-1;\r
+               ri=r;\r
+               if (ci<0) {\r
+                       if (ri==0) return [0,0];\r
+                       ci=this.maxCols-1;\r
+                       ri--;\r
+               }\r
+               if (!this.isPrintable(this.charBuf[ri][ci])) return [r,c]\r
+               else {\r
+                       r=ri;\r
+                       c=ci;\r
+               }\r
+       }\r
+       while (true) {\r
+               var ri=r;\r
+               var ci=c-1;\r
+               if (ci<0) {\r
+                       if (ri==0) break;\r
+                       ci=this.maxCols-1;\r
+                       ri--;\r
+               }\r
+               if (!this.isPrintable(this.charBuf[ri][ci])) break;;\r
+               r=ri;\r
+               c=ci;\r
+       }\r
+       return [r,c];\r
+}\r
+\r
+Terminal.prototype._getLine=function() {\r
+       var end=this._getLineEnd(this.r,this.c);\r
+       var r=end[0];\r
+       var c=end[1];\r
+       var line=new Array();\r
+       while (this.isPrintable(this.charBuf[r][c])) {\r
+               line[line.length]=String.fromCharCode(this.charBuf[r][c]);\r
+               if (c>0) c--\r
+               else if (r>0) {\r
+                       c=this.maxCols-1;\r
+                       r--;\r
+               }\r
+               else break;\r
+       }\r
+       line.reverse();\r
+       return line.join('');\r
+}\r
+\r
+Terminal.prototype._clearLine=function() {\r
+       var end=this._getLineEnd(this.r,this.c);\r
+       var r=end[0];\r
+       var c=end[1];\r
+       var line='';\r
+       while (this.isPrintable(this.charBuf[r][c])) {\r
+               this.charBuf[r][c]=0;\r
+               if (c>0) {\r
+                       c--;\r
+               }\r
+               else if (r>0) {\r
+                       this.redraw(r);\r
+                       c=this.maxCols-1;\r
+                       r--;\r
+               }\r
+               else break;\r
+       }\r
+       if (r!=end[0]) this.redraw(r);\r
+       c++;\r
+       this.cursorSet(r,c);\r
+       this.insert=false;\r
+}\r
+\r
+Terminal.prototype.isPrintable=function(ch, unicodePage1only) {\r
+       if ((unicodePage1only) && (ch>255)) {\r
+               return ((ch==termKey.EURO) && (this.printEuro))? true:false;\r
+       }\r
+       return (\r
+               ((ch>=32) && (ch!=termKey.DEL)) ||\r
+               ((this.printTab) && (ch==termKey.TAB))\r
+       );\r
+}\r
+\r
+// keyboard focus\r
+\r
+Terminal.prototype.focus=function() {\r
+       TermGlobals.activeTerm=this;\r
+}\r
+\r
+// global store and functions\r
+\r
+var TermGlobals={\r
+       termToInitialze:null,\r
+       activeTerm:null,\r
+       kbdEnabled:false,\r
+       keylock:false,\r
+       lcMorePrompt1: ' -- MORE -- ',\r
+       lcMorePromtp1Style: 1,\r
+       lcMorePrompt2: ' (Type: space to continue, \'q\' to quit)',\r
+       lcMorePrompt2Style: 0,\r
+       lcMoreKeyAbort: 113,\r
+       lcMoreKeyContinue: 32\r
+};\r
+\r
+// keybard focus\r
+\r
+TermGlobals.setFocus=function(termref) {\r
+       TermGlobals.activeTerm=termref;\r
+}\r
+\r
+// text related\r
+\r
+TermGlobals.normalize=function(n,m) {\r
+       var s=''+n;\r
+       while (s.length<m) s='0'+s;\r
+       return s;\r
+}\r
+\r
+TermGlobals.fillLeft=function(t,n) {\r
+       if (typeof t != 'string') t=''+t;\r
+       while (t.length<n) t=' '+t;\r
+       return t;\r
+}\r
+\r
+TermGlobals.center=function(t,l) {\r
+       var s='';\r
+       for (var i=t.length; i<l; i+=2) s+=' ';\r
+       return s+t;\r
+}\r
+\r
+TermGlobals.stringReplace=function(s1,s2,t) {\r
+       var l1=s1.length;\r
+       var l2=s2.length;\r
+       var ofs=t.indexOf(s1);\r
+       while (ofs>=0) {\r
+               t=t.substring(0,ofs)+s2+t.substring(ofs+l1);\r
+               ofs=t.indexOf(s1,ofs+l2);\r
+       }\r
+       return t;\r
+}\r
+\r
+// keyboard\r
+\r
+var termKey= {\r
+       // special key codes\r
+       'NUL': 0x00,\r
+       'SOH': 0x01,\r
+       'STX': 0x02,\r
+       'ETX': 0x03,\r
+       'EOT': 0x04,\r
+       'ENQ': 0x05,\r
+       'ACK': 0x06,\r
+       'BEL': 0x07,\r
+       'BS': 0x08,\r
+       'HT': 0x09,\r
+       'TAB': 0x09,\r
+       'LF': 0x0A,\r
+       'VT': 0x0B,\r
+       'FF': 0x0C,\r
+       'CR': 0x0D,\r
+       'SO': 0x0E,\r
+       'SI': 0x0F,\r
+       'DLE': 0x10,\r
+       'DC1': 0x11,\r
+       'DC2': 0x12,\r
+       'DC3': 0x13,\r
+       'DC4': 0x14,\r
+       'NAK': 0x15,\r
+       'SYN': 0x16,\r
+       'ETB': 0x17,\r
+       'CAN': 0x18,\r
+       'EM': 0x19,\r
+       'SUB': 0x1A,\r
+       'ESC': 0x1B,\r
+       'IS4': 0x1C,\r
+       'IS3': 0x1D,\r
+       'IS2': 0x1E,\r
+       'IS1': 0x1F,\r
+       'DEL': 0x7F,\r
+       // other specials\r
+       'EURO': 0x20AC,\r
+       // cursor mapping\r
+       'LEFT': 0x1C,\r
+       'RIGHT': 0x1D,\r
+       'UP': 0x1E,\r
+       'DOWN': 0x1F\r
+};\r
+\r
+var termDomKeyRef = {\r
+       DOM_VK_LEFT: termKey.LEFT,\r
+       DOM_VK_RIGHT: termKey.RIGHT,\r
+       DOM_VK_UP: termKey.UP,\r
+       DOM_VK_DOWN: termKey.DOWN,\r
+       DOM_VK_BACK_SPACE: termKey.BS,\r
+       DOM_VK_RETURN: termKey.CR,\r
+       DOM_VK_ENTER: termKey.CR,\r
+       DOM_VK_ESCAPE: termKey.ESC,\r
+       DOM_VK_DELETE: termKey.DEL,\r
+       DOM_VK_TAB: termKey.TAB\r
+};\r
+\r
+TermGlobals.enableKeyboard=function(term) {\r
+       if (!this.kbdEnabled) {\r
+               if (document.addEventListener) document.addEventListener("keypress", this.keyHandler, true)\r
+               else {\r
+                       if ((self.Event) && (self.Event.KEYPRESS)) document.captureEvents(Event.KEYPRESS);\r
+                       document.onkeypress = this.keyHandler;\r
+               }\r
+               window.document.onkeydown=this.keyFix;\r
+               this.kbdEnabled=true;\r
+       }\r
+       this.activeTerm=term;\r
+}\r
+\r
+TermGlobals.keyFix=function(e) {\r
+       var term=TermGlobals.activeTerm;\r
+       if ((TermGlobals.keylock) || (term.lock)) return true;\r
+       if (window.event) {\r
+               var ch=window.event.keyCode;\r
+               if  (!e) e=window.event;\r
+               if (e.DOM_VK_UP) {\r
+                       for (var i in termDomKeyRef) {\r
+                               if ((e[i]) && (ch == e[i])) {\r
+                                       this.keyHandler({which:termDomKeyRef[i],_remapped:true});\r
+                                       if (e.preventDefault) e.preventDefault();\r
+                                       if (e.stopPropagation) e.stopPropagation();\r
+                                       e.cancleBubble=true;\r
+                                       return false;\r
+                               }\r
+                       }\r
+                       e.cancleBubble=false;\r
+                       return true;\r
+               }\r
+               else {\r
+                       // no DOM support\r
+                       if ((ch==8) && (!term.isSafari)) TermGlobals.keyHandler({which:termKey.BS,_remapped:true})\r
+                       else if (ch==9) TermGlobals.keyHandler({which:termKey.TAB,_remapped:true})\r
+                       else if (ch==37) TermGlobals.keyHandler({which:termKey.LEFT,_remapped:true})\r
+                       else if (ch==39) TermGlobals.keyHandler({which:termKey.RIGHT,_remapped:true})\r
+                       else if (ch==38) TermGlobals.keyHandler({which:termKey.UP,_remapped:true})\r
+                       else if (ch==40) TermGlobals.keyHandler({which:termKey.DOWN,_remapped:true})\r
+                       else if (ch==127) TermGlobals.keyHandler({which:termKey.DEL,_remapped:true})\r
+                       else if ((ch>=57373) && (ch<=57376)) {\r
+                               if (ch==57373) TermGlobals.keyHandler({which:termKey.UP,_remapped:true})\r
+                               else if (ch==57374) TermGlobals.keyHandler({which:termKey.DOWN,_remapped:true})\r
+                               else if (ch==57375) TermGlobals.keyHandler({which:termKey.LEFT,_remapped:true})\r
+                               else if (ch==57376) TermGlobals.keyHandler({which:termKey.RIGHT,_remapped:true});\r
+                       }\r
+                       else {\r
+                               e.cancleBubble=false;\r
+                               return true;\r
+                       }\r
+                       if (e.preventDefault) e.preventDefault();\r
+                       if (e.stopPropagation) e.stopPropagation();\r
+                       e.cancleBubble=true;\r
+                       return false;\r
+               }\r
+       }\r
+}\r
+\r
+TermGlobals.keyHandler=function(e) {\r
+       var term=TermGlobals.activeTerm;\r
+       if ((TermGlobals.keylock) || (term.lock)) return true;\r
+       if ((window.event) && (window.event.preventDefault)) window.event.preventDefault()\r
+       else if ((e) && (e.preventDefault)) e.preventDefault();\r
+       if ((window.event) && (window.event.stopPropagation)) window.event.stopPropagation()\r
+       else if ((e) && (e.stopPropagation)) e.stopPropagation();\r
+       var ch;\r
+       var ctrl=false;\r
+       var shft=false;\r
+       var remapped=false;\r
+       if (e) {\r
+               ch=e.which;\r
+               ctrl=(((e.ctrlKey) && (e.altKey)) || (e.modifiers==2));\r
+               shft=((e.shiftKey) || (e.modifiers==4));\r
+               if (e._remapped) {\r
+                       remapped=true;\r
+                       if (window.event) {\r
+                               //ctrl=((ctrl) || (window.event.ctrlKey));\r
+                               ctrl=((ctrl) || ((window.event.ctrlKey) && (!window.event.altKey)));\r
+                               shft=((shft) || (window.event.shiftKey));\r
+                       }\r
+               }\r
+       }\r
+       else if (window.event) {\r
+               ch=window.event.keyCode;\r
+               //ctrl=(window.event.ctrlKey);\r
+               ctrl=((window.event.ctrlKey) && (!window.event.altKey)); // allow alt gr == ctrl alts\r
+               shft=(window.event.shiftKey);\r
+       }\r
+       else {\r
+               return true;\r
+       }\r
+       if ((ch=='') && (remapped==false)) {\r
+               // map specials\r
+               if (e==null) e=window.event;\r
+               if ((e.charCode==0) && (e.keyCode)) {\r
+                       if (e.DOM_VK_UP) {\r
+                               for (var i in termDomKeyRef) {\r
+                                       if ((e[i]) && (e.keyCode == e[i])) {\r
+                                               ch=termDomKeyRef[i];\r
+                                               break;\r
+                                       }\r
+                               }\r
+                       }\r
+                       else {\r
+                               // NS4\r
+                               if (e.keyCode==28) ch=termKey.LEFT\r
+                               else if (e.keyCode==29) ch=termKey.RIGHT\r
+                               else if (e.keyCode==30) ch=termKey.UP\r
+                               else if (e.keyCode==31) ch=termKey.DOWN\r
+                               // Mozilla alike but no DOM support\r
+                               else if (e.keyCode==37) ch=termKey.LEFT\r
+                               else if (e.keyCode==39) ch=termKey.RIGHT\r
+                               else if (e.keyCode==38) ch=termKey.UP\r
+                               else if (e.keyCode==40) ch=termKey.DOWN\r
+                               // just to have the TAB mapping here too\r
+                               else if (e.keyCode==9) ch=termKey.TAB;\r
+                       }\r
+               }\r
+       }\r
+       // key actions\r
+       if (term.charMode) {\r
+               term.insert=false;\r
+               term.inputChar=ch;\r
+               term.lineBuffer='';\r
+               term.handler();\r
+               if ((ch<=32) && (window.event)) window.event.cancleBubble=true;\r
+               return false;\r
+       }\r
+       if (!ctrl) {\r
+               // special keys\r
+               if (ch==termKey.CR) {\r
+                       term.lock=true;\r
+                       term.cursorOff();\r
+                       term.insert=false;\r
+                       if (term.rawMode) {\r
+                               term.lineBuffer=term.lastLine;\r
+                       }\r
+                       else {\r
+                               term.lineBuffer=term._getLine();\r
+                               if (\r
+                                   (term.lineBuffer!='') && ((!term.historyUnique) ||\r
+                                   (term.history.length==0) ||\r
+                                   (term.lineBuffer!=term.history[term.history.length-1]))\r
+                                  ) {\r
+                                       term.history[term.history.length]=term.lineBuffer;\r
+                               }\r
+                               term.histPtr=term.history.length;\r
+                       }\r
+                       term.lastLine='';\r
+                       term.inputChar=0;\r
+                       term.handler();\r
+                       if (window.event) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+               else if (ch==termKey.ESC) {\r
+                       if (term.conf.closeOnESC) term.close();\r
+                       if (window.event) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+               if ((ch<32) && (term.rawMode)) {\r
+                       if (window.event) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+               else {\r
+                       if (ch==termKey.LEFT) {\r
+                               term.cursorLeft();\r
+                               if (window.event) window.event.cancleBubble=true;\r
+                               return false;\r
+                       }\r
+                       else if (ch==termKey.RIGHT) {\r
+                               term.cursorRight();\r
+                               if (window.event) window.event.cancleBubble=true;\r
+                               return false;\r
+                       }\r
+                       else if (ch==termKey.UP) {\r
+                               term.cursorOff();\r
+                               if (term.histPtr==term.history.length) term.lastLine=term._getLine();\r
+                               term._clearLine();\r
+                               if ((term.history.length) && (term.histPtr>=0)) {\r
+                                       if (term.histPtr>0) term.histPtr--;\r
+                                       term.type(term.history[term.histPtr]);\r
+                               }\r
+                               else if (term.lastLine) term.type(term.lastLine);\r
+                               term.cursorOn();\r
+                               if (window.event) window.event.cancleBubble=true;\r
+                               return false;\r
+                       }\r
+                       else if (ch==termKey.DOWN) {\r
+                               term.cursorOff();\r
+                               if (term.histPtr==term.history.length) term.lastLine=term._getLine();\r
+                               term._clearLine();\r
+                               if ((term.history.length) && (term.histPtr<=term.history.length)) {\r
+                                       if (term.histPtr<term.history.length) term.histPtr++;\r
+                                       if (term.histPtr<term.history.length) term.type(term.history[term.histPtr])\r
+                                       else if (term.lastLine) term.type(term.lastLine);\r
+                               }\r
+                               else if (term.lastLine) term.type(term.lastLine);\r
+                               term.cursorOn();\r
+                               if (window.event) window.event.cancleBubble=true;\r
+                               return false;\r
+                       }\r
+                       else if (ch==termKey.BS) {\r
+                               term.backspace();\r
+                               if (window.event) window.event.cancleBubble=true;\r
+                               return false;\r
+                       }\r
+                       else if (ch==termKey.DEL) {\r
+                               if (term.DELisBS) term.backspace()\r
+                               else term.fwdDelete();\r
+                               if (window.event) window.event.cancleBubble=true;\r
+                               return false;\r
+                       }\r
+               }\r
+       }\r
+       if (term.rawMode) {\r
+               if (term.isPrintable(ch)) {\r
+                       term.lastLine+=String.fromCharCode(ch);\r
+               }\r
+               if ((ch==32) && (window.event)) window.event.cancleBubble=true\r
+               else if ((window.opera) && (window.event)) window.event.cancleBubble=true;\r
+               return false;\r
+       }\r
+       else {\r
+               if ((term.conf.catchCtrlH) && ((ch==termKey.BS) || ((ctrl) && (ch==72)))) {\r
+                       // catch ^H\r
+                       term.backspace();\r
+                       if (window.event) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+               else if ((term.ctrlHandler) && ((ch<32) || ((ctrl) && (term.isPrintable(ch,true))))) {\r
+                       if (((ch>=65) && (ch<=96)) || (ch==63)) {\r
+                               // remap canonical\r
+                               if (ch==63) ch=31\r
+                               else ch-=64;\r
+                       }\r
+                       term.inputChar=ch;\r
+                       term.ctrlHandler();\r
+                       if (window.event) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+               else if ((ctrl) || (!term.isPrintable(ch,true))) {\r
+                       if (window.event) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+               else if (term.isPrintable(ch,true)) {\r
+                       if (term.blinkTimer) clearTimeout(term.blinkTimer);\r
+                       if (term.insert) {\r
+                               term.cursorOff();\r
+                               term._scrollRight(term.r,term.c);\r
+                       }\r
+                       term._charOut(ch);\r
+                       term.cursorOn();\r
+                       if ((ch==32) && (window.event)) window.event.cancleBubble=true\r
+                       else if ((window.opera) && (window.event)) window.event.cancleBubble=true;\r
+                       return false;\r
+               }\r
+       }\r
+       return true;\r
+}\r
+\r
+// term gui\r
+\r
+TermGlobals.hasSubDivs=false;\r
+TermGlobals.hasLayers=false;\r
+TermGlobals.termStringStart='';\r
+TermGlobals.termStringEnd='';\r
+\r
+TermGlobals.termSpecials=new Array();\r
+TermGlobals.termSpecials[0]='&nbsp;';\r
+TermGlobals.termSpecials[1]='&nbsp;';\r
+TermGlobals.termSpecials[9]='&nbsp;';\r
+TermGlobals.termSpecials[32]='&nbsp;';\r
+TermGlobals.termSpecials[34]='&quot;';\r
+TermGlobals.termSpecials[38]='&amp;';\r
+TermGlobals.termSpecials[60]='&lt;';\r
+TermGlobals.termSpecials[62]='&gt;';\r
+TermGlobals.termSpecials[127]='&loz;';\r
+TermGlobals.termSpecials[0x20AC]='&euro;';\r
+\r
+TermGlobals.termStyles=new Array(1,2,4,8);\r
+TermGlobals.termStyleOpen=new Array();\r
+TermGlobals.termStyleClose=new Array();\r
+TermGlobals.termStyleOpen[1]='<span class="termReverse">';\r
+TermGlobals.termStyleClose[1]='<\/span>';\r
+TermGlobals.termStyleOpen[2]='<u>';\r
+TermGlobals.termStyleClose[2]='<\/u>';\r
+TermGlobals.termStyleOpen[4]='<i>';\r
+TermGlobals.termStyleClose[4]='<\/i>';\r
+TermGlobals.termStyleOpen[8]='<strike>';\r
+TermGlobals.termStyleClose[8]='<\/strike>';\r
+\r
+Terminal.prototype._makeTerm=function(rebuild) {\r
+       window.status='Building terminal ...';\r
+       TermGlobals.hasLayers=(document.layers)? true:false;\r
+       TermGlobals.hasSubDivs=(navigator.userAgent.indexOf('Gecko')<0);\r
+       var divPrefix=this.termDiv+'_r';\r
+       var s='';\r
+       s+='<table border="0" cellspacing="0" cellpadding="'+this.conf.frameWidth+'">\n';\r
+       s+='<tr><td bgcolor="'+this.conf.frameColor+'"><table border="0" cellspacing="0" cellpadding="2"><tr><td  bgcolor="'+this.conf.bgColor+'"><table border="0" cellspacing="0" cellpadding="0">\n';\r
+       var rstr='';\r
+       for (var c=0; c<this.conf.cols; c++) rstr+='&nbsp;';\r
+       for (var r=0; r<this.conf.rows; r++) {\r
+               var termid=((TermGlobals.hasLayers) || (TermGlobals.hasSubDivs))? '' : ' id="'+divPrefix+r+'"';\r
+               s+='<tr><td nowrap height="'+this.conf.rowHeight+'"'+termid+' class="'+this.conf.fontClass+'">'+rstr+'<\/td><\/tr>\n';\r
+       }\r
+       s+='<\/table><\/td><\/tr>\n';\r
+       s+='<\/table><\/td><\/tr>\n';\r
+       s+='<\/table>\n';\r
+       var termOffset=2+this.conf.frameWidth;\r
+       if (TermGlobals.hasLayers) {\r
+               for (var r=0; r<this.conf.rows; r++) {\r
+                       s+='<layer name="'+divPrefix+r+'" top="'+(termOffset+r*this.conf.rowHeight)+'" left="'+termOffset+'" class="'+this.conf.fontClass+'"><\/layer>\n';\r
+               }\r
+               this.ns4ParentDoc=document.layers[this.termDiv].document;\r
+               TermGlobals.termStringStart='<table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap height="'+this.conf.rowHeight+'" class="'+this.conf.fontClass+'">';\r
+               TermGlobals.termStringEnd='<\/td><\/tr><\/table>';\r
+       }\r
+       else if (TermGlobals.hasSubDivs) {\r
+               for (var r=0; r<this.conf.rows; r++) {\r
+                       s+='<div id="'+divPrefix+r+'" style="position:absolute; top:'+(termOffset+r*this.conf.rowHeight)+'px; left: '+termOffset+'px;" class="'+this.conf.fontClass+'"><\/div>\n';\r
+               }\r
+               TermGlobals.termStringStart='<table border="0" cellspacing="0" cellpadding="0"><tr><td nowrap height="'+this.conf.rowHeight+'" class="'+this.conf.fontClass+'">';\r
+               TermGlobals.termStringEnd='<\/td><\/tr><\/table>';\r
+       }\r
+       TermGlobals.writeElement(this.termDiv,s);\r
+       if (!rebuild) {\r
+               TermGlobals.setElementXY(this.termDiv,this.conf.x,this.conf.y);\r
+               TermGlobals.setVisible(this.termDiv,1);\r
+       }\r
+       window.status='';\r
+}\r
+\r
+Terminal.prototype.rebuild=function() {\r
+       // check for bounds and array lengths\r
+       var rl=this.conf.rows;\r
+       var cl=this.conf.cols;\r
+       for (var r=0; r<rl; r++) {\r
+               var cbr=this.charBuf[r];\r
+               if (!cbr) {\r
+                       this.charBuf[r]=this.getRowArray(cl,0);\r
+                       this.styleBuf[r]=this.getRowArray(cl,0);\r
+               }\r
+               else if (cbr.length<cl) {\r
+                       for (var c=cbr.length; c<cl; c++) {\r
+                               this.charBuf[r][c]=0;\r
+                               this.styleBuf[r][c]=0;\r
+                       }\r
+               }\r
+       }\r
+       var resetcrsr=false;\r
+       if (this.r>=rl) {\r
+               r=rl-1;\r
+               resetcrsr=true;\r
+       }\r
+       if (this.c>=cl) {\r
+               c=cl-1;\r
+               resetcrsr=true;\r
+       }\r
+       if ((resetcrsr) && (this.cursoractive)) this.cursorOn();\r
+       // and actually rebuild\r
+       this._makeTerm(true);\r
+       for (var r=0; r<rl; r++) {\r
+               this.redraw(r);\r
+       }\r
+}\r
+\r
+Terminal.prototype.moveTo=function(x,y) {\r
+       TermGlobals.setElementXY(this.termDiv,x,y);\r
+}\r
+\r
+Terminal.prototype.resizeTo=function(x,y) {\r
+       if (this.termDivReady()) {\r
+               x=parseInt(x,10);\r
+               y=parseInt(y,10);\r
+               if ((isNaN(x)) || (isNaN(y)) || (x<4) || (y<2)) return false;\r
+               this.maxCols=this.conf.cols=x;\r
+               this.maxLines=this.conf.rows=y;\r
+               this._makeTerm();\r
+               this.clear();\r
+               return true;\r
+       }\r
+       else return false;\r
+}\r
+\r
+Terminal.prototype.redraw=function(r) {\r
+       var s=TermGlobals.termStringStart;\r
+       var curStyle=0;\r
+       var tstls=TermGlobals.termStyles;\r
+       var tscls=TermGlobals.termStyleClose;\r
+       var tsopn=TermGlobals.termStyleOpen;\r
+       var tspcl=TermGlobals.termSpecials;\r
+       var t_cb=this.charBuf;\r
+       var t_sb=this.styleBuf;\r
+       for (var i=0; i<this.conf.cols; i++) {\r
+               var c=t_cb[r][i];\r
+               var cs=t_sb[r][i];\r
+               if (cs!=curStyle) {\r
+                       if (curStyle) {\r
+                               for (var k=tstls.length-1; k>=0; k--) {\r
+                                       var st=tstls[k];\r
+                                       if (curStyle&st) s+=tscls[st];\r
+                               }\r
+                       }\r
+                       curStyle=cs;\r
+                       for (var k=0; k<tstls.length; k++) {\r
+                               var st=tstls[k];\r
+                               if (curStyle&st) s+=tsopn[st];\r
+                       }\r
+               }\r
+               s+= (tspcl[c])? tspcl[c] : String.fromCharCode(c);\r
+       }\r
+       if (curStyle>0) {\r
+               for (var k=tstls.length-1; k>=0; k--) {\r
+                       var st=tstls[k];\r
+                       if (curStyle&st) s+=tscls[st];\r
+               }\r
+       }\r
+       s+=TermGlobals.termStringEnd;\r
+       TermGlobals.writeElement(this.termDiv+'_r'+r,s,this.ns4ParentDoc);\r
+}\r
+\r
+Terminal.prototype.guiReady=function() {\r
+       ready=true;\r
+       if (TermGlobals.guiElementsReady(this.termDiv, self.document)) {\r
+               for (var r=0; r<this.conf.rows; r++) {\r
+                       if (TermGlobals.guiElementsReady(this.termDiv+'_r'+r,this.ns4ParentDoc)==false) {\r
+                               ready=false;\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+       else ready=false;\r
+       return ready;\r
+}\r
+\r
+Terminal.prototype.termDivReady=function() {\r
+       if (document.layers) {\r
+               return (document.layers[this.termDiv])? true:false;\r
+       }\r
+       else if (document.getElementById) {\r
+               return (document.getElementById(this.termDiv))? true:false;\r
+       }\r
+       else if (document.all) {\r
+               return (document.all[this.termDiv])? true:false;\r
+       }\r
+       else {\r
+               return false;\r
+       }\r
+}\r
+\r
+Terminal.prototype.getDimensions=function() {\r
+       var w=0;\r
+       var h=0;\r
+       var d=this.termDiv;\r
+       if (document.layers) {\r
+               if (document.layers[d]) {\r
+                       w=document.layers[d].clip.right;\r
+                       h=document.layers[d].clip.bottom;\r
+               }\r
+       }\r
+       else if (document.getElementById) {\r
+               var obj=document.getElementById(d);\r
+               if ((obj) && (obj.firstChild)) {\r
+                       w=parseInt(obj.firstChild.offsetWidth,10);\r
+                       h=parseInt(obj.firstChild.offsetHeight,10);\r
+        }\r
+               else if ((obj) && (obj.children) && (obj.children[0])) {\r
+                       w=parseInt(obj.children[0].offsetWidth,10);\r
+                       h=parseInt(obj.children[0].offsetHeight,10);\r
+        }\r
+       }\r
+       else if (document.all) {\r
+               var obj=document.all[d];\r
+               if ((obj) && (obj.children) && (obj.children[0])) {\r
+                       w=parseInt(obj.children[0].offsetWidth,10);\r
+                       h=parseInt(obj.children[0].offsetHeight,10);\r
+        }\r
+       }\r
+       return { width: w, height: h };\r
+}\r
+\r
+// basic dynamics\r
+\r
+TermGlobals.writeElement=function(e,t,d) {\r
+       if (document.layers) {\r
+               var doc=(d)? d : self.document;\r
+               doc.layers[e].document.open();\r
+               doc.layers[e].document.write(t);\r
+               doc.layers[e].document.close();\r
+       }\r
+       else if (document.getElementById) {\r
+               var obj=document.getElementById(e);\r
+               obj.innerHTML=t;\r
+       }\r
+       else if (document.all) {\r
+               document.all[e].innerHTML=t;\r
+       }\r
+}\r
+\r
+TermGlobals.setElementXY=function(d,x,y) {\r
+       if (document.layers) {\r
+               document.layers[d].moveTo(x,y);\r
+       }\r
+       else if (document.getElementById) {\r
+               var obj=document.getElementById(d);\r
+               obj.style.left=x+'px';\r
+               obj.style.top=y+'px';\r
+       }\r
+       else if (document.all) {\r
+               document.all[d].style.left=x+'px';\r
+               document.all[d].style.top=y+'px';\r
+       }\r
+}\r
+\r
+TermGlobals.setVisible=function(d,v) {\r
+       if (document.layers) {\r
+               document.layers[d].visibility= (v)? 'show':'hide';\r
+       }\r
+       else if (document.getElementById) {\r
+               var obj=document.getElementById(d);\r
+               obj.style.visibility= (v)? 'visible':'hidden';\r
+       }\r
+       else if (document.all) {\r
+               document.all[d].style.visibility= (v)? 'visible':'hidden';\r
+       }\r
+}\r
+\r
+TermGlobals.setDisplay=function(d,v) {\r
+       if (document.getElementById) {\r
+               var obj=document.getElementById(d);\r
+               obj.style.display=v;\r
+       }\r
+       else if (document.all) {\r
+               document.all[d].style.display=v;\r
+       }\r
+}\r
+\r
+TermGlobals.guiElementsReady=function(e,d) {\r
+       if (document.layers) {\r
+               var doc=(d)? d : self.document;\r
+               return ((doc) && (doc.layers[e]))? true:false;\r
+       }\r
+       else if (document.getElementById) {\r
+               return (document.getElementById(e))? true:false;\r
+       }\r
+       else if (document.all) {\r
+               return (document.all[e])? true:false;\r
+       }\r
+       else return false;\r
+}\r
+\r
+\r
+// constructor mods (ie4 fix)\r
+\r
+var termString_keyref;\r
+var termString_keycoderef;\r
+\r
+function termString_makeKeyref() {\r
+       termString_keyref= new Array();\r
+       termString_keycoderef= new Array();\r
+       var hex= new Array('A','B','C','D','E','F');\r
+       for (var i=0; i<=15; i++) {\r
+               var high=(i<10)? i:hex[i-10];\r
+               for (var k=0; k<=15; k++) {\r
+                       var low=(k<10)? k:hex[k-10];\r
+                       var cc=i*16+k;\r
+                       if (cc>=32) {\r
+                               var cs=unescape("%"+high+low);\r
+                               termString_keyref[cc]=cs;\r
+                               termString_keycoderef[cs]=cc;\r
+                       }\r
+               }\r
+       }\r
+}\r
+\r
+if (!String.fromCharCode) {\r
+       termString_makeKeyref();\r
+       String.fromCharCode=function(cc) {\r
+               return (cc!=null)? termString_keyref[cc] : '';\r
+       };\r
+}\r
+if (!String.prototype.charCodeAt) {\r
+       if (!termString_keycoderef) termString_makeKeyref();\r
+       String.prototype.charCodeAt=function(n) {\r
+               cs=this.charAt(n);\r
+               return (termString_keycoderef[cs])? termString_keycoderef[cs] : 0;\r
+       };\r
+}\r
+\r
+// eof
\ No newline at end of file
diff --git a/unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js b/unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js
new file mode 100644 (file)
index 0000000..27c0c5f
--- /dev/null
@@ -0,0 +1,199 @@
+/*\r
+  termlib_parser.js  v.1.0\r
+  command line parser for termlib.js\r
+  (c) Norbert Landsteiner 2005\r
+  mass:werk - media environments\r
+  <http://www.masswerk.at>\r
+\r
+  you are free to use this parser under the "termlib.js" license.\r
+\r
+  usage:  call "parseLine(this)" from your Terminal handler\r
+          parsed args in this.argv\r
+          quoting levels per arg in this.argQL (value: quote char)\r
+          this.argc: pointer to this.argv and this.argQL (used by parserGetopt)\r
+          call parseretopt(this, "<options>") from your handler to get opts\r
+          (returns an object with properties for every option flag. any float\r
+          values are stored in Object.<flag>.value; illegal opts in array\r
+          Object.illegals)\r
+\r
+  configuration: you may want to overide the follow objects (or add properties):\r
+          parserWhiteSpace: chars to be parsed as whitespace\r
+          parserQuoteChars: chars to be parsed as quotes\r
+          parserSingleEscapes: chars to escape a quote or escape expression\r
+          parserOptionChars: chars that start an option\r
+          parserEscapeExpressions: chars that start escape expressions\r
+*/\r
+\r
+// chars to be parsed as white space\r
+var parserWhiteSpace = {\r
+       ' ': true,\r
+       '\t': true\r
+}\r
+\r
+// chars to be parsed as quotes\r
+var parserQuoteChars = {\r
+       '"': true,\r
+       "'": true,\r
+       '`': true\r
+};\r
+\r
+// chars to be parsed as escape char\r
+var parserSingleEscapes = {\r
+       '\\': true\r
+};\r
+\r
+// chars that mark the start of an option-expression\r
+// for use with parserGetopt\r
+var parserOptionChars = {\r
+       '-': true\r
+}\r
+\r
+// chars that start escape expressions (value = handler)\r
+// plugin handlers for ascii escapes or variable substitution\r
+var parserEscapeExpressions = {\r
+       '%': parserHexExpression\r
+}\r
+\r
+function parserHexExpression(termref, pointer, echar, quotelevel) {\r
+       /* example for parserEscapeExpressions\r
+          params:\r
+            termref: ref to Terminal instance\r
+            pointer: position in termref.lineBuffer (echar)\r
+            echar:   escape character found\r
+            quotelevel: current quoting level (quote char or empty)\r
+          char under pointer will be ignored\r
+          the return value is added to the current argument\r
+       */\r
+       // convert hex values to chars (e.g. %20 => <SPACE>)\r
+       if (termref.lineBuffer.length > pointer+2) {\r
+               // get next 2 chars\r
+               var hi = termref.lineBuffer.charAt(pointer+1);\r
+               var lo = termref.lineBuffer.charAt(pointer+2);\r
+               lo = lo.toUpperCase();\r
+               hi = hi.toUpperCase();\r
+               // check for valid hex digits\r
+               if ((((hi>='0') && (hi<='9')) || ((hi>='A') && ((hi<='F')))) &&\r
+                   (((lo>='0') && (lo<='9')) || ((lo>='A') && ((lo<='F'))))) {\r
+                       // next 2 chars are valid hex, so strip them from lineBuffer\r
+                       parserEscExprStrip(termref, pointer+1, pointer+3);\r
+                       // and return the char\r
+                       return String.fromCharCode(parseInt(hi+lo, 16));\r
+               }\r
+       }\r
+       // if not handled return the escape character (=> no conversion)\r
+       return echar;\r
+}\r
+\r
+function parserEscExprStrip(termref, from, to) {\r
+       // strip characters from termref.lineBuffer (for use with escape expressions)\r
+       termref.lineBuffer =\r
+               termref.lineBuffer.substring(0, from) +\r
+               termref.lineBuffer.substring(to);\r
+}\r
+\r
+function parserGetopt(termref, optsstring) {\r
+    // scans argv form current position of argc for opts\r
+    // arguments in argv must not be quoted\r
+       // returns an object with a property for every option flag found\r
+       // option values (absolute floats) are stored in Object.<opt>.value (default -1)\r
+       // the property "illegals" contains an array of  all flags found but not in optstring\r
+       // argc is set to first argument that is not an option\r
+       var opts = { 'illegals':[] };\r
+       while ((termref.argc < termref.argv.length) && (termref.argQL[termref.argc]==''))  {\r
+               var a = termref.argv[termref.argc];\r
+               if ((a.length>0) && (parserOptionChars[a.charAt(0)])) {\r
+                       var i = 1;\r
+                       while (i<a.length) {\r
+                               var c=a.charAt(i);\r
+                               var v = '';\r
+                               while (i<a.length-1) {\r
+                                       var nc=a.charAt(i+1);\r
+                                       if ((nc=='.') || ((nc>='0') && (nc<='9'))) {\r
+                                               v += nc;\r
+                                               i++;\r
+                                       }\r
+                                       else break;\r
+                               }\r
+                               if (optsstring.indexOf(c)>=0) {\r
+                                       opts[c] = (v == '')? {value:-1} : (isNaN(v))? {value:0} : {value:parseFloat(v)};\r
+                               }\r
+                               else {\r
+                                       opts.illegals[opts.illegals.length]=c;\r
+                               }\r
+                               i++;\r
+                       }\r
+                       termref.argc++;\r
+               }\r
+               else break;\r
+       }\r
+       return opts;\r
+}\r
+\r
+function parseLine(termref) {\r
+       // stand-alone parser, takes a Terminal instance as argument\r
+       // parses the command line and stores results as instance properties\r
+       //   argv:  list of parsed arguments\r
+       //   argQL: argument's quoting level (<empty> or quote character)\r
+       //   argc:  cursur for argv, set initinally to zero (0)\r
+       // open quote strings are not an error but automatically closed.\r
+       var argv = [''];     // arguments vector\r
+       var argQL = [''];    // quoting level\r
+       var argc = 0;        // arguments cursor\r
+       var escape = false ; // escape flag\r
+       for (var i=0; i<termref.lineBuffer.length; i++) {\r
+               var ch= termref.lineBuffer.charAt(i);\r
+               if (escape) {\r
+                       argv[argc] += ch;\r
+                       escape = false;\r
+               }\r
+               else if (parserEscapeExpressions[ch]) {\r
+                       var v = parserEscapeExpressions[ch](termref, i, ch, argQL[argc]);\r
+                       if (typeof v != 'undefined') argv[argc] += v;\r
+               }\r
+               else if (parserQuoteChars[ch]) {\r
+                       if (argQL[argc]) {\r
+                               if (argQL[argc] == ch) {\r
+                                       argc ++;\r
+                                       argv[argc] = argQL[argc] = '';\r
+                               }\r
+                               else {\r
+                                       argv[argc] += ch;\r
+                               }\r
+                       }\r
+                       else {\r
+                               if (argv[argc] != '') {\r
+                                       argc ++;\r
+                                       argv[argc] = '';\r
+                                       argQL[argc] = ch;\r
+                               }\r
+                               else {\r
+                                       argQL[argc] = ch;\r
+                               }\r
+                       }\r
+               }\r
+               else if (parserWhiteSpace[ch]) {\r
+                       if (argQL[argc]) {\r
+                               argv[argc] += ch;\r
+                       }\r
+                       else if (argv[argc] != '') {\r
+                               argc++;\r
+                               argv[argc] = argQL[argc] = '';\r
+                       }\r
+               }\r
+               else if (parserSingleEscapes[ch]) {\r
+                       escape = true;\r
+               }\r
+               else {\r
+                       argv[argc] += ch;\r
+               }\r
+       }\r
+       if ((argv[argc] == '') && (!argQL[argc])) {\r
+               argv.length--;\r
+               argQL.length--;\r
+       }\r
+       termref.argv = argv;\r
+       termref.argQL = argQL;\r
+       termref.argc = 0;\r
+}\r
+\r
+// eof
\ No newline at end of file
diff --git a/unmaintained/webapps/fjsc/summary.txt b/unmaintained/webapps/fjsc/summary.txt
new file mode 100644 (file)
index 0000000..74e8bbb
--- /dev/null
@@ -0,0 +1 @@
+Web interface for Factor to Javascript compiler
diff --git a/unmaintained/webapps/fjsc/tags.txt b/unmaintained/webapps/fjsc/tags.txt
new file mode 100644 (file)
index 0000000..1b93c9e
--- /dev/null
@@ -0,0 +1 @@
+webapp
diff --git a/unmaintained/webapps/help/authors.txt b/unmaintained/webapps/help/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/unmaintained/webapps/help/help.factor b/unmaintained/webapps/help/help.factor
new file mode 100644 (file)
index 0000000..28d7360
--- /dev/null
@@ -0,0 +1,89 @@
+! Copyright (C) 2005, 2007 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel furnace furnace.validator http.server.responders
+       help help.topics html splitting sequences words strings 
+       quotations macros vocabs tools.browser combinators
+       arrays io.files ;
+IN: webapps.help 
+
+! : string>topic ( string -- topic )
+    ! " " split dup length 1 = [ first ] when ;
+
+: show-help ( topic -- )
+    serving-html
+    dup article-title [
+        [ help ] with-html-stream
+    ] simple-html-document ;
+
+\ show-help {
+    { "topic" }
+} define-action
+\ show-help { { "topic" "handbook" } } default-values
+
+M: link browser-link-href
+    link-name
+    dup word? over f eq? or [
+        browser-link-href
+    ] [
+        dup array? [ " " join ] when
+        [ show-help ] curry quot-link
+    ] if ;
+
+: show-word ( word vocab -- )
+    lookup show-help ;
+
+\ show-word {
+    { "word" }
+    { "vocab" }
+} define-action
+\ show-word { { "word" "call" } { "vocab" "kernel" } } default-values
+
+M: f browser-link-href
+    drop \ f browser-link-href ;
+
+M: word browser-link-href
+    dup word-name swap word-vocabulary
+    [ show-word ] 2curry quot-link ;
+
+: show-vocab ( vocab -- )
+    f >vocab-link show-help ;
+
+\ show-vocab {
+    { "vocab" }
+} define-action
+
+\ show-vocab { { "vocab" "kernel" } } default-values
+
+M: vocab-spec browser-link-href
+    vocab-name [ show-vocab ] curry quot-link ;
+
+: show-vocabs-tagged ( tag -- )
+    <vocab-tag> show-help ;
+
+\ show-vocabs-tagged {
+    { "tag" }
+} define-action
+
+M: vocab-tag browser-link-href
+    vocab-tag-name [ show-vocabs-tagged ] curry quot-link ;
+
+: show-vocabs-by ( author -- )
+    <vocab-author> show-help ;
+
+\ show-vocabs-by {
+    { "author" }
+} define-action
+
+M: vocab-author browser-link-href
+    vocab-author-name [ show-vocabs-by ] curry quot-link ;
+
+"help" "show-help" "extra/webapps/help" web-app
+
+! Hard-coding for factorcode.org
+PREDICATE: pathname resource-pathname
+    pathname-string "resource:" head? ;
+
+M: resource-pathname browser-link-href
+    pathname-string
+    "resource:" ?head drop
+    "/responder/source/" swap append ;
diff --git a/unmaintained/webapps/numbers/authors.txt b/unmaintained/webapps/numbers/authors.txt
new file mode 100755 (executable)
index 0000000..44b06f9
--- /dev/null
@@ -0,0 +1 @@
+Chris Double
diff --git a/unmaintained/webapps/numbers/numbers.factor b/unmaintained/webapps/numbers/numbers.factor
new file mode 100644 (file)
index 0000000..59247e9
--- /dev/null
@@ -0,0 +1,95 @@
+! cont-number-guess
+!
+! Copyright (C) 2004 Chris Double.
+! 
+! Redistribution and use in source and binary forms, with or without
+! modification, are permitted provided that the following conditions are met:
+! 
+! 1. Redistributions of source code must retain the above copyright notice,
+!    this list of conditions and the following disclaimer.
+! 
+! 2. Redistributions in binary form must reproduce the above copyright notice,
+!    this list of conditions and the following disclaimer in the documentation
+!    and/or other materials provided with the distribution.
+! 
+! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+!
+! This example modifies the console based 'numbers-game' example
+! in a very minimal way to demonstrate conversion of a console
+! program to a web based application.
+!
+! All that was required was changing the input and output functions
+! to use HTML. The remaining code was untouched. 
+!
+! The result is not that pretty but it shows the basic idea.
+USING: kernel math parser html html.elements io namespaces
+math.parser random webapps.continuation ;
+
+IN: webapps.numbers
+
+: web-print ( str -- )
+  #! Display the string in a web page.
+  [
+    swap dup
+    <html>
+      <head> <title> write </title> </head>
+      <body>
+        <p> write </p>
+        <p> <a =href a> "Press to continue" write </a> </p>
+      </body>
+    </html>
+  ] show 2drop ;
+
+: read-number ( -- )
+  [
+    <html>
+      <head> <title> "Enter a number" write </title> </head>
+      <body>
+        <form =action "post" =method form>
+          <p> 
+            "Enter a number:" write
+            <input "text" =type "num" =name "20" =size input/>
+            <input "submit" =type "Press to continue" =value input/>
+          </p>
+        </form>
+      </body>
+    </html>
+  ] show [ "num" get ] bind string>number ;
+
+: guess-banner
+  "I'm thinking of a number between 0 and 100." web-print ;
+: guess-prompt  ;
+: too-high "Too high" web-print ;
+: too-low "Too low" web-print ;
+: correct "Correct - you win!" web-print ;
+: inexact-guess ( actual guess -- )
+     < [ too-high ] [ too-low ] if ;
+
+: judge-guess ( actual guess -- ? )
+    2dup = [
+        2drop correct f
+    ] [
+        inexact-guess t
+    ] if ;
+
+: number-to-guess ( -- n ) 100 random ;
+
+: numbers-game-loop ( actual -- )
+    dup guess-prompt read-number judge-guess [
+        numbers-game-loop
+    ] [
+        drop
+    ] if ;
+
+: numbers-game number-to-guess numbers-game-loop ;
+
+"numbers-game" [ numbers-game ] install-cont-responder
diff --git a/unmaintained/webapps/pastebin/annotate-paste.furnace b/unmaintained/webapps/pastebin/annotate-paste.furnace
new file mode 100755 (executable)
index 0000000..14a424f
--- /dev/null
@@ -0,0 +1,47 @@
+<% USING: io math math.parser namespaces furnace ; %>
+
+<h1>Annotate</h1>
+
+<form method="POST" action="/responder/pastebin/annotate-paste">
+
+<table>
+
+<tr>
+<th align="right">Summary:</th>
+<td><input type="TEXT" name="summary" value="<% "summary" render %>" /></td>
+<td align="left" class="error"><% "summary" "*Required" render-error %></td>
+</tr>
+
+<tr>
+<th align="right">Your name:</th>
+<td><input type="TEXT" name="author" value="<% "author" render  %>" /></td>
+<td class="error"><% "author" "*Required" render-error %></td>
+</tr>
+
+<tr>
+<th align="right">File type:</th>
+<td><% "modes" render-template %></td>
+</tr>
+
+<!--
+<tr>
+<th align="right">Channel:</th>
+<td><input type="TEXT" name="channel" value="#concatenative" /></td>
+</tr>
+-->
+
+<tr>
+<td></td>
+<td colspan="2" class="error" align="left"><% "contents" "*Required" render-error %></td>
+</tr>
+
+<tr>
+<th align="right" valign="top">Content:</th>
+<td colspan="2"><textarea rows="24" cols="60" name="contents"><% "contents" render %></textarea></td>
+</tr>
+</table>
+
+<input type="hidden" name="n" value="<% "n" get number>string write %>" />
+<input type="hidden" name="furnace-form-submitted" value="annotate-paste"/>
+<input type="SUBMIT" value="Annotate" />
+</form>
diff --git a/unmaintained/webapps/pastebin/annotation.furnace b/unmaintained/webapps/pastebin/annotation.furnace
new file mode 100755 (executable)
index 0000000..e59db32
--- /dev/null
@@ -0,0 +1,11 @@
+<% USING: namespaces io furnace calendar ; %>
+
+<h2>Annotation: <% "summary" get write %></h2>
+
+<table>
+<tr><th align="right">Annotation by:</th><td><% "author" get write %></td></tr>
+<tr><th align="right">File type:</th><td><% "mode" get write %></td></tr>
+<tr><th align="right">Created:</th><td><% "date" get timestamp>string write %></td></tr>
+</table>
+
+<% "syntax" render-template %>
diff --git a/unmaintained/webapps/pastebin/authors.txt b/unmaintained/webapps/pastebin/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/unmaintained/webapps/pastebin/footer.furnace b/unmaintained/webapps/pastebin/footer.furnace
new file mode 100644 (file)
index 0000000..15b9011
--- /dev/null
@@ -0,0 +1,3 @@
+</body>
+
+</html>
diff --git a/unmaintained/webapps/pastebin/header.furnace b/unmaintained/webapps/pastebin/header.furnace
new file mode 100644 (file)
index 0000000..2c8e79a
--- /dev/null
@@ -0,0 +1,23 @@
+<% USING: namespaces io furnace sequences xmode.code2html webapps.pastebin ; %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+
+       <title><% "title" get write %></title>
+       <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
+       <% default-stylesheet %>
+    <link rel="alternate" type="application/atom+xml" title="Pastebin - Atom" href="feed.xml" />
+</head>
+
+<body id="index">
+
+    <div class="navbar">
+        <% [ paste-list ] "Paste list" render-link %> |
+        <% [ new-paste ] "New paste" render-link %> |
+        <% [ feed.xml ] "Syndicate" render-link %>
+    </div>
+    <h1 class="pastebin-title"><% "title" get write %></h1>
diff --git a/unmaintained/webapps/pastebin/modes.furnace b/unmaintained/webapps/pastebin/modes.furnace
new file mode 100644 (file)
index 0000000..18bbec1
--- /dev/null
@@ -0,0 +1,7 @@
+<% USING: furnace xmode.catalog sequences kernel html.elements assocs io sorting continuations ; %>
+
+<select name="mode">
+    <% modes keys natural-sort [
+        <option dup "mode" session-var = [ "true" =selected ] when option> write </option>
+    ] each %>
+</select>
diff --git a/unmaintained/webapps/pastebin/new-paste.furnace b/unmaintained/webapps/pastebin/new-paste.furnace
new file mode 100755 (executable)
index 0000000..b21e197
--- /dev/null
@@ -0,0 +1,51 @@
+<% USING: continuations furnace namespaces ; %>
+
+<%
+    "New paste" "title" set
+    "header" render-template
+%>
+
+<form method="POST" action="/responder/pastebin/submit-paste">
+
+<table>
+
+<tr>
+<th align="right">Summary:</th>
+<td><input type="TEXT" name="summary" value="<% "summary" render %>" /></td>
+<td align="left" class="error"><% "summary" "*Required" render-error %></td>
+</tr>
+
+<tr>
+<th align="right">Your name:</th>
+<td><input type="TEXT" name="author" value="<% "author" render  %>" /></td>
+<td class="error"><% "author" "*Required" render-error %></td>
+</tr>
+
+<tr>
+<th align="right">File type:</th>
+<td><% "modes" render-template %></td>
+</tr>
+
+<!--
+<tr>
+<th align="right">Channel:</th>
+<td><input type="TEXT" name="channel" value="#concatenative" /></td>
+</tr>
+-->
+
+<tr>
+<td></td>
+<td colspan="2" class="error" align="left"><% "contents" "*Required" render-error %></td>
+</tr>
+
+<tr>
+<th align="right" valign="top">Content:</th>
+<td colspan="2"><textarea rows="24" cols="60" name="contents"><% "contents" render %></textarea></td>
+</tr>
+</table>
+
+<input type="hidden" name="furnace-form-submitted" value="new-paste"/>
+<input type="SUBMIT" value="Submit paste" />
+</form>
+
+<% "footer" render-template %>
diff --git a/unmaintained/webapps/pastebin/paste-list.furnace b/unmaintained/webapps/pastebin/paste-list.furnace
new file mode 100644 (file)
index 0000000..51813ec
--- /dev/null
@@ -0,0 +1,33 @@
+<% USING: namespaces furnace sequences ; %>
+
+<%
+    "Pastebin" "title" set
+    "header" render-template
+%>
+
+<table width="100%" cellspacing="10">
+    <tr>
+        <td valign="top">
+            <table width="100%">
+                <tr align="left" class="pastebin-headings">
+                    <th width="50%">Summary:</th>
+                    <th width="100">Paste by:</th>
+                    <th width="200">Date:</th>
+                </tr>
+                <% "pastes" get <reversed> [ "paste-summary" render-component ] each %>
+            </table>
+        </td>
+        <td valign="top" width="25%">
+            <div class="infobox">
+                <p>This pastebin is written in <a href="http://factorcode.org/">Factor</a>. It is inspired by <a href="http://paste.lisp.org">lisppaste</a>.
+                </p>
+                <p>It can be used for collaborative development over IRC. You can post code for review, and annotate other people's code. Syntax highlighting for over a hundred file types is supported.
+                </p>
+                <p>
+                <% "webapps.pastebin" browse-webapp-source %></p>
+            </div>
+        </td>
+    </tr>
+</table>
+
+<% "footer" render-template %>
diff --git a/unmaintained/webapps/pastebin/paste-summary.furnace b/unmaintained/webapps/pastebin/paste-summary.furnace
new file mode 100644 (file)
index 0000000..dc25fe1
--- /dev/null
@@ -0,0 +1,12 @@
+<% USING: continuations namespaces io kernel math math.parser
+furnace webapps.pastebin calendar sequences ; %>
+
+<tr>
+    <td>
+        <a href="<% model get paste-link write %>">
+        <% "summary" get write %>
+        </a>
+    </td>
+    <td><% "author" get write %></td>
+    <td><% "date" get timestamp>string write %></td>
+</tr>
diff --git a/unmaintained/webapps/pastebin/pastebin.factor b/unmaintained/webapps/pastebin/pastebin.factor
new file mode 100755 (executable)
index 0000000..36a7279
--- /dev/null
@@ -0,0 +1,119 @@
+USING: calendar furnace furnace.validator io.files kernel
+namespaces sequences http.server.responders html math.parser rss
+xml.writer xmode.code2html math calendar.format ;
+IN: webapps.pastebin
+
+TUPLE: pastebin pastes ;
+
+: <pastebin> ( -- pastebin )
+    V{ } clone pastebin construct-boa ;
+
+<pastebin> pastebin set-global
+
+TUPLE: paste
+summary author channel mode contents date
+annotations n ;
+
+: <paste> ( summary author channel mode contents -- paste )
+    f V{ } clone f paste construct-boa ;
+
+TUPLE: annotation summary author mode contents ;
+
+C: <annotation> annotation
+
+: get-paste ( n -- paste )
+    pastebin get pastebin-pastes nth ;
+
+: show-paste ( n -- )
+    serving-html
+    get-paste
+    [ "show-paste" render-component ] with-html-stream ;
+
+\ show-paste { { "n" v-number } } define-action
+
+: new-paste ( -- )
+    serving-html
+    [ "new-paste" render-template ] with-html-stream ;
+
+\ new-paste { } define-action
+
+: paste-list ( -- )
+    serving-html
+    [
+        [ show-paste ] "show-paste-quot" set
+        [ new-paste ] "new-paste-quot" set
+        pastebin get "paste-list" render-component
+    ] with-html-stream ;
+
+\ paste-list { } define-action
+
+: paste-link ( paste -- link )
+    paste-n number>string [ show-paste ] curry quot-link ;
+
+: safe-head ( seq n -- seq' )
+    over length min head ;
+
+: paste-feed ( -- entries )
+    pastebin get pastebin-pastes <reversed> 20 safe-head [
+        {
+            paste-summary
+            paste-link
+            paste-date
+        } get-slots timestamp>rfc3339 f swap <entry>
+    ] map ;
+
+: feed.xml ( -- )
+    "text/xml" serving-content
+    "pastebin"
+    "http://pastebin.factorcode.org"
+    paste-feed <feed> feed>xml write-xml ;
+
+\ feed.xml { } define-action
+
+: add-paste ( paste pastebin -- )
+    >r now over set-paste-date r>
+    pastebin-pastes 2dup length swap set-paste-n push ;
+
+: submit-paste ( summary author channel mode contents -- )
+    <paste> [ pastebin get add-paste ] keep
+    paste-link permanent-redirect ;
+
+\ new-paste
+\ submit-paste {
+    { "summary" v-required }
+    { "author" v-required }
+    { "channel" }
+    { "mode" v-required }
+    { "contents" v-required }
+} define-form
+
+\ new-paste {
+    { "channel" "#concatenative" }
+    { "mode" "factor" }
+} default-values
+
+: annotate-paste ( n summary author mode contents -- )
+    <annotation> swap get-paste
+    [ paste-annotations push ] keep
+    paste-link permanent-redirect ;
+
+[ "n" show-paste ]
+\ annotate-paste {
+    { "n" v-required v-number }
+    { "summary" v-required }
+    { "author" v-required }
+    { "mode" v-required }
+    { "contents" v-required }
+} define-form
+
+\ show-paste {
+    { "mode" "factor" }
+} default-values
+
+: style.css ( -- )
+    "text/css" serving-content
+    "style.css" send-resource ;
+
+\ style.css { } define-action
+
+"pastebin" "paste-list" "extra/webapps/pastebin" web-app
diff --git a/unmaintained/webapps/pastebin/show-paste.furnace b/unmaintained/webapps/pastebin/show-paste.furnace
new file mode 100755 (executable)
index 0000000..30129ed
--- /dev/null
@@ -0,0 +1,21 @@
+<% USING: namespaces io furnace sequences xmode.code2html calendar ; %>
+
+<%
+    "Paste: " "summary" get append "title" set
+    "header" render-template
+%>
+
+<table>
+<tr><th>Paste by:</th><td><% "author" get write %></td></tr>
+<!-- <tr><th>Channel:</th><td><% "channel" get write %></td></tr> -->
+<tr><th>Created:</th><td><% "date" get timestamp>string write %></td></tr>
+<tr><th>File type:</th><td><% "mode" get write %></td></tr>
+</table>
+
+<% "syntax" render-template %>
+
+<% "annotations" get [ "annotation" render-component ] each %>
+
+<% model get "annotate-paste" render-component %>
+
+<% "footer" render-template %>
diff --git a/unmaintained/webapps/pastebin/style.css b/unmaintained/webapps/pastebin/style.css
new file mode 100644 (file)
index 0000000..4a469f9
--- /dev/null
@@ -0,0 +1,41 @@
+body {
+       font:75%/1.6em "Lucida Grande", "Lucida Sans Unicode", verdana, geneva, sans-serif;
+       color:#888;
+}
+
+h1.pastebin-title {
+       font-size:300%;
+}
+
+a {
+       color:#222;
+       border-bottom:1px dotted #ccc;
+       text-decoration:none;
+}
+
+a:hover {
+       border-bottom:1px solid #ccc;
+}
+
+pre.code {
+       border:1px dashed #ccc;
+       background-color:#f5f5f5;
+       padding:5px;
+       font-size:150%;
+       color:#000000;
+}
+
+.navbar {
+       background-color:#eeeeee;
+       padding:5px;
+       border:1px solid #ccc;
+}
+
+.infobox {
+       border: 1px solid #C1DAD7;
+       padding: 10px;
+}
+
+.error {
+       color: red;
+}
diff --git a/unmaintained/webapps/pastebin/syntax.furnace b/unmaintained/webapps/pastebin/syntax.furnace
new file mode 100755 (executable)
index 0000000..17b64b9
--- /dev/null
@@ -0,0 +1,3 @@
+<% USING: xmode.code2html splitting namespaces ; %>
+
+<pre class="code"><% "contents" get string-lines "mode" get htmlize-lines %></pre>
diff --git a/unmaintained/webapps/planet/authors.txt b/unmaintained/webapps/planet/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/unmaintained/webapps/planet/planet.factor b/unmaintained/webapps/planet/planet.factor
new file mode 100755 (executable)
index 0000000..9a5f8ee
--- /dev/null
@@ -0,0 +1,129 @@
+USING: sequences rss arrays concurrency.combinators kernel
+sorting html.elements io assocs namespaces math threads vocabs
+html furnace http.server.templating calendar math.parser
+splitting continuations debugger system http.server.responders
+xml.writer prettyprint logging calendar.format ;
+IN: webapps.planet
+
+: print-posting-summary ( posting -- )
+    <p "news" =class p>
+        <b> dup entry-title write </b> <br/>
+        <a entry-link =href "more" =class a>
+            "Read More..." write
+        </a>
+    </p> ;
+
+: print-posting-summaries ( postings -- )
+    [ print-posting-summary ] each ;
+
+: print-blogroll ( blogroll -- )
+    <ul "description" =class ul>
+        [
+            <li> <a dup third =href a> first write </a> </li>
+        ] each
+    </ul> ;
+
+: format-date ( date -- string )
+    rfc3339>timestamp timestamp>string ;
+
+: print-posting ( posting -- )
+    <h2 "posting-title" =class h2>
+        <a dup entry-link =href a>
+            dup entry-title write-html
+        </a>
+    </h2>
+    <p "posting-body" =class p>
+        dup entry-description write-html
+    </p>
+    <p "posting-date" =class p>
+        entry-pub-date format-date write
+    </p> ;
+
+: print-postings ( postings -- )
+    [ print-posting ] each ;
+
+SYMBOL: default-blogroll
+SYMBOL: cached-postings
+
+: safe-head ( seq n -- seq' )
+    over length min head ;
+
+: mini-planet-factor ( -- )
+    cached-postings get 4 safe-head print-posting-summaries ;
+
+: planet-factor ( -- )
+    serving-html [ "planet" render-template ] with-html-stream ;
+
+\ planet-factor { } define-action
+
+: planet-feed ( -- feed )
+    "[ planet-factor ]"
+    "http://planet.factorcode.org"
+    cached-postings get 30 safe-head <feed> ;
+
+: feed.xml ( -- )
+    "text/xml" serving-content
+    planet-feed feed>xml write-xml ;
+
+\ feed.xml { } define-action
+
+: style.css ( -- )
+    "text/css" serving-content
+    "style.css" send-resource ;
+
+\ style.css { } define-action
+
+SYMBOL: last-update
+
+: <posting> ( author entry -- entry' )
+    clone
+    [ ": " swap entry-title 3append ] keep
+    [ set-entry-title ] keep ;
+
+: fetch-feed ( url -- feed )
+    download-feed feed-entries ;
+
+\ fetch-feed DEBUG add-error-logging
+
+: fetch-blogroll ( blogroll -- entries )
+    dup 0 <column> swap 1 <column>
+    [ fetch-feed ] parallel-map
+    [ [ <posting> ] with map ] 2map concat ;
+
+: sort-entries ( entries -- entries' )
+    [ [ entry-pub-date ] compare ] sort <reversed> ;
+
+: update-cached-postings ( -- )
+    default-blogroll get
+    fetch-blogroll sort-entries
+    cached-postings set-global ;
+
+: update-thread ( -- )
+    millis last-update set-global
+    [ update-cached-postings ] "RSS feed update slave" spawn drop
+    10 60 * 1000 * sleep
+    update-thread ;
+
+: start-update-thread ( -- )
+    [
+        "webapps.planet" [
+            update-thread
+        ] with-logging
+    ] "RSS feed update master" spawn drop ;
+
+"planet" "planet-factor" "extra/webapps/planet" web-app
+
+{
+    { "Berlin Brown" "http://factorlang-fornovices.blogspot.com/feeds/posts/default" "http://factorlang-fornovices.blogspot.com" }
+    { "Chris Double" "http://www.blogger.com/feeds/18561009/posts/full/-/factor" "http://www.bluishcoder.co.nz/" }
+    { "Elie Chaftari" "http://fun-factor.blogspot.com/feeds/posts/default" "http://fun-factor.blogspot.com/" }
+    { "Doug Coleman" "http://code-factor.blogspot.com/feeds/posts/default" "http://code-factor.blogspot.com/" }
+    { "Daniel Ehrenberg" "http://useless-factor.blogspot.com/feeds/posts/default" "http://useless-factor.blogspot.com/" }
+    { "Gavin Harrison" "http://gmh33.blogspot.com/feeds/posts/default" "http://gmh33.blogspot.com/" }
+    { "Kio M. Smallwood"
+    "http://sekenre.wordpress.com/feed/atom/"
+    "http://sekenre.wordpress.com/" }
+    { "Phil Dawes" "http://www.phildawes.net/blog/category/factor/feed/atom" "http://www.phildawes.net/blog/" }
+    { "Samuel Tardieu" "http://www.rfc1149.net/blog/tag/factor/feed/atom/" "http://www.rfc1149.net/blog/tag/factor/" }
+    { "Slava Pestov" "http://factor-language.blogspot.com/atom.xml" "http://factor-language.blogspot.com/" }
+} default-blogroll set-global
diff --git a/unmaintained/webapps/planet/planet.furnace b/unmaintained/webapps/planet/planet.furnace
new file mode 100644 (file)
index 0000000..4c6676c
--- /dev/null
@@ -0,0 +1,45 @@
+<% USING: namespaces html.elements webapps.planet sequences
+furnace ; %>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+
+       <title>planet-factor</title>
+       <link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
+    <link rel="alternate" type="application/atom+xml" title="Planet Factor - Atom" href="feed.xml" />
+</head>
+
+<body id="index">
+    <h1 class="planet-title">[ planet-factor ]</h1>
+    <table width="100%" cellpadding="10">
+        <tr>
+            <td> <% cached-postings get 20 safe-head print-postings %> </td>
+            <td valign="top" width="25%" class="infobox">
+                <p>
+                    <b>planet-factor</b> is an Atom/RSS aggregator that collects the
+                    contents of <a href="http://factorcode.org/">Factor</a>-related blogs. It is inspired by
+                    <a href="http://planet.lisp.org">Planet Lisp</a>.
+                </p>
+                <p>
+                    <img src="http://planet.lisp.org/feed-icon-14x14.png" />
+                    <a href="feed.xml"> Syndicate </a>
+                </p>
+                <p>
+                    This webapp is written in <a href="http://factorcode.org/">Factor</a>.<br/>
+                    <% "webapps.planet" browse-webapp-source %>
+                </p>
+                <h2 class="blogroll-title">Blogroll</h2>
+                <% default-blogroll get print-blogroll %>
+                <p>
+                    If you want your weblog added to the blogroll, <a href="http://factorcode.org/gethelp.fhtml">just ask</a>.
+                </p>
+            </td>
+        </tr>
+    </table>
+</body>
+
+</html>
diff --git a/unmaintained/webapps/planet/style.css b/unmaintained/webapps/planet/style.css
new file mode 100644 (file)
index 0000000..7a66d8d
--- /dev/null
@@ -0,0 +1,45 @@
+body {
+       font:75%/1.6em "Lucida Grande", "Lucida Sans Unicode", verdana, geneva, sans-serif;
+       color:#888;
+}
+
+h1.planet-title {
+       font-size:300%;
+}
+
+a {
+       color:#222;
+       border-bottom:1px dotted #ccc;
+       text-decoration:none;
+}
+
+a:hover {
+       border-bottom:1px solid #ccc;
+}
+
+.posting-title {
+       background-color:#f5f5f5;
+}
+
+pre, code {
+       color:#000000;
+       font-size:120%;
+}
+
+.infobox {
+       border-left: 1px solid #C1DAD7;
+}
+
+.posting-date {
+       text-align: right;
+       font-size:90%;
+}
+
+a.more {
+       display:block;
+       padding:0 0 5px 0;
+       color:#333;
+       text-decoration:none;
+       text-align:right;
+       border:none;
+}