~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/console/console.js

  • Committer: mattgiuca
  • Date: 2008-01-30 06:32:15 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:333
console.js: enter_line now accepts the line as an argument instead of reading
it from the text box. catch_input reads it from the text box and passes it as
an argument. This allows other services to call enter_line with their own
python code.
tutorial.js: The "Run" button no longer submits Ajax to the tutorial system.
Instead, it calls console's enter_line, with the code, hoping that the console
will execute this code.
(At the moment this doesn't work for multiple lines).

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
 
156
156
var hist = new History();
157
157
 
158
 
function enter_line()
 
158
/** Send a line of text to the Python server, wait for its return, and react
 
159
 * to its response by writing to the output box.
 
160
 * Also maximize the console window if not already.
 
161
 */
 
162
function console_enter_line(inputline)
159
163
{
160
 
    var inp = document.getElementById('console_inputText');
161
 
    var digest = hex_md5(inp.value + magic);
 
164
    var digest = hex_md5(inputline + magic);
162
165
    var args = {"host": server_host, "port": server_port,
163
 
                    "digest":digest, "text":inp.value};
 
166
                    "digest":digest, "text":inputline};
164
167
    var xmlhttp = ajax_call("consoleservice", "chat", args, "POST");
165
168
 
166
169
    var res = JSON.parse(xmlhttp.responseText);
168
171
    {
169
172
        var pre = document.createElement("pre");
170
173
        pre.setAttribute("class", "inputMsg");
171
 
        pre.appendChild(document.createTextNode(inp.value + "\n"));
 
174
        pre.appendChild(document.createTextNode(inputline + "\n"));
172
175
        output.appendChild(pre);
173
176
    }
174
177
    if (res.hasOwnProperty('okay'))
220
223
    var inp = document.getElementById('console_inputText');
221
224
    if (key == 13)
222
225
    {
223
 
        enter_line();
 
226
        console_enter_line(inp.value);
224
227
        hist.add(inp.value);
225
228
        inp.value = hist.curr();
226
229
    }