annotate options.js @ 129:46822bd329da

Make the options page functional. The options page now uses the /uinfo interface to change e-mail and password values.
author John "Elwin" Edwards <elwin@sdf.org>
date Tue, 28 Aug 2012 17:38:25 -0700
parents bea4e7e703a2
children a2e071a95055
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
129
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
1 function setup() {
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
2 if (!("lcred" in sessionStorage))
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
3 return;
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
4 var url = "/uinfo/email?key=" + sessionStorage.getItem("lcred");
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
5 var req = new XMLHttpRequest();
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
6 req.onreadystatechange = function () {
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
7 if (req.readyState != 4 || req.status != 200)
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
8 return;
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
9 var reply = JSON.parse(req.responseText);
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
10 if (!("email" in reply))
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
11 return;
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
12 document.getElementById("input_email").value = reply["email"];
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
13 }
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
14 req.open('GET', url, true);
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
15 req.send();
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
16 }
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
17
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
18 function postemail() {
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
19 if (!("lcred" in sessionStorage))
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
20 return;
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
21 var posturl = "/uinfo/email?key=" + sessionStorage.getItem("lcred");
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
22 var msg = {"v": document.getElementById("input_email").value};
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
23 var req = new XMLHttpRequest();
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
24 req.open('POST', posturl, true);
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
25 req.send(JSON.stringify(msg));
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
26 }
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
27
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
28 function postpw() {
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
29 if (!("lcred" in sessionStorage))
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
30 return;
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
31 var posturl = "/uinfo/pw?key=" + sessionStorage.getItem("lcred");
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
32 var msg = {"v": document.getElementById("input_pw").value};
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
33 var req = new XMLHttpRequest();
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
34 req.open('POST', posturl, true);
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
35 req.send(JSON.stringify(msg));
46822bd329da Make the options page functional.
John "Elwin" Edwards <elwin@sdf.org>
parents: 128
diff changeset
36 }