Last active
October 6, 2024 00:32
-
-
Save kyledinh/7addffe711f6aac1a78e706d43a5f1a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var APP = APP || {}; | |
APP.deckURL = "https://gfx.tarot.com/images/site/decks/rider/full_size/"; // xx.jpg | |
APP.randCard = function () { return Math.floor((Math.random() * 77)) }; // 0 - 77 | |
APP.mkTarotImg = function (id, cardNum) { | |
var cardNum = cardNum || APP.randCard(); | |
var card = document.createElement("img"); | |
card.id = id; | |
card.className = "tarot"; | |
card.src = APP.deckURL + cardNum + ".jpg"; | |
card.width = 100; | |
card.addEventListener("click", function() { | |
this.src = APP.deckURL + APP.randCard() + '.jpg'; | |
}); | |
return card; | |
}; | |
var card1 = APP.mkTarotImg("card1", APP.randCard()); | |
var card2 = APP.mkTarotImg("card2", APP.randCard()); | |
var card3 = APP.mkTarotImg("card3", APP.randCard()); | |
var card4 = APP.mkTarotImg("card4", APP.randCard()); | |
var card5 = APP.mkTarotImg("card5", APP.randCard()) | |
var deck = document.getElementById("deck"); | |
deck.appendChild(card1); | |
deck.appendChild(card2); | |
deck.appendChild(card3); | |
deck.appendChild(card4); | |
deck.appendChild(card5); | |
document.getElementById("stop").addEventListener("click", function() { | |
clearInterval(timer1); | |
clearInterval(timer2); | |
clearInterval(timer3); | |
clearInterval(timer4); | |
clearInterval(timer5); | |
}); | |
var timer1 = setInterval( function () { | |
document.getElementById("card1").click(); | |
}, 5000); | |
var timer2 = setInterval( function () { | |
document.getElementById("card2").click(); | |
}, 7000); | |
var timer3 = setInterval( function () { | |
document.getElementById("card3").click(); | |
}, 9000); | |
var timer4 = setInterval( function () { | |
document.getElementById("card4").click(); | |
}, 4000); | |
var timer5 = setInterval( function () { | |
document.getElementById("card5").click(); | |
}, 6000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://jsfiddle.net/ronincoder/ts9au3n7/2/