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

« back to all changes in this revision

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

  • Committer: wagrant
  • Date: 2008-12-20 03:46:56 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1060
Make IVLE work fine in Firefox 3.1 (ie. Gecko/XULRunner 1.9.1). Gecko 1.9.1 has
a built-in JSON object, so our json2.js isn't used, and compatibility problems
arise. The only one significant to us is that Gecko's doesn't support having
a primitive as the root object. Unfortunately we use that sort of thing in a
few places, so IVLE ends up pretty much broken.

A few adjustments were needed both client- and server-side for proto changes:

 - consoleservice and the JS interacting with it now deal with the key returned
   by start_server in a dict like {'key': ...}.
 - tutorialservice and interacting JS deal with code returned by getattempt in
   a dict like {'code': ...}.


The JS repr() implementation used JSON.stringify on the given object, and was
used only with primitive objects in order to create function calls. This needed
to be eliminated for compatibility with the new Gecko, so these call
constructions were replaced with better events:

 - listing.js constructed events for generated file listings by repr()ing some
   strings. That is foul, so we instead use DOM operations from 'this' in a
   somewhat nicer event handler.
 - tutorial.js previously created save_exercise() call strings by repr()ing
   lots of stuff. That was really bad, and broke like the rest. I replaced it
   with something that's still bad, but not quite as awful - grabbing the call
   string from the save button. This should be fixed at some point.
 - console.js had some strange Firebug logging stuff which used repr(). I
   removed it, as it shouldn't have been in released code in the first place.

repr() itself was removed after all references were.
   

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
            populate(user);
33
33
        }
34
34
    /* Just get details for the logged in user */
35
 
    ajax_call(callback, "userservice", "get_user", {"login": settings_login}, "GET");
 
35
    ajax_call(callback, "userservice", "get_user", {}, "GET");
36
36
    return false;
37
37
}
38
38
 
106
106
        p.appendChild(document.createTextNode("Change password"))
107
107
        changepassword.appendChild(p);
108
108
        p = document.createElement("p");
109
 
        
110
 
        p.appendChild(document.createTextNode("Please type your old password, "
111
 
                + "and new password twice, for verification."));
 
109
        p.appendChild(document.createTextNode("Please type your new password "
 
110
            + "twice, to make sure you remember it."))
112
111
        changepassword.appendChild(p);
113
112
 
114
113
        table = document.createElement("table");
116
115
 
117
116
        tr = document.createElement("tr");
118
117
        td = document.createElement("td");
119
 
        td.appendChild(document.createTextNode("Old password:"))
120
 
        tr.appendChild(td);
121
 
        td = document.createElement("td");
122
 
        inputbox = document.createElement("input");
123
 
        inputbox.setAttribute("type", "password");
124
 
        inputbox.setAttribute("name", "oldpass");
125
 
        inputbox.setAttribute("id", "oldpass");
126
 
        inputbox.setAttribute("size", "40");
127
 
        td.appendChild(inputbox)
128
 
        tr.appendChild(td);
129
 
        tbody.appendChild(tr);
130
 
 
131
 
        tr = document.createElement("tr");
132
 
        td = document.createElement("td");
133
118
        td.appendChild(document.createTextNode("New password:"))
134
119
        tr.appendChild(td);
135
120
        td = document.createElement("td");
212
197
    /* Textbox (input) elements */
213
198
    try
214
199
    {
215
 
        var oldpass = document.getElementById("oldpass");
216
200
        var newpass = document.getElementById("newpass");
217
201
        var repeatpass = document.getElementById("repeatpass");
218
202
    }
225
209
    var email = document.getElementById("email");
226
210
 
227
211
    /* Check */
228
 
    oldpassval = oldpass == null ? null : oldpass.value;
229
212
    newpassval = newpass == null ? null : newpass.value;
230
213
    repeatpassval = repeatpass == null ? null : repeatpass.value;
231
214
    nickval = nick.value;
272
255
            dom_removechildren(usernick);
273
256
            usernick.appendChild(document.createTextNode(nickval));
274
257
        }
275
 
        else if (xhr.getResponseHeader("X-IVLE-Action-Error"))
276
 
        {
277
 
            set_result(decodeURIComponent(xhr.getResponseHeader(
278
 
                                     "X-IVLE-Action-Error").toString()), true);        
279
 
        }
280
258
        else
281
259
        {
282
260
            set_result("There was a problem updating the details."
283
 
                + " Your changes have not been saved.", true);
 
261
                + " Your changes have not been saved.");
284
262
        }
285
263
    }
286
264
    data = {
287
265
        "login": user_data.login,
288
266
        "nick": nickval,
289
267
        "email": emailval,
290
 
        "oldpass": oldpassval,
291
268
    }
292
269
    if (newpassval != null && newpassval != "")
293
270
        data['password'] = newpassval;