Deprecated: Creation of dynamic property Post::$results is deprecated in /home/freerea/www/inc/class/Post.php on line 10
Deprecated: Creation of dynamic property Post::$nb is deprecated in /home/freerea/www/inc/class/Post.php on line 10
Deprecated: Creation of dynamic property Post::$results is deprecated in /home/freerea/www/inc/class/Post.php on line 10
Deprecated: Creation of dynamic property Post::$nb is deprecated in /home/freerea/www/inc/class/Post.php on line 10
Deprecated: Creation of dynamic property Post::$results is deprecated in /home/freerea/www/inc/class/Post.php on line 10
Deprecated: Creation of dynamic property Post::$nb is deprecated in /home/freerea/www/inc/class/Post.php on line 10
function loadJSON(callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open("GET", "https://freereadings.org/themes/tpl/app/cards_en.json", true); // Replace 'my_data' with the path to your file
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
// Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
callback(xobj.responseText);
}
};
xobj.send(null);
}
function initJson() {
loadJSON(function (response) {
// Parse JSON string into object
window.actual_JSON = JSON.parse(response);
console.log(window.actual_JSON);
console.log(Object.keys(window.actual_JSON).length);
});
}
function selectSubject($btnId) {
var elements = document.getElementsByClassName("btn-active");
console.log(elements);
if (elements.length > 0) {
elements[0].classList.remove("btn-active");
}
var element = document.getElementById($btnId);
element.classList.add("btn-active");
document.getElementById("card_subject").value = $btnId;
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min) + min);
}
function newDraw() {
setTimeout(function () {
var loader = document.getElementById("appDraw");
loader.style.transition = ".5s";
loader.style.opacity = "0";
loader.style.visibility = "hidden";
}, 650);
setTimeout(function () {
var loader = document.getElementById("appDraw");
loader.style.display = "none";
}, 650);
setTimeout(function () {
var loader = document.getElementById("appHome");
loader.style.transition = ".5s";
loader.style.opacity = "100";
loader.style.visibility = "visible";
}, 650);
setTimeout(function () {
var loader = document.getElementById("appHome");
loader.style.display = "block";
}, 650);
//document.getElementById("appHome").style.display = "block"; //hide
//document.getElementById("appDraw").style.display = "none"; //hide
document.getElementById("appHome").scrollIntoView();
}
function draw() {
//document.getElementById("appHome").style.display = "none"; //hide
//document.getElementById("appDraw").style.display = "block"; //hide
setTimeout(function () {
var loader = document.getElementById("appDraw");
loader.style.transition = ".3s";
loader.style.opacity = "100";
loader.style.visibility = "visible";
}, 650);
setTimeout(function () {
var loader = document.getElementById("appDraw");
loader.style.display = "block";
}, 650);
setTimeout(function () {
var loader = document.getElementById("appHome");
loader.style.transition = ".3s";
loader.style.opacity = "0";
loader.style.visibility = "hidden";
}, 650);
setTimeout(function () {
var loader = document.getElementById("appHome");
loader.style.display = "none";
}, 650);
document.getElementById("appDraw").scrollIntoView();
console.log(actual_JSON);
cardId = getRandomInt(0, Object.keys(window.actual_JSON).length);
cardSide = getRandomInt(0, 2);
card = actual_JSON[cardId];
console.log(cardId);
console.log(cardSide);
console.log(document.getElementById("card_subject").value);
console.log(card.cd_name);
var cd_name = document.getElementsByClassName("cd_name");
Array.from(cd_name).forEach((el) => {
el.innerHTML = card.cd_name;
});
var cd_desc = document.getElementById("cd_desc");
cd_desc.innerHTML = card.cd_desc;
if (cardSide == 0) {
cardSideText = "Upright";
cardSide = "up";
cardClassName = "dailytarot__img";
} else {
cardSideText = "Reversed";
cardSide = "down";
cardClassName = "dailytarot__img_reversed";
}
var cd_side_text = document.getElementById("cd_side_text");
cd_side_text.innerHTML = cardSideText;
var cd_draw = document.getElementById("cd_draw");
eval(
"cd_draw.innerHTML = card.cd_" +
document.getElementById("card_subject").value +
"_" +
cardSide
);
var cd_img = document.getElementById("cd_img");
cd_img.src =
"https://freereadings.org/themes/tpl/assets/arcanes/" + cardId + ".jpg";
cd_img.className = cardClassName;
}
initJson();
document.getElementById("appDraw").style.display = "none"; //hide