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

« back to all changes in this revision

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

  • Committer: drtomc
  • Date: 2008-02-06 03:21:36 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:432
usrmgt: more work on this. Still some work to go.
console: refactored to use the ivle-chat protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Date: 30/1/2008
21
21
 */
22
22
 
23
 
digest_constant = "hello";
24
 
 
25
 
var server_host;
26
 
var server_port;
27
 
var server_magic;
 
23
var server_key;
28
24
 
29
25
/* Begin religious debate (tabs vs spaces) here: */
30
26
/* (This string will be inserted in the console when the user presses the Tab
43
39
 * This is a separate step from console_init, as the server is only to be
44
40
 * started once the first command is entered.
45
41
 * Does not return a value. Writes to global variables
46
 
 * server_host, server_port, server_magic.
 
42
 * server_host, and server_port.
47
43
 */
48
44
function start_server()
49
45
{
50
46
    if (server_started) return;
51
47
    var xhr = ajax_call("consoleservice", "start", {}, "POST");
52
48
    var json_text = xhr.responseText;
53
 
    var server_info = JSON.parse(json_text);
54
 
    server_host = server_info.host;
55
 
    server_port = server_info.port;
56
 
    server_magic = server_info.magic;
 
49
    server_key = JSON.parse(json_text);
57
50
    server_started = true;
58
51
}
59
52
 
212
205
{
213
206
    /* Start the server if it hasn't already been started */
214
207
    start_server();
215
 
    var digest = hex_md5(inputline + server_magic);
216
 
    var args = {"host": server_host, "port": server_port,
217
 
                    "digest":digest, "text":inputline};
 
208
    var args = {"key": server_key, "text":inputline};
218
209
    var xmlhttp = ajax_call("consoleservice", which, args, "POST");
219
210
 
220
211
    var res = JSON.parse(xmlhttp.responseText);