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

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/user-media/settings.js

Added module ivle.config, which takes care of some work interfacing with
    configobj, including searching for the file and opening the object.
ivle.conf.conf now uses this instead of having its own search.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
var user_data;
24
24
 
25
 
function onload()
26
 
{
27
 
    revert_settings();
28
 
}
29
 
 
30
25
/* Fetch the user's details from the server, and populate the page.
31
26
 * Returns false. */
32
27
function revert_settings()
37
32
            populate(user);
38
33
        }
39
34
    /* Just get details for the logged in user */
40
 
    ajax_call(callback, "userservice", "get_user", {}, "GET");
 
35
    ajax_call(callback, "userservice", "get_user", {"login": settings_login}, "GET");
41
36
    return false;
42
37
}
43
38
 
111
106
        p.appendChild(document.createTextNode("Change password"))
112
107
        changepassword.appendChild(p);
113
108
        p = document.createElement("p");
114
 
        p.appendChild(document.createTextNode("Please type your new password "
115
 
            + "twice, to make sure you remember it."))
 
109
        
 
110
        p.appendChild(document.createTextNode("Please type your old password, "
 
111
                + "and new password twice, for verification."));
116
112
        changepassword.appendChild(p);
117
113
 
118
114
        table = document.createElement("table");
120
116
 
121
117
        tr = document.createElement("tr");
122
118
        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");
123
133
        td.appendChild(document.createTextNode("New password:"))
124
134
        tr.appendChild(td);
125
135
        td = document.createElement("td");
202
212
    /* Textbox (input) elements */
203
213
    try
204
214
    {
 
215
        var oldpass = document.getElementById("oldpass");
205
216
        var newpass = document.getElementById("newpass");
206
217
        var repeatpass = document.getElementById("repeatpass");
207
218
    }
214
225
    var email = document.getElementById("email");
215
226
 
216
227
    /* Check */
 
228
    oldpassval = oldpass == null ? null : oldpass.value;
217
229
    newpassval = newpass == null ? null : newpass.value;
218
230
    repeatpassval = repeatpass == null ? null : repeatpass.value;
219
231
    nickval = nick.value;
253
265
            set_result("Successfully updated details.");
254
266
            user_data.nick = nickval;
255
267
            user_data.email = emailval;
 
268
            /* Now a little hack - update the user's nick display
 
269
             * in the heading bar, so they are sure it has been changed.
 
270
             */
 
271
            var usernick = document.getElementById("usernick");
 
272
            dom_removechildren(usernick);
 
273
            usernick.appendChild(document.createTextNode(nickval));
 
274
        }
 
275
        else if (xhr.getResponseHeader("X-IVLE-Action-Error"))
 
276
        {
 
277
            set_result(decodeURIComponent(xhr.getResponseHeader(
 
278
                                     "X-IVLE-Action-Error").toString()), true);        
256
279
        }
257
280
        else
258
281
        {
259
282
            set_result("There was a problem updating the details."
260
 
                + " Your changes have not been saved.");
 
283
                + " Your changes have not been saved.", true);
261
284
        }
262
285
    }
263
286
    data = {
264
287
        "login": user_data.login,
265
288
        "nick": nickval,
266
289
        "email": emailval,
 
290
        "oldpass": oldpassval,
267
291
    }
268
292
    if (newpassval != null && newpassval != "")
269
293
        data['password'] = newpassval;