From cbcb7991f526cb5d56894daea2d87fd6ebe2bc65 Mon Sep 17 00:00:00 2001 From: Redume Date: Sat, 14 Sep 2024 21:05:54 +0300 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D0=B7=D0=B0=20=D0=BD=D0=B5=D0=BD=D0=B0=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web/static/script/wallpaperLoad.js | 38 -------------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/web/static/script/wallpaperLoad.js diff --git a/src/web/static/script/wallpaperLoad.js b/src/web/static/script/wallpaperLoad.js deleted file mode 100644 index 0d66d24..0000000 --- a/src/web/static/script/wallpaperLoad.js +++ /dev/null @@ -1,38 +0,0 @@ -function load(date) { - fetch(`https://api.starlio.space/wallpaper/${date}`).then(res => { - res.json().then(data => { - if (data.length === 0) return; - - document.querySelector("div.wallpaper img").src = data.hdurl; - document.querySelector("div.wallpaper img").alt = data.title; - document.querySelector("div.wallpaper div.wallpaper-text div.wallpaper-desc h1").innerHTML = data.title; - document.querySelector(".copyright").innerHTML = data.copyright ? `Copyright: ${data.copyright}` : '' - document.querySelector(".desc").innerHTML = data.explanation; - }); - }); -} - -function parseURL() { - let pathname = document.location.pathname; - pathname = pathname.slice(pathname.lastIndexOf('/')+1) - - if (isNaN(new Date(pathname).getTime())) return window.location.replace("../404.html"); - if (!isValidDate(pathname)) return window.location.replace("../404.html"); - - return pathname; -} - - -/* THX, bro <3 - https://stackoverflow.com/a/35413963/20781634 - */ -function isValidDate(dateString) { - var regEx = /^\d{4}-\d{2}-\d{2}$/; - if(!dateString.match(regEx)) return false; - var d = new Date(dateString); - var dNum = d.getTime(); - if(!dNum && dNum !== 0) return false; - return d.toISOString().slice(0,10) === dateString; -} - -load(parseURL()); \ No newline at end of file