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

« back to all changes in this revision

Viewing changes to console/console.js

  • Committer: drtomc
  • Date: 2008-01-02 22:05:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:127
A bit of simplification - unify the output areas and use colours to
distinguish output, return values and errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
136
136
    xmlhttp.send(make_post_body({"digest":digest, "text":inp.value}))
137
137
    var res = JSON.parse(xmlhttp.responseText);
138
 
    var output = document.getElementById("outputArea")
139
 
    output.appendChild(document.createTextNode(inp.value + "\n"));
 
138
    var output = document.getElementById("output")
 
139
    {
 
140
        var pre = document.createElement("pre");
 
141
        pre.setAttribute("class", "inputMsg");
 
142
        pre.appendChild(document.createTextNode(inp.value + "\n"));
 
143
        output.appendChild(pre);
 
144
    }
140
145
    if (res && res[0])
141
146
    {
142
147
        // Success!
143
148
        // print out the output (res[0])
144
 
        output.appendChild(document.createTextNode(res[0]));
 
149
        var pre = document.createElement("pre");
 
150
        pre.setAttribute("class", "outputMsg");
 
151
        pre.appendChild(document.createTextNode(res[0]));
 
152
        output.appendChild(pre);
145
153
        // print out the return value (res[1])
146
154
        if (res[1])
147
155
        {
148
 
            output.appendChild(document.createTextNode(res[1] + "\n"));
 
156
            var pre = document.createElement("pre");
 
157
            pre.setAttribute("class", "outputMsg");
 
158
            pre.appendChild(document.createTextNode(res[1] + "\n"));
 
159
            output.appendChild(pre);
149
160
        }
150
161
        // set the prompt to >>>
151
162
        var prompt = document.getElementById("prompt");
155
166
    {
156
167
        // Failure!
157
168
        // print out the error message (res[2])
158
 
        output.appendChild(document.createTextNode(res[2]));
 
169
        var pre = document.createElement("pre");
 
170
        pre.setAttribute("class", "errorMsg");
 
171
        pre.appendChild(document.createTextNode(res[2]));
 
172
        output.appendChild(pre);
159
173
    }
160
174
    else
161
175
    {
172
186
    {
173
187
        enter_line();
174
188
        hist.add(inp.value);
 
189
        inp.value = hist.curr();
175
190
    }
176
191
    if (key == 38)
177
192
    {
178
193
        hist.up();
 
194
        inp.value = hist.curr();
179
195
    }
180
196
    if (key == 40)
181
197
    {
182
198
        hist.down();
 
199
        inp.value = hist.curr();
183
200
    }
184
 
    inp.value = hist.curr();
185
201
}