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)); +}