Loop through an array with animation
So, I want to iterate over the list of arrays, when I click the button, I found the information, but I can't figure out how and where to put it in the code I already have, check below to see what I already;
[1]: http://codepen.io/anon/pen/PqKYwz
If anyone could help me that would be great! Would it be a bonus if someone could show me how to create a Launch link, for some reason it's annoying as hell?
source to share
If on a loop, you want to display all the game names one by one before displaying the final game name, here's what you can do,
So, I changed PickRandomWord()
and tick()
and created 2 global variables "i" and "s" as shown below,
var i = 0;
var s;
function PickRandomWord(frm) {
s = setInterval(function() {
tick(frm);
}, 180);
}
function tick(frm) {
frm.WordBox.value = words[i+1];
i++;
if (i > 27) {
clearInterval(s);
var rnd = Math.ceil(Math.random() * NumberOfWords);
var index = words[rnd].indexOf("/");
frm.WordBox.value = words[rnd].substring(0, index);
var link = document.getElementById("gameLink");
var str = words[rnd].substring(index + 1, words[rnd].length);
link.innerHTML = "<a class='launchLink' href ='steam://run/" + str + "'>Launch</a>";
i = 0;
}
}
As you requested, I created a class launchLink
for your Launch button and applied some simple styles. You can change the style according to your preference.
source to share