mirror of
https://github.com/SinTan1729/chhoto-url
synced 2024-12-26 07:38:36 -06:00
Reorganize files, keep table from moving on alert
This commit is contained in:
parent
2f48b1e58c
commit
e18a71a73c
6 changed files with 12 additions and 10 deletions
|
@ -15,10 +15,10 @@
|
||||||
<link rel="icon" type="image/png" href="assets/favicon-32.png" sizes="32x32">
|
<link rel="icon" type="image/png" href="assets/favicon-32.png" sizes="32x32">
|
||||||
<link rel="icon" type="image/png" href="assets/favicon-196.png" sizes="196x196">
|
<link rel="icon" type="image/png" href="assets/favicon-196.png" sizes="196x196">
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="static/script.js"></script>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.1/build/pure-min.css"
|
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.1/build/pure-min.css"
|
||||||
integrity="sha384-oAOxQR6DkCoMliIh8yFnu25d7Eq/PHS21PClpwjOTeU2jRSq11vu66rf90/cZr47" crossorigin="anonymous">
|
integrity="sha384-oAOxQR6DkCoMliIh8yFnu25d7Eq/PHS21PClpwjOTeU2jRSq11vu66rf90/cZr47" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" type="text/css" rel="noopener" target="_blank" href="styles.css">
|
<link rel="stylesheet" type="text/css" target="_blank" href="static/styles.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -40,6 +40,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-controls">
|
<div class="pure-controls">
|
||||||
<button class="pure-button pure-button-primary">Shorten!</button>
|
<button class="pure-button pure-button-primary">Shorten!</button>
|
||||||
|
<p id="alert-box"> </p>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
@ -49,7 +50,7 @@
|
||||||
<br>
|
<br>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td id="short-url-header">Short URL (click to copy)</td>
|
<td id="short-url-header">Short URL<br>(click to copy)</td>
|
||||||
<td>Long URL</td>
|
<td>Long URL</td>
|
||||||
<td>Hits</td>
|
<td>Hits</td>
|
||||||
<td name="deleteBtn">×</td>
|
<td name="deleteBtn">×</td>
|
||||||
|
|
|
@ -48,7 +48,7 @@ const displayData = async (data) => {
|
||||||
const table = document.querySelector("#url-table");
|
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 (right click and copy)";
|
shortUrlHeader.innerHTML = "Short URL<br>(right click and copy)";
|
||||||
}
|
}
|
||||||
table_box.style.visibility = "visible";
|
table_box.style.visibility = "visible";
|
||||||
table.innerHTML = ''; // Clear
|
table.innerHTML = ''; // Clear
|
||||||
|
@ -57,10 +57,10 @@ const displayData = async (data) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const showAlert = async (text, col) => {
|
const showAlert = async (text, col) => {
|
||||||
document.getElementById("alertBox")?.remove();
|
document.getElementById("alert-box")?.remove();
|
||||||
const controls = document.querySelector(".pure-controls");
|
const controls = document.querySelector(".pure-controls");
|
||||||
const alertBox = document.createElement("p");
|
const alertBox = document.createElement("p");
|
||||||
alertBox.setAttribute("id", "alertBox");
|
alertBox.setAttribute("id", "alert-box");
|
||||||
alertBox.setAttribute("style", `color:${col}`);
|
alertBox.setAttribute("style", `color:${col}`);
|
||||||
alertBox.innerHTML = text;
|
alertBox.innerHTML = text;
|
||||||
controls.appendChild(alertBox);
|
controls.appendChild(alertBox);
|
||||||
|
@ -121,7 +121,8 @@ const deleteButton = (shortUrl) => {
|
||||||
btn.onclick = e => {
|
btn.onclick = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (confirm("Do you want to delete the entry " + shortUrl + "?")) {
|
if (confirm("Do you want to delete the entry " + shortUrl + "?")) {
|
||||||
document.getElementById("alertBox")?.remove();
|
document.getElementById("alert-box")?.remove();
|
||||||
|
showAlert(" ", "black");
|
||||||
fetch(`/api/del/${shortUrl}`, {
|
fetch(`/api/del/${shortUrl}`, {
|
||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
}).then(_ => refreshData());
|
}).then(_ => refreshData());
|
|
@ -32,7 +32,7 @@ fn check(token: Option<String>) -> bool {
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
.expect("Time went backwards!")
|
.expect("Time went backwards!")
|
||||||
.as_secs();
|
.as_secs();
|
||||||
if token_text == "valid-session-token" && time_now < token_time + 1209600 {
|
if token_text == "session-token" && time_now < token_time + 1209600 {
|
||||||
// There are 1209600 seconds in 14 days
|
// There are 1209600 seconds in 14 days
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +43,7 @@ fn check(token: Option<String>) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn gen_token() -> String {
|
pub fn gen_token() -> String {
|
||||||
let token_text = "valid-session-token".to_string();
|
let token_text = "session-token".to_string();
|
||||||
let time = SystemTime::now()
|
let time = SystemTime::now()
|
||||||
.duration_since(SystemTime::UNIX_EPOCH)
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
.expect("Time went backwards!")
|
.expect("Time went backwards!")
|
||||||
|
|
|
@ -59,7 +59,7 @@ async fn siteurl(session: Session) -> HttpResponse {
|
||||||
// 404 error page
|
// 404 error page
|
||||||
#[get("/err/404")]
|
#[get("/err/404")]
|
||||||
async fn error404() -> impl Responder {
|
async fn error404() -> impl Responder {
|
||||||
NamedFile::open_async("./resources/404.html").await
|
NamedFile::open_async("./resources/static/404.html").await
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle a given shortlink
|
// Handle a given shortlink
|
||||||
|
|
Loading…
Reference in a new issue