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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2009-12-01 04:27:58 UTC
  • mfrom: (1164.2.46 sphinx-docs)
  • Revision ID: matt.giuca@gmail.com-20091201042758-wuxd9bdec00c283i
Merged sphinx-docs branch. This adds Sphinx documentation for the entire IVLE system (for system administrators and developers), and removes all of our random old document files (all either irrelevant, or moved into the Sphinx docs nicely). Currently incomplete, but ready to merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 */
 
262
        /* Disable the text box */
 
263
        inputbox.setAttribute("disabled", "disabled");
 
264
 
264
265
        var inputline = inputbox.value + "\n";
265
 
        var graytimer = setTimeout("GLOBAL_inputbox.setAttribute(\"class\", "
266
 
            + "\"disabled\");", 100);
267
266
    }
268
267
    var output = document.getElementById("console_output");
269
268
    {
271
270
        var span = document.createElement("span");
272
271
        span.setAttribute("class", "inputPrompt");
273
272
        span.appendChild(document.createTextNode(
274
 
              document.getElementById("console_prompt").firstChild.textContent)
 
273
              document.getElementById("console_prompt").firstChild.nodeValue)
275
274
                        );
276
275
        output.appendChild(span);
277
276
        // Print input line itself in a span
280
279
        span.appendChild(document.createTextNode(inputline));
281
280
        output.appendChild(span);
282
281
    }
283
 
    var args = {"key": server_key, "text":inputline};
 
282
    var args = {"ivle.op": "chat", "kind": which, "key": server_key, "text":inputline};
284
283
    var callback = function(xhr)
285
284
        {
286
 
            console_response(inputbox, graytimer, inputline, xhr.responseText);
 
285
            console_response(inputbox, inputline, xhr.responseText);
287
286
        }
288
 
    /* Disable the text box */
289
 
    if (inputbox != null)
290
 
        inputbox.setAttribute("disabled", "disabled");
291
 
    ajax_call(callback, "consoleservice", which, args, "POST");
 
287
    ajax_call(callback, "console", "service", args, "POST");
292
288
}
293
289
 
294
 
function console_response(inputbox, graytimer, inputline, responseText)
 
290
function console_response(inputbox, inputline, responseText)
295
291
{
296
292
    try
297
293
    {
350
346
        }
351
347
        var callback = function(xhr)
352
348
            {
353
 
                console_response(inputbox, graytimer,
354
 
                                 null, xhr.responseText);
 
349
                console_response(inputbox, null, xhr.responseText);
355
350
            }
356
351
        if (interrupted)
357
352
        {
361
356
        {
362
357
            var kind = "chat";
363
358
        }
364
 
        var args = {"key": server_key, "text":''};
365
 
        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");
366
361
 
367
362
        // Open up the console so we can see the output
368
363
        // FIXME: do we need to maximize here?
383
378
    if (inputbox != null)
384
379
    {
385
380
        /* Re-enable the text box */
386
 
        clearTimeout(graytimer);
387
381
        inputbox.removeAttribute("disabled");
388
 
        inputbox.removeAttribute("class");
389
382
        interrupted = false;
390
383
    }
391
384
 
447
440
    case 38:                /* Up arrow */
448
441
        hist.up(inp.value);
449
442
        inp.value = hist.curr();
 
443
        /* Inhibit further responses to this event, or WebKit moves the
 
444
         * cursor to the start. */
 
445
        return false;
450
446
        break;
451
447
    case 40:                /* Down arrow */
452
448
        hist.down(inp.value);
453
449
        inp.value = hist.curr();
 
450
        return false;
454
451
        break;
455
452
    }
456
453
}
470
467
    }
471
468
    else
472
469
    {
473
 
        xhr = ajax_call(null, "consoleservice", "restart", {"key": server_key}, "POST");
474
 
        console_response(null, null, null, xhr.responseText);
 
470
        xhr = ajax_call(null, "console", "service", {"ivle.op": "chat", "kind": "terminate", "key": server_key}, "POST");
 
471
        console_response(null, null, xhr.responseText);
475
472
    }
476
473
}
477
474