From eb2e44e13e9f1052419f470e585bc485b3d1a181 Mon Sep 17 00:00:00 2001 From: "John \"Elwin\" Edwards" Date: Tue, 28 Aug 2012 17:38:25 -0700 Subject: [PATCH] Make the options page functional. The options page now uses the /uinfo interface to change e-mail and password values. --- options.html | 6 +++--- options.js | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/options.html b/options.html index ae7d1a1..6903268 100644 --- a/options.html +++ b/options.html @@ -5,7 +5,7 @@ - +

RLG-Web Options

E-mail @@ -13,11 +13,11 @@
E-mail:
-
Save
Cancel
+
Save
Cancel
Password:
-
Save
Cancel
+
Save
Cancel
diff --git a/options.js b/options.js index 9151f55..971ac30 100644 --- a/options.js +++ b/options.js @@ -1 +1,36 @@ -/* Nothing here yet. */ +function setup() { + if (!("lcred" in sessionStorage)) + return; + var url = "/uinfo/email?key=" + sessionStorage.getItem("lcred"); + var req = new XMLHttpRequest(); + req.onreadystatechange = function () { + if (req.readyState != 4 || req.status != 200) + return; + var reply = JSON.parse(req.responseText); + if (!("email" in reply)) + return; + document.getElementById("input_email").value = reply["email"]; + } + req.open('GET', url, true); + req.send(); +} + +function postemail() { + if (!("lcred" in sessionStorage)) + return; + var posturl = "/uinfo/email?key=" + sessionStorage.getItem("lcred"); + var msg = {"v": document.getElementById("input_email").value}; + var req = new XMLHttpRequest(); + req.open('POST', posturl, true); + req.send(JSON.stringify(msg)); +} + +function postpw() { + if (!("lcred" in sessionStorage)) + return; + var posturl = "/uinfo/pw?key=" + sessionStorage.getItem("lcred"); + var msg = {"v": document.getElementById("input_pw").value}; + var req = new XMLHttpRequest(); + req.open('POST', posturl, true); + req.send(JSON.stringify(msg)); +}