mirror of
https://gitlab.com/skysthelimit.dev/selenite.git
synced 2025-06-16 02:22:07 -05:00
add random game button
This commit is contained in:
parent
776fe6e42a
commit
fac33033d8
@ -63,6 +63,7 @@
|
|||||||
<br />
|
<br />
|
||||||
<p id="gamecounter"></p>
|
<p id="gamecounter"></p>
|
||||||
<input type="text" id="gamesearch" placeholder="Type here to search.." />
|
<input type="text" id="gamesearch" placeholder="Type here to search.." />
|
||||||
|
<button id="random" onclick="selectRandomGame()">Click to play a random game!</button>
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<h2>Pinned Games</h2>
|
<h2>Pinned Games</h2>
|
||||||
|
20
js/games.js
20
js/games.js
@ -8,6 +8,7 @@ $.getJSON("/games.json", function (data) {
|
|||||||
console.log(starredgames);
|
console.log(starredgames);
|
||||||
$("#gamesearch").prop({ placeholder: "Click here to search through our " + data.length + " games!" });
|
$("#gamesearch").prop({ placeholder: "Click here to search through our " + data.length + " games!" });
|
||||||
data.sort(dynamicSort("name"));
|
data.sort(dynamicSort("name"));
|
||||||
|
gamelist = data;
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
let $element = $("<div>")
|
let $element = $("<div>")
|
||||||
.prop({
|
.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