~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-01-30 06:14:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:332
console plugin: Now presents minimize/maximize buttons, allowing itself to be
opened and closed.
The console python "present" function now also requires a windowpane=True if
in window pane mode (updated tutorial).
Implemented minimal/maximal classes in console.css (a lot of this feature is
CSS-based - min and max buttons just change the class and the CSS handles the
mode switch).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* IVLE - Informatics Virtual Learning Environment
 
2
 * Copyright (C) 2007-2008 The University of Melbourne
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 *
 
18
 * Module: Console (Client-side JavaScript)
 
19
 * Author: Tom Conway, Matt Giuca
 
20
 * Date: 30/1/2008
 
21
 */
 
22
 
1
23
digest_constant = "hello";
2
24
 
3
25
var server_host;
4
26
var server_port;
5
27
var server_magic;
6
28
 
 
29
/* Console DOM objects */
 
30
console_body = null;
 
31
console_filler = null;
 
32
 
7
33
/* Starts the console server.
8
34
 * Returns an object with fields "host", "port", "magic" describing the
9
35
 * server.
15
41
    return JSON.parse(json_text);
16
42
}
17
43
 
 
44
/** Initialises the console. All apps which import console are required to
 
45
 * call this function.
 
46
 * Optional "windowpane" (bool), if true, will cause the console to go into
 
47
 * "window pane" mode which will allow it to be opened and closed, and float
 
48
 * over the page.
 
49
 * (Defaults to closed).
 
50
 */
18
51
function console_init(windowpane)
19
52
{
20
53
    /* Set up the console as a floating pane */
 
54
    console_body = document.getElementById("console_body");
 
55
    console_filler = document.getElementById("console_filler");
21
56
    if (windowpane)
22
 
    {
23
 
        var cb = document.getElementById("console_body");
24
 
        var cb2 = document.getElementById("console_filler");
25
 
        cb.setAttribute("class", "windowpane");
26
 
        cb2.setAttribute("class", "windowpane");
27
 
    }
 
57
        console_minimize();
28
58
    /* Start the server */
29
59
    var server_info = start_server();
30
60
    server_host = server_info.host;
32
62
    server_magic = server_info.magic;
33
63
}
34
64
 
 
65
/** Hide the main console panel, so the console minimizes to just an input box
 
66
 *  at the page bottom. */
 
67
function console_minimize()
 
68
{
 
69
    console_body.setAttribute("class", "windowpane minimal");
 
70
    console_filler.setAttribute("class", "windowpane minimal");
 
71
}
 
72
 
 
73
/** Show the main console panel, so it enlarges out to its full size.
 
74
 */
 
75
function console_maximize()
 
76
{
 
77
    console_body.setAttribute("class", "windowpane maximal");
 
78
    console_filler.setAttribute("class", "windowpane maximal");
 
79
}
 
80
 
35
81
/* Below here imported from trunk/console/console.js
36
82
 * (Tom Conway)
37
83
 */
165
211
        var prompt = document.getElementById("console_prompt");
166
212
        prompt.replaceChild(document.createTextNode("+++ "), prompt.firstChild);
167
213
    }
 
214
    /* Open up the console so we can see the output */
 
215
    console_maximize();
168
216
}
169
217
 
170
218
function catch_input(key)