| Server IP : 103.48.194.25 / Your IP : 216.73.216.74 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/quagiare.com-bk/public_html/skin/js/ |
Upload File : |
window.Myweb || (window.Myweb = {}),
Myweb.mediaDomainName = site, Myweb.each = function (a, b) {
for (var c = 0; c < a.length; c++) b(a[c], c)
},
Myweb.getClass = function (a) {
return Object.prototype.toString.call(a).slice(8, -1)
},
Myweb.map = function (a, b) {
for (var c = [], d = 0; d < a.length; d++) c.push(b(a[d], d));
return c
},
Myweb.arrayContains = function (a, b) {
for (var c = 0; c < a.length; c++)
if (a[c] == b) return !0;
return !1
},
Myweb.distinct = function (a) {
for (var b = [], c = 0; c < a.length; c++) Myweb.arrayContains(b, a[c]) || b.push(a[c]);
return b
},
Myweb.getUrlParameter = function (a) {
var b = RegExp("[?&]" + a + "=([^&]*)").exec(window.location.search);
return b && decodeURIComponent(b[1].replace(/\+/g, " "))
},
Myweb.uniq = function (a) {
for (var b = [], c = 0; c < a.length; c++) Myweb.arrayIncludes(b, a[c]) || b.push(a[c]);
return b
},
Myweb.arrayIncludes = function (a, b) {
for (var c = 0; c < a.length; c++)
if (a[c] == b) return !0;
return !1
},
Myweb.Product = function () {
function a(a) {
if ("undefined" != typeof a)
for (property in a) this[property] = a[property]
}
return a.prototype.optionNames = function () {
return "Array" == Myweb.getClass(this.options) ? this.options : []
}, a.prototype.optionValues = function (a) {
if ("undefined" == typeof this.variants) return null;
var b = Myweb.map(this.variants, function (b) {
var c = "option" + (a + 1);
return "undefined" == typeof b[c] ? null : b[c]
});
return null == b[0] ? null : Myweb.distinct(b)
}, a.prototype.getVariant = function (a) {
var b = null;
return a.length != this.options.length ? null : (Myweb.each(this.variants, function (c) {
for (var d = !0, e = 0; e < a.length; e++) {
var f = "option" + (e + 1);
c[f] != a[e] && (d = !1)
}
if (d) return void(b = c)
}), b)
}, a.prototype.getVariantById = function (a) {
for (var b = 0; b < this.variants.length; b++) {
var c = this.variants[b];
if (c.id == a) return c
}
return null
}, a.name = "Product", a
}(),
Myweb.money_format = "{{amount}} VND",
Myweb.formatMoney = function (a, b) {
return a; //trit:dont use
function f(a, b, c, d) {
if ("undefined" == typeof b && (b = 2), "undefined" == typeof c && (c = "."), "undefined" == typeof d && (d = ","), "undefined" == typeof a || null == a) return 0;
a = a.toFixed(b);
var e = a.split("."),
f = e[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + c),
g = e[1] ? d + e[1] : "";
return f + g
}
"string" == typeof a && (a = a.replace(/\./g, ""), a = a.replace(/\,/g, ""));
var c = "",
d = /\{\{\s*(\w+)\s*\}\}/,
e = b || this.money_format;
switch (e.match(d)[1]) {
case "amount":
c = f(a, 2);
break;
case "amount_no_decimals":
c = f(a, 0);
break;
case "amount_with_comma_separator":
c = f(a, 2, ".", ",");
break;
case "amount_no_decimals_with_comma_separator":
c = f(a, 0, ".", ",")
}
return e.replace(d, c)
},
Myweb.OptionSelectors = function () {
function a(a, b) {
return
this.selectorDivClass = "selector-wrapper",
this.selectorClass = "single-option-selector",
this.variantIdFieldIdSuffix = "-variant-id",
this.variantIdField = null,
this.selectors = [],
this.domIdPrefix = a,
this.product = new Myweb.Product(b.product), "undefined" != typeof b.onVariantSelected ? this.onVariantSelected = b.onVariantSelected : this.onVariantSelected = function () {},
this.replaceSelector(a),
this.initDropdown(), !0
}
return a.prototype.replaceSelector = function (a) {
var b = document.getElementById(a),
c = b.parentNode;
Myweb.each(this.buildSelectors(), function (a) {
c.insertBefore(a, b)
}), b.style.display = "none", this.variantIdField = b
}, a.prototype.buildSelectors = function () {
for (var a = 0; a < this.product.optionNames().length; a++) {
var b = new Myweb.SingleOptionSelector(this, a, this.product.optionNames()[a], this.product.optionValues(a));
b.element.disabled = !1, this.selectors.push(b)
}
var c = this.selectorDivClass,
d = this.product.optionNames(),
e = Myweb.map(this.selectors, function (a) {
var b = document.createElement("div");
if (b.setAttribute("class", c), d.length > 1) {
var e = document.createElement("label");
e.htmlFor = a.element.id, e.innerHTML = a.name, b.appendChild(e)
}
return b.appendChild(a.element), b
});
return e
}, a.prototype.initDropdown = function () {
var a = {
initialLoad: !0
},
b = this.selectVariantFromDropdown(a);
if (!b) {
var c = this;
setTimeout(function () {
c.selectVariantFromParams(a) || c.selectors[0].element.onchange(a)
})
}
}, a.prototype.selectVariantFromDropdown = function (a) {
var b = document.getElementById(this.domIdPrefix).querySelector("[selected]");
return !!b && this.selectVariant(b.value, a)
}, a.prototype.selectVariantFromParams = function (a) {
var b = Myweb.getUrlParameter("variantid");
return null == b && (b = Myweb.getUrlParameter("variantId")), this.selectVariant(b, a)
}, a.prototype.selectVariant = function (a, b) {
var c = this.product.getVariantById(a);
if (null == c) return !1;
for (var d = 0; d < this.selectors.length; d++) {
var e = this.selectors[d].element,
f = e.getAttribute("data-option"),
g = c[f];
null != g && this.optionExistInSelect(e, g) && (e.value = g)
}
return "undefined" != typeof jQuery ? jQuery(this.selectors[0].element).trigger("change", b) : this.selectors[0].element.onchange(b), !0
}, a.prototype.optionExistInSelect = function (a, b) {
for (var c = 0; c < a.options.length; c++)
if (a.options[c].value == b) return !0
}, a.prototype.updateSelectors = function (a, b) {
var c = this.selectedValues(),
d = this.product.getVariant(c);
d ? (this.variantIdField.disabled = !1, this.variantIdField.value = d.id) : this.variantIdField.disabled = !0, this.onVariantSelected(d, this, b), null != this.historyState && this.historyState.onVariantChange(d, this, b)
}, a.prototype.selectedValues = function () {
for (var a = [], b = 0; b < this.selectors.length; b++) {
var c = this.selectors[b].element.value;
a.push(c)
}
return a
}, a.name = "OptionSelectors", a
}(),
Myweb.SingleOptionSelector = function (a, b, c, d) {
this.multiSelector = a,
this.values = d,
this.index = b,
this.name = c,
this.element = document.createElement("select");
for (var e = 0; e < d.length; e++) {
var f = document.createElement("option");
f.value = d[e], f.innerHTML = d[e],
this.element.appendChild(f)
}
return
this.element.setAttribute("class", this.multiSelector.selectorClass),
this.element.setAttribute("data-option", "option" + (b + 1)),
this.element.id = a.domIdPrefix + "-option-" + b,
this.element.onchange = function (c, d) {
d = d || {},
a.updateSelectors(b, d)
}, !0
},
Myweb.Image = {
preload: function (a, b) {
for (var c = 0; c < a.length; c++) {
var d = a[c];
this.loadImage(this.getSizedImageUrl(d, b))
}
},
loadImage: function (a) {
(new Image).src = a
},
switchImage: function (a, b, c) {
if (a && b) {
var d = this.imageSize(b.src),
e = this.getSizedImageUrl(a.src, d);
c ? c(e, a, b) : b.src = e
}
},
imageSize: function (a) {
var b = a.match(/thumb\/(1024x1024|2048x2048|pico|icon|thumb|small|compact|medium|large|grande)\//);
return null != b ? b[1] : null
},
getSizedImageUrl: function (a, b) {
if (null == b) return a;
if ("master" == b) return this.removeProtocol(a);
var c = a.match(/\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?$/i);
if (null != c) {
var d = Myweb.mediaDomainName + "thumb/" + b + "/";
return this.removeProtocol(a).replace(Myweb.mediaDomainName, d).split("?")[0]
}
return null
},
removeProtocol: function (a) {
return a.replace(/http(s)?:/, "")
}
};
Myweb.onCartRemoveClick = function(cart, variantId) {
jQuery.each(cart, function(key, value) {
if (key === 'items') {
jQuery.each(value, function(i, item) {
if(item.proid == variantId){
$('.productid-'+variantId).remove();
}
});
}
});
updateCartDesc(cart);
}
$(document).on('click', '.add_to_cart_detail', function (e) {
e.preventDefault();
$('#quickview').modal('hide');
var $this = $(this);
var form = $this.parents('form');
$.ajax({
type: 'POST',
url: site+'sanpham/cart/add',
async: false,
data: form.serialize(),
dataType: 'json',
error: addToCartFail,
beforeSend: function () {},
success: addToCartSuccess,
cache: false
});
});
var GLOBAL = {
common: {
init: function () {
$('.add_to_cart').bind('click', addToCart);
}
},
templateIndex: {
init: function () {}
},
templateProduct: {
init: function () {}
},
templateCart: {
init: function () {}
}
}
var UTIL = {
fire: function (func, funcname, args) {
var namespace = GLOBAL;
funcname = (funcname === undefined) ? 'init' : funcname;
if (func !== '' && namespace[func] && typeof namespace[func][funcname] == 'function') {
namespace[func][funcname](args);
}
},
loadEvents: function () {
var bodyId = document.body.id;
// hit up common first.
UTIL.fire('common');
// do all the classes too.
$.each(document.body.className.split(/\s+/), function (i, classnm) {
UTIL.fire(classnm);
UTIL.fire(classnm, bodyId);
});
}
};
$(document).ready(UTIL.loadEvents);
Number.prototype.formatMoney = function (c, d, t) {
var n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "." : d,
t = t == undefined ? "." : t,
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
function addToCart(e) {
if (typeof e !== 'undefined') e.preventDefault();
var $this = $(this);
var form = $this.parents('form');
$.ajax({
type: 'POST',
url: site+'sanpham/cart/add',
async: false,
data: form.serialize(),
dataType: 'json',
error: addToCartFail,
beforeSend: function () {},
success: addToCartSuccess,
cache: false
});
}
function addToCartSuccess(jqXHR, textStatus, errorThrown) {
$.ajax({
type: 'GET',
url: site+'sanpham/cart/get',
async: false,
cache: false,
dataType: 'json',
success: function (cart) {
//awe_hidePopup('.loading');
Myweb.updateCartFromForm(cart, '.top-cart-content .mini-products-list');
Myweb.updateCartPopupForm(cart, '#popup-cart-desktop .tbody-popup');
Myweb.updateCartPageForm(cart, '.cart_desktop_page .page_cart');
}
});
trit(jqXHR);
var url_product = jqXHR['url'];
var class_id = jqXHR['product_id'];
var name = jqXHR['name'];
var textDisplay = ('<i style="margin-right:5px; color:red; font-size:13px;" class="fa fa-check" aria-hidden="true"></i>Sản phẩm vừa thêm vào giỏ hàng');
var id = jqXHR['proid'];
if (product.image != null) {
var src = Myweb.resizeImage(product.image, 'medium');
} else {
var src = skin+"images/noimage.gif";
}
var dataList = $(".item-name a").map(function () {
var plus = $(this).text();
return plus;
}).get();
$('.title-popup-cart .cart-popup-name').html('<a href="' + url_product + '"style="color:red;" title="' + name + '">' + name + '</a> ');
var nameid = dataList,
found = $.inArray(name, nameid);
var textfind = found;
$(".item-info > p:contains(" + id + ")").html('<span class="add_sus" style="color:#898989;"><i style="margin-right:5px; color:red; font-size:13px;" class="fa fa-check" aria-hidden="true"></i>Sản phẩm vừa thêm!</span>');
var windowW = $(window).width();
if (windowW > 768) {
$('#popup-cart').modal();
} else {
$('#myModal').html('');
var $popupMobile = '<div class="modal-dialog"><div class="modal-content"><div class="modal-header">' +
'<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="position: relative; z-index: 9;"><span aria-hidden="true">×</span></button>' +
'<h4 class="modal-title" style="line-height:44px;"><span><i class="fa fa-check" aria-hidden="true"></i></span>Thêm vào giỏ hàng thành công</h4></div>' +
'<div class="modal-body"><div class="media"><div class="media-left"><div class="thumb-1x1">' +
'<img width="70px" src="' + Myweb.resizeImage(jqXHR['image'], 'small') + '" alt="' + jqXHR['title'] + '"></div></div>' +
'<div class="media-body"><div class="product-title">' + jqXHR['name'] + '</div>' +
'<div class="product-new-price"><span>' + jqXHR['price'] + ' đ</span></div></div></div>' +
'<button class="btn btn-block btn-outline-red" data-dismiss="modal">Tiếp tục mua hàng</button>' +
'<a href="'+site+'thanh-toan.html" class="btn btn-block btn-red">Tiến hành thanh toán »</a></div></div></div>';
$('#myModal').html($popupMobile);
$('#myModal').modal();
clearTimeout($('#myModal').data('hideInterval'));
//$('.product-new-price span').formatCurrency();
}
}
function addToCartFail(jqXHR, textStatus, errorThrown) {
var response = $.parseJSON(jqXHR.responseText);
var $info = '<div class="error">' + response.description + '</div>';
}
$(document).on('click', ".remove-item-cart", function () {
var variantId = $(this).attr('data-id');
removeItemCart(variantId);
});
$(document).on('click', ".items-count", function () {
$(this).parent().children('.items-count').prop('disabled', true);
var thisBtn = $(this);
var variantId = $(this).parent().find('.variantID').val();
var qty = $(this).parent().children('.number-sidebar').val();
updateQuantity(qty, variantId);
});
//thay doi số lượng sản phẩm
$(document).on('change', ".number-sidebar", function () {
var variantId = $(this).parent().children('.variantID').val();
var qty = $(this).val();
updateQuantity(qty, variantId);
});
function updateQuantity(qty, variantId) {
var variantIdUpdate = variantId;
$.ajax({
type: "POST",
url: site+"sanpham/cart/change",
data: {
"quantity": qty,
"proid": variantId
},
dataType: "json",
success: function (cart, variantId) {
window.location.reload();
//Myweb.onCartUpdateClick(cart, variantIdUpdate);
},
error: function (qty, variantId) {
//Myweb.onError(qty, variantId)
}
})
}
function removeItemCart(variantId) {
var variantIdRemove = variantId;
$.ajax({
type: "POST",
url: site+"sanpham/cart/remove",
data: {
"quantity": 0,
"proid": variantId
},
dataType: "json",
success: function (cart, variantId) {
//Myweb.onCartRemoveClick(cart, variantIdRemove);
$('.productid-' + variantIdRemove).remove();
if ($('.tbody-popup>div').length == '0') {
$('#popup-cart').modal('hide');
}
if ($('.list-item-cart>li').length == '0') {
$('.mini-products-list').html('<div class="no-item"><p>Không có sản phẩm nào trong giỏ hàng.</p></div>');
}
if ($('.cart_page_mobile>div').length == '0') {
$('.cart_page_mobile').remove();
$('.header-cart-price').remove();
$('.header-cart').remove();
jQuery('<div class="cart-empty">' +
'<span class="empty-icon"><i class="ico ico-cart"></i></span>' +
'<div class="btn-cart-empty">' +
'<a class="btn btn-default" href="'+site+'" title="Tiếp tục mua sắm">Tiếp tục mua sắm</a>' +
'</div>' +
'</div>').appendTo('.header-cart-content');
}
if ($('.cart-tbody>div').length == '0') {
$('.bg-cart-page').remove();
$('.bg-cart-page-mobile').remove();
jQuery('<div class="bg-cart-page" style="min-height: auto"><p>Không có sản phẩm nào trong giỏ hàng. Quay lại <a href="/">cửa hàng</a> để tiếp tục mua sắm.</p></div>').appendTo('.cart');
}
if ($('.cart-tbody>div').length == '0') {
$('.bg-cart-page').remove();
$('.bg-cart-page-mobile').remove();
$('.cart_des_page').remove();
jQuery('<div class="cart-empty">' +
'<span class="empty-icon"><i class="ico ico-cart"></i></span>' +
'<div class="btn-cart-empty">' +
'<a class="btn btn-default" href="'+site+'" title="Tiếp tục mua sắms">Tiếp tục lựa chọn</a>' +
'</div>' +
'</div>').appendTo('.cart_desktop_page');
}
updateCartDesc(cart);
},
error: function (variantId, r) {
Myweb.onError(variantId, r)
}
})
}