Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 221 lines (221 sloc) 8.672 kb
967359e4 »
2010-03-27 added a demo, fixed a '
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <title>JQuery Console Demo</title>
6 <meta name="Content-Type" content="text/html; charset=UTF-8">
c394fd20 »
2014-05-21 Use jquery CDN in demo
7 <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
967359e4 »
2010-03-27 added a demo, fixed a '
8 <script type="text/javascript" src="jquery.console.js"></script>
9 <!-- Everything beyond this point is user-customized -->
10 <script type="text/javascript">
11 $(document).ready(function(){
12 /* First console */
13 var console1 = $('<div class="console1">');
14 $('body').append(console1);
f680bb40 » spratt
2010-06-14 Fixed an bug where if the console did not define a welcome message, t…
15 var controller1 = console1.console({
967359e4 »
2010-03-27 added a demo, fixed a '
16 promptLabel: 'Demo> ',
17 commandValidate:function(line){
18 if (line == "") return false;
19 else return true;
20 },
21 commandHandle:function(line){
22 return [{msg:"=> [12,42]",
23 className:"jquery-console-message-value"},
24 {msg:":: [a]",
25 className:"jquery-console-message-type"}]
26 },
27 autofocus:true,
28 animateScroll:true,
a87daa7f »
2010-04-23 added extra example to demo.html
29 promptHistory:true,
30 charInsertTrigger:function(keycode,line){
31 // Let you type until you press a-z
32 // Never allow zero.
33 return !line.match(/[a-z]+/) && keycode != '0'.charCodeAt(0);
34 }
967359e4 »
2010-03-27 added a demo, fixed a '
35 });
36 /* Second console */
37 var console2 = $('<div class="console2">');
38 $('body').append(console2);
421b5c12 » Chris Done
2010-05-29 added promptText function for setting the text of the current prompt
39 var controller2 = console2.console({
967359e4 »
2010-03-27 added a demo, fixed a '
40 promptLabel: 'JavaScript> ',
41 commandValidate:function(line){
42 if (line == "") return false;
43 else return true;
44 },
45 commandHandle:function(line){
46 try { var ret = eval(line);
47 if (typeof ret != 'undefined') return ret.toString();
48 else return true; }
49 catch (e) { return e.toString(); }
50 },
51 animateScroll:true,
a87daa7f »
2010-04-23 added extra example to demo.html
52 promptHistory:true,
53 welcomeMessage:'Enter some JavaScript expressions to evaluate.'
54 });
421b5c12 » Chris Done
2010-05-29 added promptText function for setting the text of the current prompt
55 controller2.promptText('5 * 4');
6c326e8f » spratt
2010-06-03 Fixed history bug.
56 /* Third console */
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
57 var console3CancelFlag = false;
58 var console3 = $('<div class="console3">');
a87daa7f »
2010-04-23 added extra example to demo.html
59 $('body').append(console3);
f680bb40 » spratt
2010-06-14 Fixed an bug where if the console did not define a welcome message, t…
60 var controller3 = console3.console({
a87daa7f »
2010-04-23 added extra example to demo.html
61 promptLabel: 'Echo> ',
62 commandValidate:function(line){
63 if (line == "") return false;
64 else return true;
65 },
66 commandHandle:function(line,report){
6fa359bc » spratt
2010-06-03 Fixed input bug. User can no longer type while a command is running.
67 setTimeout(function() {
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
68 if(!console3CancelFlag)
69 report(line);
70 else {
71 report([{msg:"User interrupt",
72 className:"jquery-console-message-error"}]);
73 console3CancelFlag = false;
74 }
6fa359bc » spratt
2010-06-03 Fixed input bug. User can no longer type while a command is running.
75 },1000);
a87daa7f »
2010-04-23 added extra example to demo.html
76 },
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
77 cancelHandle:function() {
78 console3CancelFlag = true;
79 },
a87daa7f »
2010-04-23 added extra example to demo.html
80 animateScroll:true,
967359e4 »
2010-03-27 added a demo, fixed a '
81 promptHistory:true
82 });
b0dac7d4 »
2010-06-15 added fourth console example with multiple line input support
83 /* Fourth console */
84 var console4 = $('<div class="console4">');
85 $('body').append(console4);
86 var controller4 = console4.console({
87 promptLabel: 'SQL> ',
88 continuedPromptLabel: ' -> ',
89 commandValidate:function(line){
90 if (line == "") return false;
91 else return true;
92 },
93 commandHandle:function(line,report){
94 if (line.match(/;$/)) {
95 controller4.continuedPrompt = false;
df4744fd »
2010-06-15 added alert to demonstrate getting a multi-line statement
96 alert("Execute: " + line);
b0dac7d4 »
2010-06-15 added fourth console example with multiple line input support
97 return true;
98 } else {
99 controller4.continuedPrompt = true;
100 return;
101 }
102 },
103 promptHistory:true
104 });
9cdf6a31 » vietj
2012-07-15 add command completion feature
105 /* Fifth console */
106 var console5 = $('<div class="console1">');
107 $('body').append(console5);
108 var controller5 = console5.console({
109 promptLabel: 'Complete> ',
110 commandHandle:function(line){
111 if (line) {
112 return [{msg:"you typed " + line,className:"jquery-console-message-value"}];
113 } else {
114 var m = "type a color among (" + this.colors.join(", ") + ")";
115 return [{msg:m,className:"jquery-console-message-value"}];
116 }
117 },
118 colors: ["red","blue","green","black","yellow","white","grey"],
119 cols: 40,
120 completeHandle:function(prefix){
121 var colors = this.colors;
122 var ret = [];
123 for (var i=0;i<colors.length;i++) {
124 var color=colors[i];
125 if (color.lastIndexOf(prefix,0) === 0) {
126 ret.push(color.substring(prefix.length));
127 }
128 }
129 return ret;
130 }
131 })
967359e4 »
2010-03-27 added a demo, fixed a '
132 });
133 </script>
134 <style type="text/css" media="screen">
041787a3 »
2011-11-05 Drop use of wbr, use word-wrap: break-word; — thanks, calebegg (refs #6
135 div.console1,div.console2,div.console3 { word-wrap: break-word; }
967359e4 »
2010-03-27 added a demo, fixed a '
136 /* First console */
137 div.console1 { font-size: 14px }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
138 div.console1 div.jquery-console-inner
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
139 { width:900px; height:200px; background:#333; padding:0.5em;
967359e4 »
2010-03-27 added a demo, fixed a '
140 overflow:auto }
141 div.console1 div.jquery-console-prompt-box
142 { color:#fff; font-family:monospace; }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
143 div.console1 div.jquery-console-focus span.jquery-console-cursor
967359e4 »
2010-03-27 added a demo, fixed a '
144 { background:#fefefe; color:#333; font-weight:bold }
145 div.console1 div.jquery-console-message-error
146 { color:#ef0505; font-family:sans-serif; font-weight:bold;
147 padding:0.1em; }
148 div.console1 div.jquery-console-message-value
149 { color:#1ad027; font-family:monospace;
150 padding:0.1em; }
151 div.console1 div.jquery-console-message-type
152 { color:#52666f; font-family:monospace;
153 padding:0.1em; }
154 div.console1 span.jquery-console-prompt-label { font-weight:bold }
155 /* Second console */
156 div.console2 { font-size: 14px; margin-top:1em }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
157 div.console2 div.jquery-console-inner
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
158 { width:900px; height:200px; background:#efefef; padding:0.5em;
967359e4 »
2010-03-27 added a demo, fixed a '
159 overflow:auto }
160 div.console2 div.jquery-console-prompt-box
161 { color:#444; font-family:monospace; }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
162 div.console2 div.jquery-console-focus span.jquery-console-cursor
967359e4 »
2010-03-27 added a demo, fixed a '
163 { background:#333; color:#eee; font-weight:bold }
164 div.console2 div.jquery-console-message-error
165 { color:#ef0505; font-family:sans-serif; font-weight:bold;
166 padding:0.1em; }
167 div.console2 div.jquery-console-message-success
168 { color:#187718; font-family:monospace;
169 padding:0.1em; }
170 div.console2 span.jquery-console-prompt-label { font-weight:bold }
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
171 /* Third console */
172 div.console3 { font-size: 14px; margin-top:1em }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
173 div.console3 div.jquery-console-inner
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
174 { width:900px; height:200px; background:#efefef; padding:0.5em;
175 overflow:auto }
176 div.console3 div.jquery-console-prompt-box
177 { color:#444; font-family:monospace; }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
178 div.console3 div.jquery-console-focus span.jquery-console-cursor
096d4c6e » spratt
2010-06-09 Added a hook to allow user to handle C-c, the user interrupt
179 { background:#333; color:#eee; font-weight:bold }
180 div.console3 div.jquery-console-message-error
181 { color:#ef0505; font-family:sans-serif; font-weight:bold;
182 padding:0.1em; }
183 div.console3 div.jquery-console-message-success
184 { color:#187718; font-family:monospace;
185 padding:0.1em; }
b0dac7d4 »
2010-06-15 added fourth console example with multiple line input support
186 div.console3 span.jquery-console-prompt-label {
187 font-weight:bold }
188 /* Fourth console */
189 div.console4 { font-size: 14px; margin-top:1em }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
190 div.console4 div.jquery-console-inner
b0dac7d4 »
2010-06-15 added fourth console example with multiple line input support
191 { width:900px; height:200px; background:#efefef; padding:0.5em;
192 overflow:auto }
193 div.console4 div.jquery-console-prompt-box
194 { color:#444; font-family:monospace; }
562cec62 » Gun.io Whitespace Robot
2011-10-31 Remove whitespace [Gun.io WhitespaceBot]
195 div.console4 div.jquery-console-focus span.jquery-console-cursor
b0dac7d4 »
2010-06-15 added fourth console example with multiple line input support
196 { background:#444; color:#eee; font-weight:bold }
197 div.console4 div.jquery-console-message-error
198 { color:#ef0505; font-family:sans-serif; font-weight:bold;
199 padding:0.1em; }
200 div.console4 div.jquery-console-message-success
201 { color:#187718; font-family:monospace;
202 padding:0.1em; }
203 div.console4 span.jquery-console-prompt-label { font-weight:bold }
967359e4 »
2010-03-27 added a demo, fixed a '
204 </style>
205 </head>
206 <body>
207 <noscript>
208 <p>
209 <strong>Please enable JavaScript or upgrade your browser.</strong>
210 </p>
211 </noscript>
212 <h1>Simple console demo</h1>
213 <p>Tested on:</p>
214 <ul>
215 <li>Internet Explorer 6</li>
216 <li>Opera 10.01</li>
217 <li>Chromium 4.0.237.0 (Ubuntu build 31094)</li>
218 <li>Firefox 3.5.8</li>
219 </ul>
220 </body>
221 </html>
Something went wrong with that request. Please try again.