From 4e28c7a3e7b799683e0557f78b073f494e677b18 Mon Sep 17 00:00:00 2001 From: Redume Date: Mon, 22 Jul 2024 22:31:18 +0300 Subject: [PATCH] Improved the quality of the images. Added alt to the image via js. If the author is not present, then he will not be shown. If there is no picture, then there will be a redirect to error 404 --- localized-files/ru/static/script/wallpaperLoad.js | 11 ++++++----- static/script/wallpaperLoad.js | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/localized-files/ru/static/script/wallpaperLoad.js b/localized-files/ru/static/script/wallpaperLoad.js index 31c3dfc..2394032 100644 --- a/localized-files/ru/static/script/wallpaperLoad.js +++ b/localized-files/ru/static/script/wallpaperLoad.js @@ -3,20 +3,21 @@ function load(date) { res.json().then(data => { if (data.length === 0) return; - document.querySelector("div.wallpaper img").src = data.url; + 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 = `Image Credit & Copyright: ${data.copyright}`; + document.querySelector(".copyright").innerHTML = data.copyright ? `Автор: ${data.copyright}` : '' document.querySelector(".desc").innerHTML = data.explanation; }); }); } function parseURL() { - let pathname = document.location.pathname + let pathname = document.location.pathname; pathname = pathname.slice(pathname.lastIndexOf('/')+1) - if (isNaN(new Date(pathname).getTime())) return null; - if (!isValidDate(pathname)) return null; + if (isNaN(new Date(pathname).getTime())) return window.location.replace("./404.html"); + if (!isValidDate(pathname)) return window.location.replace("./404.html"); return pathname; } diff --git a/static/script/wallpaperLoad.js b/static/script/wallpaperLoad.js index 31c3dfc..425f479 100644 --- a/static/script/wallpaperLoad.js +++ b/static/script/wallpaperLoad.js @@ -3,20 +3,21 @@ function load(date) { res.json().then(data => { if (data.length === 0) return; - document.querySelector("div.wallpaper img").src = data.url; + 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 = `Image Credit & Copyright: ${data.copyright}`; + document.querySelector(".copyright").innerHTML = data.copyright ? `Copyright: ${data.copyright}` : '' document.querySelector(".desc").innerHTML = data.explanation; }); }); } function parseURL() { - let pathname = document.location.pathname + let pathname = '2024-01-01'; pathname = pathname.slice(pathname.lastIndexOf('/')+1) - if (isNaN(new Date(pathname).getTime())) return null; - if (!isValidDate(pathname)) return null; + if (isNaN(new Date(pathname).getTime())) return window.location.replace("./404.html"); + if (!isValidDate(pathname)) return window.location.replace("./404.html"); return pathname; }