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

« back to all changes in this revision

Viewing changes to console/console.js

  • Committer: mattgiuca
  • Date: 2008-01-09 21:33:56 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:144
Trunk, and all subdirectories with Python files:
    Added to svn:ignore all *.pyc *.pyo, to avoid compiled files
    showing up in svn st / diff / commit lists.
    Added to svn:ignore trampoline/trampoline.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
function historyAdd(text)
29
29
{
30
30
    this.items[this.items.length] = text;
31
 
    this.cursor = this.items.length;
 
31
    this.cursor = this.items.length
32
32
}
33
33
 
34
34
function historyShow()
93
93
            {
94
94
                qs += "&";
95
95
            }
96
 
            qs += encodeURIComponent(key) + "=" + encodeURIComponent(val);
 
96
            qs += encodeURI(key) + "=" + encodeURI(val);
97
97
        }
98
98
    }
99
99
    return qs;
120
120
            {
121
121
                qs += "&";
122
122
            }
123
 
            qs += encodeURIComponent(key) + "=" + encodeURIComponent(val);
 
123
            qs += encodeURI(key) + "=" + encodeURI(val);
124
124
        }
125
125
    }
126
126
    return qs;
131
131
    var inp = document.getElementById('inputText');
132
132
    var digest = hex_md5(inp.value + magic);
133
133
    var xmlhttp = new XMLHttpRequest();
 
134
    alert(inp.value);
134
135
    xmlhttp.open("POST", "chat", false);
135
136
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
136
137
    xmlhttp.send(make_post_body({"digest":digest, "text":inp.value}))
137
138
    var res = JSON.parse(xmlhttp.responseText);
138
 
    var output = document.getElementById("output");
 
139
    var output = document.getElementById("output")
139
140
    {
140
141
        var pre = document.createElement("pre");
141
142
        pre.setAttribute("class", "inputMsg");
142
143
        pre.appendChild(document.createTextNode(inp.value + "\n"));
143
144
        output.appendChild(pre);
144
145
    }
145
 
    if (res.hasOwnProperty('okay'))
 
146
    if (res && res[0])
146
147
    {
147
148
        // Success!
148
 
        // print out the output (res.okay[0])
 
149
        // print out the output (res[0])
149
150
        var pre = document.createElement("pre");
150
151
        pre.setAttribute("class", "outputMsg");
151
 
        pre.appendChild(document.createTextNode(res.okay[0]));
 
152
        pre.appendChild(document.createTextNode(res[0]));
152
153
        output.appendChild(pre);
153
 
        // print out the return value (res.okay[1])
154
 
        if (res.okay[1])
 
154
        // print out the return value (res[1])
 
155
        if (res[1])
155
156
        {
156
157
            var pre = document.createElement("pre");
157
158
            pre.setAttribute("class", "outputMsg");
158
 
            pre.appendChild(document.createTextNode(res.okay[1] + "\n"));
 
159
            pre.appendChild(document.createTextNode(res[1] + "\n"));
159
160
            output.appendChild(pre);
160
161
        }
161
162
        // set the prompt to >>>
162
163
        var prompt = document.getElementById("prompt");
163
164
        prompt.replaceChild(document.createTextNode(">>> "), prompt.firstChild);
164
165
    }
165
 
    else if (res.hasOwnProperty('exc'))
 
166
    else if (res)
166
167
    {
167
168
        // Failure!
168
 
        // print out the error message (res.exc)
 
169
        // print out the error message (res[2])
169
170
        var pre = document.createElement("pre");
170
171
        pre.setAttribute("class", "errorMsg");
171
 
        pre.appendChild(document.createTextNode(res.exc));
 
172
        pre.appendChild(document.createTextNode(res[2]));
172
173
        output.appendChild(pre);
173
174
    }
174
 
    else if (res.hasOwnProperty('more'))
 
175
    else
175
176
    {
176
177
        // Need more input, so set the prompt to ...
177
178
        var prompt = document.getElementById("prompt");
178
179
        prompt.replaceChild(document.createTextNode("... "), prompt.firstChild);
179
180
    }
180
 
    else {
181
 
        // assert res.hasOwnProperty('input')
182
 
        var prompt = document.getElementById("prompt");
183
 
        prompt.replaceChild(document.createTextNode("+++ "), prompt.firstChild);
184
 
    }
185
181
}
186
182
 
187
183
function catch_input(key)