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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-12-07 04:22:22 UTC
  • Revision ID: grantw@unimelb.edu.au-20091207042222-lor5fixbzwniti3i
Revert client-side parts of r1333; reliance on the deprecated tab mechanism is to be avoided.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
                callback();
65
65
        }
66
66
 
67
 
    var cwd = get_cwd();
68
 
    ajax_call(callback1, "console", "service", {"ivle.op": "start",
69
 
            "cwd": cwd}, "POST");
70
 
}
71
 
 
72
 
/** Try and get the current working directory of this app */
73
 
function get_cwd()
74
 
{
75
 
    /** Can get CWD from filesystem app */
76
 
    if((typeof(this_app) != 'undefined') && this_app == "files")
 
67
    //var current_path;
 
68
    if((typeof(current_path) != 'undefined') && current_file)
77
69
    {
 
70
        // We have a current_path - give a suggestion to the server
 
71
        var path;
78
72
        if (current_file.isdir)
79
73
        {
80
 
            // Browser - already a directory
81
 
            return path_join("/home", current_path);
 
74
            // Browser
 
75
            path = path_join("/home", current_path);
82
76
        }
83
77
        else
84
78
        {
85
79
            // Editor - need to chop off filename
86
80
            var tmp_path = current_path.split('/');
87
81
            tmp_path.pop();
88
 
            return path_join("/home", tmp_path.join('/'));
 
82
            path = path_join("/home", tmp_path.join('/'));
89
83
        }
 
84
        ajax_call(callback1, "console", "service", {"ivle.op": "start", "cwd": path}, "POST");
90
85
    }
91
86
    else
92
87
    {
93
 
        // Unable to determine CWD
94
 
        return '';
 
88
        // No current_path - let the server decide
 
89
        ajax_call(callback1, "console", "service", {"ivle.op": "start"}, "POST");
95
90
    }
96
91
}
97
92
 
284
279
        span.appendChild(document.createTextNode(inputline));
285
280
        output.appendChild(span);
286
281
    }
287
 
    var cwd = get_cwd();
288
 
    var args = {"ivle.op": "chat", "kind": which, "key": server_key,
289
 
            "text":inputline, "cwd": cwd};
 
282
    var args = {"ivle.op": "chat", "kind": which, "key": server_key, "text":inputline};
290
283
    var callback = function(xhr)
291
284
        {
292
285
            console_response(inputbox, inputline, xhr.responseText);
363
356
        {
364
357
            var kind = "chat";
365
358
        }
366
 
        var cwd = get_cwd();
367
 
        var args = {"ivle.op": "chat", "kind": kind, "key": server_key,
368
 
                "text":'', "cwd": cwd};
 
359
        var args = {"ivle.op": "chat", "kind": kind, "key": server_key, "text":''};
369
360
        ajax_call(callback, "console", "service", args, "POST");
370
361
 
371
362
        // Open up the console so we can see the output
476
467
    }
477
468
    else
478
469
    {
479
 
        /* Terminate the old server and start a new one */
480
 
        var cwd = get_cwd();
481
 
        xhr = ajax_call(null, "console", "service", {"ivle.op": "chat",
482
 
                "kind": "terminate", "key": server_key, "cwd": cwd},
483
 
                "POST");
 
470
        xhr = ajax_call(null, "console", "service", {"ivle.op": "chat", "kind": "terminate", "key": server_key}, "POST");
484
471
        console_response(null, null, xhr.responseText);
485
472
    }
486
473
}