/* 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) { 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); function rate(t, i) { var l = lead(t); if (COE_FIRST && /^COE/.test(skuOf(t))) l = -1; return { t: t, i: i, lead: l, save: save(t) }; } // ---------- 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) { clusterize(groups[p].sort(cmp), 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 = clusterize(list, 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('