/*UBUYWEB-NEW LIVE*/
var UB_BASEURL = uba_baseurl + "ubuywebanalytics/webtrack/track.php";
var uba_hostname = window.location.origin;
var uba_currenturl = window.location.href.toString();
//console.log(uba_hostname+"-----------"+uba_currenturl);
var uba_ssSessionId = "";
var uba_cookieId = (recentViewData = mostViewData = "");
var uba_screen_width = jQuery(window).width();
const dt = new Date();
var is_rtl = false;
if (uba_is_arabic_store == true) {
is_rtl = true;
}
//console.log('page details '+uba_currentPage);
if (uba_ssGetURLParameter("utm_source") != null) {
uba_ssSessionId = uba_ssGetURLParameter("utm_source");
}
if (uba_ssSessionId != "") {
if (uba_ssSessionId.toLowerCase() == "ubanalytics") {
var uba_ssSessionId = uba_ssSessionId.toLowerCase();
const ubaUrlSearchParams = new URLSearchParams(window.location.search);
const ubautmparams = Object.fromEntries(ubaUrlSearchParams.entries());
trackUserUtm(ubautmparams);
setCacheWithExpiry("REFUBA", ubautmparams, 360);
}
}
function restrictKey(parm) {
if (
parm.indexOf("Saxenda") >= 0 ||
parm.indexOf("beef") >= 0 ||
parm.indexOf("Beef") >= 0 ||
parm.indexOf("belly dance") >= 0 ||
parm.indexOf("bikini") >= 0 ||
parm.indexOf("xnxx.xom") >= 0 ||
parm.indexOf("penis") >= 0 ||
parm.indexOf("masturbation") >= 0 ||
parm.indexOf("genitals") >= 0 ||
parm.indexOf("wanking") >= 0 ||
parm.indexOf("frigging") >= 0 ||
parm.indexOf("jerk off") >= 0 ||
parm.indexOf("adult automatic") >= 0 ||
parm.indexOf("silicone") >= 0 ||
parm.indexOf("adult toy") >= 0 ||
parm.indexOf("hot ass") >= 0 ||
parm.indexOf("g spot") >= 0 ||
parm.indexOf("vibrating Panti") >= 0 ||
parm.indexOf("gutterfly vibrator") >= 0 ||
parm.indexOf("sex toy") >= 0 ||
parm.indexOf("sexy") >= 0 ||
parm.indexOf("adult sex") >= 0 ||
parm.indexOf("sex toys") >= 0 ||
parm.indexOf("sucking vibrator") >= 0 ||
parm.indexOf("oral sex") >= 0 ||
parm.indexOf("couple solo") >= 0 ||
parm.indexOf("xxx video") >= 0 ||
parm.indexOf("tribal belt") >= 0
) {
return false;
} else {
return true;
}
}
/******Start MD5********/
var uba_user_id =
(uba_username =
uba_emailid =
uba_cartcount =
uba_productId =
uba_store =
"");
var uba_subStore = "";
var ub_userdetails = getUserDetails();
uba_username = ub_userdetails.username;
uba_emailid = ub_userdetails.cem;
uba_cartcount = ub_userdetails.cartcount;
if (uba_current_store == "" || uba_current_store == "undefined") {
uba_current_store = ub_userdetails.store;
}
if (uba_emailid == "" && uba_username != "Sign In") {
uba_username = "Sign In";
}
uba_subStore = ub_userdetails.substore;
const now = new Date();
var ub_current_time = now.getTime();
/******Start Document*********/
//var UB_BASEURL = "https://ubuyanalytics.ubuy.com.kw/webtrack/track.php";
var uba_canonical_url = jQuery('link[rel="canonical"]').attr("href");
if (uba_canonical_url == undefined) {
var uba_Activepage = "unknown";
} else {
const split_url = uba_canonical_url.split("/");
if (split_url[4] == undefined) {
var uba_Activepage = "unknown";
} else {
var uba_Activepage = split_url[4];
}
}
function UbaGetURLParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split("&");
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split("=");
if (sParameterName[0] == sParam) {
return sParameterName[1];
}
}
}
var stickstatus = "";
var stickstatus = UbaGetURLParameter("exitintent");
// UpdateTriggerActivity();
var ub_isSticky = false;
var ubei_is_code_copied = false;
jQuery(document).ready(function () {
jQuery(window).scroll(function () {
if (jQuery(window).scrollTop() > 300 && jQuery(window).width() > 992) {
jQuery("#product_addtocart_form .qty-cart").addClass("fixed-add-to-cart");
ub_isSticky = true;
} else {
jQuery("#product_addtocart_form .qty-cart").removeClass(
"fixed-add-to-cart"
);
ub_isSticky = false;
}
});
uba_cookieId = getCacheWithExpiry("new_session_id");
var ub_tabTalk = "";
/*Check Current URL */
if (uba_cookieId == "") {
setTrackCookies();
}
if (uba_currentPage == "home") {
// setInterval(getHomepagePurchase, 107500);
myFunction();
getRecentViewProducts();
getHelloBar();
if (uba_website_id == 5 || uba_website_id == 14) {
}
get_curiosity_timer();
}
if (uba_currentPage == "detail") {
// setInterval(getHomepagePurchase, 107500);
myFunction();
/*Start Tab Talk*/
var ub_tabTalk = "";
trackUserDetail(ub_tabTalk);
setRecentSearch();
getHelloBar();
if (uba_website_id == 5 || uba_website_id == 14 || uba_website_id == 52) {
//getBoughtWithProducts();
}
if (
uba_website_id == 195 ||
uba_website_id == 156 ||
uba_website_id == 19
) {
// get_curiosity_timer();
}
get_curiosity_timer();
}
/****Start Saving in Browser Storage****/
var uba_search_keyword = jQuery(".search-box-text").val();
if (uba_search_keyword != "" && uba_search_keyword != undefined) {
if (uba_catId != "" && uba_catId != undefined) {
uba_search_keyword = "";
}
var uba_oldItems =
JSON.parse(localStorage.getItem("recent_" + uba_cookieId)) || [];
if (uba_search_keyword != "" && uba_search_keyword != undefined) {
uba_oldItems.push(uba_search_keyword);
var uba_x = uba_oldItems;
var uba_keyArr = [];
var uba_list = uba_x;
jQuery.each(uba_list, function (index, value) {
if (uba_keyArr.indexOf(value) === -1) {
value = value.replaceAll("-", " ");
value = value.replaceAll("_", " ");
value = value.replaceAll("<", " ");
value = value.replaceAll(">", " ");
value = value.replaceAll("|", " ");
value = value
.replace('""', '"')
.replace("''", "'")
.replace(",,", ",");
value = value.toLowerCase();
uba_keyArr.push(value);
}
});
localStorage.setItem(
"recent_" + uba_cookieId,
JSON.stringify(uba_keyArr)
);
}
}
/****End Saving in Browser Storage****/
/*Start Showing Data From Browser Storage*/
var uba_lastThree = "";
var getRecentArr = localStorage.getItem("recent_" + uba_cookieId);
var uba_lastThree = JSON.parse(getRecentArr);
function unique(list) {
var result = [];
jQuery.each(list, function (i, e) {
if (jQuery.inArray(e, result) == -1) result.push(e);
});
return result;
}
var uba_lastThree = unique(uba_lastThree);
if (
uba_lastThree != "" &&
uba_lastThree != undefined &&
uba_lastThree.length >= 2
) {
uba_lastThree = uba_lastThree.reverse();
uba_lastThree = uba_lastThree.slice(0, 5);
uba_searchkey = uba_newsearchkey = "";
jQuery.each(uba_lastThree, function (index, value) {
value = value
.replace('""', '"')
.replace("''", "'")
.replace(",,", ",");
value = value.replaceAll("-", " ");
value = value.replaceAll("_", " ");
value = value.replaceAll("<", " ");
value = value.replaceAll(">", " ");
value = value.replaceAll("|", " ");
uba_newsearchkey +=
"
" +
value +
"";
});
if (
uba_currenturl.includes("action-figures-2514571011") ||
uba_currenturl.includes("hareem-al-sultan-perfume-oil") ||
uba_currenturl.includes("energy-drinks-16318341") ||
uba_currenturl.includes("soccer-3417981") ||
uba_currenturl.includes("cricket-3402931")
) {
} else {
if ( uba_newsearchkey != '') {
jQuery('.recent-search').show();
jQuery(".recent-li").after(uba_newsearchkey);
}
// var uba_recentSearchNewDiv =
// '- Recent Search -
' +
// uba_newsearchkey +
// "
";
// //var uba_sbbreaddiv = jQuery('.uba-breadcrumbs');
// var uba_sbbreaddiv = jQuery(".breadcrumb");
// if (uba_currentPage != "unknown") {
// jQuery(uba_sbbreaddiv).after(uba_recentSearchNewDiv);
// }
}
}
/*End Showing Data Form Browser Storage*/
if (uba_currentPage == "checkout") {
//getChooseUsData(uba_store_id);
}
if (uba_currentPage == "success") {
setSuccessOrderData(uba_order_items_data);
}
if (uba_currentPage == "catalogsearch_result") {
// setInterval(getHomepagePurchase, 107500);
// getHomepagePurchase();
myFunction();
if (uba_catId != "" && uba_catId != undefined) {
// getTopCategoryProduct();
}
if (
uba_currenturl.includes("action-figures-2514571011") ||
uba_currenturl.includes("hareem-al-sultan-perfume-oil") ||
uba_currenturl.includes("energy-drinks-16318341") ||
uba_currenturl.includes("soccer-3417981") ||
uba_currenturl.includes("cricket-3402931")
) {
} else {
setRecentSearch();
}
getHelloBar();
if (uba_website_id == 5 || uba_website_id == 14) {
setSearchTracking();
}
// setUserHomePageCategories();
if (
uba_website_id == 195 ||
uba_website_id == 156 ||
uba_website_id == 19
) {
// get_curiosity_timer();
}
get_curiosity_timer();
}
if (
uba_currentPage == "cart" &&
uba_cartcount != "0" &&
true &&
uba_is_mobile == "0"
) {
}
});
function addkey(uba_titlevalue = "") {
if (uba_titlevalue != "" && uba_titlevalue != undefined) {
jQuery(".search-box-text").val(uba_titlevalue);
}
}
/******End Document*********/
/*==================================Start Functions==========================*/
function encodeData(data) {
if (!data) {
data = "";
}
var uba_enctoken = "";
var uba_data = JSON.stringify(data);
uba_enctoken = window.btoa(unescape(encodeURI(uba_data)));
return uba_enctoken;
}
/*****End Encode Function*****/
/**********************GET MOST VIEWED PRODUCTS STARTS *********************/
function getMostViewProducts() {
var mostviewjson = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
};
mostjsonenc = encodeData(mostviewjson);
jQuery
.get(UB_BASEURL + "?action=get_most", { token: mostjsonenc })
.done(function (data, status) {
if (data != "") {
var uba_obj = JSON.parse(data);
var uba_objdata = uba_obj.data;
var uba_textview = uba_obj.text_view;
var uba_text_view_detail = uba_obj.text_view_detail;
if (
uba_objdata.home_product != "" &&
uba_objdata.home_html != "" &&
uba_currentPage == "home"
) {
setCrouselWithData_New(
"most_view_new",
"mostly_viewed_products_new",
uba_objdata.home_product,
uba_textview
);
setProductOnElement(
uba_objdata.home_html,
"most_view_new",
"mostly_viewed_products_new",
uba_objdata.home_product,
uba_textview,
"uba-mostly-viewed-products"
);
} else if (
uba_objdata.detail.detail_product != "" &&
uba_currentPage == "detail"
) {
jQuery(".uba-mostly-products").removeClass("d-none");
setProductOnElement(
uba_objdata.detail.detail_html,
"most_view_new",
"mostly_viewed_products_new",
uba_objdata.detail.detail_product,
uba_text_view_detail,
"uba-mostly-viewed-products"
);
} else if (uba_objdata.new_data != "" && uba_is_mobile) {
if (uba_obj.device_type == "ipad") {
setMostlyViewed(uba_objdata.old_data);
} else {
setCrouselWithData_New(
"most_view_new",
"mostly_viewed_products_new",
uba_objdata.new_data,
uba_textview
);
}
}
}
});
}
function setMostlyViewed(data) {
if (!jQuery(".mostly_viewed_products").length > 0) {
setTimeout(function () {
setMostlyViewed(data);
}, 5000);
return;
}
setCrouselWithData("most_view", "mostly_viewed_products", data);
}
function setProductOnElement(
data = "",
append_cls1 = "",
append_cls2 = "",
append_data = "",
textview = "",
id = ""
) {
var p5 = 5;
if (!jQuery("#" + id).length > 0) {
setTimeout(function () {
setProductOnElement(
data,
append_cls1,
append_cls2,
append_data,
textview,
id
);
}, 1000);
return;
}
if (jQuery("." + append_cls1).length) {
jQuery("." + append_cls1).remove();
}
jQuery("#" + id).append(data);
if (uba_is_mobile) {
p5 = "";
}
if (uba_currentPage == "catalogsearch_result") {
setCrouselWithData(
append_cls1,
append_cls2,
append_data,
1,
2,
3,
4,
4,
textview
);
} else if (uba_currentPage == "home" && append_cls1 == "home_cat") {
setHomeCatCrouselWithData(
append_cls1,
append_cls2,
append_data,
1,
2,
3,
4,
6,
textview
);
} else if (uba_currentPage == "tamara") {
setTamaraPageCarousel(
append_cls1,
append_cls2,
append_data,
1,
2,
3,
4,
5,
textview
);
} else {
setCrouselWithData(
append_cls1,
append_cls2,
append_data,
1,
2,
3,
4,
5,
textview
);
}
}
function getRecentViewProducts() {
var recentViewJson = {
cookie_id: uba_cookieId,
user_email: uba_emailid,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
};
var recentViewJsonEnc = encodeData(recentViewJson);
var productdata = "";
//jQuery(".recently-viewed-mobile").hide();
jQuery
.get(UB_BASEURL + "?action=get_recent", { token: recentViewJsonEnc })
.done(function (data, status) {
if (data != "") {
var uba_obj = JSON.parse(data);
uba_obj = uba_obj.data;
var uba_objdata = uba_obj.data;
var uba_homedata = uba_objdata.home_data;
var uba_detaildata = uba_objdata.detail_data;
var uba_textview = uba_obj.text_view;
if (uba_homedata != "" && uba_homedata != undefined) {
if (
uba_homedata.home_html != "" &&
uba_homedata.home_product != "" &&
uba_currentPage == "home"
) {
setProductOnElement(
uba_homedata.home_html,
"recent_view_new",
"recently_viewed_products_new",
uba_homedata.home_product,
uba_textview,
"uba-recently-viewed-products"
);
}
if (
uba_currentPage == "detail" &&
uba_obj.data.vdata != "" &&
uba_obj.device_type == "desktop"
) {
jQuery(".ubuy-recently-viewed").after(uba_objdata.detail_data.html);
/*Start Vertical For Desktop*/
moreProductsSlider1();
/*End Vertical For Desktop*/
jQuery("#vertical-recent-track").html("");
jQuery("#vertical-recent-track").html(
uba_objdata.detail_data.vdata
);
jQuery(".vs-row-1").addClass("active");
if (!jQuery(".vs-products.active").next().length) {
jQuery(".vs-control.down").addClass("deactivate");
}
/*Start Vertical For Mobile*/
vhSlider();
/*End Vertical For Mobile*/
setCrouselWithData(
"recent_view_slide",
"recent_view_slide_carousel",
uba_objdata.detail_data.hdata,
3,
3,
3,
3,
3
);
}
if (
uba_objdata.detail_data != "" &&
uba_objdata.detail_data != undefined
) {
jQuery(".recently-viewed-mobile").show();
if (
uba_currentPage == "detail" &&
uba_objdata.detail_data.hdata != "" &&
uba_objdata.detail_data.hdata != undefined &&
(uba_obj.device_type == "ipad" || uba_obj.device_type == "phone")
) {
jQuery(".recently-viewed-mobile").show();
setCrouselWithDataMobile(
"webversus-mobile",
"recently-viewed-mobile-fixed-popup",
uba_objdata.detail_data.hdata,
uba_textview
);
} else {
jQuery(".recently-viewed-mobile").hide();
}
} else {
jQuery(".recently-viewed-mobile").hide();
}
}
}
});
}
/**********************GET MOST VIEWED PRODUCTS END *********************/
jQuery(document).on("click", "#add-to-cart-btn", function (e) {
//var data = jQuery('#product_addtocart_form').serialize();
var data = JSON.stringify(jQuery("#product_addtocart_form").serializeArray());
if (data != "" && data != undefined) {
//trackAddToCart(data);
}
});
/********************** Below Function call from Ubuy Side Start *********************/
function trackAddToCart1(jsarr) {
var res = { message: "" };
res.username = uba_username;
res.emailid = uba_emailid;
res.substore = uba_subStore;
res.cookie_id = uba_cookieId;
res.store = uba_current_store;
res.store_id = uba_store_id;
res.website_id = uba_website_id;
res.page = uba_currentPage;
res.asin = jsarr.asin;
res.pasin = jsarr.parent_asin;
res.qty = jsarr.qty;
res.pimg = decodeURIComponent(jsarr.product_image);
res.current_url = uba_currenturl;
res.hostname = uba_hostname;
res.pid = jsarr.p_full_id;
res.detailurl = uba_currenturl;
res.is_sticky = ub_isSticky;
res.weburl = uba_weburl;
var uba_title = jsarr.product_name;
uba_title = uba_RemoveSpecialChar(uba_title);
//res.pname = jsarr["product_name"].replaceAll("+", " ");
res.pname = uba_title;
var uba_addtocartencjson = encodeData(res);
if (uba_website_id == 5 || 1) {
jQuery
.get(UB_BASEURL + "?action=set_addtocart", {
token: uba_addtocartencjson,
})
.done(function (data, status) {
//getSocialProofsCount();
});
}
}
function ubaaddtowishlist(jsonArr) {
if (uba_cookieId == "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
if (jsonArr != "" && typeof jsonArr != "undefined" && uba_cookieId != "") {
var res = jsonArr;
res.current_url = uba_currenturl;
res.hostname = uba_hostname;
res.weburl = uba_weburl;
res.username = uba_username;
res.emailid = uba_emailid;
res.substore = uba_subStore;
res.cookie_id = uba_cookieId;
res.store = uba_current_store;
res.store_id = uba_store_id;
res.website_id = uba_website_id;
res.page = uba_currentPage;
var uba_addtowishlistencjson = encodeData(res);
jQuery
.get(UB_BASEURL + "?action=set_addtowslist", {
token: uba_addtowishlistencjson,
})
.done(function (data, status) {
//getSocialProofsCount();
});
} else {
}
}
/********************** Above Function call from Ubuy Side End *********************/
/**********************Set Track Cookies Start *********************/
function newcookieId() {
var uba_navigator_info = window.navigator;
var uba_screen_info = window.screen;
var uba_uid = uba_navigator_info.mimeTypes.length;
uba_uid += uba_navigator_info.userAgent.replace(/\D+/g, "");
uba_uid += uba_navigator_info.plugins.length;
uba_uid += uba_screen_info.height || "";
uba_uid += uba_screen_info.width || "";
uba_uid += uba_screen_info.pixelDepth || "";
return uba_uid;
}
function setTrackCookies() {
var dnew = new Date();
var newtime = dnew.getTime();
uba_cookieId = newcookieId() + newtime;
setCacheWithExpiry("new_session_id", uba_cookieId, 525600);
}
/**********************End Track Cookies Start *********************/
function getTotalPurchaseCount(uba_totalviewjsonenc) {
jQuery
.get(UB_BASEURL + "?action=get_totalpurchase", {
token: uba_totalviewjsonenc,
})
.done(function (data, status) {
if (data != "") {
var uba_obj = JSON.parse(data);
var uba_totalview = uba_obj.totalview;
if (uba_totalview > 0) {
var uba_socialhtml =
'';
if (jQuery(".h2-heading.price").length) {
jQuery(".h2-heading.price").parent().append(uba_socialhtml);
jQuery("#social-proofs-text").html(uba_obj.textview);
}
}
} else {
}
});
}
function getTotalAddToCartCount(uba_totalviewjsonenc) {
jQuery
.get(UB_BASEURL + "?action=get_totalcartproduct", {
token: uba_totalviewjsonenc,
})
.done(function (data, status) {
if (data != "") {
var uba_obj = JSON.parse(data);
var uba_totalview = uba_obj.totalview;
if (uba_totalview > 0) {
var uba_socialhtml =
'';
if (jQuery(".h2-heading.price").length) {
jQuery(".h2-heading.price").parent().append(uba_socialhtml);
jQuery("#social-proofs-text").html(uba_obj.textview);
}
}
} else {
//getTotalAddToCartCount(uba_totalviewjsonenc)
}
});
}
function getProductDetails() {
//var detaildata = "";
var uba_pimg = jQuery("#product_image").val();
var uba_title = jQuery("#product_name").val();
var uba_asin = jQuery("#asin").val();
var uba_pasin = jQuery("#parent_asin").val();
uba_productId = jQuery("#p_full_id").val();
if (jQuery(".in-stock").text() != "") {
var uba_isstock = jQuery(".in-stock").attr("content");
}
if (jQuery(".out-of-stock").text() != "") {
var uba_isstock = jQuery(".out-of-stock").attr("content");
}
if (
uba_title == "" ||
uba_pimg == "" ||
uba_asin == "" ||
uba_productId == "" ||
uba_title == undefined ||
uba_pimg == undefined ||
uba_asin == undefined ||
uba_productId == undefined ||
uba_isstock == "" ||
uba_pasin == undefined ||
uba_pasin == ""
) {
setTimeout(function () {
getProductDetails();
}, 2000);
return;
} else {
uba_title = uba_title.replace(/[^a-zA-Z0-9 .]/g, "");
detaildata = {
pname: uba_title,
pimg: uba_pimg,
asin: uba_asin,
pasin: uba_pasin,
pid: uba_productId,
isstock: uba_isstock,
};
return detaildata;
}
}
/********************************* Get TOTAL VIEW COUNT END ***********************************************/
/********************Start Get Track Cookies Start *******************/
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
/********************End Get Track Cookies Start *******************/
/******************************Start Track User Detail**************/
function trackUserDetail(ub_tabTalk) {
var detaildata = {
detail_url: uba_currenturl,
cookie_id: uba_cookieId,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
tabtalkstatus: ub_tabTalk,
is_mobile: uba_is_mobile,
weburl: uba_weburl,
};
if (uba_ssSessionId == "ubanalytics" || uba_ssSessionId == "") {
// console.log('Track user details');
setRecentProduct(detaildata);
}
}
/*********************End Track User Detail**************/
/******************Start Set Recent Product Data**************/
function setRecentProduct(detaildata) {
var product_sku_store = jQuery(
"form#product_addtocart_form div.stock-store div.product-store span"
).text();
var pimg = jQuery("#product_image").val();
var title = jQuery("#product_name").val();
var asin = jQuery("#asin").val();
var pasin = jQuery("#parent_asin").val();
// var ubuy_sku = jQuery(".banner-slider").find("input[name='ubuy_sku']").val();
if (uba_is_mobile) {
var ubuy_sku = jQuery("#product_addtocart_form")
.find("input[name='ubuy_sku']")
.val();
} else {
var ubuy_sku = jQuery(".banner-content")
.find("input[name='ubuy_sku']")
.val();
}
var uba_canonical_url = jQuery('link[rel="canonical"]').attr("href");
var is_prime = jQuery("#is_prime").val();
var ub_product_rating = jQuery("#product_total_review").text();
var rating_outof = jQuery(".rating-outof").text();
if (
ub_product_rating != "" &&
ub_product_rating != null &&
ub_product_rating != " No rating"
) {
ub_product_rating = ub_product_rating.match(/[+-]?\d+(\.\d+)?/g)[0];
}
var langtitle = "";
if (langtitle == "") {
langtitle = jQuery("h1.title.h1.mb-2").text();
}
if (langtitle == "") {
langtitle = jQuery("h2#product-name").text();
}
if (langtitle == "") {
langtitle = jQuery("h1.title").text();
}
if (langtitle == "") {
langtitle = title;
}
if (typeof langtitle !== 'undefined' && langtitle !== null) {
langtitle = langtitle.trim();
langtitle = langtitle.replace(/\n/g, "");
}
var uba_productId = jQuery("#p_full_id").val();
var isstock = false;
if (jQuery(".in-stock").text() != "") {
isstock = true;
}
// || rating_outof == ''
//console.log('title ' + title+' pimg ' + pimg+' asin ' + asin+' uba_productId'+uba_productId+' isstock'+isstock+' pasin'+pasin+' langtitle '+langtitle);
if (
title == "" ||
pimg == "" ||
asin == "" ||
uba_productId == "" ||
title == undefined ||
pimg == undefined ||
asin == undefined ||
uba_productId == undefined ||
isstock == "" ||
pasin == undefined ||
pasin == "" ||
langtitle == undefined ||
langtitle == ""
) {
setTimeout(function () {
setRecentProduct(detaildata);
}, 2000);
return;
}
var title = title.replace(/[^a-zA-Z0-9 .]/g, "");
var sproof = getAssignSProof();
detaildata.pname = title;
detaildata.pimg = pimg;
detaildata.asin = asin;
detaildata.pasin = pasin;
detaildata.pid = uba_productId;
detaildata.isstock = isstock;
detaildata.saveDetail = true;
detaildata.settime = "" + ub_current_time + "";
detaildata.hostname = uba_hostname;
detaildata.current_url = uba_currenturl;
detaildata.weburl = uba_weburl;
detaildata.langtitle = langtitle;
detaildata.is_mobile = uba_is_mobile;
detaildata.canonicalurl = uba_canonical_url;
detaildata.ubuy_sku = ubuy_sku;
detaildata.is_prime = is_prime;
detaildata.view_sproof = sproof;
detaildata.ub_product_rating = ub_product_rating;
detaildata.ub_product_sku_store = product_sku_store;
var uba_isvalid = restrictKey(title);
if (isstock && detaildata.pimg != "" && uba_isvalid) {
detaildataEnc = encodeData(detaildata);
jQuery
.post(UB_BASEURL + "?action=set_recent", { token: detaildataEnc })
.done(function (data, status) {
});
}
}
/********Start Set Data in Browser********/
function setCacheWithExpiry(key, value, minute) {
const now = new Date();
const item = {
value: value,
expiry: now.getTime() + minute * 60000,
};
localStorage.setItem(key, JSON.stringify(item));
}
/********End Set Data in Browser********/
/********Start Get Data from Browser********/
function getCacheWithExpiry(key) {
const itemStr = localStorage.getItem(key);
// if the item doesn't exist, return null
if (!itemStr) {
return "";
}
const item = JSON.parse(itemStr);
const now = new Date();
// compare the expiry time of the item with the current time
if (now.getTime() > item.expiry) {
if (key == "new_session_id") {
setCacheWithExpiry("new_session_id", item.value, 525600);
return item.value;
} else {
localStorage.removeItem(key);
return "";
}
}
return item.value;
}
/********End Get Data from Browser********/
function setcache(data, key, time) {
var val1 = data;
var getdata = getCacheWithExpiry(key);
var jsondata = {};
if (getdata != "") {
jsondata = getdata;
var count = Object.keys(jsondata).length;
jsondata[count] = val1;
} else {
jsondata[0] = val1;
}
jsonarr = [];
var uniqueNames = [];
var jsonstring = {};
jsonarr = Object.values(jsondata);
jQuery.each(jsonarr, function (i, el) {
if (jQuery.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
});
uniqueNames = JSON.stringify(Object.assign({}, uniqueNames));
jsonstring = JSON.parse(uniqueNames);
setCacheWithExpiry(key, jsonstring, time);
}
function setCrouselWithData(
key,
classname,
value,
p0 = 1,
p1 = 2,
p2 = 3,
p3 = 4,
p4 = 5,
textview
) {
var view = "";
if (value != "" && value != undefined) {
jQuery("." + key).css("display", "block");
jQuery(".uba_" + key).css("display", "block");
if (!textview) {
textview = "";
}
jQuery("#" + key + "_text_view").html(textview);
jQuery("." + classname).html(value);
view = jQuery("." + classname);
if (view) {
view.owlCarousel({
rtl: is_rtl,
autoplay: false,
autoplayHoverPause: false,
loop: false,
rewind: true,
lazyLoad: true,
navigation: true,
margin: 30,
nav: true,
dots: false,
responsive: {
0: {
items: 2,
margin: 10,
},
767: {
items: 3,
margin: 10,
},
992: {
items: 4,
},
},
});
}
}
}
function setCrouselWithData_New(
key,
classname,
value,
uba_textview,
p0,
p1,
p2,
p3,
p4
) {
var view = "";
jQuery("." + key).css("display", "block");
if (!uba_textview) {
uba_textview = "";
}
if (!p0) {
p0 = 1;
}
if (!p1) {
p1 = 2;
}
if (!p2) {
p2 = 3;
}
if (!p3) {
p3 = 4;
}
if (!p4) {
p4 = 5;
}
jQuery("#" + key + "_text_view").html(uba_textview);
jQuery("." + classname).html(value);
view = jQuery("." + classname);
if (view) {
view.owlCarousel({
rtl: is_rtl,
loop: false,
rewind: true,
nav: true,
margin: 30,
lazyLoad: true,
dots: false,
responsive: {
0: {
items: 2,
margin: 12,
},
480: {
items: 2,
margin: 12,
},
575: {
margin: 18,
},
767: {
items: 4,
margin: 0,
},
991: {
margin: 0,
},
1200: {
items: 4,
},
},
});
}
}
/********************************* Get Top Category Product End ***********************************************/
function setCrouselWithDataCategory(
key,
classname,
value,
uba_textview,
p0,
p1,
p2,
p3,
p4
) {
var view = "";
jQuery("." + key).css("display", "block");
if (!uba_textview) {
uba_textview = "";
}
if (!p0) {
p0 = 1;
}
if (!p1) {
p1 = 2;
}
if (!p2) {
p2 = 3;
}
if (!p3) {
p3 = 4;
}
if (!p4) {
p4 = 5;
}
jQuery("#" + key + "_text_view").html(uba_textview);
jQuery("." + classname).html(value);
view = jQuery("." + classname);
if (view) {
view.owlCarousel({
rtl: is_rtl,
loop: false,
rewind: true,
nav: true,
margin: 30,
lazyLoad: true,
dots: false,
responsive: {
0: {
items: 2,
margin: 10,
},
767: {
items: 3,
margin: 10,
},
992: {
items: 4,
},
},
});
}
}
/**********End Set Data in Carousel****************/
/**Start Get User Details**/
function getUserDetails() {
if (typeof uba_user_details != "undefined") {
return uba_user_details;
} else {
var return_first = (function () {
var tmp = null;
jQuery.ajax({
async: false,
url: uba_customer_url,
dataType: "html",
type: "GET",
data: "",
success: function (resp) {
var menuHtml = resp;
if (jQuery.trim(menuHtml) != "") {
tmp = jQuery.parseJSON(menuHtml);
}
},
});
return tmp;
})();
return return_first;
}
}
/**End Get User Details**/
/**Start Set Success Order Data**/
function setSuccessOrderData(orderItemsData) {
if (orderItemsData != "") {
if (uba_cookieId == "" || uba_cookieId == undefined) {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var ubrefdata = getCacheWithExpiry("REFUBA");
var detaildata = {
cookie_id: uba_cookieId,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
productsData: orderItemsData,
ubref: ubrefdata,
useragent: navigator.userAgent,
};
dataEnc = encodeData(detaildata);
jQuery
.post(UB_BASEURL + "?action=set_success_order_data", { token: dataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
}
/**End Set Success Order Data**/
/************Start Get Bought With Products Data For Detail Page*****************/
function getBoughtWithProducts() {
var BASE_URL = (recenthtml = productUrl = imageUrl = html = productdata = "");
var asin = jQuery("#p_full_id").val();
if (asin == "" || asin == undefined) {
setTimeout(function () {
getBoughtWithProducts();
}, 2000);
return;
}
if (asin != "") {
var detailjson = {
asin: asin,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
};
dataenc = encodeData(detailjson);
jQuery
.get(UB_BASEURL + "?action=get_bought_with", { token: dataenc })
.done(function (productdata, status) {
if (productdata != "" && productdata != undefined) {
var obj = JSON.parse(productdata);
objdata = obj.html;
if (objdata != "" && objdata != undefined) {
setCrouselWithData(
"bought_with",
"bought-with-products-carousel",
objdata,
1,
2,
3,
4,
5
);
}
}
});
}
}
/********************************* Get Category Product End ***********************************************/
/**********************************Get Top Selling Product For Tamara Start *************************************/
if (uba_currentPage == "tamara") {
// getTopSellingForTamaraPage();
}
function getTopSellingForTamaraPage() {
jQuery("#loading_custom").fadeIn();
var catviewjson = {
catId: uba_catId,
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
arabic: uba_is_arabic_store,
};
catviewjsonenc = encodeData(catviewjson);
jQuery
.get(UB_BASEURL + "?action=get_topsellingtamara", { token: catviewjsonenc })
.done(function (productdata, status) {
if (productdata != "" && productdata != undefined) {
jQuery("#loading_custom").fadeOut();
var uba_obj = JSON.parse(productdata);
var uba_objdata = uba_obj.data;
var uba_textview = uba_obj.text_view;
var textview_detail = uba_obj.textview_detail;
if (uba_objdata != "" && uba_objdata != undefined) {
if (
uba_objdata.detail.detail_product != "" &&
uba_currentPage == "tamara"
) {
jQuery(".uba-top-products").removeClass("d-none");
setProductOnElement(
uba_objdata.detail.detail_html,
"top_selling_new",
"top_selling_products_new",
uba_objdata.detail.detail_product,
textview_detail,
"uba-top-selling-products"
);
}
}
}
});
}
/**********************************Get Top Selling Product For Tamara End *************************************/
/********************************* Get Top Category Product Start ***********************************************/
function getTopCategoryProduct() {
var catviewjson = {
catId: uba_catId,
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
arabic: uba_is_arabic_store,
};
catviewjsonenc = encodeData(catviewjson);
jQuery
.get(UB_BASEURL + "?action=get_topcatproduct", { token: catviewjsonenc })
.done(function (productdata, status) {
if (productdata != "" && productdata != undefined) {
var obj = JSON.parse(productdata);
objdata = obj.html;
if (objdata != "" && objdata != undefined) {
setCrouselWithDataCategory(
"top_cat_product",
"ubuy_top_category_products",
objdata,
"TOP CATEGORY PRODUCT"
);
}
}
});
}
/********************************* Get Top Category Product End ***********************************************/
/********************************* Get Top Selling Product For Detail Page Start ***********************************************/
function getTopSellingForDetailPage() {
var catviewjson = {
catId: uba_catId,
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
arabic: uba_is_arabic_store,
};
catviewjsonenc = encodeData(catviewjson);
jQuery
.get(UB_BASEURL + "?action=get_topsellingdetail", { token: catviewjsonenc })
.done(function (productdata, status) {
if (productdata != "" && productdata != undefined) {
var uba_obj = JSON.parse(productdata);
var uba_objdata = uba_obj.data;
var uba_textview = uba_obj.text_view;
var textview_detail = uba_obj.textview_detail;
if (uba_objdata != "" && uba_objdata != undefined) {
if (
uba_objdata.detail.detail_product != "" &&
uba_currentPage == "detail"
) {
jQuery(".uba-top-products").removeClass("d-none");
setProductOnElement(
uba_objdata.detail.detail_html,
"top_selling_new",
"top_selling_products_new",
uba_objdata.detail.detail_product,
textview_detail,
"uba-top-selling-products"
);
}
}
}
});
}
/********************************* Get Top Selling Product For Detail Page End ***********************************************/
/************Start Get Viewed With Product Data For Detail Page*****************/
function getDetailViewProducts() {
var BASE_URL = (recenthtml = productUrl = title = imageUrl = "");
uba_productId = jQuery("#p_full_id").val();
if (uba_productId == "" || uba_productId == undefined) {
setTimeout(function () {
getDetailViewProducts();
}, 2000);
return;
}
if (uba_productId != "") {
var detailjson = {
pid: uba_productId,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
};
dataenc = encodeData(detailjson);
jQuery
.get(UB_BASEURL + "?action=get_viewed_with", { token: dataenc })
.done(function (data, status) {
if (data != "") {
setCrouselWithData("view_with", "viewed-products-carousel", data);
jQuery(".view_with").show();
}
});
}
}
/************End Get Viewed With Product Data For Detail Page*****************/
/******************Start Set Recent Searches User Data**************/
function setRecentSearch() {
var uba_search_keyword = jQuery(".search-box-text").val();
//var uba_cookieId = getCacheWithExpiry('new_session_id');
if (
uba_search_keyword != "" &&
uba_search_keyword != undefined &&
uba_cookieId != ""
) {
detaildata = {
search_keyword: uba_search_keyword,
sessionId: uba_cookieId,
userip: uba_user_ip,
catid: uba_catId,
current_url: uba_currenturl,
weburl: uba_weburl,
hostname: uba_hostname,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
useragent: navigator.userAgent,
};
dataEnc = encodeData(detaildata);
jQuery
.get(UB_BASEURL + "?action=set_recent_search", { token: dataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
}
/******************End Set Recent Searches User Data**************/
/*Start Get Hello Bar*/
function getHelloBar() {
if (uba_cookieId == "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var htmldata = "";
var ipadCheck = $("body").attr("class");
detaildata = {
cookie_id: uba_cookieId,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
hostname: uba_hostname,
current_url: uba_currenturl,
page: uba_currentPage,
weburl: uba_weburl,
is_mobile: uba_is_mobile,
arabic: uba_is_arabic_store,
website_id: uba_website_id,
screen_size: uba_screen_width,
ipadCheck: ipadCheck,
};
dataEnc = encodeData(detaildata);
jQuery
.get(UB_BASEURL + "?action=get_hellobar", { token: dataEnc })
.done(function (htmldata, status) {
if (htmldata != "" && htmldata != undefined) {
var obj = JSON.parse(htmldata);
objdata = obj.html;
if (objdata != "" && objdata != undefined) {
var hbardata = getCacheWithExpiry("hellobar_closed");
if (hbardata != "" && hbardata != undefined) {
hellobarsession();
} else if (uba_screen_width <= 1200) {
jQuery(".ubuy_home_bar").append(objdata);
jQuery("body").addClass("uba_hbar");
jQuery(".ubuy_home_bar").css({ display: "block" });
} else {
jQuery(".ubuy_home_bar").append(objdata);
jQuery(".ubuy_home_bar").show();
jQuery("body").addClass("uba_hbar");
}
} else {
jQuery(".ubuy_home_bar").hide();
}
} else {
jQuery(".ubuy_home_bar").hide();
}
});
}
function hellobarsession() {
var hbardata = JSON.parse(localStorage.getItem("hellobar_closed"));
if (hbardata != "" && hbardata != undefined) {
var nowhbar = new Date();
var browsertime = nowhbar.getTime();
hbarshowtime = hbardata.expiry + 30 * 60000;
if (uba_screen_width <= 1200) {
if (browsertime > hbarshowtime) {
jQuery(".ubuy_home_bar").show();
} else {
jQuery(".ubuy_home_bar").hide();
}
}
}
}
function closehellobar() {
setCacheWithExpiry("hellobar_closed", "hbar_closed", 30);
if (uba_screen_width <= 1200) {
jQuery(".ubuy_home_bar").hide();
} else {
jQuery(".ubuy_home_bar").remove();
}
}
/*End Get Hello Bar*/
/*Start Web Versus Functions*/
function moreProductsSlider1() {
// Cache elements
var $productsOuter = jQuery(".vs-products-outer");
// Get row height
var rowHeight = jQuery(".vs-slides-inner").height();
// Set control click state
var canClick = true;
// Slide Up
jQuery(".vs-control.down").click(function () {
var $activeRow = jQuery(".vs-products.active");
// Check if there is a next row to slide to
if ($activeRow.next().length && canClick) {
canClick = false;
// Get animation distance
var distance = -(parseInt($activeRow.data("row-num")) * rowHeight);
$productsOuter.velocity(
{
top: distance,
},
500,
function () {
canClick = true;
// Change active row
$activeRow.removeClass("active").next().addClass("active");
// Activate other control
jQuery(".vs-control.up").removeClass("deactivate");
// If there is no next row
if (!jQuery(".vs-products.active").next().length) {
jQuery(".vs-control.down").addClass("deactivate");
}
}
);
}
});
// Slide Down
jQuery(".vs-control.up").click(function () {
var $activeRow = jQuery(".vs-products.active");
// Check if there is a next row to slide to
if ($activeRow.prev().length && canClick) {
canClick = false;
// Get animation distance
var distance = -(parseInt($activeRow.data("row-num") - 2) * rowHeight);
$productsOuter.velocity(
{
top: distance,
},
500,
function () {
canClick = true;
// Change active row
$activeRow.removeClass("active").prev().addClass("active");
// Activate other control
jQuery(".vs-control.down").removeClass("deactivate");
// If there is no next row
if (!jQuery(".vs-products.active").prev().length) {
jQuery(".vs-control.up").addClass("deactivate");
}
}
);
}
});
return this;
}
function vhSlider() {
var headerRecentView = jQuery(".header-RecentView");
var closeRecentView = jQuery(".close-RecentView, .recentView-overlay");
var miniRecentView = jQuery(".mini-RecentView");
var miniRecentViewWrap = jQuery(".mini-RecentView-wrap");
headerRecentView.on("click", function (e) {
e.preventDefault();
jQuery(".recentView-overlay").addClass("visible");
miniRecentViewWrap.addClass("open");
});
miniRecentView.on("click", function (e) {
e.preventDefault();
jQuery(".recentView-overlay").removeClass("visible");
miniRecentViewWrap.removeClass("open");
});
closeRecentView.on("click", function (e) {
e.preventDefault();
jQuery(".recently-viewed-block").css("display", "none");
//miniRecentViewWrap.removeClass('open');
});
}
function hideRecentlyViewedMobile() {
var recentElement = document.getElementById("recently-viewed-mobile-fixed");
recentElement.classList.toggle("recently-view-apply");
//jQuery('#recently-viewed-mobile-fixed').remove();
}
function closeRecentlyViewedMobile() {
var recentElement = document.getElementById("recently-viewed-mobile-fixed");
recentElement.classList.toggle("recently-view-apply");
jQuery(".recently-viewed-mobile-open").css("display", "none");
}
/*Start Carousel For Web Versus For Detail Page*/
function setCrouselWithDataMobile(key, classname, value, textview) {
var view = "";
jQuery("." + key).css("display", "block");
if (textview != "") {
var textcls = jQuery("." + key + "_text_view").length;
if (!(textcls > 0)) {
setTimeout(function () {
setCrouselWithDataMobile(key, classname, value, textview);
}, 1000);
return;
}
jQuery("." + key + "_text_view").html(textview);
}
jQuery("." + classname).html(value);
view = jQuery("." + classname);
if (view) {
view.owlCarousel({
rtl: is_rtl,
loop: false,
dots: false,
margin: 10,
nav: false,
responsive: {
0: {
items: 4,
},
600: {
items: 4,
},
1000: {
items: 4,
},
},
});
}
}
/*End Carousel For Web Versus For Detail Page*/
/*End Web Versus Functions*/
/*Start Get Coupon*/
function getCoupon() {
var cookie_id = getCookie("new_session_id");
if (cookie_id == "") {
cookie_id = getCacheWithExpiry("new_session_id");
}
detaildata = {
cookie_id: uba_cookieId,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
hostname: uba_hostname,
current_url: uba_currenturl,
page: uba_currentPage,
weburl: uba_weburl,
is_mobile: uba_is_mobile,
};
dataEnc = encodeData(detaildata);
jQuery
.post(UB_BASEURL + "?action=get_coupon", { token: dataEnc })
.done(function (htmldata, status) {
if (htmldata != "" && htmldata != undefined) {
var obj = JSON.parse(htmldata);
objdata = obj.html;
if (objdata != "" && objdata != undefined) {
jQuery(".ubuy_coupon_assistant").append(objdata);
//jQuery(".ubuy_coupon_assistant").show();
var opentstatus = "opened";
setCouponTracking(opentstatus, "", "");
var cpadata = JSON.parse(
localStorage.getItem("coupon_assistant_closed")
);
if (cpadata != "" && cpadata != undefined) {
couponassistantsession();
} else {
jQuery(".ubuy_coupon_assistant").show();
}
} else {
jQuery(".ubuy_coupon_assistant").hide();
}
let btn_tooltip = jQuery(".coupon_assistant_copy_icon");
btn_tooltip.click(function () {
value = jQuery(".coupon_text").text();
var $temp = jQuery("");
jQuery("body").append($temp);
$temp.val(value).select();
document.execCommand("copy");
$temp.remove();
jQuery(".copy_message").fadeIn().delay(20000).fadeOut();
var copystatus = "copied";
setCouponTracking("", copystatus, "");
});
/*jQuery('.close-btn').on('click', function () {
var closestatus = 'closed';
setCouponTracking('', '', closestatus);
jQuery('.coupon-popup').hide();
});*/
jQuery(".coupon-popup i.fa-minus").on("click", function () {
jQuery(".coupon-popup").animate(
{
height: "40px",
top: jQuery(window).height() - 50,
},
500
);
jQuery(".coupon_close_btn").hide();
jQuery(this).hide();
jQuery(".coupon-popup i.fa-plus").show();
jQuery(".popup-content").hide();
});
jQuery(".coupon-popup i.fa-plus").on("click", function () {
jQuery(".coupon-popup").animate(
{
top: jQuery(window).height() - 230,
height: "100%",
},
200
);
jQuery(".coupon_close_btn").show();
jQuery(this).hide();
jQuery(".coupon-popup i.fa-minus").show();
jQuery(".popup-content").show();
});
countDown(300, jQuery("#display"));
}
});
}
function countDown(duration, display) {
if (!isNaN(duration)) {
var timer = duration,
minutes,
seconds;
var interVal = setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
jQuery(display).html("" + minutes + "m : " + seconds + "s" + "");
if (--timer < 0) {
timer = duration;
jQuery(".coupon-popup").hide();
jQuery(display).empty();
clearInterval(interVal);
}
}, 1000);
}
}
function couponassistantsession() {
var cpadata = JSON.parse(localStorage.getItem("coupon_assistant_closed"));
if (cpadata != "" && cpadata != undefined) {
var nowcpa = new Date();
var cpabrowsertime = nowcpa.getTime();
cpashowtime = cpadata.expiry;
if (cpabrowsertime > cpashowtime) {
jQuery(".ubuy_coupon_assistant").show();
} else {
jQuery(".ubuy_coupon_assistant").hide();
}
}
}
function closecouponassistant() {
var closestatus = "closed";
setCouponTracking("", "", closestatus);
setCacheWithExpiry("coupon_assistant_closed", "ca_closed", 60);
//jQuery(".ubuy_coupon_assistant").hide();
jQuery(".ubuy_coupon_assistant").hide();
}
/*End Coupon Assistant*/
/*End Get Coupon*/
/************Start Get Choose Us Data For Checkout Page*****************/
function getChooseUsData(parm) {
var user_email = ub_userdetails.cem;
//var choose_us_base_url = uba_hostname;
var detailjson = {
store_id: parm,
store: uba_current_store,
page: uba_currentPage,
arabic: uba_is_arabic_store,
is_mobile: uba_is_mobile,
current_url: uba_currenturl,
hostname: uba_hostname,
weburl: uba_weburl,
user_email: user_email,
};
dataenc = encodeData(detailjson);
jQuery
.get(UB_BASEURL + "?action=get_choose_us", { token: dataenc })
.done(function (htmldata, status) {
if (htmldata != "" && htmldata != undefined) {
var obj = JSON.parse(htmldata);
objdata = obj.html;
if (objdata != "" && objdata != undefined) {
jQuery(".ubuy_chooseus_popup").html(objdata);
}
}
});
}
function chooseustoggle() {
if (jQuery(".why-choose--block-outer").css("right") == "-386px") {
jQuery(".why-choose--block-outer").animate({ right: "0px" });
} else {
jQuery(".why-choose--block-outer").animate({ right: "-386px" });
}
}
function chooseustogglear() {
if (jQuery(".why-choose--block-outer").css("left") == "-386px") {
jQuery(".why-choose--block-outer").animate({ left: "0px" });
} else {
jQuery(".why-choose--block-outer").animate({ left: "-386px" });
}
}
/************End Get Choose Us Data For Checkout Page*****************/
/******************Start Coupon Tracking**************/
function setCouponTracking(openstatus = "", copystatus = "", closestatus = "") {
var coupontext = jQuery(".coupon-code span").text();
if (coupontext == "") {
setTimeout(function () {
setCouponTracking();
}, 5000);
}
if (uba_cookieId != "" && coupontext != "") {
var detaildata = {
sessionId: uba_cookieId,
coupontext: coupontext,
userip: uba_user_ip,
current_url: uba_currenturl,
weburl: uba_weburl,
hostname: uba_hostname,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
useragent: navigator.userAgent,
openstatus: openstatus,
copystatus: copystatus,
closestatus: closestatus,
};
dataEnc = encodeData(detaildata);
jQuery
.post(UB_BASEURL + "?action=set_coupon_tracking", { token: dataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
}
/******************End Coupon Tracking**************/
/*End Get Coupon*/
/******************Start Set Search Page Tracking**************/
function setSearchTracking() {
if (uba_cookieId != "" && uba_cookieId != undefined) {
var uba_canonical_url = jQuery('link[rel="canonical"]').attr("href");
var searchdata = {
sessionId: uba_cookieId,
userip: uba_user_ip,
catid: uba_catId,
current_url: uba_currenturl,
weburl: uba_weburl,
hostname: uba_hostname,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
useragent: navigator.userAgent,
canonicalurl: uba_canonical_url,
};
dataEnc = encodeData(searchdata);
jQuery
.post(UB_BASEURL + "?action=set_search_tracking", { token: dataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
}
/******************End Set Recent Searches User Data**************/
function uba_ssGetURLParameter(name) {
return (
decodeURIComponent(
(new RegExp("[?|&]" + name + "=" + "([^&;]+?)(&|#|;|$)").exec(
location.search
) || [, ""])[1].replace(/\+/g, "%20")
) || null
);
}
/*Start Get Exit Intent*/
/*************************Get Exit Intent********************************************/
function ubaExitIntentPopupTracking(type = "") {
var ubaction = "uc";
var cc = jQuery(".eicode").text();
if (type == "declined") {
ubaction = "ud";
} else if (type == "opened") {
ubaction = "uo";
}
var qData = {
cc: cc,
ubaction: ubaction,
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
};
var qDataEnc = encodeData(qData);
if (uba_is_mobile == 0) {
jQuery
.get(UB_BASEURL + "?action=exitentent-tracking", { token: qDataEnc })
.done(function (data, status) {
if (data !== "") {
}
});
}
}
function ubaCopyCouponCode(text) {
if (ubaCopyToClipboard2(text)) {
var element = event.target;
element.onclick = function () {
return false;
};
}
return true;
}
function ubadeclineExitPopup() {
if (!ubei_is_code_copied) {
ubaExitIntentPopupTracking("declined");
}
}
function ubaCopyToClipboard2(text) {
if (!navigator.clipboard) {
return ubaFallbackCopyToClipboard2();
}
navigator.clipboard.writeText(text).then(
function () {
return true;
},
function (err) {
return false;
}
);
return true;
}
function ubaFallbackCopyToClipboard2() {
if (window.clipboardData && window.clipboardData.setData) {
// Internet Explorer-specific code path to prevent textarea being shown while dialog is visible.
return clipboardData.setData("Text", text);
} else if (
document.queryCommandSupported &&
document.queryCommandSupported("copy")
) {
var textArea = document.createElement("textarea");
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
return false;
} finally {
document.body.removeChild(textArea);
}
}
}
function getExitIntent() {
var qData = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
emailid: uba_emailid,
};
var qDataEnc = encodeData(qData);
jQuery
.get(UB_BASEURL + "?action=get_exitentent", { token: qDataEnc })
.done(function (data, status) {
if (data != "") {
var ubobjdata = JSON.parse(data);
if (typeof ubobjdata.html != "undefined" && ubobjdata.html != "") {
jQuery(".intend-popup").html(ubobjdata.html);
}
}
});
}
function getMobileExitIntent() {
if (uba_is_mobile == "1") {
var mCookie = "UBMEI";
var mEiVisit = "";
mEiVisit = getCacheWithExpiry(mCookie);
var qData = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
};
var qDataEnc = encodeData(qData);
jQuery
.get(UB_BASEURL + "?action=get_mobile_exitentent", { token: qDataEnc })
.done(function (data, status) {
if (data != "") {
var ubobjdata = JSON.parse(data);
if (typeof ubobjdata.html != "undefined" && ubobjdata.html != "") {
jQuery(".uba-mobile-intend-popup").html(ubobjdata.html);
if (mEiVisit != "" && mEiVisit != undefined) {
mobileintentsession();
ubaExitIntentPopupTracking("opened");
} else {
ubaExitIntentPopupTracking("opened");
setCacheWithExpiry("UBMEI", "mobile_intent", 1440);
jQuery("#ubuy-delete-confirm-modal").hide();
jQuery(".uba-mobile-intend-popup").show();
}
jQuery(".uba_mobile_popup_close").click(function () {
jQuery(".uba-mobile-intend-popup").hide();
jQuery("#ubuy-delete-confirm-modal").show();
});
jQuery(".uba_mobile_popup_continue_close").click(function () {
jQuery(".uba-mobile-intend-popup").hide();
jQuery("#ubuy-delete-confirm-modal").hide();
jQuery("div").removeClass("modal-backdrop");
});
}
jQuery("body").on("click", ".uba-ei-tooltip", function (e) {
//btn_tooltip.click(function () {
var code = jQuery(".uba-ei-tooltip").attr("data-value");
//var code = jQuery(".eicode").text();
if (typeof code != "undefined" && code != "") {
if (ubaCopyCouponCode(code)) {
if (!ubei_is_code_copied) {
ubaExitIntentPopupTracking("copied");
ubei_is_code_copied = true;
}
jQuery(".uba-ei-tooltip").attr("title", "Copied");
//jQuery('.intent_copy_message').show();
jQuery(".intent_copy_message").fadeIn().delay(2000).fadeOut();
}
//btn_tooltip.bstooltip('show');
}
});
jQuery("body").removeClass("modal-open");
}
});
}
}
function copythecode(copy, copied) {
/* Get the text field */
var copyText = document.getElementById("code");
if (ubaCopyToClipboard2(copyText.value)) {
var element = event.target;
element.onclick = function () {
return false;
};
jQuery("#copy")
.html(" " + copied)
.addClass("green");
$("#copy").fadeOut(2000, function () {
jQuery("#copy").text(copy);
element.onclick = function () {
copythecode(copy, copied);
};
jQuery("#copy").removeClass("green");
});
$("#copy").fadeIn();
}
}
function copythecode545() {
/* Get the text field */
var copyText = document.getElementById("code");
if (ubaCopyToClipboard2(copyText.value)) {
var element = event.target;
element.onclick = function () {
return false;
};
jQuery("#copy")
.html(" COPIED")
.addClass("green");
$("#copy").fadeOut(2000, function () {
jQuery("#copy").text("COPY");
element.onclick = copythecode;
jQuery("#copy").removeClass("green");
});
$("#copy").fadeIn();
}
}
/*End Get Exit Intent*/
function mobileintentsession() {
var mobileintentdata = JSON.parse(localStorage.getItem("UBMEI"));
if (mobileintentdata != "" && mobileintentdata != undefined) {
var nowhbar = new Date();
var browsertime = nowhbar.getTime();
mobileintentshowtime = mobileintentdata.expiry + 1440 * 60000;
if (uba_screen_width <= 1200) {
if (browsertime > mobileintentshowtime) {
jQuery("#ubuy-delete-confirm-modal").hide();
jQuery(".uba-mobile-intend-popup").show();
} else {
jQuery("#ubuy-delete-confirm-modal").show();
jQuery(".uba-mobile-intend-popup").hide();
}
}
}
}
function uba_RemoveSpecialChar(str) {
return str
.replace(/[^A-Z0-9 .,]/gi, "")
.trim()
.slice(0, 100);
}
/******************Start Active User Tracking**************/
function trackUserUtm(ubautmparams) {
if (typeof uba_cookieId == "undefined" || uba_cookieId == "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var qData = ubautmparams;
qData.store = uba_current_store;
qData.cookie_id = uba_cookieId;
qData.page = uba_currentPage;
qData.is_mobile = uba_is_mobile;
qData.hostname = uba_hostname;
qData.current_url = uba_currenturl;
qData.weburl = uba_weburl;
if (qData.utm_source == "ubanalytics") {
var qDataEnc = encodeData(qData);
jQuery
.get(UB_BASEURL + "?action=set_userutm", { token: qDataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
}
function getAssignSProof() {
var sprooftype = "";
if (uba_cookieId == "" || uba_cookieId == undefined) {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var cachekey = "sproof_" + uba_cookieId;
var sp_type = getCacheWithExpiry(cachekey);
if (sp_type != "") {
sprooftype = getSProof(sp_type);
} else {
sprooftype = setProofType(cachekey);
}
return sprooftype;
}
function getSProof(type) {
var sprooftype = "";
if (type == "sp1") {
sprooftype = "total_view";
} else if (type == "sp2") {
sprooftype = "total_add_to_cart";
} else if (type == "sp3") {
sprooftype = "total_purchase";
}
return sprooftype;
}
function setProofType(cachekey) {
var sec = dt.getSeconds();
var type,
sprooftype = "";
if (sec <= 20) {
type = "sp1";
sprooftype = "total_view";
} else if (sec > 20 && sec <= 40) {
type = "sp2";
sprooftype = "total_add_to_cart";
} else if (sec > 40 && sec <= 60) {
type = "sp3";
sprooftype = "total_purchase";
}
setCacheWithExpiry(cachekey, type, 30); // 1440 for 24 hrs
return sprooftype;
}
/******************End Active User Tracking **************/
/********************************* Get Static Categories Start ***********************************************/
function getStaticCategories() {
var catviewjson = {
cookie_id: uba_cookieId,
catId: uba_catId,
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
arabic: uba_is_arabic_store,
emailid: uba_emailid,
};
catviewjsonenc = encodeData(catviewjson);
jQuery
.get(UB_BASEURL + "?action=get_staticcat", { token: catviewjsonenc })
.done(function (catdata, status) {
if (catdata != "" && catdata != undefined) {
var uba_obj = JSON.parse(catdata);
var uba_objdata = uba_obj.data;
var uba_textview = uba_obj.text_view;
var textview_detail = uba_obj.textview_detail;
if (uba_objdata != "" && uba_objdata != undefined) {
if (
uba_objdata.detail.detail_html != "" &&
uba_currentPage == "home"
) {
setProductOnElement(
uba_objdata.detail.detail_html,
"home_cat",
"home_categories_new",
uba_objdata.detail.cat_html,
textview_detail,
"uba-category-header"
);
//setProductOnElement("uba-mostly-viewed-products", uba_objdata.home_html, "most_view_new", "mostly_viewed_products_new", uba_objdata.home_product, uba_textview);
}
}
}
});
}
function setUserHomePageCategories() {
//var uba_cookieId = getCacheWithExpiry('new_session_id');
if (
uba_cookieId != "" &&
uba_cookieId != undefined &&
uba_catId != "" &&
uba_catId != undefined
) {
var uba_canonical_url = jQuery('link[rel="canonical"]').attr("href");
var langtitle = "";
if (langtitle == "") {
langtitle = jQuery("h1.title.h1.mb-2").text();
}
if (langtitle == "") {
langtitle = jQuery("h2#product-name").text();
}
langtitle = langtitle.trim();
langtitle = langtitle.replace(/\n/g, "");
detaildata = {
sessionId: uba_cookieId,
userip: uba_user_ip,
catid: uba_catId,
current_url: uba_currenturl,
weburl: uba_weburl,
hostname: uba_hostname,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
useragent: navigator.userAgent,
canonicalurl: uba_canonical_url,
langtitle: langtitle,
};
dataEnc = encodeData(detaildata);
jQuery
.post(UB_BASEURL + "?action=set_user_home_categories", { token: dataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
}
function setHomeCatCrouselWithData(
key,
classname,
value,
p0 = 1,
p1 = 2,
p2 = 3,
p3 = 4,
p4 = 5,
textview
) {
var view = "";
if (value != "" && value != undefined) {
jQuery("." + key).css("display", "block");
if (!textview) {
textview = "";
}
jQuery("#" + key + "_text_view").html(textview);
jQuery("." + classname).html(value);
view = jQuery("." + classname);
if (view) {
view.owlCarousel({
rtl: is_rtl,
autoplay: true,
autoplayHoverPause: false,
loop: false,
rewind: true,
lazyLoad: true,
navigation: true,
margin: 30,
nav: false,
dots: false,
responsive: {
0: {
items: 1,
},
480: {
items: 2,
margin: 10,
},
768: {
items: 3,
},
1024: {
items: 4,
},
1366: {
items: 5,
},
1600: {
items: 6,
},
},
});
}
}
}
/********************************* Get Static Categories End ***********************************************/
/********************************* Update Trigger Event Start ***********************************************/
function UpdateTriggerActivity() {
if (uba_cookieId == "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
detaildata = {
cookie_id: uba_cookieId,
username: uba_username,
emailid: uba_emailid,
cartcount: uba_cartcount,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
hostname: uba_hostname,
current_url: uba_currenturl,
page: uba_currentPage,
weburl: uba_weburl,
is_mobile: uba_is_mobile,
};
dataEnc = encodeData(detaildata);
jQuery
.post(UB_BASEURL + "?action=trigger_event", { token: dataEnc })
.done(function (data, status) {
if (data != "") {
}
});
}
function leaving_us_popup() {
if (uba_cookieId == "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var qData = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
username: uba_username,
emailid: uba_emailid,
current_url: uba_currenturl,
weburl: uba_weburl,
activepage: uba_Activepage,
};
var qDataEnc = encodeData(qData);
jQuery
.get(UB_BASEURL + "?action=get_leaving_us_popup", { token: qDataEnc })
.done(function (data, status) {
if (data != "") {
var ubobjdata = JSON.parse(data);
if (typeof ubobjdata.html != "undefined" && ubobjdata.html != "") {
jQuery(".intend-popup").html(ubobjdata.html);
}
var leavingdata = getCacheWithExpiry("leaving_us_closed");
if (leavingdata != "" && leavingdata != undefined) {
leaving_us_popup_session();
} else {
jQuery.stickToMe({
layer: "#stickLayer",
maxamount: 1,
onleave: function (e) {
var ubelm = jQuery("#uba_exit-popup");
ubelm.modal("show");
},
});
// stick_func();
setCacheWithExpiry("leaving_us_closed", "leaving_closed", 60 * 24);
}
} else {
}
});
}
jQuery("body").on("click", "#popup_submit_data", function (e) {
var popup_concern = jQuery("#popup_concern").val().trim();
var popup_email = jQuery("#popup_email").val();
var fill_concern_err = "Please fill your concern";
var fill_concern_atleast_err =
"Please type your concern at least in 10 characters";
if (popup_concern == "") {
if (!is_rtl) {
jQuery("#popup_concern_error").html(fill_concern_err);
} else {
var tData = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
fill_concern_err: fill_concern_err,
fill_concern_atleast_err: fill_concern_atleast_err,
};
var tDataEnc = encodeData(tData);
jQuery
.get(UB_BASEURL + "?action=ub_translate", { token: tDataEnc })
.done(function (result, status) {
obj = JSON.parse(result);
fill_concern_err = obj.fill_concern_err;
jQuery("#popup_concern_error").html(fill_concern_err);
});
}
} else {
if (popup_concern.length < 10) {
if (!is_rtl) {
jQuery("#popup_concern_error").html(fill_concern_atleast_err);
} else {
var tData = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
fill_concern_err: fill_concern_err,
fill_concern_atleast_err: fill_concern_atleast_err,
};
var tDataEnc = encodeData(tData);
jQuery
.get(UB_BASEURL + "?action=ub_translate", { token: tDataEnc })
.done(function (result, status) {
obj = JSON.parse(result);
fill_concern_atleast_err = obj.fill_concern_atleast_err;
jQuery("#popup_concern_error").html(fill_concern_atleast_err);
});
}
} else {
jQuery("#popup_concern_error").html(" ");
var qData = {
store: uba_current_store,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
popup_concern: popup_concern,
popup_email: popup_email,
activepage: uba_Activepage,
};
var qDataEnc = encodeData(qData);
jQuery
.get(UB_BASEURL + "?action=set_leaving_us_popup", { token: qDataEnc })
.done(function (result, status) {
if (result != "") {
obj = JSON.parse(result);
objres = obj.res;
objmsg = obj.msg;
if (status != "") {
if (objres == "success") {
$("#popup_dialog").show();
$("#popup_dialog").fadeIn("slow").delay(2000).fadeOut("slow");
$("#exampleModalCenter").fadeOut("slow");
$(".stick_block_layer").delay(5000).remove();
} else {
jQuery("#popup_email_error").html(objmsg);
}
}
} else {
}
});
}
}
});
function leaving_us_popup_session() {
var leavingdata = JSON.parse(localStorage.getItem("leaving_us_closed"));
if (leavingdata != "" && leavingdata != undefined && leavingdata != null) {
var nowleaving = new Date();
var browsertime = nowleaving.getTime();
leavingshowtime = leavingdata.expiry + 60 * 24 * 60000;
if (browsertime > leavingshowtime) {
jQuery.stickToMe({
layer: "#stickLayer",
maxamount: 1,
onleave: function (e) {
var ubelm = jQuery("#uba_exit-popup");
ubelm.modal("show");
},
});
// stick_func();
} else {
jQuery(".intend-popup").hide();
}
}
}
function getBoughtWithBelowCart() {
var BASE_URL = (recenthtml = productUrl = imageUrl = html = productdata = "");
var asin = jQuery("#p_full_id").val();
if (asin == "" || asin == undefined) {
setTimeout(function () {
getBoughtWithBelowCart();
}, 2000);
return;
}
if (asin != "") {
var detailjson = {
asin: asin,
store: uba_current_store,
substore: uba_subStore,
store_id: uba_store_id,
website_id: uba_website_id,
page: uba_currentPage,
weburl: uba_weburl,
current_url: uba_currenturl,
hostname: uba_hostname,
};
dataenc = encodeData(detailjson);
jQuery
.get(UB_BASEURL + "?action=get_bought_cart", { token: dataenc })
.done(function (productdata, status) {
if (productdata != "" && productdata != undefined) {
var obj = JSON.parse(productdata);
objdata = obj.html;
if (objdata != "" && objdata != undefined) {
jQuery(objdata).insertAfter("#uba-bought-with");
$(".center").slick({
rtl: is_rtl,
slidesToShow: 4,
slidesToScroll: 4,
dots: false,
responsive: [
{
breakpoint: 1500,
settings: {
slidesToShow: 4,
slidesToScroll: 4,
},
},
{
breakpoint: 1400,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
},
},
{
breakpoint: 1200,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
},
},
{
breakpoint: 992,
settings: {
slidesToShow: 4,
slidesToScroll: 4,
},
},
{
breakpoint: 768,
settings: {
slidesToShow: 3,
slidesToScroll: 3,
},
},
{
breakpoint: 480,
settings: {
slidesToShow: 2,
slidesToScroll: 2,
},
},
],
});
}
}
});
}
}
function setDealTimerData(classname, value) {
var view = "";
if (value != "" && value != undefined) {
view = jQuery("." + classname);
if (view) {
view.owlCarousel({
rtl: is_rtl,
loop: false,
margin: 25,
smartSpeed: 1000,
autoplay: true,
autoplayTimeout: 5000,
items: 1,
nav: false,
dots: false,
});
}
}
}
function dealtimersession() {
var hbardata = JSON.parse(localStorage.getItem("dealtimer_closed"));
if (hbardata != "" && hbardata != undefined) {
var nowhbar = new Date();
var browsertime = nowhbar.getTime();
hbarshowtime = hbardata.expiry + 1440 * 60000;
if (uba_screen_width <= 1200) {
if (browsertime > hbarshowtime) {
jQuery(".uba-curiosity-timer").show();
} else {
jQuery(".uba-curiosity-timer").hide();
}
}
}
}
function closedealtimer() {
setCacheWithExpiry("dealtimer_closed", "dtimer_closed", 1440);
jQuery(".uba-curiosity-timer").hide();
}
function get_curiosity_timer() {
if (uba_cookieId != "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var uba_canonical_url = jQuery('link[rel="canonical"]').attr("href");
var qData = {
store_id: uba_store_id,
website_id: uba_website_id,
arabic: uba_is_arabic_store,
store: uba_current_store,
canonicalurl: uba_canonical_url,
store_id: uba_store_id,
website_id: uba_website_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
};
var qDataEnc = encodeData(qData);
//jQuery(".uba-curiosity-timer").hide();
jQuery
.get(UB_BASEURL + "?action=get_curiosity_timer", { token: qDataEnc })
.done(function (data, status) {
if (data != "") {
var ubobjdata = JSON.parse(data);
console.log(ubobjdata);
if (typeof ubobjdata.html != "undefined" && ubobjdata.html != "") {
var hbardata = getCacheWithExpiry("dealtimer_closed");
if (hbardata != "" && hbardata != undefined) {
dealtimersession();
} else {
jQuery(".uba-curiosity-timer").html(ubobjdata.html);
setDealTimerData("dealtimer-slider", ubobjdata.html);
}
} else {
document.getElementsByClassName("close-timeslider")[0].onclick =
function () {
this.parentNode.hide();
};
}
}
});
}
function getHomepagePurchase() {
if(uba_screen_width < 1024){
return false;
}
if (uba_cookieId == "") {
uba_cookieId = getCacheWithExpiry("new_session_id");
}
var htmldata = "";
var uba_canonical_url = jQuery('link[rel="canonical"]').attr("href");
var qData = {
website_id: uba_website_id,
arabic: uba_is_arabic_store,
store: uba_current_store,
canonicalurl: uba_canonical_url,
store_id: uba_store_id,
cookie_id: uba_cookieId,
page: uba_currentPage,
is_mobile: uba_is_mobile,
hostname: uba_hostname,
current_url: uba_currenturl,
weburl: uba_weburl,
screen_size: uba_screen_width
};
var qDataEnc = encodeData(qData);
if (uba_is_arabic_store == false) {
if(["1", "2", "3", "4", "5", "7", "8", "9", "10", "11", "14", "18", "19", "20", "25", "32", "33", "34", "36", "41", "43", "44", "49", "50", "51", "52", "57", "58", "60", "87", "92"].includes(uba_website_id)==false){
// console.log('Popup working..'+uba_website_id);
/* }
if (
uba_website_id == "81" ||
uba_website_id == "39" ||
uba_website_id == "65" ||
uba_website_id == "68" ||
uba_website_id == "103"
) {*/
jQuery
.get(UB_BASEURL + "?action=get_hp_purchase_popup", {
token: qDataEnc,
})
.done(function (htmldata, status) {
$("#dynamicContent").remove();
if (htmldata != "" && htmldata != undefined) {
var obj = JSON.parse(htmldata);
//objdata = obj.html;
objdata = obj;
var index = 0;
if (objdata != "" && objdata != undefined) {
var pbardata = getCacheWithExpiry("purchase_popup_closed");
if (pbardata != "" && pbardata != undefined) {
purchasepop();
} else {
var uba_sbbreaddiv = jQuery(".top-purches-popup");//jQuery(".review");
jQuery(uba_sbbreaddiv).after(
''
);
jQuery(".recent-purchased-card").css({ display: "none" });
var interval = setInterval(function () {
if (jQuery("#dynamicContent:hover").length != 0) {
jQuery(".recent-purchased-card").show();
index = index - 1;
} else {
jQuery(".recent-purchased-card").hide();
}
if (index % 2 == 0) {
jQuery(".recent-purchased-card").html(obj[index]);
jQuery(".recent-purchased-card").fadeIn("fast");
} else {
jQuery(".recent-purchased-card").fadeOut("fast");
}
if (index > 10) {
index = 0;
jQuery(".recent-purchased-card").fadeOut("fast");
clearInterval(interval);
}
index++;
}, 10000);
setInterval(
localStorage.setItem("_purchase_data", objdata),
10000
);
let purchase = localStorage.getItem("_purchase_data");
if (purchase !== null) {
}
// }
}
} else {
jQuery(".recent-purchased-card").hide();
}
} else {
jQuery(".recent-purchased-card").hide();
}
});
}
}
}
function purchasepop() {
var purchasedata = JSON.parse(localStorage.getItem("purchase_popup_closed"));
if (purchasedata != "" && purchasedata != undefined) {
var nowpbar = new Date();
var browsertimepur = nowpbar.getTime();
purchaseshowtime = purchasedata.expiry + 60 * 24 * 60000;
if (uba_screen_width <= 1200) {
if (browsertimepur > purchaseshowtime) {
jQuery(".recent-purchased-card").show();
} else {
jQuery(".recent-purchased-card").hide();
}
}
}
}
function closepurchasepopup() {
setCacheWithExpiry("purchase_popup_closed", "pur_closed", 1440);
if (uba_screen_width <= 1200) {
jQuery(".recent-purchased-card").hide();
} else {
jQuery(".recent-purchased-card").remove();
}
}
let isFunctionRunning = false;
function myFunction() {
if (isFunctionRunning) {
return; // If the function is already running, exit
}
// Set the flag to indicate that the function is running
isFunctionRunning = true;
//getHomepagePurchase();
// Reset the flag when the function is done
isFunctionRunning = false;
}