Improved UI interactions with things

This commit is contained in:
G2-Games 2024-10-24 12:58:11 -05:00
parent 094fb67649
commit 4809be56a9
2 changed files with 6 additions and 5 deletions

View file

@ -2,7 +2,7 @@ mod database;
mod strings; mod strings;
mod settings; mod settings;
use std::{fs, path::Path, sync::{Arc, RwLock}, thread, time::Duration}; use std::{fs, path::Path, sync::{Arc, RwLock}};
use blake3::Hash; use blake3::Hash;
use chrono::{DateTime, TimeDelta, Utc}; use chrono::{DateTime, TimeDelta, Utc};
use database::{clean_loop, Database, MochiFile}; use database::{clean_loop, Database, MochiFile};
@ -55,7 +55,7 @@ fn home(settings: &State<Settings>) -> Markup {
h2 { "Files up to " (settings.max_filesize.bytes()) " in size are allowed!" } h2 { "Files up to " (settings.max_filesize.bytes()) " in size are allowed!" }
hr; hr;
button.main_file_upload onclick="document.getElementById('fileInput').click()" { button.main_file_upload onclick="document.getElementById('fileInput').click()" {
h4 { "Upload File" } h4 { "Upload File(s)" }
p { "Click or Drag and Drop" } p { "Click or Drag and Drop" }
} }
h3 { "Expire after:" } h3 { "Expire after:" }

View file

@ -58,21 +58,22 @@ function makeFinished(progressBar, progressText, linkRow, linkAddress, hash) {
const link = progressText.appendChild(document.createElement("a")); const link = progressText.appendChild(document.createElement("a"));
link.textContent = hash; link.textContent = hash;
link.href = linkAddress; link.href = linkAddress;
link.target = "_blank";
let button = linkRow.appendChild(document.createElement("button")); let button = linkRow.appendChild(document.createElement("button"));
button.textContent = "📝"; button.textContent = "📝";
let buttonTimeout = null; let buttonTimeout = null;
button.addEventListener('click', function(e) { button.addEventListener('click', function(_e) {
if (buttonTimeout) { if (buttonTimeout) {
clearTimeout(buttonTimeout) clearTimeout(buttonTimeout)
} }
navigator.clipboard.writeText( navigator.clipboard.writeText(
encodeURI("https://" + window.location.host + "/" + linkAddress) encodeURI(window.location.protocol + "//" + window.location.host + "/" + linkAddress)
) )
button.textContent = "✅"; button.textContent = "✅";
buttonTimeout = setTimeout(function() { buttonTimeout = setTimeout(function() {
button.textContent = "📝"; button.textContent = "📝";
}, 500); }, 750);
}) })
progressBar.style.display = "none"; progressBar.style.display = "none";