diff --git a/confetti-box/src/lib.rs b/confetti-box/src/lib.rs index 5be8e1a..18bbf59 100644 --- a/confetti-box/src/lib.rs +++ b/confetti-box/src/lib.rs @@ -35,6 +35,7 @@ pub fn home(settings: &State) -> Markup { center { h1 { "Confetti-Box 🎉" } h2 { "Files up to " (settings.max_filesize.bytes()) " in size are allowed!" } + noscript { "Javascript must be enabled for this site to function!" } hr; button.main_file_upload #fileButton onclick="document.getElementById('fileInput').click()" { h4 { "Upload File(s)" } diff --git a/confetti-box/src/main.rs b/confetti-box/src/main.rs index 4ff148c..d2f0fc8 100644 --- a/confetti-box/src/main.rs +++ b/confetti-box/src/main.rs @@ -68,7 +68,8 @@ async fn main() { confetti_box::home, pages::api_info, pages::about, - resources::favicon, + resources::favicon_svg, + resources::favicon_ico, resources::form_handler_js, resources::stylesheet, resources::font_static, diff --git a/confetti-box/src/pages.rs b/confetti-box/src/pages.rs index 94bb85c..11e39aa 100644 --- a/confetti-box/src/pages.rs +++ b/confetti-box/src/pages.rs @@ -9,7 +9,7 @@ pub fn head(page_title: &str) -> Markup { meta charset="UTF-8"; meta name="viewport" content="width=device-width, initial-scale=1"; title { (page_title) } - link rel="icon" type="image/svg+xml" href="/resources/favicon.svg"; + link rel="icon" type="image/svg+xml" href="/favicon.svg"; link rel="stylesheet" href="/resources/main.css"; link rel="preload" href="/resources/fonts/Roboto.woff2" as="font" type="font/woff2" crossorigin; link rel="preload" href="/resources/fonts/FiraCode.woff2" as="font" type="font/woff2" crossorigin; diff --git a/confetti-box/src/resources.rs b/confetti-box/src/resources.rs index 8d89b99..e542d07 100644 --- a/confetti-box/src/resources.rs +++ b/confetti-box/src/resources.rs @@ -31,7 +31,12 @@ pub fn form_handler_js() -> RawJavaScript<&'static str> { RawJavaScript(include_str!("../web/request.js")) } -#[get("/resources/favicon.svg")] -pub fn favicon() -> (ContentType, &'static str) { +#[get("/favicon.svg")] +pub fn favicon_svg() -> (ContentType, &'static str) { (ContentType::SVG, include_str!("../web/favicon.svg")) } + +#[get("/favicon.ico")] +pub fn favicon_ico() -> (ContentType, &'static [u8]) { + (ContentType::Icon, include_bytes!("../web/favicon.ico")) +} diff --git a/confetti-box/web/favicon.ico b/confetti-box/web/favicon.ico new file mode 100644 index 0000000..1dd801e Binary files /dev/null and b/confetti-box/web/favicon.ico differ diff --git a/confetti-box/web/favicon.png b/confetti-box/web/favicon.png new file mode 100644 index 0000000..a1e4126 Binary files /dev/null and b/confetti-box/web/favicon.png differ diff --git a/confetti-box/web/request.js b/confetti-box/web/request.js index 69efd16..1d95f0e 100644 --- a/confetti-box/web/request.js +++ b/confetti-box/web/request.js @@ -3,6 +3,8 @@ const TOO_LARGE_TEXT = "Too large!"; const ZERO_TEXT = "File is blank!"; const ERROR_TEXT = "Error!"; +const USERAGENT = navigator.userAgent; +const USE_CHUNKS_COMPAT = /Ladybird/.test(USERAGENT); async function formSubmit() { const form = document.getElementById("uploadForm"); @@ -63,27 +65,28 @@ async function pasteSubmit(evt) { } async function sendFiles(files, duration, maxSize) { + if (USE_CHUNKS_COMPAT) { + console.warn("This browser is known to have problems with WebSockets, falling back to chunked upload"); + } + const inProgressUploads = new Set(); const concurrencyLimit = 10; - // Create a reference for the Wake Lock. + // Try to get a wake-lock let wakeLock = null; - - // create an async function to request a wake lock try { wakeLock = await navigator.wakeLock.request("screen"); } catch (err) { console.warn("Failed to set wake-lock!"); } - let start = performance.now(); for (const file of files) { console.log("Started upload for", file.name); // Start the upload and add it to the set of in-progress uploads let uploadPromise; - if ('WebSocket' in window && window.WebSocket.CLOSING === 2) { + if ('WebSocket' in window && window.WebSocket.CLOSING === 2 && !USE_CHUNKS_COMPAT) { console.log("Uploading file using Websockets"); uploadPromise = uploadFileWebsocket(file, duration, maxSize); } else { @@ -230,7 +233,7 @@ async function uploadFileWebsocket(file, duration, maxSize) { socket.send(""); }); - return new Promise(function(resolve, reject) { + return new Promise(function(resolve, _reject) { socket.addEventListener("message", (event) => { const response = JSON.parse(event.data); if (response.mmid == null) {