mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-15 18:12:08 -05:00
add random game button
This commit is contained in:
parent
776fe6e42a
commit
fac33033d8
@ -63,6 +63,7 @@
|
||||
<br />
|
||||
<p id="gamecounter"></p>
|
||||
<input type="text" id="gamesearch" placeholder="Type here to search.." />
|
||||
<button id="random" onclick="selectRandomGame()">Click to play a random game!</button>
|
||||
<br />
|
||||
<br />
|
||||
<h2>Pinned Games</h2>
|
||||
|
20
js/games.js
20
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 = $("<div>")
|
||||
.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);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user