shii.moe

Source for `shii.moe' website.
git clone git://git.knutsen.co/shii.moe
Log | Files | Refs | README | LICENSE

commit 1e2fc11f2978cda7a238f41ff93180d0721f3d62
parent b20c91be88b832d57847ee52c23763d86dd7cd2a
Author: Shiimoe <samuelfrost@tuta.io>
Date:   Thu,  1 Jul 2021 21:44:53 +0100

Exclude novelty mascots on initial page load

Diffstat:
Mpublic/image.js | 10++++++++--
Mstatic/books.html | 2+-
Mstatic/index.html | 2+-
Mstatic/music.html | 2+-
Mstatic/norsk.html | 2+-
Mstatic/school.html | 2+-
6 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/public/image.js b/public/image.js @@ -1,11 +1,17 @@ const YUI_COUNT = 17; +const NOVELTY = [11, 15, 16]; const mascot = document.getElementById("mascot"); const favicon = document.querySelector("link[rel~='icon']"); mascot.style.opacity = 0; -const randomYui = () => { - const pick = Math.floor(1 + Math.random() * YUI_COUNT); +const randomYui = (excludeList=[]) => { + if (!Array.isArray(excludeList)) + excludeList = []; + const picks = [...new Array(YUI_COUNT)] + .map((_, i) => i + 1) + .filter(e => !excludeList.includes(e)); + const pick = picks[Math.floor(Math.random() * picks.length)]; const stem = "/mascots/" + pick; mascot.style.opacity = 0; mascot.setAttribute("src", stem + ".png"); diff --git a/static/books.html b/static/books.html @@ -30,6 +30,6 @@ <img src="/mascots/1.png" id="mascot"></img> <script src="colours.js"></script> <script src="image.js"></script> - <script>randomYui();</script> + <script>randomYui(NOVELTY);</script> </body> </html> diff --git a/static/index.html b/static/index.html @@ -47,6 +47,6 @@ <img src="/mascots/1.png" id="mascot"></img> <script src="colours.js"></script> <script src="image.js"></script> - <script>randomYui();</script> + <script>randomYui(NOVELTY);</script> </body> </html> diff --git a/static/music.html b/static/music.html @@ -55,6 +55,6 @@ <img src="/mascots/1.png" id="mascot"></img> <script src="colours.js"></script> <script src="image.js"></script> - <script>randomYui();</script> + <script>randomYui(NOVELTY);</script> </body> </html> diff --git a/static/norsk.html b/static/norsk.html @@ -31,6 +31,6 @@ <img src="/mascots/1.png" id="mascot"></img> <script src="colours.js"></script> <script src="image.js"></script> - <script>randomYui();</script> + <script>randomYui(NOVELTY);</script> </body> </html> diff --git a/static/school.html b/static/school.html @@ -30,6 +30,6 @@ <img src="/mascots/1.png" id="mascot"></img> <script src="colours.js"></script> <script src="image.js"></script> - <script>randomYui();</script> + <script>randomYui(NOVELTY);</script> </body> </html>