Report unexpected errors in the reader
[jscl.git] / test.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; }
7
8     #console {
9       position: absolute;
10       width: 100%;
11       height: 100%;
12       background-color:black;
13     }
14     /* The inner console element. */
15     .jqconsole {
16         padding: 10px;
17     }
18     /* The cursor. */
19     .jqconsole-cursor {
20         background-color: gray;
21     }
22     /* The cursor color when the console looses focus. */
23     .jqconsole-blurred .jqconsole-cursor {
24         background-color: #666;
25     }
26     /* The current prompt text color */
27     .jqconsole-prompt {
28         color: White;
29     }
30     /* The command history */
31     .jqconsole-old-prompt {
32         color: White;
33         font-weight: normal;
34     }
35     /* The text color when in input mode. */
36     .jqconsole-input {
37         color: White;
38     }
39     /* Previously entered input. */
40     .jqconsole-old-input {
41         color: White;
42         font-weight: normal;
43     }
44     /* The text color of the output. */
45     .jqconsole-output, .jqconsole-header {
46         color: gray;
47     }
48     .jqconsole-error {
49         color: red;
50     }
51 </style>
52   </head>
53
54   <body>
55     <div id="console"></div>
56     <script src="test.js" type="text/javascript"></script>
57     <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
58     <script src="jqconsole.min.js" type="text/javascript" charset="utf-8"></script>
59     <script>
60       $(function () {
61         var jqconsole = $('#console').jqconsole('Welcome to Lisptrack!\n\n', '> ');
62         jqconsole.RegisterMatching('(', ')', 'parents');
63
64         var startPrompt = function () {
65           // Start the prompt with history enabled.
66           jqconsole.Prompt(true, function (input) {
67             // Output input with the class jqconsole-output.
68             if (input[0] != ','){
69                 try {
70                     jqconsole.Write(JSON.stringify(lisp.evalString(input)) + '\n', 'jqconsole-output');
71                 } catch(error) {
72                     jqconsole.Write('ERROR: ' + error + '\n', 'jqconsole-error');
73                 }
74             } else {
75                 jqconsole.Write(JSON.stringify(lisp.compileString(input.slice(1))) + '\n', 'jqconsole-output');
76             }
77             // Restart the prompt.
78             startPrompt();
79           });
80         };
81         startPrompt();
82       });
83     </script>
84   </body>
85 </html>