Printer
[jscl.git] / lispstrack.html
1 <!doctype html>
2 <html>
3   <head>
4     <style>
5      /* The console container element */
6     body { background-color: black; font-size: 16px; font-family: Courier; overflow: hidden; padding: 0 0 0 0;}
7     #console {
8       position: absolute;
9       top: 0px;
10       bottom: 0px;
11       left: 0px;
12       right: 0px;
13       background-color:black;
14     }
15
16     .parents {
17         font-weight: bold;
18     }
19
20     /* The inner console element. */
21     .jqconsole {
22         padding: 10px;
23     }
24     /* The cursor. */
25     .jqconsole-cursor {
26         background-color: gray;
27     }
28     /* The cursor color when the console looses focus. */
29     .jqconsole-blurred .jqconsole-cursor {
30         background-color: #666;
31     }
32     /* The current prompt text color */
33     .jqconsole-prompt {
34         color: White;
35     }
36     /* The command history */
37     .jqconsole-old-prompt {
38         color: White;
39         font-weight: normal;
40     }
41     /* The text color when in input mode. */
42     .jqconsole-input {
43         color: White;
44     }
45     /* Previously entered input. */
46     .jqconsole-old-input {
47         color: White;
48         font-weight: normal;
49     }
50     /* The text color of the output. */
51     .jqconsole-output, .jqconsole-header {
52         color: gray;
53     }
54     .jqconsole-error {
55         color: red;
56     }
57 </style>
58   </head>
59
60   <body>
61     <div id="console"></div>
62     <script src="lispstrack.js" type="text/javascript"></script>
63     <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
64     <script src="jqconsole.min.js" type="text/javascript" charset="utf-8"></script>
65     <script>
66       $(function () {
67         var jqconsole = $('#console').jqconsole('Welcome to Lisptrack!\n\n', '> ');
68         jqconsole.RegisterMatching('(', ')', 'parents');
69
70         var startPrompt = function () {
71           // Start the prompt with history enabled.
72           jqconsole.Prompt(true, function (input) {
73             // Output input with the class jqconsole-output.
74             if (input[0] != ','){
75                 try {
76                     jqconsole.Write(lisp.print(lisp.evalString(input)) + '\n', 'jqconsole-output');
77                 } catch(error) {
78                     jqconsole.Write('ERROR: ' + error + '\n', 'jqconsole-error');
79                 }
80             } else {
81                 jqconsole.Write(lisp.compileString(input.slice(1)) + '\n', 'jqconsole-output');
82             }
83             // Restart the prompt.
84             startPrompt();
85           }, function(input){
86             try {
87                 lisp.read(input[0]==','? input.slice(1): input);
88             } catch(error) {
89                 return 0;
90             }
91             return false;
92           });
93         };
94         startPrompt();
95       });
96     </script>
97   </body>
98 </html>