28
/* Populate the page with this user's account details */
28
/* Fetch the user's details from the server, and populate the page */
29
function revert_settings()
31
31
var callback = function(xhr)
33
33
user = JSON.parse(xhr.responseText);
35
36
/* Just get details for the logged in user */
36
37
ajax_call(callback, "userservice", "get_user", {}, "GET");
40
/* Populate the page with the given user's account details */
41
function populate(user)
43
/* Plain text elements (non-editable) */
44
var login = document.getElementById("login");
45
var role = document.getElementById("role");
46
var changepassword = document.getElementById("changepassword");
47
var notices = document.getElementById("notices");
48
/* Textbox (input) elements */
49
var nick = document.getElementById("nick");
50
var email = document.getElementById("email");
62
dom_removechildren(login);
63
dom_removechildren(role);
64
dom_removechildren(notices);
66
/* Construct the page */
68
/* "login" : Full Name (<b>login</b> / studentid) */
69
text = user.fullname + " (";
70
login.appendChild(document.createTextNode(text));
72
b = document.createElement("b");
73
b.appendChild(document.createTextNode(text));
75
if (user.studentid != null)
76
text = " / " + user.studentid + ")"
79
login.appendChild(document.createTextNode(text));
81
/* "role" : <p>Your privilege level is <b>rolenm</b>.</p>
82
* Unless rolenm is "student"
84
if (user.rolenm != "student")
86
text = "Your privilege level is ";
87
role.appendChild(document.createTextNode(text));
88
b = document.createElement("b");
90
b.appendChild(document.createTextNode(text));
93
role.appendChild(document.createTextNode(text));
96
/* "nick" and "email" boxes */
97
nick.value = user.nick;
98
email.value = user.email;
100
/* Password change box */
101
/* (Only if this user has a local password) */
102
if (user.local_password)
104
p = document.createElement("h3");
105
p.appendChild(document.createTextNode("Change password"))
106
changepassword.appendChild(p);
107
table = document.createElement("table");
108
tbody = document.createElement("tbody");
110
tr = document.createElement("tr");
111
td = document.createElement("td");
112
td.appendChild(document.createTextNode("New password:"))
114
td = document.createElement("td");
115
inputbox = document.createElement("input");
116
inputbox.setAttribute("type", "password");
117
inputbox.setAttribute("name", "newpass");
118
inputbox.setAttribute("id", "newpass");
119
inputbox.setAttribute("size", "40");
120
td.appendChild(inputbox)
122
tbody.appendChild(tr);
124
tr = document.createElement("tr");
125
td = document.createElement("td");
126
td.appendChild(document.createTextNode("Retype password:"))
128
td = document.createElement("td");
129
inputbox = document.createElement("input");
130
inputbox.setAttribute("type", "password");
131
inputbox.setAttribute("name", "repeatpass");
132
inputbox.setAttribute("id", "repeatpass");
133
inputbox.setAttribute("size", "40");
134
td.appendChild(inputbox)
136
tbody.appendChild(tr);
138
table.appendChild(tbody);
139
changepassword.appendChild(table);
141
p = document.createElement("p");
142
p.appendChild(document.createTextNode("Please type your new password "
143
+ "twice, to make sure you remember it."))
144
changepassword.appendChild(p);
147
if (user.pass_exp != null || user.acct_exp != null)
149
p = document.createElement("h3");
151
p.appendChild(document.createTextNode(text));
152
notices.appendChild(p);
153
if (user.pass_exp != null)
155
p = document.createElement("p");
156
/* TODO: Nice passexp */
157
var pass_exp = user.pass_exp.toString()
158
text = "Your password will expire on " + pass_exp
159
+ ". You should change it before then to avoid having your "
160
+ "account disabled.";
161
p.appendChild(document.createTextNode(text));
162
notices.appendChild(p);
164
if (user.acct_exp != null)
166
p = document.createElement("p");
167
/* TODO: Nice acct_exp */
168
var acct_exp = user.acct_exp.toString()
169
text = "Your IVLE account will expire on " + acct_exp + ".";
170
p.appendChild(document.createTextNode(text));
171
notices.appendChild(p);