// === GLOBAL VAR
// === DOCUMENT READY (= DOM READY)
$(document).ready(function() {
// === PAGE TITLE & CART ===
// =========================
$(".pageTitle").attr("pageTitle", " | The Shop");
cartRedraw();
// === PRODUCT COLOR CHANGE ===
// ============================
$("span[setColor]").hover(
function() { // Mouse enter
var $this = $(this);
var $product = $this.closest(".product[reactToColor]");
$product.attr("reactToColor", $this.attr("setColor"));
$this.parent().find("span[setColor]").removeClass("selected");
$this.addClass("selected");
}, function() { } // Mouse leave
);
$(".product").hover(
function() { // Mouse enter
$(this).addClass('shadow');
}, function() { // Mouse leave
$(this).removeClass('shadow');
}
);
// === PRODUCT | BUY BUTTON ===
// ============================
$(".content-master .buy").on("click", function(event) {
var $product = $(this).closest(".product");
$.ajax({
type: "POST",
url: "_cart.php",
data: "p=" + B64.encode("add/§/"+ $product.attr("product") + "/§/"+ $product.attr("reactToColor") + "/§/"+ Math.floor(Date.now() / 1000)),
cache: false,
success: function(data) {
try {
var obj = JSON.parse(data);
}
catch(err) {
notifyMsg("danger", "Cart", "Server did not reply correctly.", "bi bi-journal-x");
return false;
}
if (obj.error != 0) {
notifyMsg("danger", "Cart ("+ obj.error +")", ""+ obj.shMsg +"
"+ obj.lngMsg +"", "bi bi-journal-x");
} else {
cartRedraw();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
notifyMsg("danger", "Internet (AJAX : "+ XMLHttpRequest.status +")", errorThrown, "bi bi-journal-x");
}
});
});
});