From fac33033d843240b282eb974d339c7d904e9fdae Mon Sep 17 00:00:00 2001 From: Sky Date: Sat, 29 Jul 2023 15:41:56 -0400 Subject: [PATCH] add random game button --- index.html | 1 + js/games.js | 20 ++++++++++++++++++++ style.css | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/index.html b/index.html index f0b6aae9..4704f823 100644 --- a/index.html +++ b/index.html @@ -63,6 +63,7 @@

+

Pinned Games

diff --git a/js/games.js b/js/games.js index cd560cf2..a89a314a 100644 --- a/js/games.js +++ b/js/games.js @@ -8,6 +8,7 @@ $.getJSON("/games.json", function (data) { console.log(starredgames); $("#gamesearch").prop({ placeholder: "Click here to search through our " + data.length + " games!" }); data.sort(dynamicSort("name")); + gamelist = data; for (let i = 0; i < data.length; i++) { let $element = $("
") .prop({ @@ -135,3 +136,22 @@ function dynamicSort(property) { } }; } + +function selectRandomGame() { + randomgame = Math.floor(Math.random() * gamelist.length - 1); + Toastify({ + text: 'You will be redirected to ' + gamelist[randomgame].name + ' in 3 seconds', + duration: 3000, + gravity: "top", // `top` or `bottom` + position: "center", // `left`, `center` or `right` + style: { + background: "linear-gradient(42deg, rgba(36, 69, 128, 1) 100%, rgb(24, 17, 87) 0%)", + width: "25%", + }, + onClick: function () {}, // Callback after click + }).showToast(); + setTimeout(() => { + redirectGame(gamelist[randomgame].directory);s + }, 3000); + +} \ No newline at end of file diff --git a/style.css b/style.css index 1cf0e836..ae6a4fd3 100644 --- a/style.css +++ b/style.css @@ -232,3 +232,7 @@ h3 { #starred { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 48; } + +#random { + padding: 0.8% 0.8%; +} \ No newline at end of file