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

« back to all changes in this revision

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

  • Committer: dcoles
  • Date: 2008-02-29 02:11:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:624
forum: Removed the subsilver2 style and phpBB installer
Modified prosilver theme to be more IVLE integrated
Added db dumps for setup

setup.py: Added config.php generator code

doc/setup/install_proc.txt: New setup/install details

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
windowpane_mode = false;
35
35
server_started = false;
36
36
 
37
 
interrupted = false;
38
 
 
39
37
/* Starts the console server, if it isn't already.
40
38
 * This can be called any number of times - it only starts the one server.
41
39
 * Note that this is asynchronous. It will return after signalling to start
86
84
        windowpane_mode = true;
87
85
        console_minimize();
88
86
    }
 
87
    /* TEMP: Start the server now.
 
88
     * Ultimately we want the server to start only when a line is typed, but
 
89
     * it currently does it asynchronously and doesn't start in time for the
 
90
     * first line. */
 
91
    start_server();
89
92
}
90
93
 
91
94
/** Hide the main console panel, so the console minimizes to just an input box
104
107
    if (!windowpane_mode) return;
105
108
    console_body.setAttribute("class", "windowpane maximal");
106
109
    console_filler.setAttribute("class", "windowpane maximal");
 
110
    /* Focus the input box by default */
 
111
    document.getElementById("console_inputText").focus()
107
112
}
108
113
 
109
114
/* current_text is the string currently on the command line.
206
211
 
207
212
var hist = new History();
208
213
 
209
 
function set_interrupt()
210
 
{
211
 
    interrupted = true;
212
 
}
213
 
 
214
 
function clear_output()
215
 
{
216
 
    var output = document.getElementById("console_output");
217
 
    while (output.firstChild)
218
 
    {
219
 
        output.removeChild(output.firstChild);
220
 
    }
221
 
}
222
 
 
223
214
/** Send a line of text to the Python server, wait for its return, and react
224
215
 * to its response by writing to the output box.
225
216
 * Also maximize the console window if not already.
226
217
 */
227
218
function console_enter_line(inputbox, which)
228
219
{
229
 
    interrupted = false;
230
 
 
231
220
    if (typeof(inputbox) == "string")
232
221
    {
233
222
        var inputline = inputbox;
243
232
    }
244
233
    var output = document.getElementById("console_output");
245
234
    {
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
252
235
        var span = document.createElement("span");
253
236
        span.setAttribute("class", "inputMsg");
254
237
        span.appendChild(document.createTextNode(inputline + "\n"));
267
250
 
268
251
function console_response(inputbox, graytimer, inputline, responseText)
269
252
{
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
 
    }
 
253
    var res = JSON.parse(responseText);
279
254
    var output = document.getElementById("console_output");
280
255
    if (res.hasOwnProperty('okay'))
281
256
    {
297
272
        span.setAttribute("class", "errorMsg");
298
273
        span.appendChild(document.createTextNode(res.exc + "\n"));
299
274
        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
 
 
321
275
    }
322
276
    else if (res.hasOwnProperty('more'))
323
277
    {
336
290
                console_response(inputbox, graytimer,
337
291
                                 null, xhr.responseText);
338
292
            }
339
 
        if (interrupted)
340
 
        {
341
 
            var kind = "interrupt";
342
 
        }
343
 
        else
344
 
        {
345
 
            var kind = "chat";
346
 
        }
347
293
        var args = {"key": server_key, "text":''};
348
 
        ajax_call(callback, "consoleservice", kind, args, "POST");
 
294
        ajax_call(callback, "consoleservice", "chat", args, "POST");
349
295
 
350
 
        // Open up the console so we can see the output
351
 
        // FIXME: do we need to maximize here?
 
296
        /* Open up the console so we can see the output */
352
297
        console_maximize();
353
 
 
354
298
        /* Auto-scrolling */
355
299
        divScroll.activeScroll();
356
300
 
369
313
        clearTimeout(graytimer);
370
314
        inputbox.removeAttribute("disabled");
371
315
        inputbox.removeAttribute("class");
372
 
        interrupted = false;
373
316
    }
374
317
 
375
318
    /* Open up the console so we can see the output */
376
319
    console_maximize();
377
320
    /* Auto-scrolling */
378
321
    divScroll.activeScroll();
379
 
 
380
 
    // Focus the input box by default
381
 
    document.getElementById("console_output").focus()
382
 
    document.getElementById("console_inputText").focus()
383
322
}
384
323
 
385
324
function catch_input(key)