1"use strict"; 2 3function bindSections(PageName) { 4 hideViews(); 5 if (SectionCount > 0) { 6 $.ajax({ 7 url: '/Account/getSections', 8 type: 'POST', 9 data: { UserID: UserID, VendorID: VendorID, Url: Url, PageName: PageName, CountryCode: VisitorCountry }, 10 success: function (returnData) { 11 if (returnData.Result == "OK") { 12 Sections = JSON.parse(returnData.dataSection); 13 SectionGallery = JSON.parse(returnData.dataGallery); 14 var SectionTemplate = JSON.parse(returnData.dataTemplate); 15 var SectionList = JSON.parse(returnData.dataSectionList); 16 if (ItemID !== -1) window.history.replaceState({}, document.title, HomeURL); 17 ItemID = -1; 18 ViewPage = ""; 19 20 var tblSectionView = $("#tblSectionView"); tblSectionView.show(); tblSectionView.empty(); 21 22 var IsFirstBannerCrousel = false; 23 for (var i = 0; i < SectionList.length; i++) { 24 var idr = SectionList[i].ID; 25 var renderFromCache = SectionList[i].RenderFromCache; 26 if (renderFromCache == 0) { 27 var Sec = Sections.filter(item => item.ThemeID === idr); 28 if (Sec.length > 0) { 29 if (Sec.filter(item => item.ThemeType === 2).length > 0 || Sec.filter(item => item.ThemeType === 34).length > 0 || Sec.filter(item => item.ThemeType === 35).length > 0 || Sec.filter(item => item.ThemeType === 38).length > 0 || Sec.filter(item => item.ThemeType === 61).length > 0 || Sec.filter(item => item.ThemeType === 62).length > 0 || Sec.filter(item => item.ThemeType === 67).length > 0 || Sec.filter(item => item.ThemeType === 131).length > 0 || Sec.filter(item => item.ThemeType === 373).length > 0 || Sec.filter(item => item.ThemeType === 375).length > 0) {//List Done 30 31 var List = Sec.filter(item => item.ThemeType === 2 || item.ThemeType === 34 || item.ThemeType === 35 || item.ThemeType === 38 || item.ThemeType === 61 || item.ThemeType === 62 || item.ThemeType === 67 || item.ThemeType === 131 || item.ThemeType === 373 || item.ThemeType === 375); 32 if (i == 1 && IsFirstBannerCrousel) { $(".banner .owl-dots").css('bottom', '100px'); } 33 tblSectionView.append('<div id="D' + idr + '" class="kt-container' + (List[0].IsFullWidth ? '--fluid px-4 w-100' : '') + '"><div class="kt-heading kt-heading--md w-100 head-' + List[0].TitlePosition + ' ' + (List[0].ThemeTitle === '' ? 'no-after kt-hidden' : '') + '">' + List[0].ThemeTitle + '</div><div id="List_' + i + '" class="listSlider newcat row"></div></div>'); 34 var h = 0; 35 var Cats = []; 36 for (var j = 0; j < List.length; j++) { 37 38 var full = List[j]; 39 var hasVariation = full.ParentProductID !== -1; 40 var btnText = hasVariation ? Store_Open : Store_Add; 41 if (full.AddToCartButtonText !== "") btnText = full.AddToCartButtonText; 42 43 var gallery = SectionGallery.filter(element => element.ProductID == full.ID); 44 45 var DisAmt = full.MRP - full.Price1; 46 var Discount = Number(full.MRP) == 0 ? 0 : (DisAmt / full.MRP * 100); 47 48 49 var GUID = createGuid(); 50 var MultiImageIcon = ""; 51 var IsVideo = false; 52 for (var a = 0; a < gallery.length; a++) { 53 var item = gallery[a]; 54 if (!IsVideo) { if (item.OrdPos === 2) IsVideo = true; else IsVideo = false; } 55 } 56 if (IsVideo && gallery.length > 1) MultiImageIcon = '<div class="iv-icon"></div>'; 57 else if (IsVideo) MultiImageIcon = '<div class="v-icon"></div>'; 58 else if (gallery.length > 1) MultiImageIcon = '<div class="i-icon"></div>'; 59 60 var DiscountHTMLText = ""; 61 if (Discount > 0) { 62 if (DiscountType === "Percent") DiscountHTMLText = parseInt(Discount) + '% Off'; 63 else if (DiscountType === "Amount") DiscountHTMLText = full.CurrencyCode + ' ' + DisAmt.toFixed(DecimalFormat).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + ' Off'; 64 else if (DiscountType === "Save Percent") DiscountHTMLText = 'Save ' + parseInt(Discount) + '%'; 65 else if (DiscountType === "Save Amount") DiscountHTMLText = 'Save ' + full.CurrencyCode + ' ' + DisAmt.toFixed(DecimalFormat).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"); 66 } 67 var OutOfStockCondition = (IsShowOutofStock && full["Avl Qty"] < 1 && !hasVariation); 68 //if (OutOfStockCondition) { var temp = IDandQtys.filter((item) => item.ID !== full.ID); IDandQtys = temp; } 69 var URL = HomeURL + 'item/' + full.ID; 70 if (full.Permalink !== '' && full.Permalink !== "undefined") URL = HomeURL + 'product/' + encodeURIComponent(full.Permalink).replace(/%26/g, '--'); 71 var MetaHTML = '<div class="mb-0" itemscope itemtype="http://schema.org/Product">\ 72 <meta itemprop="name" content="' + full.SEOTitle + '">\ 73 <meta itemprop="description" content="' + full.SEODescription + '">\ 74 <meta itemprop="productID" content="' + full.ID + '">\ 75 <meta itemprop="url" content="'+ URL + '">\ 76 <meta itemprop="image" content="' + full.PhotoIMG + '">\ 77 <meta itemprop="category" content="' + full.GoogleCategory + '">\ 78 <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">\ 79 <link itemprop="availability" href="http://schema.org/InStock">\ 80 <link itemprop="itemCondition" href="http://schema.org/NewCondition">\ 81 <meta itemprop="price" content="'+ full.Price1 + '">\ 82 <meta itemprop="priceCurrency" content="'+ full.CurrencyCodeFB + '">\ 83 </div>\ 84 </div>'; 85 86 var OnlyPhotoGallery = gallery.filter(x => x.OrdPos === 3); 87 var Photo2 = full.PhotoIMG; 88 if (OnlyPhotoGallery.length >= 1) Photo2 = OnlyPhotoGallery[0].PhotoIMG; 89 90 var strBadge = ''; 91 var badges = full.Val01.split('|'); 92 for (var z = 0; z < badges.length; z++) { 93 if (badges[z] !== "")
93strBadge += '<p class="info-block info-Vegan mx-1 d-inline-block bg-green black px-3 py-1 tt-u ' + badges[z] + '">' + badges[z] + '</p>'; 94 } 95 if (Sec.filter(item => item.ThemeType === 373).length > 0) { 96 if (Cats.indexOf(full.ProductCategory) === -1) 97 Cats.push(full.ProductCategory); 98 } 99 if (Sec.filter(item => item.ThemeType === 375).length > 0) { 100 if (Cats.indexOf(full.CatalogName) === -1) 101 Cats.push(full.CatalogName); 102 } 103 104 var wishClass = 'far'; 105 if (Wishlist.map(function (e) { return e.ID; }).indexOf(full.ID) > -1) wishClass = 'fas text-danger'; 106 var configItemHTML = configItemHTMLMain; 107 configItemHTML = configItemHTML.replace(/__GUID__/g, GUID) 108 .replace(/__COLS__/g, ("item " + (full.IsFullWidth ? "col-md-2" : "col-md-3") + " " + (full.OpenTarget === "Crousel" ? 'mb-0' : 'mb-5') + " " + (Sec.filter(item => item.ThemeType === 373).length > 0 ? full.ProductCategory.replace(/ /g, '').replace(/>/g, '-') : '') + " " + (Sec.filter(item => item.ThemeType === 375).length > 0 ? full.CatalogName.replace(/ /g, '').replace(/>/g, '-') : ''))) 109 .replace(/__PRODUCTID__/g, full.ID) 110 .replace(/__PRODUCTCATEGORY__/g, full.ProductCategory) 111 .replace(/__META__/g, MetaHTML) 112 .replace(/__PERMALINK__/g, full.Permalink) 113 .replace(/__OPENINNEW__/g, "false") //TODO: Recheck 114 .replace(/__MULTIIMAGEICON__/g, MultiImageIcon) 115 .replace(/__PHOTOIMG__/g, full.PhotoIMG) 116 .replace(/__PHOTOIMGHOVER__/g, Photo2) 117 .replace(/__OBJECTFIT__/g, ImageView.toLowerCase()) 118 .replace(/__PRODUCTNAME__/g, full.Name) 119 .replace(/__PRODUCTCODE__/g, full.ProductCode) 120 .replace(/__BORDERCOLOR__/g, BorderColor) 121 .replace(/__ADDTEXT__/g, btnText) 122 .replace(/__COLOR1__/g, CatalogBackgroundColor) 123 .replace(/__COLOR2__/g, CatalogBackgroundColor2) 124 .replace(/__HIDEPRICE__/g, IsHidePrice ? "kt-hidden" : "") 125 .replace(/__DISCOUNTDISPLAY__/g, Discount > 0 ? "" : "kt-hidden")//Always Hidden 126 .replace(/__PRICE__/g, full.Price) 127 .replace(/__MRP__/g, full.MRPDisplay) 128 .replace(/__DISCOUNT__/g, DiscountHTMLText) 129 .replace(/__HIDEDISCOUNT__/g, (DiscountHTMLText === "" ? "d-none" : "")) 130 .replace(/__OUTOFSTOCKTEXT__/g, OutOfStockCondition ? OutOfStockText : "") 131 .replace(/__OUTOFSTOCKDISPLAY__/g, OutOfStockCondition ? "" : "kt-hidden") 132 .replace(/__ADDBUTTONDISPLAY__/g, OutOfStockCondition ? "kt-hidden" : "") 133 .replace(/__CLASSLTD__/g, full.IsLimited ? "item-limited" : "") 134 .replace(/__BADGE__/g, strBadge) 135 .replace(/__COL4DIVSTART__/g, ColumnCount === 4 ? "<div style='margin-left:-10px'>" : "") 136 .replace(/__FASORFAR__/g, wishClass) 137 .replace(/__RR__/g, full.RatingReview) 138 .replace(/__COL4DIVEND__/g, ColumnCount === 4 ? "</div>" : ""); 139 140 141 $("#List_" + i).append(configItemHTML); 142 143 if (full.RatingReview === 0) $(".rr_" + full.ID).hide(); 144 if (StandardWidth === 0 || StandardHeight === 0) 145 $("#d-" + GUID).css('height', $("#d-" + GUID).width() + 'px'); 146 else { 147 var height = ($("#d-" + GUID).width() * StandardHeight) / StandardWidth; 148 $("#d-" + GUID).css('height', height - 10 + 'px'); 149 } 150 151 var w = $("#d-" + GUID).width(); h = $("#d-" + GUID).height(); 152 $("#d-" + GUID + " a img").attr({ onerror: 'this.src="https://dummyimage.com/' + parseInt(w) + 'x' + parseInt(h) + '/f5f5f5/808080?text=Product%20Image"' }); 153 if (full.ImagesWeb === '') $("#d-" + GUID + " a img").attr('data-src', 'https://dummyimage.com/' + parseInt(w) + 'x' + parseInt(h) + '/f5f5f5/808080?text=Product%20Image').removeClass('lazyloaded').addClass('lazyload'); 154 155 $("#d-" + GUID).data('data', gallery); 156 $("#d-" + GUID).data('full', full); 157 $("#btnAdd_" + GUID).data('elem', 'btnAdd_Qty_' + GUID); 158 159 $("#btnAdd_" + GUID).data('Item', full); 160 161 var AvlQty = full["Avl Qty"]; 162 if (!OutOfStockCondition){ 163 164 pushUniqueID(full.ID, GUID, full.MinimumOrderQty, full.MaximumOrderQty, full.MinimumIncreaseQty, AvlQty); 165 166 //if (IDandQtys.map(function (e) { return e.ID; }).indexOf(full.ID) > -1) { 167 // $('#btnAdd_Qty_' + GUID).val(IDandQtys.filter((item) => item.ID === full.ID)[0].Qty); 168 // $('#btnAdd_Qty_' + GUID).show(); 169 // $('#btnAdd_Qty_' + GUID).TouchSpin({ buttondown_class: "btn btn-danger", buttonup_class: "btn btn-success", min: (full.MinimumOrderQty - 1), max: (IsShowOutofStock ? GetLessValue(AvlQty, full.MaximumOrderQty) : full.MaximumOrderQty), step: full.MinimumIncreaseQty, mousewheel: true, stepintervaldelay: 86400000 }); 170 // $('#btnAdd_' + GUID).hide(); 171 //} 172 //else { 173 // $('#btnAdd_Qty_' + GUID).trigger('touchspin.destroy'); 174 // $('#btnAdd_Qty_' + GUID).val(full.MinimumOrderQty - 1); 175 // $('#btnAdd_' + GUID).show(); 176 // $('#btnAdd_Qty_' + GUID).hide(); 177 //} 178 179 180 $('#btnAdd_' + GUID).click(function () { 181 var addQty = $(this).next('input'); 182 var item = addQty.data('Item'); 183 var hasVariation = item.ParentProductID !== -1; 184 if (hasVariation) $(".gal_" + item.ID).click(); 185 else if (item.IsBox) {
186 $("#BoxModal").data('item', item); 187 openBoxDetail(addQty); 188 } 189 else { 190 $('.qty-' + item.ID).val(item.MinimumOrderQty); 191 $('.qty-' + item.ID).show(); 192 $('.qty-' + item.ID).TouchSpin({ buttondown_class: "btn btn-danger", buttonup_class: "btn btn-success", min: (item.MinimumOrderQty - 1), max: (IsShowOutofStock ? GetLessValue(item["Avl Qty"], item.MaximumOrderQty) : item.MaximumOrderQty), step: item.MinimumIncreaseQty, mousewheel: true, stepintervaldelay: 86400000 }); 193 $('.add-' + item.ID).hide(); 194 QtyChange(addQty); 195 } 196 }); 197 $('#btnAdd_Qty_' + GUID).data('Item', full); 198 } 199 200 } 201 if (Sec.filter(item => item.ThemeType === 2).length > 0 || Sec.filter(item => item.ThemeType === 38).length > 0 || Sec.filter(item => item.ThemeType === 61).length > 0 || Sec.filter(item => item.ThemeType === 62).length > 0 || Sec.filter(item => item.ThemeType === 67).length > 0 || Sec.filter(item => item.ThemeType === 131).length > 0 || Sec.filter(item => item.ThemeType === 373).length > 0 || Sec.filter(item => item.ThemeType === 375).length > 0) { 202 if (List[0].OpenTarget === "Crousel") { 203 $("#List_" + i).addClass('owl-carousel'); 204 $('#List_' + i).owlCarousel({ 205 margin: 10, 206 loop: false, 207 autoplay: ID === 23881 ? true : false, 208 dots: false, 209 autoHeight: false, 210 smartSpeed: 1200, 211 nav: true, 212 navText: ["<span class='la la-arrow-left'><span/>", "<span class='la la-arrow-right'><span/>"], 213 animateOut: 'fadeOut', 214 animateIn: 'fadeIn', 215 responsive: { 216 0: { 217 items: 1 218 }, 219 480: { 220 items: 2 221 }, 222 680: { 223 items: List[0].IsFullWidth ? 6 : 4 224 }, 225 1000: { 226 items: List[0].IsFullWidth ? 6 : 4 227 } 228 } 229 }); 230 $("#List_" + i + " .owl-prev").attr('aria-label', 'Prev'); 231 $("#List_" + i + " .owl-next").attr('aria-label', 'Next'); 232 $("#List_" + i + " .item." + (List[0].IsFullWidth ? "col-md-2" : "col-md-3")).css({ 'flex': '0 0 0 100%', 'max-width': '100%' }); 233 } 234 if (Sec.filter(item => item.ThemeType === 373).length > 0 || Sec.filter(item => item.ThemeType === 375).length > 0) { 235 var tabHtml = '<ul class="nav nav-tabs tabs-new-p">'; 236 for (var x = 0; x < Cats.length; x++) { 237 tabHtml += '<li><a ' + (x == 0 ? "class='active'" : "") + ' href="javascript:void(0);" onclick="showCatProducts(' + idr + ',this,\'' + List[0].OpenTarget + '\');" data-cat="' + Cats[x].replace(/ /g, '').replace(/>/g,'-') + '">' + Cats[x] + '</a></li>'; 238 239 } 240 tabHtml += '</ul>'; 241 $("#List_" + i).before(tabHtml); 242 showCatProducts(idr, $("#D" + idr + " .tabs-new-p a.active"), List[0].OpenTarget); 243 } 244 } 245 else { 246 if (Sec.filter(item => item.ThemeType === 34).length > 0) { 247 $("#List_" + i).append('<div class="' + (List[0].IsFullWidth ? "col-md-2" : "col-md-3") + '"><div class="border-config" style="background:' + CatalogBackgroun
247dColor + ';text-align: center;display: flex;width: 100%;padding: 0.9375rem;min-height: ' + h + 'px;">' + 248 '<div style="position: relative; z-index: 9; align-self: center; width: 100%;"> <span><a href="' + List[0].CatalogURL + '" style="font-size:14px; color:#fff; margin-top:5px; display:block;">View all</a></span>' + 249 '<span style="font-size:18px; color:#fff; margin-top:5px; display:block;">' + List[0].CatalogName + '</span></div></div></div>'); 250 } 251 else { 252 $("#List_" + i).prepend('<div class="' + (List[0].IsFullWidth ? "col-md-2" : "col-md-3") + '"><div style="text-align: left; display: flex; width: 100%; padding: 0.9375rem;min-height: 100%;"><div style="position: relative; z-index: 9; align-self: center; width: 100%; text-align:center;">' + 253 '<span style="font-size:30px; color:#333; margin-top:5px; display:block;">' + List[0].CatalogName + '</span><span><a href="' + List[0].CatalogURL + '" style="font-size:16px; color:#ff0649; margin-top:5px; display:block;">View all</a> </span></div></div></div>'); 254 } 255 } 256 } 257 } 258 } 259 else { 260 261 var Cached = SectionTemplate.filter(i => i.ID == idr)[0]; 262 if (Cached !== undefined) { 263 if (Cached.IncludeCSS !== "") { 264 $(decodeURIComponent(Cached.IncludeCSS)).appendTo('head'); 265 } 266 if (Cached.IncludeJS !== "") { 267 $(decodeURIComponent(Cached.IncludeJS)).appendTo('body'); 268 } 269 tblSectionView.append(decodeURIComponentSafe(Cached.HtmlWeb)); 270 if (Cached.ScriptWeb !== "") { 271 var newdiv = document.createElement('div'); 272 var script = document.createElement('script'); 273 script.innerHTML = decodeURIComponentSafe(Cached.ScriptWeb); 274 newdiv.appendChild(script); 275 document.getElementById('tblSectionView').appendChild(newdiv); 276 } 277 } 278 279 280 } 281 } 282 283 if (PageParam != "") { 284 $('.' + PageParam).hide(); 285 var htmlIndx = PageLink.split('|').indexOf(PageParam); 286 var Inp1 = $('.' + PageParam).find('.Inp1').text(); 287 var Inp2 = $('.' + PageParam).find('.Inp2').text(); 288 var strNewsHtml = PageHTML.split('|')[htmlIndx]; 289 var NewsDetail = `<div class="kt-container" style="margin-top: 190px;"> 290 <div class="row justify-content-center align-items-center"> 291 <div class="col-12 col-lg-9 "> 292 <div class="entry-header"> 293 <h1 class="display-3 mt-5 pt-5 pt-lg-0 mt-lg-0">`+ Inp1 + `</h1> 294 <p class="entry-meta h4 pt-3 pb-5 f-900 tt-u">`+ Inp2 + `</p> 295 </div> 296 <div class="entry-content f-500 mb-5 pb-5">`+ strNewsHtml + `</div> 297 </div> 298 </div> 299 </div>`; 300 $("#tblSectionView #D84564").remove(); 301 $("#tblSectionView").prepend(NewsDetail); 302 } 303 304 //Format Mobile 305 $(".format-mobile").text(function (i, text) { 306 if (text.length == 13) { 307 text = text.replace(/(\d{2})(\d{3})(\d{3})(\d{4})/, "$1 $2 $3 $4"); 308 return text; 309 } else if (text.length == 12) { 310 text = text.replace(/(\d{1})(\d{3})(\d{3})(\d{4})/, "$1-$2-$3-$4"); 311 return text; 312 } 313 }); 314 getCart(false); 315 //setStorageWithExpiry(cookieName + "-products", JSON.stringify(IDandQtys), 86400000 * 30); 316 //setAddedProducts(); 317 if (IsBindHeader === false) { 318 bindFooter(); 319 IsBindHeader = true; 320 } 321 } 322 else alert(Global_Oops + ", Error: getSections"); 323 }, 324 error: function () { alert(Global_Oops + ", Error: getSections"); } 325 }); 326 } 327 else bindFooter(); 328} 329 330function SubscribeNews(id) { 331 var Email = $("#NewsEmail_" + id).val(); 332 var Check = $("#NewsCheck_" + id).is(':checked'); 333 $.ajax({
334 url: '/Account/EmailSubscription', 335 type: 'POST', 336 data: { VendorID: VendorID, StoreCatalogID: ID, LeadID: LeadID, Email: Email, IsActive: Check }, 337 success: function (returnData) { 338 if (returnData.Result == "OK") { 339 alert(returnData.Message); 340 $("#NewsEmail_" + id).val(''); 341 $("#NewsCheck_" + id).prop('checked', false); 342 if (FreshMarketDomainName !== "") { 343 fwcrm.identify(Email); 344 fwcrm.trackCustomEvent("Newsletter Subscription", { "Email Id": Email }); 345 } 346 } 347 else alert(Global_Oops + ", Error: SubscribeNews"); 348 }, 349 error: function () { alert(Global_Oops + ", Error: SubscribeNews"); } 350 }); 351}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.