/* EQS_QS_SORT_V15 | V15 (Dec 3): Desks open with the COEDBLFLOS102 series, then the other COE desks; Best Seller/Value picks start after the 102 block; transaction tops follow the reception desk shells; Tables open with the COEOS conference tables; Boards open with their Best Sellers, then Best Values; Educational shows the student desks with book boxes together near the top; Room Dividers does the same with the Flash mobile whiteboards. EQS_QS_SORT_V14 | V14 (Dec 3): tags now drawn by EQS_QS_BADGES (no outlines); this file still spreads the tagged items through each category. EQS_QS_SORT_V13 | V13 (Dec 3): Best Seller / Best Value badges scattered through each category (Seating: each type opens with its highlights; the Closeout tag gives way to the badge); Seating keeps each type together (Task, then Executive, ...), each type fastest delivery first; back-to-top button. EQS_QS_SORT_V12 | V12 (Dec 3): on Desk & Table Accessories, all Next Day Delivery items go last. EQS_QS_SORT_V11 | V11 (Dec 2): Desk & Table Accessories shows monitor arms, then keyboard trays, then power first. EQS_QS_SORT_V10 | V10 (Dec 2): "Next Day Delivery" items sort first under Fastest delivery. EQS_QS_SORT_V9 | V9 (Nov 30): lounge sets and Aiden guest seating stay together on every category page. EQS_QS_SORT_V8 | V8 (Nov 29): Add to cart works on every card. Cards brought in from later pages (fastest-delivery sort, Type filter) are now priced by EvoX and their buttons turned on. EQS_QS_SORT_V7 | V7 (Nov 29): on Desks and Seating, OfficeSource (COE) items show first (ahead of Lorell), then the rest fastest delivery first. EQS_QS_SORT_V6 | V6: reads the item list named in the footer (window.EQS_QS_INDEX_URL). EQS_QS_SORT_V5 | V5 (Nov 28): loads the rest of the category 8 pages at a time, starting at once, so the fastest items come up in a few seconds. EQS_QS_SORT_V4 | Emerald Quick Ship: "Fastest delivery" sorts the WHOLE category, not just each page of 24. Nov 28, 2026. - Runs on the Quick Ship category pages (Desks through Room Dividers, Closeouts) when the shopper hasn't picked another sort (no ?sort= or ?sort=relevance). The default option is shown as "Fastest delivery". - The first 24 cards are ordered at once. The rest of the category then loads quietly in the background, 8 pages at a time, and the whole list is shown fastest first: 1–2 day, 3–5, 5–7, 7–10, 10–14 day, biggest savings first within each speed. More cards are added as you scroll (24 at a time). - Delivery speed comes from the Quick Ship item list (EQS_QS_INDEX_V15) or the card's delivery line; savings from the item's list price and the card's price. - When a Type box is ticked (Quick Ship Type filter), the filter already shows every match; those cards are sorted the same way. - The loaded pages are kept for 15 minutes in this browser tab, so going back to a category is instant and the site isn't asked again. */ (function () { 'use strict'; var VERSION = 'EQS_QS_SORT_V9_2026_11_30'; if (window.EQS_QS_SORT) return; // V8: EvoX only prices (and turns on Add to cart for) the cards that came with the page. Cards brought in // from later pages (this sort, the Type filter) are priced here: any card in the grid whose button is still // off is handed to EvoX's own live-pricing (fetchLiveData), which sets the price and turns the button on. (function primeCards() { if (window.EQS_PRIME_CARDS) return; window.EQS_PRIME_CARDS = 1; var t = 0, tries = {}; function run() { t = 0; if (typeof window.fetchLiveData !== 'function') return; var need = [].slice.call(document.querySelectorAll('.griditems .tileparent.product[data-sku]')).filter(function (el) { var b = el.querySelector('button.btn-add-to-cart'); if (!b || !b.disabled) return false; var s = el.getAttribute('data-sku'); tries[s] = (tries[s] || 0) + 1; if (tries[s] > 3) return false; el.removeAttribute('data-scraped'); el.removeAttribute('data-bid'); return true; }); if (need.length) { try { window.fetchLiveData(); } catch (e) {} } } function later() { if (!t) t = setTimeout(run, 400); } function start() { if (!document.body) { setTimeout(start, 100); return; } new MutationObserver(function (ms) { for (var i = 0; i < ms.length; i++) { if (ms[i].addedNodes.length && ms[i].target.closest && ms[i].target.closest('.griditems')) { later(); return; } } }).observe(document.body, { childList: true, subtree: true }); later(); setTimeout(later, 4000); } start(); })(); var IDS = ['1366566', '1366567', '1366568', '1366569', '1366570', '1366571', '1366572', '1366573', '1366574', '1367676', '1367679']; var INDEX_URL = window.EQS_QS_INDEX_URL || 'https://us.evocdn.io/dealer/1516/content/media/EQS_QS_INDEX_V16.js'; var PER = 24, FIRST = 48, CONCURRENT = 8; function onPage() { var b = document.body; if (!b) return false; return IDS.some(function (id) { return b.classList.contains('ex-categoryid-' + id); }); } function userSorted() { var s = new URLSearchParams(location.search).get('sort'); return !!s && s !== 'relevance'; } function typeFiltered() { var u = new URLSearchParams(location.search); return ['qt', 'qs', 'qf', 'z'].some(function (k) { return u.has(k); }) || document.documentElement.classList.contains('eqt-filtering'); } // ---------- delivery and savings ---------- var IDXM = null; function idx() { var X = window.EQS_QS_INDEX; if (!X || !X.items) return null; if (!IDXM) { IDXM = {}; X.items.forEach(function (r) { IDXM[String(r[0]).toUpperCase()] = r; }); } return X; } function needIndex() { if (idx() || document.querySelector('script[src*="EQS_QS_INDEX_V"]')) return; var s = document.createElement('script'); s.src = INDEX_URL; s.async = true; document.head.appendChild(s); } function leadTxt(t) { if (/next[\s-]*day/i.test(t)) return 0.5; // V10: Next Day Delivery sorts first var m = /(\d+)\s*[–-]\s*\d+\s*Day/i.exec(t) || /(\d+)\s*Day/i.exec(t); return m ? +m[1] : 99; } function skuOf(t) { return (t.getAttribute('data-sku') || '').toUpperCase(); } function lead(t) { var X = idx(), r = X && IDXM[skuOf(t)]; if (r && X.dels[r[5]]) return leadTxt(X.dels[r[5]]); return leadTxt(t.textContent || ''); } function save(t) { var m = /(\d+)%\s*off list/i.exec(t.textContent || ''); if (m) return +m[1]; var X = idx(), r = X && IDXM[skuOf(t)], p = parseFloat(t.getAttribute('data-native-price')) || 0; return r && r[6] > 0 && p > 0 ? Math.round(100 * (1 - p / r[6])) : 0; } function cmp(a, b) { return a.lead - b.lead || b.save - a.save || a.i - b.i; } // Sets that always sit together (lounge sets, Aiden guest seating by finish): the first member reached pulls the rest in behind it var EQS_CL = [["COEOSGS4012FCGBK","COEOSGS4013FCGBK","COEOSGS4017FCGBK","COEOSGS4012PCGBK","COEOSGS4013PCGBK","COEOSGS4017PCGBK","COEOSGS4012PCGSM","COEOSGS4013PCGSM","COEOSGS4017PCGSM","COEOSGS4007CG"],["COEOSGS4012FMOBK","COEOSGS4013FMOBK","COEOSGS4017FMOBK","COEOSGS4012PMOBK","COEOSGS4013PMOBK","COEOSGS4017PMOBK","COEOSGS4012PMOSM","COEOSGS4013PMOSM","COEOSGS4017PMOSM","COEOSGS4007MO"],["COEOSGS4012FMWBK","COEOSGS4013FMWBK","COEOSGS4017FMWBK","COEOSGS4012PMWBK","COEOSGS4013PMWBK","COEOSGS4017PMWBK","COEOSGS4012PMWSM","COEOSGS4013PMWSM","COEOSGS4017PMWSM","COEOSGS4007MW"],["COEOSGS4012FNABK","COEOSGS4013FNABK","COEOSGS4017FNABK","COEOSGS4012PNABK","COEOSGS4013PNABK","COEOSGS4017PNABK","COEOSGS4012PNASM","COEOSGS4013PNASM","COEOSGS4017PNASM","COEOSGS4007NA"],["COEOSRL3018FBK","COEOSRL3020FBK"],["COEOSRL3018FGT","COEOSRL3020FGT"],["COEOSRL3018FTP","COEOSRL3020FTP"],["OTG13051","OTG13052","OTG13053"],["COEDEFINECLUBGRY","COEDEFINELSEATGRY","COEDEFINESOFAGRY"],["COEHARPERBLK","COEHARPERBLKLS","COEHARPERBLKSOFA"],["COEHARPERSMK","COEHARPERSMKLS","COEHARPERSMKSOFA"],["LLR68952","LLR68953","LLR68951","LLR68950"],["COEMADISONCLUBBK","COEMADISONLSEATBK","COEMADISONSOFABK"],["COEMADISONCLUBGRY","COEMADISONLSEATGRY","COEMADISONSOFAGRY"],["HONVP3LCHRBLK","HONVP3LLOVEBLK","HONVP3LSOFABLK"],["N9N67311ARLOGRY","N9N67331ARLOGRY"],["N9N68211ENZOGRY","N9N68231ENZOGRY"]]; var EQS_CLI = {}; EQS_CL.forEach(function (g, gi) { g.forEach(function (s, k) { EQS_CLI[s] = [gi, k]; }); }); function clusterize(arr, skuF) { var byG = {}, out = [], done = {}; arr.forEach(function (x) { var c = EQS_CLI[String(skuF(x) || '').toUpperCase()]; if (c) (byG[c[0]] = byG[c[0]] || []).push(x); }); Object.keys(byG).forEach(function (g) { byG[g].sort(function (a, b) { return EQS_CLI[String(skuF(a)).toUpperCase()][1] - EQS_CLI[String(skuF(b)).toUpperCase()][1]; }); }); arr.forEach(function (x) { var c = EQS_CLI[String(skuF(x) || '').toUpperCase()]; if (!c) { out.push(x); return; } if (done[c[0]]) return; done[c[0]] = 1; byG[c[0]].forEach(function (y) { out.push(y); }); }); return out; } // V7: on Desks and Seating, OfficeSource (COE) items come first, then everything else fastest first. var COE_FIRST = /\/category\/(1366566|1366567)-/i.test(location.pathname); var TBL = /^\/conference-and-training-tables\/?$/i.test(location.pathname), CONF_OS = null; function confOS() { if (CONF_OS) return CONF_OS; var m = {}; try { window.EQS_QS_TYPES.data.Tables.subs.forEach(function (s) { if (/^Conference/i.test(s[0])) s[2].forEach(function (t) { t[2].forEach(function (k) { if (/^COEOS/i.test(k)) m[String(k).toUpperCase()] = 1; }); }); }); } catch (e) {} return (CONF_OS = m); } var DESK_TOP = /\/category\/1366566-/i.test(location.pathname) ? /^COEDBLFLOS102/i : null; // V11: on Desk & Table Accessories, monitor arms first, then keyboard trays, then power; the rest after (each group fastest delivery first) var ACC = function () { return !!document.body && document.body.classList.contains('ex-categoryid-1366572'); }; function accGroup(t) { var X = idx(), r = X && IDXM[skuOf(t)], s = (r ? r[1] : '') + ' ' + ((t.querySelector('.eqs-ma-title') || t.querySelector('.product-name') || {}).textContent || ''); if (/monitor (arm|mount|stand)|desk mount/i.test(s)) return 0; if (/keyboard/i.test(s)) return 1; if (/power|surge|outlet|extension cord|charging/i.test(s)) return 2; return 3; } // V13: Seating keeps each type together as you scroll (Task chairs, then Executive, then Big & Tall, ... in the menu's order); // inside each type, Office Source first, then fastest delivery var SEAT = /\/category\/1366567-/i.test(location.pathname), SEATG = null; function seatGroup(t) { if (!SEATG) { var T = window.EQS_QS_TYPES && window.EQS_QS_TYPES.data && window.EQS_QS_TYPES.data.Seating; if (!T) return 99; SEATG = {}; T.subs.forEach(function (sb, gi) { sb[2].forEach(function (ty) { ty[2].forEach(function (k) { k = String(k).toUpperCase(); if (!(k in SEATG)) SEATG[k] = gi; }); }); }); } var g = SEATG[String(skuOf(t) || '').toUpperCase()]; return g == null ? 99 : g; } function rate(t, i) { var l = lead(t); if (COE_FIRST && /^COE/.test(skuOf(t))) l = (DESK_TOP && DESK_TOP.test(skuOf(t))) ? -2 : -1; /* V15: COEDBLFLOS102 series first on Desks */ if (TBL && confOS()[String(skuOf(t)).toUpperCase()]) l = -1; /* V15: COEOS conference tables first on Tables */ if (SEAT) l = seatGroup(t) * 1000 + l; if (ACC()) l = (l === 0.5 ? 4 : accGroup(t)) * 100 + l; /* V12: Next Day Delivery items go last */ return { t: t, i: i, lead: l, save: save(t) }; } // ---------- V13: back-to-top button on long category pages ---------- (function backToTop() { if (document.getElementById('eqs-top')) return; var st = document.createElement('style'); st.textContent = '#eqs-top{position:fixed;right:22px;bottom:96px;z-index:9990;width:48px;height:48px;border:0;border-radius:50%;background:rgb(0,132,61);color:#fff;box-shadow:0 4px 14px rgba(0,0,0,.22);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;visibility:hidden;transform:translateY(8px);transition:opacity .2s,transform .2s,visibility .2s}' + '#eqs-top.on{opacity:1;visibility:visible;transform:none}#eqs-top:hover{background:rgb(0,100,45)}#eqs-top svg{width:22px;height:22px}' + '#eqs-top span{position:absolute;right:56px;white-space:nowrap;background:#111827;color:#fff;font:700 12px/1 Arial,sans-serif;padding:7px 9px;border-radius:6px;opacity:0;pointer-events:none;transition:opacity .15s}#eqs-top:hover span{opacity:1}' + '@media (max-width:767px){#eqs-top{right:14px;bottom:84px;width:44px;height:44px}#eqs-top span{display:none}}'; document.head.appendChild(st); var b = document.createElement('button'); b.id = 'eqs-top'; b.type = 'button'; b.setAttribute('aria-label', 'Back to top'); b.innerHTML = 'Back to top'; b.addEventListener('click', function (e) { e.preventDefault(); e.stopPropagation(); window.scrollTo({ top: 0, behavior: 'smooth' }); }); (document.body || document.documentElement).appendChild(b); var tick = function () { b.classList.toggle('on', (window.scrollY || document.documentElement.scrollTop) > 900); }; window.addEventListener('scroll', tick, { passive: true }); tick(); })(); // ---------- V13: Best Seller / Best Value highlights, scattered through each category (a new mix each visit) ---------- var HL_ALL = {"/category/1366566-desks.html":{"bs":["COEDBLFLOS101MW","COECOSMO6CB","OTGHAT6024AML","N9NRISSD1000CH","COEOSTHAT5172MWETC","LLR66903"],"bv":["COEFL689RE","COEMARKLE68W"]},"/category/1366567-seating.html":{"bs":["GLBF550914NAVY","COEORIONBLACK1","OTG11950","COESERENE","COE05AG2QHEVBK","COEOSTW8005PBK","N9N58811WHTBLU","LLR60324"],"bv":["OTG11920","LLR60121"]},"/conference-and-training-tables":{"bs":["COEOS2460TTMWSI","COEOS235MH","COEOSFBM3072GR"],"bv":["LLR65755"]},"/storage--64":{"bs":["HONSC2472P","TNNSTS121272CMG","LLR60552","LLR99791","COEOS184CG"],"bv":["NPRVF218AABK","NPRVF218AANY","COEFL450RE"]},"/boards--25":{"bs":["LLR19767","LLR19770","LLR55661","LLR52569","QRTNA9648F","QRTG9648W"],"bv":["UNV43203","UNV43234","UNV43625"]},"/educational-furniture--5":{"bs":["FLABRPTT0013M","FLAWREN60XUA60","FLAXUA2460RECOAK","SCXFSH605BDV","LLR66903","FLABRPTT0013"],"bv":["FLAFDDESKNTBK","FLAFDDESKGYGT","FLAFDDESKGYGY","FLAFDDESKMPSI"]},"/room-dividers--12":{"bs":["SCXFSH605BDV","FLABRPTT0013M","FLABRPTT0013"],"bv":[]}}; var HL = HL_ALL[location.pathname.replace(/\/+$/, '').toLowerCase()] || null, HLK = {}; if (HL) { HL.bs.forEach(function (s) { HLK[s] = 'bs'; }); HL.bv.forEach(function (s) { if (!HLK[s]) HLK[s] = 'bv'; }); } var hlOn = function () { return HL && !typeFiltered() && !new URLSearchParams(location.search).has('sort'); }; function shuffle(a) { for (var i = a.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)), t = a[i]; a[i] = a[j]; a[j] = t; } return a; } function seatGroupSku(s) { if (!SEATG) seatGroup({ getAttribute: function () { return ''; }, querySelector: function () { return null; } }); var g = SEATG && SEATG[String(s).toUpperCase()]; return g == null ? 99 : g; } /* V15: add-on pieces go right after the items they belong to (transaction tops after the reception desk shells) */ var ADDONS = [[/^COEOS169TT/i, /^COEOS169NTT/i]]; function tailAddons(arr, skuF) { if (/[?&]sort=/.test(location.search)) return arr; ADDONS.forEach(function (r) { var sk = function (x) { return String(skuF(x) || ''); }; var add = arr.filter(function (x) { return r[0].test(sk(x)); }); if (!add.length) return; var rest = arr.filter(function (x) { return !r[0].test(sk(x)); }), last = -1; rest.forEach(function (x, i) { if (r[1].test(sk(x))) last = i; }); if (last < 0) return; arr = rest.slice(0, last + 1).concat(add, rest.slice(last + 1)); }); return arr; } function spreadHL(arr, skuF) { if (!hlOn()) return arr; var hit = function (x) { return HLK[String(skuF(x) || '').toUpperCase()]; }; if (SEAT) { // Seating: each type opens with its highlighted chairs var out = [], cur = null, buf = []; var flush = function () { var h = shuffle(buf.filter(hit)); out = out.concat(h, buf.filter(function (x) { return !hit(x); })); buf = []; }; arr.forEach(function (x) { var g = seatGroupSku(skuF(x)); if (g !== cur) { flush(); cur = g; } buf.push(x); }); flush(); return out; } var picks = shuffle(arr.filter(hit)), rest = arr.filter(function (x) { return !hit(x); }), lead = []; if (!picks.length) return arr; var GRP = { '/educational-furniture--5': /^FLAFDDESK/i, '/room-dividers--12': /^FLABRPTT0013/i }[location.pathname.replace(/\/+$/, '').toLowerCase()]; if (GRP) { /* V15: these picks sit together near the top (Educational: student desks with book boxes; Room Dividers: Flash mobile whiteboards) */ var sd = function (x) { return GRP.test(String(skuF(x) || '')); }; lead = picks.filter(sd).concat(rest.filter(sd)); picks = picks.filter(function (x) { return !sd(x); }); rest = rest.filter(function (x) { return !sd(x); }); rest = rest.slice(0, 1).concat(lead, rest.slice(1)); } if (/^\/boards--25\/?$/i.test(location.pathname)) { /* V15: Boards open with all the Best Sellers, then the Best Values */ var kind = function (x) { var o = HL || {}; return (o.bs || []).indexOf(String(skuF(x) || '').toUpperCase()) >= 0 ? 0 : 1; }; return picks.filter(function (x) { return kind(x) === 0; }).concat(picks.filter(function (x) { return kind(x) === 1; }), rest); } if (!picks.length) return rest; var t0 = 0, topB = function (k) { k = String(k || '').toUpperCase(); return DESK_TOP ? DESK_TOP.test(k) : (TBL && !!confOS()[k]) || (GRP ? GRP.test(k) : false); }; if (lead.length) t0 = 1; while (t0 < rest.length && topB(skuF(rest[t0]))) t0++; /* V15: keep the lead block together */ var s0 = Math.max(1, t0), step = Math.max(5, Math.floor((rest.length - s0) / (picks.length + 1))), res = [], k = 0; rest.forEach(function (x, i) { if (k < picks.length && (i === s0 || (i > s0 && (i - s0) % step === 0))) res.push(picks[k++]); res.push(x); }); while (k < picks.length) res.push(picks[k++]); return res; } // ---------- first page: order the cards that are already there ---------- function applyLocal() { var grid = document.querySelector('.griditems'); if (!grid) return; var tiles = [].slice.call(grid.querySelectorAll(':scope > .tileparent.product')); var whole = typeFiltered(), groups = {}; tiles.forEach(function (t, i) { var p = whole ? 1 : +(t.getAttribute('data-page') || 1); (groups[p] = groups[p] || []).push(rate(t, i)); }); Object.keys(groups).forEach(function (p) { tailAddons(spreadHL(clusterize(groups[p].sort(cmp), function (x) { return skuOf(x.t); }), function (x) { return skuOf(x.t); }), function (x) { return skuOf(x.t); }).forEach(function (x, k) { var o = String(+p * 10000 + k); if (x.t.style.order !== o) x.t.style.order = o; }); }); [].slice.call(grid.children).forEach(function (c) { if (!c.matches('.tileparent.product') && c.style.order !== '9999999') c.style.order = '9999999'; }); } function label() { var sel = document.getElementById('productorderby'); if (!sel) return; [].slice.call(sel.options).forEach(function (o) { if (/sort=relevance/.test(o.value) && o.textContent.trim() !== 'Fastest delivery') o.textContent = 'Fastest delivery'; }); } // ---------- whole category ---------- var all = null; // set once every page is in function pageUrl(p) { var v = new URLSearchParams(location.search); v.delete('p'); v.set('p', p); return location.pathname + '?' + v.toString().replace(/%2C/g, ','); } function cacheKey() { var v = new URLSearchParams(location.search); v.delete('p'); return 'eqs6:' + location.pathname + '?' + v.toString(); } function parse(h) { return new DOMParser().parseFromString(h, 'text/html'); } function loadAll() { var grid = document.querySelector('.griditems'); if (!grid) return; var totalEl = document.querySelector('.itemsfound b'); var total = totalEl ? parseInt(totalEl.textContent.replace(/\D/g, ''), 10) || 0 : 0; var pages = Math.min(Math.ceil(total / PER), 40); if (pages <= 1) return; var key = cacheKey() + '|p' + (+(new URLSearchParams(location.search).get('p') || 1) || 1), cached = null; try { var c = JSON.parse(sessionStorage.getItem(key) || 'null'); if (c && Date.now() - c.t < 15 * 60e3 && c.h && c.h.length) cached = c.h; } catch (e) { /* none */ } if (cached) { finish(cached, true); return; } var cur = +(new URLSearchParams(location.search).get('p') || 1) || 1; var got = {}, failed = 0, next = cur === 1 ? 2 : 1, running = 0; function pump() { while (running < CONCURRENT && next <= pages) { (function (p) { running++; fetch(pageUrl(p), { credentials: 'same-origin' }) .then(function (r) { if (!r.ok) throw new Error(r.status); return r.text(); }) .then(function (h) { var tiles = parse(h).querySelectorAll('.tileparent.product'); if (!tiles.length) failed++; got[p] = [].map.call(tiles, function (t) { return t.outerHTML; }); }) .catch(function () { failed++; }) .then(function () { running--; if (next > pages && !running) done(); else setTimeout(pump, 0); }); })(next++); if (next === cur) next++; } } function done() { var h = []; for (var p = 1; p <= pages; p++) if (p !== cur) h = h.concat(got[p] || []); if (!failed) try { sessionStorage.setItem(key, JSON.stringify({ t: Date.now(), h: h })); } catch (e) { /* too large */ } finish(h, false); } pump(); } // EvoX writes ?p=N into the address as you scroll; with the whole list on one page that would reopen on page N function stripP() { if (!/[?&]p=/.test(location.search)) return; var u = new URLSearchParams(location.search); u.delete('p'); var q = u.toString().replace(/%2C/g, ','); history.replaceState(history.state, '', location.pathname + (q ? '?' + q : '')); } function finish(htmls, fromCache) { var grid = document.querySelector('.griditems'); if (!grid || all) return; (function wait(n) { // the item list gives each card's delivery speed; wait up to 6 s for it if (!idx() && n < 30) { needIndex(); setTimeout(function () { wait(n + 1); }, 200); return; } build(grid, htmls); })(0); } function build(grid, htmls) { var have = {}, list = [], i = 0; [].slice.call(grid.querySelectorAll(':scope > .tileparent.product')).forEach(function (t) { var s = skuOf(t); if (!s || have[s]) return; have[s] = 1; list.push({ node: t, sku: s, i: i++ }); }); var holder = document.createElement('div'); htmls.forEach(function (h) { holder.innerHTML = h; var t = holder.firstElementChild; if (!t) return; var s = skuOf(t); if (!s || have[s]) return; have[s] = 1; list.push({ html: h, sku: s, i: i++, probe: t }); }); list.forEach(function (x) { var r = rate(x.node || x.probe, x.i); x.lead = r.lead; x.save = r.save; x.probe = null; }); list.sort(cmp); list = tailAddons(spreadHL(clusterize(list, function (x) { return x.sku; }), function (x) { return x.sku; }), function (x) { return x.sku; }); all = { list: list, shown: 0 }; // take over the page: no EvoX "load more" or page links from here on [].slice.call(document.querySelectorAll('.pagination, .load-more-trigger-infinite-scroll, .load-more-infinite-scroll')).forEach(function (el) { el.remove(); }); stripP(); list.forEach(function (x) { if (x.node) { x.node.setAttribute('data-eqs4', '1'); x.node.style.order = ''; x.node.remove(); } }); new MutationObserver(function () { [].slice.call(grid.querySelectorAll(':scope > .tileparent.product')).forEach(function (t) { if (!t.hasAttribute('data-eqs4')) t.remove(); }); stripP(); }).observe(grid, { childList: true }); window.addEventListener('scroll', stripP, { passive: true }); more(grid, FIRST); var sentinel = document.createElement('div'); sentinel.className = 'eqs4-more'; sentinel.style.cssText = 'height:1px;width:100%;flex:0 0 100%;order:9999999'; grid.parentNode.insertBefore(sentinel, grid.nextSibling); if ('IntersectionObserver' in window) { new IntersectionObserver(function (es) { if (es.some(function (e) { return e.isIntersecting; })) more(grid, PER); }, { rootMargin: '1200px 0px' }).observe(sentinel); } else { window.addEventListener('scroll', function () { if (sentinel.getBoundingClientRect().top < innerHeight + 1200) more(grid, PER); }, { passive: true }); } window.EQS_QS_SORT.total = list.length; } function more(grid, n) { if (!all || all.shown >= all.list.length) return; var end = Math.min(all.shown + n, all.list.length); for (var k = all.shown; k < end; k++) { var x = all.list[k], node = x.node; if (!node) { var d = parse('
' + x.html + '
').querySelector('.tileparent.product'); node = document.importNode(d, true); node.setAttribute('data-eqs4', '1'); var scripts = [].slice.call(node.querySelectorAll('script')); grid.appendChild(node); // each card defines its cart data in an inline script: run it so Add to cart works scripts.forEach(function (sc) { try { (0, eval)(sc.textContent); } catch (e) { /* card without cart data */ } }); } else { grid.appendChild(node); } node.style.order = ''; } all.shown = end; document.dispatchEvent(new CustomEvent('eqs-tiles-replaced', { detail: { count: end } })); if (typeof window.EQS_QSNAV_APPLY === 'function') { try { window.EQS_QSNAV_APPLY(); } catch (e) { /* optional */ } } } // ---------- start ---------- var raf = 0; function run() { raf = 0; label(); if (!userSorted() && !all) applyLocal(); } function soon() { label(); if (!raf) raf = requestAnimationFrame(run); } function start() { if (!onPage()) return; window.EQS_QS_SORT = { version: VERSION, apply: applyLocal, more: function () { more(document.querySelector('.griditems'), PER); } }; needIndex(); run(); new MutationObserver(soon).observe(document.body, { childList: true, subtree: true, characterData: true }); setTimeout(soon, 1500); setTimeout(soon, 4000); if (!userSorted() && !typeFiltered()) setTimeout(loadAll, 0); document.addEventListener('eqs-tiles-replaced', soon); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start(); })();