added aio landing page

This commit is contained in:
2024-04-04 15:01:14 +05:30
parent a12121bc5b
commit d3532c6cb8
24 changed files with 2263 additions and 3122 deletions
+301 -274
View File
@@ -1,105 +1,102 @@
navINIT();
function navINIT() {
async function getAllProdouctsIds() {
let res = await API_SERVICES_ACTIONS.getAPIService(
"apis/v4/bizgaze/integrations/products/getallproducts",
true
);
if (res.isError) {
console.log(res.errorMsg);
return;
}
res = JSON.parse(res.response.result);
for (let i = 0; i < res.length; i++) {
let curr = res[i];
let productname = curr.productname;
let id = curr.productid;
// ACCESSORIES
switch (productname) {
case "Zeno Sleekbook":
appendIdNav("zenosleekbook", id);
break;
case "Zeno Dualbook":
appendIdNav("zenodualbook", id);
break;
case "FYRO Flagship":
appendIdNav("fyroflagship", id);
break;
case "AIO Fyro":
// appendIdNav('fyroaio',id);
break;
case "AIO Zeno":
// appendIdNav('zenoaio',id);
default:
break;
}
}
}
async function getAllProdouctsIds(){
let res = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getallproducts',true);
if(res.isError){
console.log(res.errorMsg);
return;
function appendIdNav(className, id) {
let html = $(`.${className}`).attr("href");
const pattern = /{[^}]+}/g;
const replacedString = html.replace(pattern, id);
$(`.${className}`).parents(".nav-tab-show").removeClass("d-none");
$(`.${className}`).attr("href", replacedString);
}
if (
!window.location.href.includes("orderconfirmation") &&
!window.location.href.includes("/w/")
) {
loadCart();
}
function loadHelper(src = "./dist/js/utils/helpers.js") {
if ($(`script[src="${src}"]`).length > 0) {
return new Promise((resolve) => resolve());
}
return new Promise(function (resolve, reject) {
var s;
s = document.createElement("script");
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
async function loadCart() {
if (!window.location.href.includes("services/paymentmethod.html")) {
let files = ["./dist/js/shoppingcart/addtocart.js"];
await loadHelper();
for (let i = 0; i < files.length; i++) {
if ($(`script[src="${files[i]}"]`).length > 0) {
continue;
}
res = JSON.parse(res.response.result);
for(let i=0;i<res.length;i++){
let curr = res[i];
let productname = curr.productname;
let id = curr.productid;
// ACCESSORIES
switch (productname) {
case 'Zeno Sleekbook':
appendIdNav('zenosleekbook',id);
break;
case 'Zeno Dualbook':
appendIdNav('zenodualbook',id);
break;
case "FYRO Flagship":
appendIdNav('fyroflagship',id);
break;
case "AIO Fyro":
// appendIdNav('fyroaio',id);
break;
case "AIO Zeno":
// appendIdNav('zenoaio',id);
default:
break;
}
try {
await loadHelper(files[i]);
} catch (error) {
console.log(error);
return;
}
}
}
function appendIdNav(className,id){
let html = $(`.${className}`).attr('href');
const pattern = /{[^}]+}/g;
const replacedString = html.replace(pattern, id);
$(`.${className}`).parents('.nav-tab-show').removeClass('d-none')
$(`.${className}`).attr('href',replacedString);
}
if(!window.location.href.includes('orderconfirmation')&&!window.location.href.includes('/w/')){
loadCart();
}
function loadHelper(src = './dist/js/utils/helpers.js'){
if ($(`script[src="${src}"]`).length > 0) {
return new Promise((resolve) => resolve());
}
return new Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
async function loadCart(){
if(!window.location.href.includes('services/paymentmethod.html')){
let files = ['./dist/js/shoppingcart/addtocart.js'];
await loadHelper();
for(let i=0;i<files.length;i++){
if ($(`script[src="${files[i]}"]`).length > 0) {
continue;
}
try {
await loadHelper(files[i])
} catch (error) {
console.log(error);
return;
}
}
}
setLengthCart();
getAllProdouctsIds();
}
let URLNAMENAV = window.location.href;
const isTransparent = URLNAMENAV.includes('login')||URLNAMENAV.includes('orderconfirmation')|| URLNAMENAV.includes('services/paymentmethod.html');
;
let nav_html = `
<header class="header-area section-padding-1 transparent-bar" ${isTransparent ?'style="background:#fff"' :''}>
setLengthCart();
getAllProdouctsIds();
}
let URLNAMENAV = window.location.href;
const isTransparent =
URLNAMENAV.includes("login") ||
URLNAMENAV.includes("orderconfirmation") ||
URLNAMENAV.includes("services/paymentmethod.html");
let nav_html = `
<header class="header-area section-padding-1 transparent-bar" ${
isTransparent ? 'style="background:#fff"' : ""
}>
<div class="header-large-device">
<div class="header-bottom sticky-bar">
<div class="container-lg">
@@ -114,7 +111,7 @@ function navINIT() {
<nav>
<ul class="mb-0 p-0">
<li class="hover_tab_1">
<a href="/laptops.html" class="satoshi_font">LAPTOPS
<a href="/laptops.html" class="satoshi_font flex items-center">LAPTOPS
<svg style="width:18px;height:15px" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
<path fill="#000" d="M1395 736q0 13-10 23l-466 466q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l393 393 393-393q10-10 23-10t23 10l50 50q10 10 10 23z"/>
</svg>
@@ -151,7 +148,7 @@ function navINIT() {
</ul>
</li>
<li class="hover_tab_2">
<a href="/allinones.html" class="satoshi_font">ALL IN ONES
<a href="/allinones.html" class="satoshi_font flex items-center">ALL IN ONES
<svg style="width:18px;height:15px;" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
<path fill="#000" d="M1395 736q0 13-10 23l-466 466q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l393 393 393-393q10-10 23-10t23 10l50 50q10 10 10 23z"/>
</svg>
@@ -180,7 +177,7 @@ function navINIT() {
</ul>
</li>
<li class="hover_tab_2">
<a href="/accessories.html" class="satoshi_font">ACCESSORIES
<a href="/accessories.html" class="satoshi_font flex items-center">ACCESSORIES
<svg style="width:18px;height:15px;" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg">
<path fill="#000" d="M1395 736q0 13-10 23l-466 466q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l393 393 393-393q10-10 23-10t23 10l50 50q10 10 10 23z"/>
</svg>
@@ -266,7 +263,11 @@ function navINIT() {
<h2 class="titleproductnav sub_nav_item me-3 fs-9"></h2></span>
<ul class="d-flex mb-0 py-3 justify-content-center align-items-center" style="list-style:none;">
<li>
<a data-overview="#${window.location.href.includes('Zeno')?'overview_data_zeno':'overview_data_fyro'}" href="#home-main-container" class="sub_nav_item overview me-3 fs-9">Overview</a>
<a data-overview="#${
window.location.href.includes("Zeno")
? "overview_data_zeno"
: "overview_data_fyro"
}" href="#home-main-container" class="sub_nav_item overview me-3 fs-9">Overview</a>
</li>
<li>
<a data-spec="true" class="sub_nav_item me-3 fs-9 overviewspecs">Specifications</a>
@@ -451,198 +452,224 @@ function navINIT() {
</div>
</div>
</div>`;
$("#navbar-head").html(nav_html);
$("#navbar-head").html(nav_html);
$('.explandlinavnameparent').click(function (e){
let parentElement = $(e.target).parents('.expandlinav');
if($(parentElement).find('.content-expandlinav').hasClass('d-none')){
const name = $(parentElement).find('.viewall_li').data('name');
$(parentElement).find('.viewall_li').html(`<a href="${name}">view all</a>`);
$(parentElement).find('.content-expandlinav').removeClass('d-none');
}else{
$(parentElement).find('.viewall_li').html('+');
$(parentElement).find('.content-expandlinav').addClass('d-none');
}
});
let width = $(window).width();
if(width <= 576){
$(".success-img.left-block").attr({"width":"250px","height":"250px"});
$(".product_item").addClass("flex-column")
$(".explandlinavnameparent").click(function (e) {
let parentElement = $(e.target).parents(".expandlinav");
if ($(parentElement).find(".content-expandlinav").hasClass("d-none")) {
const name = $(parentElement).find(".viewall_li").data("name");
$(parentElement)
.find(".viewall_li")
.html(`<a href="${name}">view all</a>`);
$(parentElement).find(".content-expandlinav").removeClass("d-none");
} else {
$(parentElement).find(".viewall_li").html("+");
$(parentElement).find(".content-expandlinav").addClass("d-none");
}
$(".menu-negative-mrg2,.menu-negative-mrg3,.menu-negative-mrg4").css("width", width);
let ele_page = $("body").hasClass("product_pg");
if (ele_page == true) {
$(".header-area").removeClass("bg-white");
$(".main-menu").find("nav ul li a").addClass("text-white");
$(".header-bottom.sticky-bar").removeClass("sticky-bar");
let src = `../dist/assets/imgs/anwi-logo-2.png`;
$(".logo-menu-wrap").find(".logo a img").attr("src", src);
$(".main-body").find("iframe").attr("width", width);
if (width <= 575 && width >= 390) {
$(".main-body").find("iframe").attr({
width: width,
height: 236,
})
} else if (width <= 390 && width >= 270) {
$(".main-body").find("iframe").attr({
width: width,
height: 210,
});
} else if (width <= 998 && width > 575) {
$(".main-body").find("iframe").attr({
width: width,
height: 530,
});
} else if (width <= 2720 && width > 2300) {
$(".main-body").find("iframe").attr({
width: width,
height: 1440,
});
} else if(width <= 2300 && width > 1921){
$(".main-body").find("iframe").attr({
width: width,
height: 1132,
});
}
else if(width <= 1920 && width > 1620){
$(".main-body").find("iframe").attr({
width: width,
height: 1083,
});
}else {
$(".main-body").find("iframe").attr({
width: width,
height: 861,
});
}
});
let width = $(window).width();
if (width <= 576) {
$(".success-img.left-block").attr({ width: "250px", height: "250px" });
$(".product_item").addClass("flex-column");
}
$(".menu-negative-mrg2,.menu-negative-mrg3,.menu-negative-mrg4").css(
"width",
width
);
let ele_page = $("body").hasClass("product_pg");
if (ele_page == true) {
$(".header-area").removeClass("bg-white");
$(".main-menu").find("nav ul li a").addClass("text-white");
$(".header-bottom.sticky-bar").removeClass("sticky-bar");
let src = `../dist/assets/imgs/anwi-logo-2.png`;
$(".logo-menu-wrap").find(".logo a img").attr("src", src);
$(".main-body").find("iframe").attr("width", width);
if (width <= 575 && width >= 390) {
$(".main-body").find("iframe").attr({
width: width,
height: 236,
});
} else if (width <= 390 && width >= 270) {
$(".main-body").find("iframe").attr({
width: width,
height: 210,
});
} else if (width <= 998 && width > 575) {
$(".main-body").find("iframe").attr({
width: width,
height: 530,
});
} else if (width <= 2720 && width > 2300) {
$(".main-body").find("iframe").attr({
width: width,
height: 1440,
});
} else if (width <= 2300 && width > 1921) {
$(".main-body").find("iframe").attr({
width: width,
height: 1132,
});
} else if (width <= 1920 && width > 1620) {
$(".main-body").find("iframe").attr({
width: width,
height: 1083,
});
} else {
$(".main-body").find("iframe").attr({
width: width,
height: 861,
});
}
}
$("a.ram_data").click(function () {
let item_id = $(this).attr("accessories_id");
let loc_path = '/products.html'
if (window.location.pathname.includes(loc_path)) {
window.location.href = `?itemid=${item_id}`
}
else {
window.location.href = `/products.html#itemid=${item_id}`;
}
})
// $(".main-menu nav ul").find("li").each(function () {
// var current = window.location.pathname;
// var $this = $(this).find("a");
// if (current != "/") {
// if ($this.attr('href').indexOf(current) !== -1) {
// $(this).addClass('active_nav');
// }
// }
// })
// destroy localstorage data
let loc_path = '/productdetails.html';
if (window.location.pathname.includes(loc_path) === false) {
localStorage.removeItem("product_data");
localStorage.removeItem("top_data")
}
let loc_path1 = '/productcatloguedetails.html';
if (window.location.pathname.includes(loc_path1) === false) {
localStorage.removeItem("product_catlogue_obj");
$("a.ram_data").click(function () {
let item_id = $(this).attr("accessories_id");
let loc_path = "/products.html";
if (window.location.pathname.includes(loc_path)) {
window.location.href = `?itemid=${item_id}`;
} else {
window.location.href = `/products.html#itemid=${item_id}`;
}
});
//services pages links and sources
// $(".main-menu nav ul").find("li").each(function () {
// var current = window.location.pathname;
// var $this = $(this).find("a");
// if (current != "/") {
// if ($this.attr('href').indexOf(current) !== -1) {
// $(this).addClass('active_nav');
// }
// }
// })
// destroy localstorage data
let loc_path = "/productdetails.html";
if (window.location.pathname.includes(loc_path) === false) {
localStorage.removeItem("product_data");
localStorage.removeItem("top_data");
}
let loc_path1 = "/productcatloguedetails.html";
if (window.location.pathname.includes(loc_path1) === false) {
localStorage.removeItem("product_catlogue_obj");
}
//services pages links and sources
let $body_pg = $("body").hasClass("services_page");
let $hm_pg = "../index.html";
let $nav_img = "../dist/assets/imgs/anwi-logo-1.png";
let $footer_img = "../dist/assets/imgs/anwi-logo-2.png";
let $scrool_top_img = "../dist/assets/imgs/Home/rocket-footer.png";
let $about_pg = $("body").hasClass("about_page");
if($about_pg == true){
$(".main-menu").find("nav ul li a").addClass("text-dark");
let img_src = `./dist/assets/imgs/anwi-logo-1.png`;
$(".logo-menu-wrap").find(".logo a img").attr("src",img_src);
let $body_pg = $("body").hasClass("services_page");
let $hm_pg = "../index.html";
let $nav_img = "../dist/assets/imgs/anwi-logo-1.png";
let $footer_img = "../dist/assets/imgs/anwi-logo-2.png";
let $scrool_top_img = "../dist/assets/imgs/Home/rocket-footer.png";
let $about_pg = $("body").hasClass("about_page");
if ($about_pg == true) {
$(".main-menu").find("nav ul li a").addClass("text-dark");
let img_src = `./dist/assets/imgs/anwi-logo-1.png`;
$(".logo-menu-wrap").find(".logo a img").attr("src", img_src);
$(".header-bottom").addClass("sticky-bar stick");
$("body.about_page")
.find(".header-large-device")
.find(".header-action-wrap")
.find(".same-style")
.find("svg")
.find("path")
.attr("fill", "#000");
}
let $body_nav = $("body").attr("class");
if (
$body_nav === "support_pg" ||
$body_nav === "media_page" ||
$body_nav === "meter_pg"
) {
$(".main-menu").find("nav ul li a").addClass("text-dark");
let img_src = `./dist/assets/imgs/anwi-logo-1.png`;
$(".logo-menu-wrap").find(".logo a img").attr("src", img_src);
$(".same-style").find("svg path").attr("fill", "#000");
}
if ($body_pg == true) {
$(".header-large-device")
.find(".logo-menu-wrap .logo")
.find("a")
.attr("href", $hm_pg);
$(".header-large-device")
.find(".logo-menu-wrap .logo")
.find("a img")
.attr("src", $nav_img);
$(".mobile-logo").find("a").attr("href", $hm_pg);
$(".mobile-logo").find(".logo a img").attr("src", $nav_img);
$("body.services_page")
.find(".header-large-device")
.find(".header-action-wrap")
.find(".same-style")
.find("svg")
.find("path")
.attr("fill", "#000");
$(".main-menu")
.find("nav ul")
.find("li a")
.each(function () {
$(this).addClass("text-dark");
$(".header-bottom").addClass("sticky-bar stick");
$("body.about_page").find(".header-large-device").find(".header-action-wrap").find(".same-style").find("svg").find("path").attr("fill","#000");
}
let $body_nav = $("body").attr("class");
if($body_nav === "support_pg" || $body_nav === "media_page" || $body_nav === "meter_pg"){
$(".main-menu").find("nav ul li a").addClass("text-dark");
let img_src = `./dist/assets/imgs/anwi-logo-1.png`;
$(".logo-menu-wrap").find(".logo a img").attr("src",img_src);
$('.same-style').find('svg path').attr('fill','#000');
}
if ($body_pg == true) {
$(".header-large-device").find(".logo-menu-wrap .logo").find("a").attr("href", $hm_pg);
$(".header-large-device").find(".logo-menu-wrap .logo").find("a img").attr("src", $nav_img);
$(".mobile-logo").find("a").attr("href", $hm_pg);
$(".mobile-logo").find(".logo a img").attr("src", $nav_img);
$("body.services_page").find(".header-large-device").find(".header-action-wrap").find(".same-style").find("svg").find("path").attr("fill","#000");
$(".main-menu").find("nav ul").find("li a").each(function () {
$(this).addClass("text-dark")
$(".header-bottom").addClass("sticky-bar stick");
let $arc = $(this).attr("href");
let $spcial_char = $arc.includes("./");
if ($spcial_char === true) {
let $refarence = `.${$arc}`
$(this).attr("href", $refarence);
}
});
$(".same-style").find("a").each(function () {
let $arc1 = $(this).attr("href");
let $spcial_char1 = $arc1.includes("./");
if ($spcial_char1 === true) {
let $refarence1 = `.${$arc1}`
$(this).attr("href", $refarence1);
}
})
$(".tab-content").find("img").each(function(){
let $img_src = $(this).attr("src");
let $img_src1 = $img_src.includes("./");
if ($img_src1 === true) {
let $refarenceimg1 = `.${$img_src}`;
$(this).attr("src", $refarenceimg1);
}
});
$(".clickable-mainmenu-wrap").find("nav ul").find("li a").each(function () {
let $arc_mbil = $(this).attr("href");
let $spcial_char_mbil = $arc_mbil.includes("./");
if ($spcial_char_mbil === true) {
let $refarence_mbil = `.${$arc_mbil}`
$(this).attr("href", $refarence_mbil);
}
});
}
setTimeout(()=>{
if(width<=600){
$('.same-style').find('svg path').attr('fill','#000');
let $arc = $(this).attr("href");
let $spcial_char = $arc.includes("./");
if ($spcial_char === true) {
let $refarence = `.${$arc}`;
$(this).attr("href", $refarence);
}
},300);
});
$(".same-style")
.find("a")
.each(function () {
let $arc1 = $(this).attr("href");
let $spcial_char1 = $arc1.includes("./");
if ($spcial_char1 === true) {
let $refarence1 = `.${$arc1}`;
$(this).attr("href", $refarence1);
}
});
$(".tab-content")
.find("img")
.each(function () {
let $img_src = $(this).attr("src");
let $img_src1 = $img_src.includes("./");
if ($img_src1 === true) {
let $refarenceimg1 = `.${$img_src}`;
$(this).attr("src", $refarenceimg1);
}
});
$(".clickable-mainmenu-wrap")
.find("nav ul")
.find("li a")
.each(function () {
let $arc_mbil = $(this).attr("href");
let $spcial_char_mbil = $arc_mbil.includes("./");
if ($spcial_char_mbil === true) {
let $refarence_mbil = `.${$arc_mbil}`;
$(this).attr("href", $refarence_mbil);
}
});
}
// overview
setTimeout(() => {
if (width <= 600) {
$(".same-style").find("svg path").attr("fill", "#000");
}
}, 300);
$('.overview').click(function (e){
let name = $(e.target).data('overview');
document.querySelector(name)?.scrollIntoView({
behavior: 'smooth'
});
// overview
$(".overview").click(function (e) {
let name = $(e.target).data("overview");
document.querySelector(name)?.scrollIntoView({
behavior: "smooth",
});
});
$('.overviewspecs').click(function (e){
document.querySelector('#specification_data')?.scrollIntoView({
behavior: 'smooth'
});
});
}
$(".overviewspecs").click(function (e) {
document.querySelector("#specification_data")?.scrollIntoView({
behavior: "smooth",
});
});
}
+886 -907
View File
File diff suppressed because it is too large Load Diff
-939
View File
@@ -1,939 +0,0 @@
function startDetails() {
// http://127.0.0.1:5502/productdetails.html?productId=106633230000024
if (window.location.search.split('=')[0] == '') {
window.location.href = "/notfound.html";
return;
}
let productId = window.location.hash.split('#')[1].split('=')[1];
console.log(productId);
let itemtagscombinationRes = null;
let labels = {};
let isThereInLabel = {};
let currentComb = null;
let colorId = null;
let group = {};
let loadingActions = {
addLoader() {
$('.loadingCall').removeClass('d-none');
$('.mainContanierProduct').addClass('d-none');
},
removeLoader() {
$('.loadingCall').addClass('d-none');
$('.mainContanierProduct').removeClass('d-none');
}
}
let currentClick = null;
if (productId) {
swapSectionsVideo();
loadingActions.addLoader();
updateProductId(productId);
getProductDetails(productId);
appendSpecs(productId)
} else {
window.location.href = "/notfound.html"
}
function updateProductId(val) {
$('#productidtag').val(val);
}
function updateItemId(val) {
$('#itemidtag').val(val);
}
let specification_wrap_action = {
remove() {
$('.specification-wrap').addClass('d-none');
},
add() {
$('.specification-wrap').removeClass('d-none');
}
}
let description_action = {
addVal(value) {
$('.description-wrap > p').html(value);
},
removeVal(value) {
$('.description-wrap > p').html('');
}
}
function getSpecsItemHTML({ name, des, itemid, id }) {
return `<div id="${id}" data-specitemid="${itemid}" class="">
<div class="row border-bottom">
<div class="col-sm-6 bg-gray-3 py-2">
${name}
</div>
<div class="col-sm-6 py-2">
${des}
</div>
</div>
</div>`;
}
// function getSpecsItemHTML({name,des,itemid,id}){
// return ` <tr id="${id}" data-specitemid="${itemid}">
// <td style="width:200px">${name}</td>
// <td class="">${des}</td>
// </tr>`;
// }
async function appendSpecs(id) {
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemspecifications/itemid/${id}`, true);
if (resData.isError) {
$('.productdetailstabs').addClass('d-none');
$('.specContainerleft').html('')
$('.specContainerRight').html('')
return;
}
$('.productdetailstabs ').removeClass('d-none');
const res = resData.response;
// console.log(JSON.parse(res.result));
const data = JSON.parse(res.result);
// console.log(data);
let html = '';
let leftHtml = '';
let rightHtml = '';
if (data.length == 0) {
$('.productdetailstabs ').addClass('d-none');
$('.specContainerleft').html('')
$('.specContainerRight').html('')
return;
}
for (let i = 0; i < data.length; i++) {
const { specificationname, specificationitemid, itemid, description } = data[i];
if ((i + 1) % 2 == 0) {
rightHtml += getSpecsItemHTML({
name: specificationname, id: specificationitemid, itemid, des: description
})
} else {
leftHtml += getSpecsItemHTML({
name: specificationname, id: specificationitemid, itemid, des: description
});
}
}
$('.specContainerleft').html(leftHtml)
$('.specContainerRight').html(rightHtml)
}
function getParentHTML(name, productid, id, isMain) {
return `<div data-parentidgroup="${name?.replace(" ", '')}-parent" class="pb-2 groupingitems_search ${name?.replace(" ", '')}-parent">
<h5 class="py-2 smallHeadingProductDetails">${name}</h5>
<div class="d-flex gap-2 flex-lg-row flex-wrap ${id}container" data-tagid="${id}">
</div>
</div>`;
}
function onClickHandler(e) {
$(e).parent().find('.borderselector').removeClass('borderselector');
$(e).addClass('borderselector')
}
function getChildHTML(tagid, name, isTrue,parentid) {
let blue = '#253746';
let greenLight = '#5e7975';
let brown = '#624839';
let bgColor = '';
if(name === 'Deep Sea Blue'){
bgColor = blue;
}else if(name == 'Desert Brown'){
bgColor = brown;
}else if(name == 'Eucalyptus Green'){
bgColor = greenLight;
}
if(colorId == parentid){
return `
<div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue ? 'borderselector' : ''} colorselector card text-center small-font cursor-pointer ">
<span style="
height: 25px;
border-radius: 5px;
width:25px;
background: ${bgColor} !important;
pointer-events:none;
"></span>
</div> `
}
return `
<div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue ? 'borderselector' : ''} card text-center small-font cursor-pointer p-3">
${name}
</div> `
}
function addeventlisteners() {
$('.optiontaganwi').each(function (i, el) {
$(el).click(function (e) {
$('#quantity').val(1);
$(e.target).parent().find('.borderselector').removeClass('borderselector');
$(e.target).addClass('borderselector');
currentClick = e.target;
;
//searchComb();
// getAllCombination();
getandsetCombination();
})
});
}
function getandsetCombination(){
let keyOption = $(currentClick).data('tagiditem');
$('.disabled-option-item').removeClass('disabled-option-item');
let tagsNames = [];
let currOptionAvaIds = {};
$('.borderselector').each(function (i,e){
let id = $(e).data('tagiditem');
tagsNames.push(id);
});
for(let i=0;i<itemtagscombinationRes.length;i++){
let tagItems = itemtagscombinationRes[i].tagids;;
if(tagItems.includes(keyOption)){
let splitArr = tagItems.split('|');
for(let j=0;j<splitArr.length;j++){
if(keyOption){
currOptionAvaIds[splitArr[j]] = splitArr[j];
}
}
}
}
console.log(currOptionAvaIds);
console.log(itemtagscombinationRes);
let parentsArr = [];
$('.optiontaganwi').each(function (i,e){
let currParent = $(e).parents('.groupingitems_search');
if(currParent.find(`[data-tagiditem="${keyOption}"]`).length==0){
let currId = $(e).data('tagiditem');
if(!currOptionAvaIds[currId]){
if($(e).hasClass('borderselector')){
parentsArr.push(currParent);
$(e).removeClass('borderselector');
}
$(e).addClass('disabled-option-item');
}
}
});
for(let i=0;i<parentsArr.length;i++){
let currParent = parentsArr[i];
currParent.find('.optiontaganwi').each(function (j,e){
let isTrue = $(e).hasClass('disabled-option-item');
if(!isTrue){
$(e).addClass('borderselector');
return false;
}
});
}
// $('.optiontaganwi').addClass('disabled-option-item');
let parentId = $(currentClick).parents('.groupingitems_search');
let parentData = $(parentId).data('parentidgroup');
let parentArr = [];
$('.groupingitems_search').each(function (i,e){
const curParentId = $(e).data('parentidgroup');
if(parentData != curParentId){
let obj = {
name:$(e).find('.smallHeadingProductDetails').html(),
arr:[]
}
$(e).find('.optiontaganwi').each(function (j,evt){
let id = $(evt).data('tagiditem');
obj.arr.push(id);
});
parentArr.push(obj);
}
})
console.log(parentArr);
let arrone = parentArr[0].arr;
let arrtwo = [];
if(parentArr.length>1){
arrtwo = parentArr[1]?.arr;
}
let currId = keyOption;
let ids = [];
for(let i=0;i<arrone.length;i++){
//let currEl = [currId,arrone[i]];
let currEl = ``
for(let j=0;j<arrtwo.length;j++){
currEl = `${currId}|${arrone[i]}|${arrtwo[j]}`;
ids.push(currEl);
currEl = '';
}
}
console.log(ids,'ids');
let findObj = [];
debugger
for(let i=0;i<ids.length;i++){
let curId = ids[i]
for(let j=0;j<itemtagscombinationRes.length;j++){
const currItem = itemtagscombinationRes[j].tagids.split('|');
let isTrue = true;
for(let k=0;k<currItem.length;k++){
if(!curId.includes(currItem[k])){
isTrue = false;
break;
}
}
if(isTrue){
findObj.push(itemtagscombinationRes[j]);
}
}
}
console.log(findObj);
$('.optiontaganwi').addClass('disabled-option-item');
debugger;
for(let i=0;i<findObj.length;i++){
let item = findObj[i].tagids.split('|');
for(let j=0;j<item.length;j++){
$(`[data-tagiditem=${item[j]}]`).removeClass('disabled-option-item');
}
}
$(parentId).find('.optiontaganwi').each(function (i,e){
$(e).removeClass('disabled-option-item')
});
for(let i=0;i<itemtagscombinationRes.length;i++){
let currIds = itemtagscombinationRes[i].tagids;
let isTrue = true;
let isPro = false;
for(let j=0;j<tagsNames.length;j++){
if(tagsNames.join().includes('106631360000128')&&(tagsNames.join().includes('106631360000132')||tagsNames.join().includes('106631360000133'))){
isPro = true;
}
if(!currIds.includes(tagsNames[j])){
isTrue = false;
}
}
if(isTrue){
const { quantity } = itemtagscombinationRes[i];
if (true) {
currentComb = itemtagscombinationRes[i];
updateDetailsByObj(itemtagscombinationRes[i]);
if(isPro){
$(`[data-tagiditem="106631360000089"]`).addClass(' disabled-option-item')
$(`[data-tagiditem="106631360000088"]`).addClass(' disabled-option-item')
}
} else {
let name = itemtagscombinationRes[i].itemname.split('-')[0];
$('#addtocart').addClass('disabled');
let itemsName = name;
$('.borderselector').each(function (i, e) {
itemsName += ` ${$(e).html().trim()}`;
});
updateItemId(null);
let defaultImg = itemtagscombinationRes[i].itemimageurl ? imgServerNameBuild(itemtagscombinationRes[i].itemimageurl) : `./dist/assets/imgs/nophoto.png`;
$('.productDetailsMain > img').attr('src', defaultImg);
specification_wrap_action.remove();
$('#skudetailitem').val(-1)
$('.productname').html(itemsName)
$('.msgErrorDetailsItem').removeClass('d-none');
$('.des_productdes').html('');
$('.price').html('');
}
initAddToCart()
return;
}
}
// return;
return;
let commonTags = [];
// $('.optiontaganwi').addClass('disabled-option-item')
for(let i=0;i<tagsNames.length;i++){
let currtagName = tagsNames[i];
let arr = currtagItemCom(currtagName);
commonTags.push(arr);
}
console.log(commonTags);
// for(let i=0;i<commonTags.length;i++){
// let currObj = commonTags[i];
// for(let item in currObj){
// console.log($(`[data-tagiditem="${item}"]`));
// $(`[data-tagiditem="${item}"]`).removeClass('disabled-option-item')
// }
// }
let finalAns = {};
let arra = [];
for(let i=0;i<commonTags.length;i++){
let currObj = commonTags[i];
for(let item in currObj){
let isTrue = true;
for(let j=0;j<commonTags.length;j++){
if(j!=i){
let currComb = commonTags[j];
if(!currComb[item]){
isTrue = false;
}
}
}
if(isTrue){
arra.push(currObj[item])
finalAns[currObj[item]] = currObj[item];
$(`[data-tagiditem="${item}"]`).removeClass('disabled-option-item')
}
}
}
// console.log(arra);
// for(let i=0;i<itemtagscombinationRes.length;i++){
// let tagItems = itemtagscombinationRes[i].tagids;;
// if(tagItems.includes(keyOption)){
// let splitArr = tagItems.split('|');
// for(let j=0;j<splitArr.length;j++){
// commonTags[splitArr[j]] = splitArr[j];
// }
// }
// }
// for(let i=0;i<currOptionAvaIds.length;i++){
// let currId = currOptionAvaIds[i];
// if(parentId.find(currId).length === 0){
// console.log(currId);
// }
// }
}
function currtagItemCom(keyOption){
debugger;
let arr = [];
let commonTags = {};
for(let i=0;i<itemtagscombinationRes.length;i++){
let tagItems = itemtagscombinationRes[i].tagids;;
if(tagItems.includes(keyOption)){
let splitArr = tagItems.split('|');
for(let j=0;j<splitArr.length;j++){
if(!commonTags[splitArr[j]]){
commonTags[splitArr[j]] = {
keyOption,
data:itemtagscombinationRes[i]
};
arr.push(splitArr[j]);
}
}
}
}
return commonTags;
}
function updateDetailsByObj(obj) {
$('.productname').html(obj.itemname);
$('.titleproductnav').html(obj.itemname);
let [currencySymbol, amount] = getCurrencySymbol(obj?.pricelist||0);
let commingSoonText = window.location.href.toLowerCase().includes('zeno')||window.location.href.includes('fyro')
$('.price').html(obj.pricelist ? `<span class="font-w600">${currencySymbol}${amount}</span>${commingSoonText?'<span class="mx-1 badge d-md-none bg-gradient-violet text-a-color">Pre Order Now!</span>':''}` : 'pre order now');
appendSpecs(obj.itemid)
$('#skudetailitem').val(obj.sku)
$('.des_productdes').html(obj.itemdescription);
$('#addtocart').attr('data-qty', obj.quantity);
let defaultImg = obj.itemimageurl ? imgServerNameBuild(obj.itemimageurl) : `./dist/assets/imgs/nophoto.png`;
// console.log(obj.itemimageurl, 'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
debugger;
let productId = window.location.hash.split('#')[1]?.split('=')[1];
let itemId = window.location.hash.split('#')[2]?.split('=')[1];
history.replaceState(undefined, undefined, `#productId=${productId}#itemid=${obj.itemid}`)
$('.productDetailsMain > img').attr('src', defaultImg).attr('loading','lazy');
updateItemId(obj.itemid);
console.log(obj,'objobjobj');
debugger;
if (!obj.pricelist || !obj.quantity) {
$('.buynow').attr('disabled', true);
$('#addtocart').attr('disabled', true);
} else {
$('.buynow').attr('disabled', false);
$('#addtocart').attr('disabled', false);
}
}
function searchComb() {
let valuesSelected = [];
$('.optiontaganwi').removeClass('disabled-option-item')
$('#addtocart').removeClass('disabled');
$('.msgErrorDetailsItem').addClass('d-none');
$('.borderselector,border_selector').each(function (i, el) {
console.log($(el).html())
let val = $(el).data('tagiditem');
valuesSelected.push(val);
});
let labelRecord = {};
for (let label in labels) {
labelRecord[label] = false;
}
console.log(labelRecord);
specification_wrap_action.add();
console.log(group);
let unFiler = null;
for (let i = 0; i < itemtagscombinationRes.length; i++) {
const currItem = itemtagscombinationRes[i];
const { tagids } = currItem;
let isTrue = true;
let labelFilter = labelRecord;
for (let i = 0; i < valuesSelected.length; i++) {
if (!tagids.includes(valuesSelected[i])) {
isTrue = false
unFiler = labelFilter;
break;
}
labelFilter[group[valuesSelected[i]]] = true;
}
if (isTrue) {
// console.log(itemtagscombinationRes[i], 'itemtagscombinationRes[i]');
const { quantity } = itemtagscombinationRes[i];
if (quantity >= $('#quantity').val() && quantity >= 1) {
currentComb = itemtagscombinationRes[i];
// $('.productname').html(itemtagscombinationRes[i].itemname)
// $('.price').html(itemtagscombinationRes[i].pricelist);
// location.hash = itemtagscombinationRes[i].itemname.trim();
// appendSpecs(itemtagscombinationRes[i].itemid)
// history.replaceState(null, null, `#itemid=${itemtagscombinationRes[i].itemid}#${itemtagscombinationRes[i].itemname.trim()}`);
// $('#skudetailitem').val(itemtagscombinationRes[i].sku)
// $('.des_productdes').html(itemtagscombinationRes[i].itemdescription);
updateDetailsByObj(itemtagscombinationRes[i]);
} else {
let name = itemtagscombinationRes[i].itemname.split('-')[0];
$('#addtocart').addClass('disabled');
let itemsName = name;
$('.borderselector').each(function (i, e) {
itemsName += ` ${$(e).html().trim()}`;
});
updateItemId(null);
let defaultImg = itemtagscombinationRes[i].itemimageurl ? imgServerNameBuild(itemtagscombinationRes[i].itemimageurl) : `./dist/assets/imgs/nophoto.png`;
// console.log(itemtagscombinationRes[i].itemimageurl, 'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
$('.productDetailsMain > img').attr('src', defaultImg);
specification_wrap_action.remove();
$('#skudetailitem').val(-1)
$('.productname').html(itemsName)
// history.replaceState(null, null, `#`);
$('.msgErrorDetailsItem').removeClass('d-none');
$('.des_productdes').html('');
$('.price').html('');
}
initAddToCart()
return;
}
}
// alert("j");
let name = itemtagscombinationRes[0].itemname.split('-')[0];
let itemsName = name;
$('.borderselector').each(function (i, e) {
itemsName += `- ${$(e).html().trim()}`;
})
specification_wrap_action.remove();
$('.productname').html(itemsName)
$('#skudetailitem').val(-1)
$('.price').html('');
$('#addtocart').addClass('disabled');
$('.msgErrorDetailsItem').removeClass('d-none');
initAddToCart()
}
function getAllCombination() {
debugger;
const currClickAttr = $(currentClick).html().trim();
const optionId = $(currentClick).data('tagiditem');
let curr = $(currentClick).parents('.groupingitems_search').data('parentidgroup');
$('.groupingitems_search').each(function (i, e) {
const id = $(e).data('parentidgroup');
if (id != curr) {
$(e).find('.optiontaganwi').addClass('disabled-option-item');
$(e).find('.borderselector').removeClass('borderselector');
}
});
let ansArr = [];
let index = 0;
let comb = null;
for(let i=0;i<itemtagscombinationRes.length;i++){
let currIds = itemtagscombinationRes[i].tagids;
if(currIds.includes(optionId)){
currIds = currIds.split('|');
for(let j=0;j<currIds.length;j++){
debugger;
if(index==0 &&optionId != currIds[j] ) {
$(`[data-tagiditem="${currIds[j]}"]`).addClass('borderselector')
comb = itemtagscombinationRes[i];
index++;
}
$(`[data-tagiditem="${currIds[j]}"]`).removeClass('disabled-option-item');
// $().parents('[data-tagid]').find()
}
}
}
// console.log(comb,'comb tag');
updateDetailsByObj(comb);
let currentItem = comb.tagids.split('|');
for(let i=0;i<currentItem.length;i++){
$(`[data-tagiditem="${currentItem[i]}"]`).removeClass('disabled-option-item').addClass('borderselector');
}
// history.replaceState(null, null, `#${comb.itemname}`);
// window.location.href = `#${comb.itemname}`
console.log(itemtagscombinationRes,'gobal');
return;
};
async function getProductDetails(id) {
debugger;
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/productattributelist/productid/${id}`, true);
if (resData.isError) {
loadingActions.removeLoader();
alert(resData.errorMsg.message);
return;
}
if(resData.response.result == '[]' || !resData.response.result){
$('.barbgnav').removeClass('d-none')
loadingActions.removeLoader();
toasterHelper("Something Went Wrong")
return;
}
let res = resData.response;
res = JSON.parse(res.result);
// console.log(res, 'productattributelist');
if (!res) {
loadingActions.removeLoader();
return;
};
let html = '';
for (let i = 0; i < res.length; i++) {
const currItem = res[i];
// parenttagid means under what label
// tag id means it know unquie id
const { parentattribute, parenttagid, tagid, attribute, productid } = currItem;
if (labels[parentattribute]) {
labels[parentattribute].items.push({
attribute,
tagid: tagid
});
} else {
labels[parentattribute] = {
id: parenttagid,
items: [{
attribute,
tagid: tagid
}]
};
if(parentattribute.toLowerCase() === 'colour'){
colorId = parenttagid;
}
html += getParentHTML(parentattribute, productid, parenttagid, i == 0);
}
}
$('#spec-container-details').html(html);
console.log(labels,'labels');
let childIds = [];
for (let item in labels) {
let { id, items } = labels[item];
// $(`[data-tagid=${id}]`)
let html = '';
for (let i = 0; i < items.length; i++) {
const { attribute, tagid } = items[i]
childIds.push(tagid);
group[attribute] = item;
console.log(attribute,colorId,"s");
html += getChildHTML(tagid, attribute, i == 0,id);
console.log(attribute,"attributeattributeattributeattribute");
}
debugger;
$(`[data-tagid="${id}"]`).html(html);
}
itemtagscombinationRes = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getitemwithoutbranch/productid/${id}`, true);
itemtagscombinationRes = JSON.parse(itemtagscombinationRes.response.result);
console.log(itemtagscombinationRes, "conductt");
let itemidSearch = window.location.hash.split('#')[2]?.split('=')[1];
if(!itemidSearch){
itemidSearch = itemtagscombinationRes[0].itemid
}
let valuesSelected = [];
$('.borderselector').each(function (i, el) {
let val = $(el).html();
valuesSelected.push(val.trim());
});
debugger;
// let searchParams = window.location.search.split("&");
// let skuId = window.location.hash.split('#')[2].split('=')[1];
// skuId = skuId.split('=')[1]
let isGo = true;
for (let i = 0; i < itemtagscombinationRes.length; i++) {
const currItem = itemtagscombinationRes[i];
const { tagnames, sku, itemid } = currItem;
isThereInLabel[tagnames] = itemtagscombinationRes[i];
let isTrue = true;
if (isGo) {
// for(let i=0;i<valuesSelected.length;i++){
// if(!tagnames.includes(valuesSelected[i])){
// isTrue = false
// }
// }
if (itemidSearch != itemid) {
isTrue = false
}
// if (i != 0) {
// isTrue = false
// }
if (isTrue) {
// console.log(itemtagscombinationRes[i], 'itemtagscombinationRes[i]');
currentComb = itemtagscombinationRes[i];
updateDetailsByObj(itemtagscombinationRes[i]);
isGo = false;
let { tagnames, tagids, pricelist } = itemtagscombinationRes[i];
tagids = tagids.split('|');
tagnames = tagnames.split('|');
$('.optiontaganwi').removeClass('borderselector');
for (let i = 0; i < tagids.length; i++) {
$(`[data-tagiditem="${tagids[i]}"]`).addClass('borderselector');
}
break;
// tagiditem
}
}
}
if (isGo && itemtagscombinationRes.length != 0) {
// console.log(itemtagscombinationRes[0]);
let { tagnames, tagids, pricelist } = itemtagscombinationRes[0];
tagids = tagids.split('|');
tagnames = tagnames.split('|');
$('.optiontaganwi').removeClass('borderselector');
currentComb = itemtagscombinationRes[0];
// updateItemId(itemtagscombinationRes[0].itemid);
for (let i = 0; i < tagids.length; i++) {
$(`[data-type="${tagids[i]}-${tagnames[i]}"]`).addClass('borderselector');
// $(`[data-type="${tagids[i]}-Eucalyptus Green"]`).removeClass('borderselector');
// $(`[data-type="${tagids[i]}-Desert Brown"]`).removeClass('borderselector');
// $(`[data-type="${tagids[i]}-Deep Sea Blue"]`).removeClass('borderselector');
}
// $('.price').html(pricelist);
// $('.des_productdes').html(itemtagscombinationRes[0].itemdescription);
// appendSpecs(itemtagscombinationRes[0].itemid);
updateDetailsByObj(itemtagscombinationRes[0]);
//console.log(childIds);
//
}
//getAllCombination()
// for(let i=0;i<itemtagscombinationRes.length;i++){
// const {tagnames} = itemtagscombinationRes[i];
// }
$('#spec-container-details').children().find('.specsmallcard').removeClass('specsmallcard');
//getting the first borderselector in first $('.groupingitems_search')[0]
let firstParentGroup = $('.groupingitems_search')[0];
debugger;
let optionId = $(firstParentGroup).find('.borderselector').data('tagiditem');
currentClick = $(firstParentGroup).find('.borderselector')
getandsetCombination();
addeventlisteners();
loadingActions.removeLoader();
return;
}
}
startDetails();
-650
View File
@@ -1,650 +0,0 @@
function startDetails() {
// http://127.0.0.1:5502/productdetails.html?productId=106633230000024
if (window.location.search.split('=')[0] == '') {
window.location.href = "/notfound.html";
return;
}
let productId = window.location.href.split('=')[1].split('&')[0].split('#')[0];
console.log(productId);
let itemtagscombinationRes = null;
let labels = {};
let isThereInLabel = {};
let currentComb = null;
let group = {};
let loadingActions = {
addLoader() {
$('.loadingCall').removeClass('d-none');
$('.mainContanierProduct').addClass('d-none');
},
removeLoader() {
$('.loadingCall').addClass('d-none');
$('.mainContanierProduct').removeClass('d-none');
}
}
let currentClick = null;
if (productId) {
loadingActions.addLoader();
updateProductId(productId);
getProductDetails(productId);
appendSpecs(productId)
} else {
window.location.href = "/notfound.html"
}
function updateProductId(val) {
$('#productidtag').val(val);
}
function updateItemId(val) {
$('#itemidtag').val(val);
}
let specification_wrap_action = {
remove() {
$('.specification-wrap').addClass('d-none');
},
add() {
$('.specification-wrap').removeClass('d-none');
}
}
let description_action = {
addVal(value) {
$('.description-wrap > p').html(value);
},
removeVal(value) {
$('.description-wrap > p').html('');
}
}
function getSpecsItemHTML({ name, des, itemid, id }) {
return `<div id="${id}" data-specitemid="${itemid}" class="">
<div class="row border-bottom">
<div class="col-sm-6 bg-gray-3 py-2">
${name}
</div>
<div class="col-sm-6 py-2">
${des}
</div>
</div>
</div>`;
return ` <tr id="${id}" data-specitemid="${itemid}">
<td style="width:200px">${name}</td>
<td class="">${des}</td>
</tr>`;
}
// function getSpecsItemHTML({name,des,itemid,id}){
// return ` <tr id="${id}" data-specitemid="${itemid}">
// <td style="width:200px">${name}</td>
// <td class="">${des}</td>
// </tr>`;
// }
async function appendSpecs(id) {
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemspecifications/itemid/${id}`, true);
if (resData.isError) {
$('.productdetailstabs').addClass('d-none');
$('.specContainerleft').html('')
$('.specContainerRight').html('')
return;
}
$('.productdetailstabs ').removeClass('d-none');
const res = resData.response;
console.log(JSON.parse(res.result));
const data = JSON.parse(res.result);
console.log(data);
let html = '';
let leftHtml = '';
let rightHtml = '';
if (data.length == 0) {
$('.productdetailstabs ').addClass('d-none');
$('.specContainerleft').html('')
$('.specContainerRight').html('')
return;
}
for (let i = 0; i < data.length; i++) {
const { specificationname, specificationitemid, itemid, description } = data[i];
if ((i + 1) % 2 == 0) {
rightHtml += getSpecsItemHTML({
name: specificationname, id: specificationitemid, itemid, des: description
})
} else {
leftHtml += getSpecsItemHTML({
name: specificationname, id: specificationitemid, itemid, des: description
});
}
}
$('.specContainerleft').html(leftHtml)
$('.specContainerRight').html(rightHtml)
}
function getParentHTML(name, productid, id, isMain) {
return `<div class="pb-2 $${name?.replace(" ", '')}-parent">
<h5 class="py-2 smallHeadingProductDetails">${name}</h5>
<div class="d-flex gap-2 flex-lg-row flex-wrap ${id}container" data-tagid="${id}">
</div>
</div>`;
}
function onClickHandler(e) {
$(e).parent().find('.borderselector').removeClass('borderselector');
$(e).addClass('borderselector')
}
function getChildHTML(tagid, name, isTrue) {
let item_color_1 = `#5e7975`;
let item_color_2 = `#624839`;
let item_color_3 = `#253746`;
if(name == "Eucalyptus Green"){
return `<p item_color=${item_color_1} data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="optiontaganwi_color specsmallcard optiontaganwi fs-7 cursor-pointer text-white rounded mb-0 me-1 py-2 px-3" ${item_color_1 ? `style="background-color:${item_color_1}"`:''}><span class="${isTrue ? 'border-bottom color' : 'color'}">${name}</span></p>`;
}else if(name == "Desert Brown"){
return `<p item_color=${item_color_2} data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="optiontaganwi_color specsmallcard optiontaganwi mb-0 fs-7 cursor-pointer me-1 rounded text-white py-2 px-3" ${item_color_2 ? `style="background-color:${item_color_2}"`:''}><span class="${isTrue ? 'border-bottom color' : 'color'}">${name}</span></p>`;
}else if(name == "Deep Sea Blue"){
return `<p item_color=${item_color_3} data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="optiontaganwi_color specsmallcard optiontaganwi mb-0 fs-7 text-white cursor-pointer rounded py-2 px-3 " ${item_color_3 ? `style="background-color:${item_color_3}"`:''}><span class="${isTrue ? 'border-bottom color' : 'color'}">${name}</span></p>`;
}
else{
return `
<div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue ? 'borderselector' : ''} card text-center small-font cursor-pointer p-3">
${name}
</div> `
}
}
function addeventlisteners() {
$('.optiontaganwi').each(function (i, el) {
$(el).click(function (e) {
$('#quantity').val(1);
debugger;
let ele_col = $(e.target).hasClass("color");
let ele_col1 = $(e.target).hasClass("optiontaganwi_color");
if(ele_col === true){
$(e.target).parent().find("span.color").removeClass('border-bottom');
$(e.target).parent().addClass("border_selector");
$(e.target).addClass("border-bottom");
$(e.target).parent().find("span.border-bottom").removeClass("border-bottom text-dark");
$(e.target).addClass("border_selector");
$(e.target).find("span.color").addClass("border-bottom text-dark");
$(e.target).parent().find('.borderselector').removeClass('borderselector');
// $(e.target).addClass('borderselector');
searchComb();
currentClick = e.target;
}else if(ele_col1 === true){
$(e.target).parent().find("span.text-dark").removeClass("text-dark border-bottom");
$(e.target).addClass("border_selector");
$(e.target).find("span.color").addClass("text-dark");
$(e.target).parent().find('.borderselector').removeClass('borderselector');
$(e.target).addClass('borderselector');
searchComb();
currentClick = e.target;
}else{
$(e.target).parent().find('.borderselector').removeClass('borderselector');
$(e.target).addClass('borderselector');
searchComb();
currentClick = e.target;
}
searchComb();
currentClick = e.target;
// getAllCombination();
})
});
// $('.optiontaganwi_color span.color').each(function (i, el) {
// $(el).click(function (e) {
// $('#quantity').val(1);
// $(e.target).parent().find("span.border-bottom").removeClass("border-bottom");
// $(e.target).addClass("border-bottom");
// searchComb();
// currentClick = e.target;
// // getAllCombination();
// })
// });
}
// function getChildHTML(tagid,name,isTrue){
// return `
// <div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue?'borderselector':''} card small-font cursor-pointer p-3">
// ${name}
// </div>
// `
// }
// function addeventlisteners(){
// $('.optiontaganwi').each(function (i,el){
// $(el).click(function (e){
// $('#quantity').val(1)
// $(e.target).parent().find('.borderselector').removeClass('borderselector');
// $(e.target).addClass('borderselector')
// searchComb();
// currentClick = e.target;
// // getAllCombination();
// })
// });
// }
function updateDetailsByObj(obj) {
$('.productname').html(obj.itemname)
$('.price').html(obj.pricelist?obj.pricelist:'coming soon');
appendSpecs(obj.itemid)
$('#skudetailitem').val(obj.sku)
$('.des_productdes').html(obj.itemdescription);
$('#addtocart').attr('data-qty', obj.quantity);
let defaultImg = obj.itemimageurl ? imgServerNameBuild(obj.itemimageurl) : `./dist/assets/imgs/nophoto.png`;
console.log(obj.itemimageurl, 'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
$('.productDetailsMain > img').attr('src', defaultImg);
updateItemId(obj.itemid);
if(!obj.pricelist){
$('.buynow').attr('disabled',true);
$('#addtocart').attr('disabled',true);
}else{
$('.buynow').attr('disabled',false);
$('#addtocart').attr('disabled',false);
}
}
function searchComb() {
let valuesSelected = [];
$('#addtocart').removeClass('disabled');
$('.msgErrorDetailsItem').addClass('d-none');
$('.borderselector,border_selector').each(function (i, el) {
console.log($(el).html())
let val = $(el).html();
valuesSelected.push(val.trim());
});
let labelRecord = {};
for (let label in labels) {
labelRecord[label] = false;
}
console.log(labelRecord);
specification_wrap_action.add();
console.log(group);
let unFiler = null;
for (let i = 0; i < itemtagscombinationRes.length; i++) {
const currItem = itemtagscombinationRes[i];
const { tagnames } = currItem;
let isTrue = true;
let labelFilter = labelRecord;
for (let i = 0; i < valuesSelected.length; i++) {
if (!tagnames.includes(valuesSelected[i])) {
isTrue = false
unFiler = labelFilter;
break;
}
labelFilter[group[valuesSelected[i]]] = true;
}
if (isTrue) {
console.log(itemtagscombinationRes[i], 'itemtagscombinationRes[i]');
const { quantity } = itemtagscombinationRes[i];
if (quantity >= $('#quantity').val() && quantity >= 1) {
currentComb = itemtagscombinationRes[i];
// $('.productname').html(itemtagscombinationRes[i].itemname)
// $('.price').html(itemtagscombinationRes[i].pricelist);
// location.hash = itemtagscombinationRes[i].itemname.trim();
// appendSpecs(itemtagscombinationRes[i].itemid)
history.replaceState(null, null, `#itemid=${itemtagscombinationRes[i].itemid}#${itemtagscombinationRes[i].itemname.trim()}`);
// $('#skudetailitem').val(itemtagscombinationRes[i].sku)
// $('.des_productdes').html(itemtagscombinationRes[i].itemdescription);
updateDetailsByObj(itemtagscombinationRes[i]);
} else {
let name = itemtagscombinationRes[i].itemname.split('-')[0];
$('#addtocart').addClass('disabled');
let itemsName = name;
$('.borderselector').each(function (i, e) {
itemsName += ` ${$(e).html().trim()}`;
});
updateItemId(null);
specification_wrap_action.remove();
$('#skudetailitem').val(-1)
$('.productname').html(itemsName)
history.replaceState(null, null, `#`);
$('.msgErrorDetailsItem').removeClass('d-none');
$('.des_productdes').html('');
$('.price').html('');
}
initAddToCart()
return;
}
}
let name = itemtagscombinationRes[0].itemname.split('-')[0];
let itemsName = name;
$('.borderselector').each(function (i, e) {
itemsName += `- ${$(e).html().trim()}`;
})
specification_wrap_action.remove();
$('.productname').html(itemsName)
$('#skudetailitem').val(-1)
$('.price').html('');
$('#addtocart').addClass('disabled');
$('.msgErrorDetailsItem').removeClass('d-none');
initAddToCart()
}
function getAllCombination() {
const currClickAttr = $(currentClick).html().trim();
let isThere = [];
for (let item in isThereInLabel) {
let { tagnames } = isThereInLabel[item];
if (tagnames.includes(currClickAttr)) {
isThere.push(isThereInLabel[item])
}
}
let selected = [];
$('.borderselector').each(function (i, e) {
selected.push($(e).html().trim())
});
// console.log(selected);
// console.log(isThere);
let ishashObj = {};
for (let i = 0; i < isThere.length; i++) {
let { tagnames, tagids } = isThere[i];
tagnames = tagnames.split('|');
tagids = tagids.split('|');
for (let j = 0; j < tagnames.length; j++) {
if (!ishashObj[tagnames[j]]) {
ishashObj[tagnames[j]] = tagids[j];
}
}
}
// console.log(ishashObj);
// for(let i=0;i<itemtagscombinationRes.length;i++){
// }
}
async function getProductDetails(id) {
// let res = await getStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/productattributelist/productid/${id}`);
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/productattributelist/productid/${id}`, true);
if (resData.isError) {
loadingActions.removeLoader();
alert(resData.errorMsg.message);
return;
}
let res = resData.response;
res = JSON.parse(res.result);
console.log(res, 'productattributelist');
if (!res) {
loadingActions.removeLoader();
return;
};
let html = '';
for (let i = 0; i < res.length; i++) {
const currItem = res[i];
// parenttagid means under what label
// tag id means it know unquie id
const { parentattribute, parenttagid, tagid, attribute, productid } = currItem;
if (labels[parentattribute]) {
labels[parentattribute].items.push({
attribute,
tagid: tagid
});
} else {
labels[parentattribute] = {
id: parenttagid,
items: [{
attribute,
tagid: tagid
}]
};
html += getParentHTML(parentattribute, productid, parenttagid, i == 0);
}
}
$('#spec-container-details').html(html);
// console.log(labels,'labels');
let childIds = [];
for (let item in labels) {
let { id, items } = labels[item];
// $(`[data-tagid=${id}]`)
let html = '';
for (let i = 0; i < items.length; i++) {
const { attribute, tagid } = items[i]
childIds.push(tagid);
group[attribute] = item;
html += getChildHTML(tagid, attribute, i == 0);
}
$(`[data-tagid="${id}"]`).html(html);
}
itemtagscombinationRes = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getitemwithoutbranch/productid/${id}`, true);
itemtagscombinationRes = JSON.parse(itemtagscombinationRes.response.result);
console.log(itemtagscombinationRes, "conductt");
let valuesSelected = [];
$('.borderselector').each(function (i, el) {
let val = $(el).html();
valuesSelected.push(val.trim());
});
let searchParams = window.location.search.split("&");
let skuId = window.location.hash.split('#')[1].split('=')[1];
// skuId = skuId.split('=')[1]
let isGo = true;
for (let i = 0; i < itemtagscombinationRes.length; i++) {
const currItem = itemtagscombinationRes[i];
const { tagnames, sku, itemid } = currItem;
isThereInLabel[tagnames] = itemtagscombinationRes[i];
let isTrue = true;
if (isGo) {
// for(let i=0;i<valuesSelected.length;i++){
// if(!tagnames.includes(valuesSelected[i])){
// isTrue = false
// }
// }
if (skuId != itemid) {
isTrue = false
}
if (isTrue) {
console.log(itemtagscombinationRes[i], 'itemtagscombinationRes[i]');
currentComb = itemtagscombinationRes[i];
// location.hash = itemtagscombinationRes[i].itemname.trim();
// $('.productname').html(itemtagscombinationRes[i].itemname);
// $('#skudetailitem').val(itemtagscombinationRes[i].sku)
// $('.price').html(itemtagscombinationRes[i].pricelist)
// appendSpecs(itemtagscombinationRes[i].itemid);
// $('.des_productdes').html(itemtagscombinationRes[i].itemdescription);
updateDetailsByObj(itemtagscombinationRes[i]);
isGo = false;
let { tagnames, tagids, pricelist } = itemtagscombinationRes[i];
tagids = tagids.split('|');
tagnames = tagnames.split('|');
$('.optiontaganwi').removeClass('borderselector');
for (let i = 0; i < tagids.length; i++) {
$(`[data-tagiditem="${tagids[i]}"]`).addClass('borderselector');
}
// tagiditem
}
}
}
if (isGo && itemtagscombinationRes.length != 0) {
console.log(itemtagscombinationRes[0]);
let { tagnames, tagids, pricelist } = itemtagscombinationRes[0];
tagids = tagids.split('|');
tagnames = tagnames.split('|');
$('.optiontaganwi').removeClass('borderselector');
currentComb = itemtagscombinationRes[0];
// updateItemId(itemtagscombinationRes[0].itemid);
for (let i = 0; i < tagids.length; i++) {
$(`[data-type="${tagids[i]}-${tagnames[i]}"]`).addClass('borderselector');
$(`[data-type="${tagids[i]}-Eucalyptus Green"]`).removeClass('borderselector');
$(`[data-type="${tagids[i]}-Desert Brown"]`).removeClass('borderselector');
$(`[data-type="${tagids[i]}-Deep Sea Blue"]`).removeClass('borderselector');
}
// $('.price').html(pricelist);
// $('.des_productdes').html(itemtagscombinationRes[0].itemdescription);
// appendSpecs(itemtagscombinationRes[0].itemid);
updateDetailsByObj(itemtagscombinationRes[0]);
//console.log(childIds);
//
}
//getAllCombination(valuesSelected)
// for(let i=0;i<itemtagscombinationRes.length;i++){
// const {tagnames} = itemtagscombinationRes[i];
// }
$('#spec-container-details').children().find('.specsmallcard').removeClass('specsmallcard');
addeventlisteners();
loadingActions.removeLoader();
return;
// let resTwo = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`);
//let html = '';
let attributesObj = {};
for (let i = 0; i < res.length; i++) {
const { parentattribute, tagid, productid } = res[i];
// let attributes = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/productattributelist/parenttagid/${tagid}`);
// attributesObj[tagid] = JSON.parse(attributes.data.result);
// console.log(attributes.data.result,tagid);
html += getParentHTML(parentattribute, productid, tagid, i == 0);
}
$('#spec-container-details').html(html);
// let attributes = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/productattributelist/parenttagid/${tagid}`);
return;
for (let attr in attributesObj) {
const arr = attributesObj[attr];
let html = '';
for (let i = 0; i < arr.length; i++) {
const { attribute, tagid } = arr[i];
html += getChildHTML(tagid, attribute, i == 0);
}
$(`[data-tagid="${attr}"]`).html(html);
}
let defaultValues = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/sellableitemlist/productid/${id}`);
defaultValues = JSON.parse(defaultValues.data.result);
let { itemname, price } = defaultValues[0];
$('.productname').html(itemname);
$('.price').html(price)
$('#spec-container-details').children().slice(1).find('.specsmallcard').removeClass('specsmallcard');
// getQuantityById(id)
}
}
startDetails();