replace PHP in html with js & bugfixes

This commit is contained in:
2022-11-20 03:06:08 +01:00
parent 728b12107f
commit 0d3526221d
22 changed files with 634 additions and 233 deletions

View File

@@ -28,7 +28,7 @@ function send()
data.append('priority', pio.value);
let xhr = new XMLHttpRequest();
xhr.open('POST', '/', true);
xhr.open('POST', '/send.php', true);
xhr.onreadystatechange = function ()
{
if (xhr.readyState !== 4) return;
@@ -81,10 +81,27 @@ function send()
xhr.send(data);
}
window.addEventListener("load",function ()
window.addEventListener("load", function ()
{
let btnSend = document.getElementById("btnSend");
const qp = new URLSearchParams(window.location.search);
if (btnSend !== undefined) btnSend.onclick = function () { send(); return false; };
const btnSend = document.getElementById("btnSend");
const selPrio = document.getElementById("prio");
const txtKey = document.getElementById("ukey");
const txtUID = document.getElementById("uid");
const txtTitl = document.getElementById("msg");
const txtCont = document.getElementById("txt");
},false);
btnSend.onclick = function () { send(); return false; };
if (qp.has('preset_priority')) selPrio.selectedIndex = parseInt(qp.get("preset_priority"));
if (qp.has('preset_user_key')) txtKey.value = qp.get("preset_user_key");
if (qp.has('preset_user_id')) txtUID.value = qp.get("preset_user_id");
if (qp.has('preset_title')) txtTitl.value = qp.get("preset_title");
if (qp.has('preset_content')) txtCont.value = qp.get("preset_content");
}, false);

View File

@@ -0,0 +1,31 @@
window.addEventListener("load", function ()
{
const qp = new URLSearchParams(window.location.search);
const spanQuota1 = document.getElementById("insQuota1");
const spanQuota2 = document.getElementById("insQuota2");
const linkSucc = document.getElementById("succ_link");
const linkErr = document.getElementById("err_link");
spanQuota1.innerText = qp.get('quota_remain') ?? 'ERR';
spanQuota2.innerText = qp.get('quota_max') ?? 'ERR';
const preset_user_id = qp.get('preset_user_id') ?? 'ERR';
const preset_user_key = qp.get('preset_user_key') ?? 'ERR';
linkSucc.setAttribute("href", "/?preset_user_id="+preset_user_id+"&preset_user_key="+preset_user_key);
if (qp.get("ok") === "1") {
linkSucc.classList.remove('display_none');
linkErr.classList.add('display_none');
} else {
linkSucc.classList.add('display_none');
linkErr.classList.remove('display_none');
}
}, false);