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

« back to all changes in this revision

Viewing changes to ivle/webapp/console/media/console.js

  • Committer: William Grant
  • Date: 2009-05-28 02:43:56 UTC
  • Revision ID: grantw@unimelb.edu.au-20090528024356-mlrhizz7omnr71hd
Test ivle.mimetypes.nice_filetype.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    var callback1 = function(xhr)
59
59
        {
60
60
            var json_text = xhr.responseText;
61
 
            server_key = JSON.parse(json_text);
 
61
            server_key = JSON.parse(json_text).key;
62
62
            server_started = true;
63
63
            if (callback != null)
64
64
                callback();
81
81
            tmp_path.pop();
82
82
            path = path_join("/home", tmp_path.join('/'));
83
83
        }
84
 
        ajax_call(callback1, "consoleservice", "start", {"startdir": path}, "POST");
 
84
        ajax_call(callback1, "console", "service", {"ivle.op": "start", "cwd": path}, "POST");
85
85
    }
86
86
    else
87
87
    {
88
88
        // No current_path - let the server decide
89
 
        ajax_call(callback1, "consoleservice", "start", {}, "POST");
 
89
        ajax_call(callback1, "console", "service", {"ivle.op": "start"}, "POST");
90
90
    }
91
91
}
92
92
 
254
254
 
255
255
    if (typeof(inputbox) == "string")
256
256
    {
257
 
        var inputline = inputbox;
 
257
        var inputline = inputbox + "\n";
258
258
        inputbox = null;
259
 
        var graytimer = null;
260
259
    }
261
260
    else
262
261
    {
263
 
        GLOBAL_inputbox = inputbox;     /* For timer */
264
 
        var inputline = inputbox.value;
265
 
        var graytimer = setTimeout("GLOBAL_inputbox.setAttribute(\"class\", "
266
 
            + "\"disabled\");", 100);
 
262
        /* Disable the text box */
 
263
        inputbox.setAttribute("disabled", "disabled");
 
264
 
 
265
        var inputline = inputbox.value + "\n";
267
266
    }
268
267
    var output = document.getElementById("console_output");
269
268
    {
270
269
        // Print ">>>" span
271
270
        var span = document.createElement("span");
272
271
        span.setAttribute("class", "inputPrompt");
273
 
        span.appendChild(document.createTextNode(">>> "));
 
272
        span.appendChild(document.createTextNode(
 
273
              document.getElementById("console_prompt").firstChild.nodeValue)
 
274
                        );
274
275
        output.appendChild(span);
275
276
        // Print input line itself in a span
276
277
        var span = document.createElement("span");
277
278
        span.setAttribute("class", "inputMsg");
278
 
        span.appendChild(document.createTextNode(inputline + "\n"));
 
279
        span.appendChild(document.createTextNode(inputline));
279
280
        output.appendChild(span);
280
281
    }
281
 
    var args = {"key": server_key, "text":inputline};
 
282
    var args = {"ivle.op": "chat", "kind": which, "key": server_key, "text":inputline};
282
283
    var callback = function(xhr)
283
284
        {
284
 
            console_response(inputbox, graytimer, inputline, xhr.responseText);
 
285
            console_response(inputbox, inputline, xhr.responseText);
285
286
        }
286
 
    /* Disable the text box */
287
 
    if (inputbox != null)
288
 
        inputbox.setAttribute("disabled", "disabled");
289
 
    ajax_call(callback, "consoleservice", which, args, "POST");
 
287
    ajax_call(callback, "console", "service", args, "POST");
290
288
}
291
289
 
292
 
function console_response(inputbox, graytimer, inputline, responseText)
 
290
function console_response(inputbox, inputline, responseText)
293
291
{
294
292
    try
295
293
    {
348
346
        }
349
347
        var callback = function(xhr)
350
348
            {
351
 
                console_response(inputbox, graytimer,
352
 
                                 null, xhr.responseText);
 
349
                console_response(inputbox, null, xhr.responseText);
353
350
            }
354
351
        if (interrupted)
355
352
        {
359
356
        {
360
357
            var kind = "chat";
361
358
        }
362
 
        var args = {"key": server_key, "text":''};
363
 
        ajax_call(callback, "consoleservice", kind, args, "POST");
 
359
        var args = {"ivle.op": "chat", "kind": kind, "key": server_key, "text":''};
 
360
        ajax_call(callback, "console", "service", args, "POST");
364
361
 
365
362
        // Open up the console so we can see the output
366
363
        // FIXME: do we need to maximize here?
381
378
    if (inputbox != null)
382
379
    {
383
380
        /* Re-enable the text box */
384
 
        clearTimeout(graytimer);
385
381
        inputbox.removeAttribute("disabled");
386
 
        inputbox.removeAttribute("class");
387
382
        interrupted = false;
388
383
    }
389
384
 
468
463
    }
469
464
    else
470
465
    {
471
 
        xhr = ajax_call(null, "consoleservice", "restart", {"key": server_key}, "POST");
472
 
        console_response(null, null, null, xhr.responseText);
 
466
        xhr = ajax_call(null, "console", "service", {"ivle.op": "chat", "kind": "terminate", "key": server_key}, "POST");
 
467
        console_response(null, null, xhr.responseText);
473
468
    }
474
469
}
475
470