~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-15 09:18:02 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:877
pulldown_subj/__init__.py: Added "enrol_user" function which pulls down a user
    and also enrols them in the database.
Added script enrolallusers.py which scriptulously performs automatic
enrolments of all users in the system, similar to remakeallusers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
        }
66
66
 
67
67
    //var current_path;
68
 
    if((typeof(current_path) != 'undefined') && current_file)
 
68
    if(typeof(current_path) != 'undefined')
69
69
    {
70
70
        // We have a current_path - give a suggestion to the server
71
71
        var path;
303
303
    var output = document.getElementById("console_output");
304
304
    if (res.hasOwnProperty('okay'))
305
305
    {
306
 
        // Success!
307
 
        if (res.okay)
308
 
        {
309
 
            output.appendChild(document.createTextNode(res.okay + "\n"));
310
 
            output.appendChild(span);
311
 
        }
312
306
        // set the prompt to >>>
313
 
        set_prompt(">>>");
 
307
        var prompt = document.getElementById("console_prompt");
 
308
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
314
309
    }
315
310
    else if (res.hasOwnProperty('exc'))
316
311
    {
317
312
        // Failure!
318
313
        // print out the error message (res.exc)
319
 
        print_error(res.exc);
320
 
        
 
314
        var span = document.createElement("span");
 
315
        span.setAttribute("class", "errorMsg");
 
316
        span.appendChild(document.createTextNode(res.exc + "\n"));
 
317
        output.appendChild(span);
321
318
        // set the prompt to >>>
322
 
        set_prompt(">>>");
 
319
        var prompt = document.getElementById("console_prompt");
 
320
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
323
321
    }
324
322
    else if (res.hasOwnProperty('restart') && res.hasOwnProperty('key'))
325
323
    {
330
328
 
331
329
        // Print a reason to explain why we'd do such a horrible thing
332
330
        // (console timeout, server error etc.)
333
 
        print_error("Console Restart: " + res.restart);
334
 
        
 
331
        var span = document.createElement("span");
 
332
        span.setAttribute("class", "errorMsg");
 
333
        span.appendChild(document.createTextNode("Console Restart: " + res.restart + "\n"));
 
334
        output.appendChild(span);
335
335
        // set the prompt to >>>
336
 
        set_prompt(">>>");
 
336
        var prompt = document.getElementById("console_prompt");
 
337
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
 
338
 
337
339
    }
338
340
    else if (res.hasOwnProperty('more'))
339
341
    {
340
342
        // Need more input, so set the prompt to ...
341
 
        set_prompt("...");
 
343
        var prompt = document.getElementById("console_prompt");
 
344
        prompt.replaceChild(document.createTextNode("... "), prompt.firstChild);
342
345
    }
343
346
    else if (res.hasOwnProperty('output'))
344
347
    {
372
375
        // Return early, so we don't re-enable the input box.
373
376
        return;
374
377
    }
375
 
    else
376
 
    {
 
378
    else {
377
379
        // assert res.hasOwnProperty('input')
378
 
        set_prompt("...");
 
380
        var prompt = document.getElementById("console_prompt");
 
381
        prompt.replaceChild(document.createTextNode("+++ "), prompt.firstChild);
379
382
    }
380
383
 
381
384
    if (inputbox != null)
393
396
    divScroll.activeScroll();
394
397
 
395
398
    // Focus the input box by default
396
 
    document.getElementById("console_output").focus();
397
 
    document.getElementById("console_inputText").focus();
 
399
    document.getElementById("console_output").focus()
 
400
    document.getElementById("console_inputText").focus()
398
401
}
399
402
 
400
403
function catch_input(key)
453
456
    }
454
457
}
455
458
 
456
 
/** Resets the console by signalling the old console to expire and starting a 
457
 
 * new one.
458
 
 */
459
 
function console_reset()
460
 
{
461
 
    // FIXME: We show some feedback here - either disable input or at very 
462
 
    // least the reset button.
463
 
 
464
 
    // Restart the console
465
 
    if(!server_started)
466
 
    {
467
 
        start_server(null);
468
 
    }
469
 
    else
470
 
    {
471
 
        xhr = ajax_call(null, "consoleservice", "restart", {"key": server_key}, "POST");
472
 
        console_response(null, null, null, xhr.responseText);
473
 
    }
474
 
}
475
 
 
476
 
/** Prints an error line in the console **/
477
 
function print_error(error)
478
 
479
 
    var output = document.getElementById("console_output");
480
 
  
481
 
    // Create text block
482
 
    var span = document.createElement("span");
483
 
    span.setAttribute("class", "errorMsg");
484
 
    span.appendChild(document.createTextNode(error + "\n"));
485
 
    output.appendChild(span);
486
 
 
487
 
    // Autoscroll
488
 
    divScroll.activeScroll();
489
 
}
490
 
 
491
 
/** Sets the prompt text **/
492
 
function set_prompt(prompt_text)
493
 
{
494
 
    var prompt = document.getElementById("console_prompt");
495
 
    prompt.replaceChild(document.createTextNode(prompt_text + " "), prompt.firstChild);
496
 
}
497
 
 
498
459
/**** Following Code modified from ******************************************/
499
460
/**** http://radio.javaranch.com/pascarello/2006/08/17/1155837038219.html ***/
500
461
/****************************************************************************/
512
473
        
513
474
    if (scrollDiv.scrollHeight > 0)
514
475
        currentHeight = scrollDiv.scrollHeight;
515
 
    else if (scrollDiv.offsetHeight > 0)
516
 
        currentHeight = scrollDiv.offsetHeight;
 
476
    else 
 
477
        if (objDiv.offsetHeight > 0)
 
478
            currentHeight = scrollDiv.offsetHeight;
517
479
 
518
480
    scrollDiv.scrollTop = currentHeight;
519
481