diff options
author | curly <curly@infernal.garden> | 2024-07-18 11:54:08 -0600 |
---|---|---|
committer | curly <curly@infernal.garden> | 2024-07-18 11:54:08 -0600 |
commit | 25bd00c21b4e389ebdbd487f0ecec8e9f2cf9fa3 (patch) | |
tree | fdeaaed284e639a5eb18f6041ed226aa9e9b337f /src/main.js | |
parent | bb7cff0016a1bb95bd987b69b586c505418c1aeb (diff) | |
download | poko_web-25bd00c21b4e389ebdbd487f0ecec8e9f2cf9fa3.tar.gz poko_web-25bd00c21b4e389ebdbd487f0ecec8e9f2cf9fa3.tar.bz2 poko_web-25bd00c21b4e389ebdbd487f0ecec8e9f2cf9fa3.zip |
use html base and relative paths
Diffstat (limited to 'src/main.js')
-rw-r--r-- | src/main.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main.js b/src/main.js index 5dc8244..91e2efb 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,6 @@ const server = window.location.protocol + "//" + window.location.hostname + ":9050"; -const host = window.location.protocol + "//" + window.location.host; -const client_id = "POKO Web 0.0" +const host = document.getElementsByTagName("base")[0].href; +const client_id = "POKO Web 0.1.0"; async function xhttp_get(url) { try { @@ -71,7 +71,7 @@ async function register() { if (req.status == 201) { await login(req.body.id, password) - window.location.href = host + "/user/" + window.location.href = host + "user/" } else { alert(req.status + ": " + req.body) } @@ -96,7 +96,7 @@ async function login(id, password) { if (req.status == 200) { // Set session cookie set_session(req.body, id) - window.location.href = host + "/user/"; + window.location.href = host + "user/"; } else { alert(req.status + ": " + req.body) } @@ -255,7 +255,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/" + window.location.href = host + "user/" } } } @@ -296,7 +296,7 @@ async function update_password_form() { const req = await xhttp_post(url, body); if (req.status == 200) { - window.location.href = host + "/user/" + window.location.href = host + "user/" } else { alert(req.status + ": " + req.body) } @@ -311,7 +311,7 @@ async function update_name_form() { const req = await xhttp_post(url, body); if (req.status == 200) { - window.location.href = host + "/user/" + window.location.href = host + "user/" } else { alert(req.status + ": " + req.body) } @@ -352,13 +352,13 @@ window.onload = async function() { // and if logged in if (await is_logged_in()) { // move to the user index page - window.location.href = host + "/user/" + window.location.href = host + "user/" } - } else if (window.location.pathname == "/user/") { + } else if (window.location.href == host + "user/") { await user() - } else if (window.location.pathname == "/admin/regkeys/") { + } else if (window.location.href == host + "admin/regkeys/") { await regkeys() - } else if (window.location.pathname == "/user/update/") { + } else if (window.location.href == host + "user/update/") { await update_form_onload() } @@ -366,12 +366,12 @@ window.onload = async function() { const elements = document.getElementsByTagName("header"); for (x in elements) { elements[x].innerHTML += ` - <a href="/admin/"> + <a href="admin/"> <center class="button navbutton">ADMIN</center> </a> ` } - } + } } async function regkeys() { |