~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-07-07 12:01:03 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:820
lib: Added new package pulldown_subj, a collection of modules designed to
    pull student subject enrolments from the server.
    Note that the actual code to do this is not included (since that is
    specific to the organisation running IVLE) - just a pluggable interface
    and an example plugin module.
configure.py: Added new config option: subject_pulldown_modules, which allows
    you to specify which modules are plugged in here.
    (Actually that was added accidentally in a previous commit; but this
    revision fixes some comments).

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        windowpane_mode = true;
87
87
        console_minimize();
88
88
    }
89
 
    /* TEMP: Start the server now.
90
 
     * Ultimately we want the server to start only when a line is typed, but
91
 
     * it currently does it asynchronously and doesn't start in time for the
92
 
     * first line. */
93
 
    start_server();
94
89
}
95
90
 
96
91
/** Hide the main console panel, so the console minimizes to just an input box
248
243
    }
249
244
    var output = document.getElementById("console_output");
250
245
    {
 
246
        // Print ">>>" span
 
247
        var span = document.createElement("span");
 
248
        span.setAttribute("class", "inputPrompt");
 
249
        span.appendChild(document.createTextNode(">>> "));
 
250
        output.appendChild(span);
 
251
        // Print input line itself in a span
251
252
        var span = document.createElement("span");
252
253
        span.setAttribute("class", "inputMsg");
253
254
        span.appendChild(document.createTextNode(inputline + "\n"));
266
267
 
267
268
function console_response(inputbox, graytimer, inputline, responseText)
268
269
{
269
 
    var res = JSON.parse(responseText);
 
270
    try
 
271
    {
 
272
        var res = JSON.parse(responseText);
 
273
    }
 
274
    catch (e)
 
275
    {
 
276
        alert("An internal error occurred in the python console.");
 
277
        return;
 
278
    }
270
279
    var output = document.getElementById("console_output");
271
280
    if (res.hasOwnProperty('okay'))
272
281
    {
288
297
        span.setAttribute("class", "errorMsg");
289
298
        span.appendChild(document.createTextNode(res.exc + "\n"));
290
299
        output.appendChild(span);
 
300
        // set the prompt to >>>
 
301
        var prompt = document.getElementById("console_prompt");
 
302
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
 
303
    }
 
304
    else if (res.hasOwnProperty('restart') && res.hasOwnProperty('key'))
 
305
    {
 
306
        // Server has indicated that the console should be restarted
 
307
        
 
308
        // Get the new key (host, port, magic)
 
309
        server_key = res.key;
 
310
 
 
311
        // Print a reason to explain why we'd do such a horrible thing
 
312
        // (console timeout, server error etc.)
 
313
        var span = document.createElement("span");
 
314
        span.setAttribute("class", "errorMsg");
 
315
        span.appendChild(document.createTextNode("Console Restart: " + res.restart + "\n"));
 
316
        output.appendChild(span);
 
317
        // set the prompt to >>>
 
318
        var prompt = document.getElementById("console_prompt");
 
319
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
 
320
 
291
321
    }
292
322
    else if (res.hasOwnProperty('more'))
293
323
    {
348
378
    divScroll.activeScroll();
349
379
 
350
380
    // Focus the input box by default
351
 
    // document.getElementById("console_inputText").focus()
 
381
    document.getElementById("console_output").focus()
 
382
    document.getElementById("console_inputText").focus()
352
383
}
353
384
 
354
385
function catch_input(key)