summaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authorcurly <curly@infernal.garden>2024-07-16 13:14:41 -0600
committercurly <curly@infernal.garden>2024-07-16 13:14:41 -0600
commitdc7a91ceeca79e01b53662b48a5e7252dc33a3f8 (patch)
tree84edc4e5736bba26d505381affeed36648b499cd /src/main.js
parent3e9a7fbf29f9aeb2dd7504c345220951c949905f (diff)
downloadpoko_web-dc7a91ceeca79e01b53662b48a5e7252dc33a3f8.tar.gz
poko_web-dc7a91ceeca79e01b53662b48a5e7252dc33a3f8.tar.bz2
poko_web-dc7a91ceeca79e01b53662b48a5e7252dc33a3f8.zip
update user info
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/main.js b/src/main.js
index e6cadce..1ef06e8 100644
--- a/src/main.js
+++ b/src/main.js
@@ -62,7 +62,7 @@ async function register() {
if (req.status == 201) {
await login(req.body.id, password)
- window.location.href = host + "/user.html"
+ window.location.href = host + "/user/"
} else {
alert(req.status + ": " + req.body)
}
@@ -87,7 +87,7 @@ async function login(id, password) {
if (req.status == 200) {
// Set session cookie
set_session(req.body, id)
- window.location.href = host + "/user.html";
+ window.location.href = host + "/user/";
} else {
alert(req.status + ": " + req.body)
}
@@ -246,7 +246,7 @@ async function transfer(to_id, color, amount) {
if (req.status != 200) {
alert(req.status + ":" + req.body)
} else if (req.status == 200) {
- window.location.href = host + "/user.html"
+ window.location.href = host + "/user/"
}
}
}
@@ -260,4 +260,36 @@ function transfer_form() {
console.log(to_id, color, amount)
transfer(to_id, color, amount)
+}
+
+async function update_form_onload() {
+ const name = document.getElementById("name");
+ const id = get_id();
+ const session = get_session();
+
+ const url = server + "/user/get"
+ const body = {"id": id, "session": session}
+ const req = await xhttp_post(url, body);
+
+ if (req.status == 200) {
+ name.value = req.body.name;
+ }
+}
+
+async function update_form() {
+ const id = get_id();
+ const session = get_session();
+ const name = document.getElementById("name").value;
+ const old_password = document.getElementById("old_password").value;
+ const new_password = document.getElementById("new_password").value;
+
+ const url = server + "/user/update/info"
+ const body = {"id": id, "session": session, "name": name, "old_password": old_password, "new_password": new_password};
+ const req = await xhttp_post(url, body);
+
+ if (req.status == 200) {
+ window.location.href = host + "/user/"
+ } else {
+ alert(req.status + ": " + req.body)
+ }
} \ No newline at end of file