From be6ff95fa629265514bfd5b3ae3624dfb92775b7 Mon Sep 17 00:00:00 2001 From: Ian Bishop <1296987+porjo@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:11:00 +1000 Subject: [PATCH] show spinner while loading --- css/style.css | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 6 ++++++ js/script.js | 5 ++++- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/css/style.css b/css/style.css index 0bb80ef..69bd07d 100644 --- a/css/style.css +++ b/css/style.css @@ -271,3 +271,53 @@ footer, header, hgroup, menu, nav, section { border-bottom: 3px solid transparent; border-top: 3px solid #8F0808; } + + +/* spinner */ + +.lds-dual-ring, +.lds-dual-ring:after { + box-sizing: border-box; +} +.lds-dual-ring { + display: inline-block; + width: 80px; + height: 80px; +} +.lds-dual-ring:after { + content: " "; + display: block; + width: 64px; + height: 64px; + margin: 8px; + border-radius: 50%; + border: 6.4px solid currentColor; + border-color: currentColor transparent currentColor transparent; + animation: lds-dual-ring 1.2s linear infinite; +} +@keyframes lds-dual-ring { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} + +.overlay { + display: none; + position: fixed; + top: 0; + left: 0; + height: 100%; + width: 100%; + z-index: 10; + background-color: rgba(255, 255, 255, 0.9) +} + +.spinner { + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} \ No newline at end of file diff --git a/index.html b/index.html index 5166533..f3aeca1 100644 --- a/index.html +++ b/index.html @@ -62,6 +62,12 @@

FreshTube

Note: the API key & other data entered will be saved in your browser's local storage.

+ +
+
+
+
+
diff --git a/js/script.js b/js/script.js index 9540ebc..dff5343 100644 --- a/js/script.js +++ b/js/script.js @@ -103,6 +103,7 @@ $('#save_button').click(function () { }) function errorBox (data) { + $('.overlay').hide() window.scrollTo({ top: 0, behavior: 'smooth' }) let errMsg = 'Unknown error occured' if (typeof data === 'object' && 'responseJSON' in data) { @@ -113,7 +114,6 @@ function errorBox (data) { errMsg = data } $('#error-box').text('Error: ' + errMsg).show() - // return Promise.reject(errMsg) } async function refresh () { @@ -212,6 +212,7 @@ async function processLine (line) { async function _refresh (lines) { $('#videos').html('') + $('.overlay').show() // update config config.lines = $('#video_urls').val().split('\n').filter(i => i) // filter ensures we don't get [""] @@ -244,6 +245,8 @@ async function _refresh (lines) { getSponsorBlock() getLiveBroadcasts() + + $('.overlay').hide() } // channel with most recently published visible video first