Files
cardconjurer/data/site/other/askScryfall/askScryfall.js
2020-07-06 17:29:48 -07:00

23 lines
748 B
JavaScript

var fullAbilityList = new Array()
function loadAbilities() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
fullAbilityList = xhttp.responseText.split("$$$")
for (var i = 0; i < 3; i ++) {
fullAbilityList[i] = fullAbilityList[i].split(";")
}
}
}
xhttp.open("GET", "/data/site/other/askScryfall/planeswalkerAbilities.txt", true);
xhttp.send();
}
function randomAbility(index) {
possibleAbilities = fullAbilityList[index]
document.getElementById("askScryfallResult").innerHTML = possibleAbilities[Math.floor(Math.random() * (possibleAbilities.length - 1))].replace(/\\"/g, '"')
}
loadAbilities()