131
131
var inp = document.getElementById('inputText');
132
132
var digest = hex_md5(inp.value + magic);
133
133
var xmlhttp = new XMLHttpRequest();
135
134
xmlhttp.open("POST", "chat", false);
136
135
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
137
136
xmlhttp.send(make_post_body({"digest":digest, "text":inp.value}))
143
142
pre.appendChild(document.createTextNode(inp.value + "\n"));
144
143
output.appendChild(pre);
145
if (res.hasOwnProperty('okay'))
149
// print out the output (res[0])
148
// print out the output (res.okay[0])
150
149
var pre = document.createElement("pre");
151
150
pre.setAttribute("class", "outputMsg");
152
pre.appendChild(document.createTextNode(res[0]));
151
pre.appendChild(document.createTextNode(res.okay[0]));
153
152
output.appendChild(pre);
154
// print out the return value (res[1])
153
// print out the return value (res.okay[1])
157
156
var pre = document.createElement("pre");
158
157
pre.setAttribute("class", "outputMsg");
159
pre.appendChild(document.createTextNode(res[1] + "\n"));
158
pre.appendChild(document.createTextNode(res.okay[1] + "\n"));
160
159
output.appendChild(pre);
162
161
// set the prompt to >>>
163
162
var prompt = document.getElementById("prompt");
164
163
prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
165
else if (res.hasOwnProperty('exc'))
169
// print out the error message (res[2])
168
// print out the error message (res.exc)
170
169
var pre = document.createElement("pre");
171
170
pre.setAttribute("class", "errorMsg");
172
pre.appendChild(document.createTextNode(res[2]));
171
pre.appendChild(document.createTextNode(res.exc));
173
172
output.appendChild(pre);
174
else if (res.hasOwnProperty('more'))
177
176
// Need more input, so set the prompt to ...
178
177
var prompt = document.getElementById("prompt");
179
178
prompt.replaceChild(document.createTextNode("... "), prompt.firstChild);
181
// assert res.hasOwnProperty('input')
182
var prompt = document.getElementById("prompt");
183
prompt.replaceChild(document.createTextNode("+++ "), prompt.firstChild);
183
187
function catch_input(key)