mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2024-11-22 01:06:46 +00:00
fix: Fixed some UI visibility related stuff
This commit is contained in:
parent
3445d5366a
commit
b1632c4c87
@ -40,7 +40,7 @@
|
|||||||
<input type="text" name="shortUrl" id="shortUrl" placeholder="Only a-z, 0-9, - and _ are allowed"
|
<input type="text" name="shortUrl" id="shortUrl" placeholder="Only a-z, 0-9, - and _ are allowed"
|
||||||
pattern="[a-z0-9\-_]+" title="Only a-z, 0-9, - and _ are allowed"/>
|
pattern="[a-z0-9\-_]+" title="Only a-z, 0-9, - and _ are allowed"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-controls">
|
<div class="pure-controls" id="controls">
|
||||||
<button class="pure-button pure-button-primary">Shorten!</button>
|
<button class="pure-button pure-button-primary">Shorten!</button>
|
||||||
<p id="alert-box"> </p>
|
<p id="alert-box"> </p>
|
||||||
</div>
|
</div>
|
||||||
@ -48,7 +48,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p id="loading-text">Loading links table...</p>
|
<p id="loading-text">Loading links table...</p>
|
||||||
<table class="pure-table" hidden>
|
<table class="pure-table" id="table-box" hidden>
|
||||||
<caption>Active links</caption>
|
<caption>Active links</caption>
|
||||||
<br />
|
<br />
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -44,6 +44,7 @@ const refreshData = async () => {
|
|||||||
let res = await fetch(prepSubdir("/api/all"));
|
let res = await fetch(prepSubdir("/api/all"));
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
let errorMsg = await res.text();
|
let errorMsg = await res.text();
|
||||||
|
document.getElementById("url-table").innerHTML = '';
|
||||||
console.log(errorMsg);
|
console.log(errorMsg);
|
||||||
if (errorMsg == "Using public mode.") {
|
if (errorMsg == "Using public mode.") {
|
||||||
document.getElementById("admin-button").hidden = false;
|
document.getElementById("admin-button").hidden = false;
|
||||||
@ -67,30 +68,30 @@ const displayData = async (data) => {
|
|||||||
admin_button.href = "javascript:logOut()";
|
admin_button.href = "javascript:logOut()";
|
||||||
admin_button.hidden = false;
|
admin_button.hidden = false;
|
||||||
|
|
||||||
table_box = document.querySelector(".pure-table");
|
table_box = document.getElementById("table-box");
|
||||||
loading_text = document.getElementById("loading-text");
|
loading_text = document.getElementById("loading-text");
|
||||||
|
const table = document.getElementById("url-table");
|
||||||
|
|
||||||
if (data.length == 0) {
|
if (data.length == 0) {
|
||||||
table_box.hidden = true;
|
table_box.hidden = true;
|
||||||
loading_text.hidden = true;
|
|
||||||
loading_text.innerHTML = "No active links.";
|
loading_text.innerHTML = "No active links.";
|
||||||
|
loading_text.hidden = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loading_text.style.display = "none";
|
loading_text.hidden = true;
|
||||||
const table = document.querySelector("#url-table");
|
|
||||||
if (!window.isSecureContext) {
|
if (!window.isSecureContext) {
|
||||||
const shortUrlHeader = document.getElementById("short-url-header");
|
const shortUrlHeader = document.getElementById("short-url-header");
|
||||||
shortUrlHeader.innerHTML = "Short URL<br>(right click and copy)";
|
shortUrlHeader.innerHTML = "Short URL<br>(right click and copy)";
|
||||||
}
|
}
|
||||||
table_box.hidden = false;
|
table_box.hidden = false;
|
||||||
table.innerHTML = ''; // Clear
|
table.innerHTML = '';
|
||||||
data.forEach(tr => table.appendChild(TR(tr, site)));
|
data.forEach(tr => table.appendChild(TR(tr, site)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const showAlert = async (text, col) => {
|
const showAlert = async (text, col) => {
|
||||||
document.getElementById("alert-box")?.remove();
|
document.getElementById("alert-box")?.remove();
|
||||||
const controls = document.querySelector(".pure-controls");
|
const controls = document.getElementById("controls");
|
||||||
const alertBox = document.createElement("p");
|
const alertBox = document.createElement("p");
|
||||||
alertBox.id = "alert-box";
|
alertBox.id = "alert-box";
|
||||||
alertBox.style.color = col;
|
alertBox.style.color = col;
|
||||||
@ -228,7 +229,8 @@ const submitLogin = () => {
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
document.getElementById("container").style.filter = "blur(0px)"
|
document.getElementById("container").style.filter = "blur(0px)"
|
||||||
document.getElementById("login-dialog").remove();
|
document.getElementById("login-dialog").close();
|
||||||
|
password.value = '';
|
||||||
refreshData();
|
refreshData();
|
||||||
} else {
|
} else {
|
||||||
const wrongPassBox = document.getElementById("wrong-pass");
|
const wrongPassBox = document.getElementById("wrong-pass");
|
||||||
@ -242,7 +244,9 @@ const submitLogin = () => {
|
|||||||
const logOut = async () => {
|
const logOut = async () => {
|
||||||
let reply = await fetch(prepSubdir("/api/logout"), {method: "DELETE"}).then(res => res.text());
|
let reply = await fetch(prepSubdir("/api/logout"), {method: "DELETE"}).then(res => res.text());
|
||||||
console.log(reply);
|
console.log(reply);
|
||||||
location.reload();
|
document.getElementById("table-box").hidden = true;
|
||||||
|
document.getElementById("loading-text").hidden = false;
|
||||||
|
refreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user