/* EMERALD QUICK SHIP - PRE-OWNED FURNITURE V1 November 20, 2026 One self-contained script for the Pre-Owned category (EvoX category 1366575, www.ebsupplies.com/pre-owned). The category has no EvoX products, so this script loads the partner inventory feed and builds the page: - "Quick Ship Pre-Owned Furniture" title panel (the Quick Ship nav script styles it) - Filter Products sidebar (search, category, availability) in the Quick Ship style - product cards in the Quick Ship card style with View Details & Photos - Quick View popup with all photos - "Your Emerald Quote List" drawer that opens a prefilled quote email to the customer's assigned rep (or furniture@ebsupplies.com). Nothing is sent automatically. Based on the original Pre-Owned quote panel from /quick-ship-test. The quote list uses the same browser storage key, so lists started there carry over. */ (function () { 'use strict'; if (!document.body || !document.body.classList.contains('ex-categoryid-1366575')) return; if (window.EQS_PO && window.EQS_PO.active) return; var VERSION = 'EQS_PREOWNED_V1B_2026_11_20'; var FEED_URL = 'https://www.conklinoffice.com/wp-json/conklin/v1/broadwayfeed'; var KEY = 'emerald-preowned-quote-v1'; var FALLBACK_QUOTE_EMAIL = 'furniture@ebsupplies.com'; var G = 'rgb(0,128,58)', DARK = '#0f3d24'; var CATS = ['Desks & Workstations', 'Seating', 'Tables', 'Storage & Filing', 'Boards & Dividers', 'Accessories', 'Other Furniture']; var products = [], list = [], state = { q: '', cat: '', brands: [], showAllBrands: false, stock: false, sort: 'featured', limit: 24 }; var representativeEmail = ''; try { var saved = JSON.parse(sessionStorage.getItem(KEY) || '[]'); if (Array.isArray(saved)) list = saved.filter(function (x) { return x && x.sku && x.title; }).slice(0, 100); } catch (e) {} /* ---------------- helpers ---------------- */ function el(tag, cls, text) { var x = document.createElement(tag); if (cls) x.className = cls; if (text !== undefined) x.textContent = String(text); return x; } function txt(x) { var d = document.createElement('div'); d.innerHTML = String(x || ''); return (d.textContent || '').replace(/\s+/g, ' ').trim(); } function imgUrl(v) { if (typeof v === 'string') return v; if (v && typeof v === 'object') return v.url || v.src || v.guid || ''; return ''; } function safeImage(url) { try { var u = new URL(url, location.href); return u.protocol === 'https:' || u.protocol === 'http:' ? u.href : ''; } catch (e) { return ''; } } function extraImages(v) { if (Array.isArray(v)) return v.map(imgUrl).filter(Boolean); if (typeof v === 'string') { try { var a = JSON.parse(v); if (Array.isArray(a)) return extraImages(a); } catch (e) {} return v.trim() ? [v] : []; } return []; } function category(p) { var t = (p.title + ' ' + p.description.slice(0, 100)).toLowerCase(); if (/chair|seating|stool|sofa|loveseat|bench|ottoman/.test(t)) return 'Seating'; if (/desk|credenza|return|reception|worksurface|workstation|cubicle|panel system/.test(t)) return 'Desks & Workstations'; if (/conference|training|meeting|table/.test(t)) return 'Tables'; if (/file|pedestal|cabinet|bookcase|shelf|shelving|storage|locker/.test(t)) return 'Storage & Filing'; if (/whiteboard|board|partition|divider|screen/.test(t)) return 'Boards & Dividers'; if (/lamp|monitor|accessor|keyboard|power module/.test(t)) return 'Accessories'; return 'Other Furniture'; } function save() { try { sessionStorage.setItem(KEY, JSON.stringify(list)); } catch (e) {} updateCount(); } function count() { return list.reduce(function (n, p) { return n + Number(p.qty || 0); }, 0); } function updateCount() { var n = count(); document.querySelectorAll('.eqs-po-count').forEach(function (x) { x.textContent = n; }); var f = document.getElementById('eqs-po-floating'); if (f) f.style.display = n ? 'flex' : 'none'; } function svg(path, cls) { var ns = 'http://www.w3.org/2000/svg', s = document.createElementNS(ns, 'svg'); s.setAttribute('viewBox', '0 0 24 24'); s.setAttribute('aria-hidden', 'true'); if (cls) s.setAttribute('class', cls); path.forEach(function (d) { var p = document.createElementNS(ns, 'path'); p.setAttribute('d', d); s.appendChild(p); }); return s; } var ICON_QUOTE = ['M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2', 'M9 3h6v4H9z', 'M9 12h6M9 16h4']; var ICON_PHOTO = ['M4 4h16v16H4z', 'M4 16l5-5 4 4 3-3 4 4', 'M15.5 8.5h.01']; /* ---------------- styles ---------------- */ var S = 'body.ex-categoryid-1366575'; var CSS = [ S + ' .noprodutctfound{display:none!important}', S + ' .breadcrumbs_container{display:none!important}', S + ' .filter-container > .eqs-po-hidden{display:none!important}', S + ' .filter-container .eqs-po-side{margin-top:0}', S + ' .eqs-po{margin:0 0 30px;font-family:Arial,sans-serif;color:#1d2a22}', S + ' .eqs-po-layout{display:grid;grid-template-columns:235px minmax(0,1fr);gap:22px;align-items:start}', S + ' .eqs-po-side{background:#fff;border:1px solid #dfe5e1;border-radius:10px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.05);position:sticky;top:60px}', S + ' .eqs-po-side-head{margin:0;padding:13px 14px;background:#16201a;border-bottom:3px solid ' + G + ';color:#fff;font:700 17px/21px Arial,sans-serif}', S + ' .eqs-po-clear{display:block;margin:10px 14px 0;padding:0;border:0;background:none;color:#7b8580;font:700 12px/16px Arial,sans-serif;cursor:pointer;text-align:left}', S + ' .eqs-po-clear:hover{color:' + G + ';text-decoration:underline}', S + ' .eqs-po-find{flex:1 1 280px;max-width:440px;margin:0 auto;position:relative}', S + ' .eqs-po-find:before{content:"";position:absolute;left:13px;top:50%;width:11px;height:11px;margin-top:-8px;border:2px solid #7a8a80;border-radius:50%;pointer-events:none}', S + ' .eqs-po-find:after{content:"";position:absolute;left:25px;top:50%;width:6px;height:2px;margin-top:5px;background:#7a8a80;transform:rotate(45deg);pointer-events:none}', S + ' .eqs-po-find input{width:100%;box-sizing:border-box;height:40px;padding:0 12px 0 38px;border:1px solid #cfd8d2;border-radius:8px;font:13px Arial,sans-serif;color:#222;background:#fff}', S + ' .eqs-po-find input:focus{outline:0;border-color:' + G + ';box-shadow:0 0 0 3px rgba(31,122,58,.15)}', '@media (max-width:991px){' + S + ' .eqs-po-find{order:3;flex:1 1 100%;max-width:none}}', S + ' .eqs-po-sec{margin:0 14px;padding:13px 0 11px;border-top:1px solid #e6e9e7}', S + ' .eqs-po-sec h5{margin:0 0 8px;color:#111;font:700 15px/19px Arial,sans-serif}', S + ' .eqs-po-opt{display:flex;align-items:flex-start;gap:8px;width:100%;padding:4px 0;border:0;background:none;color:#222;font:400 13px/17px Arial,sans-serif;text-align:left;cursor:pointer}', S + ' .eqs-po-opt::before{content:"";flex:0 0 14px;width:14px;height:14px;margin-top:1px;border:1.5px solid #767676;border-radius:3px;background:#fff;box-sizing:border-box}', S + ' .eqs-po-opt:hover::before{border-color:' + G + '}', S + ' .eqs-po-opt:hover .eqs-po-optname{color:' + G + '}', S + ' .eqs-po-opt[aria-pressed="true"]::before{content:"\\2713";display:flex;align-items:center;justify-content:center;border-color:' + G + ';color:' + G + ';font:900 12px/1 Arial,sans-serif}', S + ' .eqs-po-opt[aria-pressed="true"] .eqs-po-optname{font-weight:700}', S + ' .eqs-po-optname{flex:1 1 auto}', S + ' .eqs-po-optcount{flex:0 0 auto;color:#7b8580;font-size:12px}', S + ' .eqs-po-brands .eqs-po-extra{display:none}', S + ' .eqs-po-brands.eqs-po-allbrands .eqs-po-extra{display:flex}', S + ' .eqs-po-brands.eqs-po-allbrands{max-height:420px;overflow-y:auto}', S + ' .eqs-po-morebrands{margin:6px 0 0;padding:0;border:0;background:none;color:' + G + ';font:700 13px/17px Arial,sans-serif;cursor:pointer;text-decoration:underline}', S + ' .eqs-po-note{margin:0 14px 12px;padding-top:10px;border-top:1px solid #e6e9e7;color:#6b7570;font:12px/17px Arial,sans-serif}', S + ' .eqs-po-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:0 0 14px}', S + ' .eqs-po-found{font:400 15px/20px Arial,sans-serif;color:#1d2a22}', S + ' .eqs-po-found b{font-weight:700}', S + ' .eqs-po-tools{display:flex;align-items:center;gap:10px}', S + ' .eqs-po-tools label{font:13px Arial,sans-serif;color:#4a5550}', S + ' .eqs-po-tools select{height:38px;padding:0 10px;border:1px solid #cfd8d2;border-radius:6px;background:#fff;font:13px Arial,sans-serif;color:#222}', S + ' .eqs-po-openlist{display:inline-flex;align-items:center;gap:7px;height:38px;padding:0 16px;border:0;border-radius:8px;background:' + G + ';color:#fff;font:700 13px/1 Arial,sans-serif;cursor:pointer}', S + ' .eqs-po-openlist:hover{background:rgb(0,104,47)}', S + ' .eqs-po-openlist svg{width:16px;height:16px;fill:none;stroke:#fff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}', S + ' .eqs-po-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}', '@media (max-width:1199px){' + S + ' .eqs-po-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}', '@media (max-width:991px){' + S + ' .eqs-po-layout{grid-template-columns:1fr}' + S + ' .eqs-po-side{position:static}' + S + ' .eqs-po-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}', '@media (max-width:560px){' + S + ' .eqs-po-grid{grid-template-columns:1fr}}', S + ' .eqs-po-card{display:flex;flex-direction:column;min-width:0;padding:14px 14px 14px;background:#fff;border:.667px solid rgb(203,216,212);border-radius:14px;box-sizing:border-box}', S + ' .eqs-po-img{display:flex;align-items:center;justify-content:center;height:150px;margin:4px 0 10px;padding:6px;border:0;background:#fff;cursor:zoom-in;box-sizing:border-box}', S + ' .eqs-po-img img{max-width:100%;max-height:100%;object-fit:contain;transition:transform .2s ease}', '@media (hover:hover){' + S + ' .eqs-po-img:hover img{transform:scale(1.05)}}', S + ' .eqs-po-top{display:flex;align-items:center;justify-content:space-between;gap:6px;height:22px;margin:0 0 6px}', S + ' .eqs-po-tag{display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;background:#e8f3ec;color:' + DARK + ';font:700 10.5px/1 Arial,sans-serif;letter-spacing:.3px;text-transform:uppercase}', S + ' .eqs-po-avail{font:700 11px/14px Arial,sans-serif;color:' + G + ';white-space:nowrap}', S + ' .eqs-po-avail.eqs-po-out{color:#8a948f}', S + ' .eqs-po-title{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;height:38px;margin:0 0 4px;padding:0;border:0;background:none;color:rgb(2,2,2);font:700 14px/19px Arial,sans-serif;text-align:left;cursor:pointer}', S + ' .eqs-po-title:hover{text-decoration:underline}', S + ' .eqs-po-sku{margin:0 0 6px;color:rgb(100,116,139);font:11px/17px Arial,sans-serif}', S + ' .eqs-po-sku b{font-weight:600;color:rgb(71,85,105)}', S + ' .eqs-po-desc{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;height:48px;margin:0 0 8px;color:#333;font:12px/16px Arial,sans-serif}', S + ' .eqs-po-details{display:inline-flex;align-items:center;gap:6px;align-self:flex-start;margin:0 0 12px;padding:0;border:0;background:none;color:#496a89;font:700 11px/1.4 Arial,sans-serif;letter-spacing:.025em;text-transform:uppercase;cursor:pointer}', S + ' .eqs-po-details svg{width:15px;height:15px;fill:none;stroke:#414c56;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}', S + ' .eqs-po-details:hover{color:#345773;text-decoration:underline}', S + ' .eqs-po-add{display:flex;align-items:center;justify-content:center;gap:7px;width:100%;height:40px;margin-top:auto;border:0;border-radius:8px;background:' + G + ';color:#fff;font:700 13px/1 Arial,sans-serif;cursor:pointer}', S + ' .eqs-po-add:hover{background:rgb(0,104,47)}', S + ' .eqs-po-add svg{width:16px;height:16px;fill:none;stroke:#fff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}', S + ' .eqs-po-add.eqs-po-added{background:' + DARK + '}', S + ' .eqs-po-more{display:block;margin:24px auto 0;padding:11px 26px;border:1.5px solid ' + G + ';border-radius:999px;background:#fff;color:' + G + ';font:700 13px/1 Arial,sans-serif;cursor:pointer}', S + ' .eqs-po-more:hover{background:' + G + ';color:#fff}', S + ' .eqs-po-msg{padding:40px 20px;border:1px dashed #cfd8d2;border-radius:12px;text-align:center;color:#4a5550;font:14px/20px Arial,sans-serif}', S + ' .eqs-po-msg strong{display:block;margin-bottom:4px;color:' + DARK + ';font-size:16px}', /* floating button, drawer and quick view (outside the page column) */ '.eqs-po-floating{position:fixed;right:22px;bottom:22px;z-index:9997;display:none;align-items:center;gap:6px;padding:13px 18px;border:0;border-radius:30px;background:' + G + ';color:#fff;box-shadow:0 4px 18px rgba(0,0,0,.2);font:700 13px/1 Arial,sans-serif;cursor:pointer}', '.eqs-po-shade{position:fixed;inset:0;z-index:9998;display:none;background:rgba(0,0,0,.45)}', '.eqs-po-shade.eqs-po-on{display:block}', '.eqs-po-drawer{position:fixed;top:0;right:0;bottom:0;z-index:9999;display:flex;flex-direction:column;width:min(470px,100vw);background:#fff;color:#263238;font-family:Arial,sans-serif;box-shadow:-4px 0 24px rgba(0,0,0,.15);transform:translateX(101%);transition:transform .2s ease}', '.eqs-po-drawer.eqs-po-on{transform:translateX(0)}', '.eqs-po-dhead{display:flex;align-items:center;justify-content:space-between;padding:18px 22px;background:' + DARK + ';border-bottom:3px solid ' + G + ';color:#fff}', '.eqs-po-dhead h2{margin:0;color:#fff;font:700 20px/1.2 Poppins,Arial,sans-serif}', '.eqs-po-dhead button{border:0;background:none;color:#fff;font-size:28px;line-height:1;cursor:pointer}', '.eqs-po-dbody{flex:1;overflow-y:auto;padding:16px 20px}', '.eqs-po-item{display:grid;grid-template-columns:70px 1fr;gap:12px;padding:14px 0;border-bottom:1px solid #e1e5e3}', '.eqs-po-item img{width:70px;height:70px;object-fit:contain}', '.eqs-po-item strong{display:block;margin-bottom:3px;font-size:14px}', '.eqs-po-drawer label{display:block;margin:8px 0 4px;font-size:12px;font-weight:700}', '.eqs-po-item input{width:78px;padding:7px;border:1px solid #ccd4d0;border-radius:5px}', '.eqs-po-drawer textarea{width:100%;box-sizing:border-box;padding:9px;border:1px solid #ccd4d0;border-radius:6px;resize:vertical;font:13px Arial,sans-serif}', '.eqs-po-remove{padding:6px 0;border:0;background:none;color:#b5222b;text-decoration:underline;cursor:pointer}', '.eqs-po-info{margin:14px 0;padding:12px;border-radius:8px;background:#f1f7f3;font-size:13px;line-height:1.6}', '.eqs-po-field input{display:block;width:100%;box-sizing:border-box;margin-top:4px;padding:9px;border:1px solid #ccd6cf;border-radius:5px;font:13px Arial,sans-serif}', '.eqs-po-dfoot{padding:15px 20px;border-top:1px solid #e0e5e1;background:#fff}', '.eqs-po-dfoot button{width:100%;padding:13px;border:0;border-radius:8px;background:' + G + ';color:#fff;font:700 13px/1 Arial,sans-serif;cursor:pointer}', '.eqs-po-dfoot button:hover{background:rgb(0,104,47)}', '.eqs-po-muted{color:#68746d;font-size:12px;line-height:1.5}', '.eqs-po-status{margin-top:8px;font-size:12px;line-height:1.5}', '.eqs-po-qv{position:fixed;inset:0;z-index:10020;display:flex;align-items:center;justify-content:center;padding:18px;background:rgba(0,0,0,.6)}', '.eqs-po-qvpanel{position:relative;width:min(920px,100%);max-height:92vh;overflow:auto;padding:24px;border-radius:14px;background:#fff;color:#1d2a22;font-family:Arial,sans-serif;box-shadow:0 12px 50px rgba(0,0,0,.25)}', '.eqs-po-qvclose{position:absolute;top:10px;right:12px;z-index:2;width:38px;height:38px;border:0;border-radius:50%;background:#eef3ef;font-size:25px;cursor:pointer}', '.eqs-po-qvgrid{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);gap:24px}', '.eqs-po-qvimg{width:100%;height:370px;object-fit:contain;background:#fff}', '.eqs-po-thumbs{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}', '.eqs-po-thumbs button{padding:3px;border:2px solid #dfe7e1;border-radius:6px;background:#fff;cursor:pointer}', '.eqs-po-thumbs button[aria-pressed="true"]{border-color:' + G + '}', '.eqs-po-thumbs img{width:65px;height:55px;object-fit:contain}', '.eqs-po-qvpanel h2{margin:8px 40px 10px 0;color:' + DARK + ';font:700 22px/1.25 Poppins,Arial,sans-serif}', '.eqs-po-qvpanel p{margin:0 0 4px;font-size:13px;color:#4a5550}', '.eqs-po-qvdesc{max-height:290px;overflow:auto;margin:14px 0;font-size:14px;line-height:1.6;white-space:pre-line}', '.eqs-po-qvpanel .eqs-po-add{margin-top:14px;height:44px}', '@media (max-width:650px){.eqs-po-qvpanel{padding:15px}.eqs-po-qvgrid{grid-template-columns:1fr;gap:8px}.eqs-po-qvimg{height:230px}.eqs-po-floating{right:12px;bottom:12px}}' ].join('\n'); function addStyle() { if (document.getElementById('eqs-po-style')) return; var st = document.createElement('style'); st.id = 'eqs-po-style'; st.textContent = CSS; (document.head || document.documentElement).appendChild(st); } /* ---------------- quote drawer ---------------- */ function setupDrawer() { if (document.getElementById('eqs-po-drawer')) return; var shade = el('div', 'eqs-po-shade'); shade.id = 'eqs-po-shade'; shade.addEventListener('click', closeDrawer); document.body.appendChild(shade); var drawer = el('aside', 'eqs-po-drawer'); drawer.id = 'eqs-po-drawer'; drawer.setAttribute('role', 'dialog'); drawer.setAttribute('aria-modal', 'true'); drawer.setAttribute('aria-label', 'Your Emerald Quote List'); drawer.setAttribute('aria-hidden', 'true'); var head = el('div', 'eqs-po-dhead'), x = el('button', '', '×'); x.id = 'eqs-po-close'; x.type = 'button'; x.setAttribute('aria-label', 'Close Quote List'); x.addEventListener('click', closeDrawer); head.append(el('h2', '', 'Your Emerald Quote List'), x); drawer.appendChild(head); var body = el('div', 'eqs-po-dbody'); body.id = 'eqs-po-dbody'; drawer.appendChild(body); var foot = el('div', 'eqs-po-dfoot'), submit = el('button', '', 'OPEN EMAIL TO REQUEST QUOTE'); submit.type = 'button'; submit.addEventListener('click', prepareQuoteEmail); var status = el('div', 'eqs-po-status'); status.id = 'eqs-po-email-status'; foot.append(submit, el('div', 'eqs-po-muted', 'Opens a prefilled message in your email app. Review it and click Send there to deliver your request. Nothing is sent automatically.'), status); drawer.appendChild(foot); document.body.appendChild(drawer); var fl = el('button', 'eqs-po-floating'); fl.id = 'eqs-po-floating'; fl.type = 'button'; fl.append(svg(ICON_QUOTE), document.createTextNode('Quote List ('), el('span', 'eqs-po-count', '0'), document.createTextNode(')')); fl.querySelector('svg').setAttribute('style', 'width:16px;height:16px;fill:none;stroke:#fff;stroke-width:2'); fl.addEventListener('click', openDrawer); document.body.appendChild(fl); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') closeDrawer(); }); updateCount(); } function openDrawer() { renderDrawer(); document.getElementById('eqs-po-shade').classList.add('eqs-po-on'); var d = document.getElementById('eqs-po-drawer'); d.classList.add('eqs-po-on'); d.setAttribute('aria-hidden', 'false'); document.getElementById('eqs-po-close').focus(); loadRepresentative(); } function closeDrawer() { var s = document.getElementById('eqs-po-shade'), d = document.getElementById('eqs-po-drawer'); if (s) s.classList.remove('eqs-po-on'); if (d) { d.classList.remove('eqs-po-on'); d.setAttribute('aria-hidden', 'true'); } } function add(p) { var ex = list.find(function (x) { return x.sku === p.sku; }); if (ex) ex.qty++; else list.push({ sku: p.sku, title: p.title, image: p.image, qty: 1, note: '' }); save(); markAdded(); openDrawer(); } function renderDrawer() { var body = document.getElementById('eqs-po-dbody'); body.replaceChildren(); if (!list.length) body.appendChild(el('p', 'eqs-po-muted', 'Your Quote List is empty. Select Add to Quote on any pre-owned product.')); list.forEach(function (p) { var item = el('div', 'eqs-po-item'), image = el('img'), right = el('div'); image.src = safeImage(p.image) || ''; image.alt = ''; right.append(el('strong', '', p.title), el('div', 'eqs-po-muted', 'Item Code: ' + p.sku)); var q = el('input'); q.type = 'number'; q.min = '1'; q.max = '9999'; q.value = p.qty; q.addEventListener('change', function () { p.qty = Math.max(1, Math.min(9999, parseInt(q.value, 10) || 1)); q.value = p.qty; save(); }); var note = el('textarea'); note.rows = 2; note.placeholder = 'Finish, dimensions, questions...'; note.value = p.note || ''; note.addEventListener('input', function () { p.note = note.value.slice(0, 1500); save(); }); var remove = el('button', 'eqs-po-remove', 'Remove'); remove.type = 'button'; remove.addEventListener('click', function () { list = list.filter(function (x) { return x.sku !== p.sku; }); save(); markAdded(); renderDrawer(); }); right.append(el('label', '', 'Quantity'), q, el('label', '', 'Product notes'), note, remove); item.append(image, right); body.appendChild(item); }); var info = el('div', 'eqs-po-info'); info.append(el('strong', '', 'Your Contact Information'), el('div', 'eqs-po-muted', 'Please confirm your contact details so your Emerald representative can reply.')); [['Company', 'company', 'organization'], ['Your name', 'name', 'name'], ['Email address', 'email', 'email'], ['Phone (optional)', 'phone', 'tel'], ['Account number (optional)', 'account', 'off']].forEach(function (f) { var label = el('label', 'eqs-po-field', f[0]), input = el('input'); input.id = 'eqs-po-contact-' + f[1]; input.type = f[1] === 'email' ? 'email' : 'text'; input.autocomplete = f[2]; input.maxLength = 180; try { input.value = sessionStorage.getItem(KEY + '-contact-' + f[1]) || ''; } catch (e) {} input.addEventListener('input', function () { try { sessionStorage.setItem(KEY + '-contact-' + f[1], input.value); } catch (e) {} }); label.appendChild(input); info.appendChild(label); }); var rep = el('div', 'eqs-po-muted', 'Assigned representative: checking account...'); rep.id = 'eqs-po-rep'; info.appendChild(rep); body.appendChild(info); var notes = el('textarea'); notes.id = 'eqs-po-project-notes'; notes.rows = 4; notes.placeholder = 'Delivery address, installation, project timing, other products...'; try { notes.value = sessionStorage.getItem(KEY + '-notes') || ''; } catch (e) {} notes.addEventListener('input', function () { try { sessionStorage.setItem(KEY + '-notes', notes.value.slice(0, 4000)); } catch (e) {} }); body.append(el('label', '', 'Project notes'), notes); } function loadRepresentative() { representativeEmail = ''; fetch('/myaccount', { credentials: 'same-origin', redirect: 'follow' }).then(function (r) { if (!r.ok) throw Error('Account unavailable'); return r.text(); }).then(function (html) { var doc = new DOMParser().parseFromString(html, 'text/html'), box = doc.querySelector('#cdash_accountmanagers_list'); var m = box && (box.textContent || '').match(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i); representativeEmail = m ? m[0].toLowerCase() : ''; var node = document.getElementById('eqs-po-rep'); if (node) node.textContent = representativeEmail ? 'Your representative: ' + representativeEmail : 'Your request will go to ' + FALLBACK_QUOTE_EMAIL + '.'; }).catch(function () { var node = document.getElementById('eqs-po-rep'); if (node) node.textContent = 'Your request will go to ' + FALLBACK_QUOTE_EMAIL + '.'; }); } function prepareQuoteEmail() { var status = document.getElementById('eqs-po-email-status'); if (!list.length) { status.textContent = 'Add at least one product to your Quote List.'; return; } var f = {}; ['company', 'name', 'email', 'phone', 'account'].forEach(function (k) { var n = document.getElementById('eqs-po-contact-' + k); f[k] = n ? n.value.trim() : ''; }); if (!f.company || !f.name || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f.email)) { status.textContent = 'Please enter your company, name and a valid email address.'; return; } var to = representativeEmail || FALLBACK_QUOTE_EMAIL, project = document.getElementById('eqs-po-project-notes'); var lines = ['PRE-OWNED FURNITURE QUOTE REQUEST', '', 'Company: ' + f.company, 'Contact: ' + f.name, 'Email: ' + f.email, 'Phone: ' + (f.phone || 'Not provided'), 'Emerald account number: ' + (f.account || 'Not provided'), '', 'PRODUCTS']; list.forEach(function (p, i) { lines.push((i + 1) + '. ' + p.title, ' Item Code: ' + p.sku, ' Quantity: ' + p.qty, ' Notes: ' + (p.note || 'None')); }); lines.push('', 'PROJECT NOTES', project && project.value.trim() ? project.value.trim() : 'None', '', 'Requested via Emerald Quick Ship Pre-Owned Furniture. Pricing and inventory are subject to confirmation.'); var href = 'mailto:' + encodeURIComponent(to) + '?subject=' + encodeURIComponent('Pre-Owned Furniture Quote Request - ' + f.company) + '&body=' + encodeURIComponent(lines.join('\n')); if (href.length > 1800) { status.textContent = 'This request is too long for some email apps. Shorten the notes or email ' + to + ' directly.'; return; } status.textContent = 'Opening your email app addressed to ' + to + '. Click Send there to submit your request.'; window.location.href = href; } /* ---------------- quick view ---------------- */ function quickView(p) { var previous = document.activeElement; var overlay = el('div', 'eqs-po-qv'), panel = el('section', 'eqs-po-qvpanel'); panel.setAttribute('role', 'dialog'); panel.setAttribute('aria-modal', 'true'); panel.setAttribute('aria-label', 'Product details: ' + p.title); var closeB = el('button', 'eqs-po-qvclose', '×'); closeB.type = 'button'; closeB.setAttribute('aria-label', 'Close product details'); function dismiss() { document.removeEventListener('keydown', keys, true); overlay.remove(); if (previous && previous.isConnected) previous.focus(); } function keys(e) { if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); dismiss(); } } closeB.addEventListener('click', dismiss); overlay.addEventListener('click', function (e) { if (e.target === overlay) dismiss(); }); var grid = el('div', 'eqs-po-qvgrid'), gallery = el('div'), detail = el('div'), main = el('img', 'eqs-po-qvimg'); main.alt = p.title; var urls = [p.image].concat(p.additionalImages || []).map(safeImage).filter(Boolean).filter(function (v, i, a) { return a.indexOf(v) === i; }); if (urls.length) { main.src = urls[0]; gallery.appendChild(main); } else gallery.appendChild(el('p', 'eqs-po-muted', 'No image available')); if (urls.length > 1) { var thumbs = el('div', 'eqs-po-thumbs'); urls.forEach(function (url, i) { var b = el('button'); b.type = 'button'; b.setAttribute('aria-label', 'View photo ' + (i + 1)); b.setAttribute('aria-pressed', String(i === 0)); var t = el('img'); t.src = url; t.alt = ''; b.appendChild(t); b.addEventListener('click', function () { main.src = url; thumbs.querySelectorAll('button').forEach(function (x) { x.setAttribute('aria-pressed', String(x === b)); }); }); thumbs.appendChild(b); }); gallery.appendChild(thumbs); } var tag = el('span', 'eqs-po-tag', 'Pre-Owned'); detail.append(tag, el('h2', '', p.title), el('p', '', 'Item Code: ' + p.sku), el('p', '', p.quantity > 0 ? p.quantity + ' reported available' : 'Check availability')); detail.appendChild(el('div', 'eqs-po-qvdesc', p.description || 'No additional description available.')); detail.appendChild(el('p', 'eqs-po-muted', 'Pre-owned inventory is subject to confirmation. Request a quote for pricing and availability.')); var addB = el('button', 'eqs-po-add'); addB.type = 'button'; addB.append(svg(ICON_QUOTE), document.createTextNode('Add to Quote')); addB.addEventListener('click', function () { dismiss(); add(p); }); detail.appendChild(addB); grid.append(gallery, detail); panel.append(closeB, grid); overlay.appendChild(panel); document.body.appendChild(overlay); document.addEventListener('keydown', keys, true); closeB.focus(); } /* ---------------- page ---------------- */ // Brand detection: [display name, regex tested against the title, then the description] var BRANDS = [ ['Herman Miller', /Herman Mill+er|\bAeron\b|\bEames\b(?! Style)|\bCaper\b|\bMirra\b|\bVerus\b|\bEmbody\b|\bSayl\b|\bCosm\b|UM Keys|LL Keys/], ['Steelcase', /Steelca?s?e|\bSteelcae\b|\bQiVi\b|\bThink (Chair|V2)|\bLeap\b|\bAmia\b|\bCriterion\b|\bProtege\b|\bBrody\b|\bGesture\b|\bCobi\b|\bAvenir\b|\bAnswer\b|\bB\/F\b|\bOlogy\b|\bScoop\b|XF Keys/], ['Knoll', /\bKnoll\b|\bGeneration (Office )?Chairs?\b|\bCalibre\b|K Keys/], ['Haworth', /\bHaworth\b|\bZody\b|\bImprov\b|SL Keys/], ['Coalesse', /\bCoalesse\b/], ['Allsteel', /\bAllsteel\b|\bAcuity\b/], ['Gunlocke', /\bGunlocke\b/], ['Bernhardt', /\bBernhardt\b/], ['HBF', /\bHBF\b/], ['Humanscale', /\bHumanscale\b/], ['Keilhauer', /\bKeilhaue?r\b/], ['Vitra', /\bVitra\b/], ['Geiger', /\bGeiger\b/], ['Andreu World', /Andreu World/], ['Allermuir', /\bAll[e]r?muir\b|\bAllemuir\b/], ['Allseating', /\bAllseating\b/], ['Hightower', /\bHightower\b/], ['Davis', /^Davis\b/], ['Teknion', /\bTeknion\b/], ['OFS', /\bOFS\b/], ['Paoli', /\bPaoli\b/], ['SitOnIt', /\bSit ?On ?It\b/i], ['Global', /^Global\b/], ['Lesro', /\bLesro\b/], ['FireKing', /\bFireKing\b/], ['Framery', /\bFramery\b/], ['Innovant', /\bInnovant\b/], ['Actiu', /\bActiu\b/], ['Normann Copenhagen', /\bNorm+an+ Copenhagen\b/], ['Blu Dot', /\bBlu[ -]Dot\b/], ['Stellar Works', /Stellar Works/], ['Walter Knoll', /\bWalter K\b/], ['Arper', /\bArper\b/], ['Stua', /\bStua\b/], ['Falcon', /^Falcon\b/], ['Wilkhahn', /\bWilkhahn\b/], ['Dauphin', /\bDauphin\b/], ['Gateway', /^Gateway\b/], ['Offices To Go', /Offices To Go/], ['Restoration Hardware', /Restoration Hardware|^RH\b/], ['Room & Board', /Room (&|and) Board/], ['Frigidaire', /\bFrigidaire\b/], ['Muuto', /\bMuuto\b/], ['West Elm', /West Elm/], ['Stylex', /\bStylex\b/], ['Leland', /\bLeland\b/], ['Indiana Furniture', /Indiana Furniture/], ['National', /National Business Furniture/], ['Nucraft', /\bNucraft\b/], ['Prince Seating', /Prince Seating/], ['Izzy+', /\bIzzy\b/], ['Source International', /Source International/], ['Estel', /\bEstel\b/], ['Cassina', /\bCassina\b/], ['Fritz Hansen', /Fritz Hansen/], ['B&B Italia', /B&B Italia/], ['Artek', /\bArtek\b/], ['Nienkamper', /Nienk(ä|a)mper/], ['Swedese', /\bSwedese\b/], ['Holly Hunt', /Holly Hunt/], ['Meridian', /\bMeridian\b/], ['Logiflex', /\bLogiflex\b/], ['Office Specialty', /Office Specialty/], ['BuzziSpace', /\bBuzzi/], ['Studio TK', /Studio TK/], ['Beaufurn', /\bBeaufurn\b/], ['Cabot Wrenn', /Cabot Wrenn/], ['Cartwright', /\bCartwright\b/], ['Highmark', /\bHighmark\b/], ['NORR11', /\bNORR11\b/], ['Cappellini', /\bCapp?all?in+i\b/], ['Crassevig', /\bCrassevig\b/], ['Datesweiser', /DatesWeiser/i], ['Minotti', /\bMinoti\b|\bMinotti\b/], ['Innovation Living', /Innovation Living/], ['AIS', /^AIS\b/], ['GE Monogram', /GE Monogram/], ['Whirlpool', /\bWhirlpool\b/], ['Traulsen', /\bTraulsen\b/], ['Summit', /^Summit\b/], ['Marvel', /^Marvel\b/], ['Cybex', /\bCybex\b/] ]; var DESC_SKIP = /^(Global|Davis|Falcon|Summit|Marvel|AIS|National|Estel|Gateway|Meridian|Leland|Highmark|Cartwright|Stua|Izzy\+)$/; function reEsc(x) { return x.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); } // Brand from the title first (names and well-known product lines), then a plain brand-name mention in the description function brandOf(o) { var i, b; for (i = 0; i !== BRANDS.length; i++) { if (BRANDS[i][1].test(o.title)) return BRANDS[i][0]; } for (i = 0; i !== BRANDS.length; i++) { b = BRANDS[i][0]; if (!DESC_SKIP.test(b) && new RegExp('\\b' + reEsc(b) + '\\b').test(o.description)) return b; } return ''; } var BRAND_TOP = 12; var root, grid, found, moreBtn, catBox, brandBox, stockBtn, findInput; function mountPoint() { var nf = document.querySelector('.noprodutctfound'); var sec = (nf && nf.closest('section')) || document.querySelector('section.catalog-grid'); return sec || null; } function build() { if (document.getElementById('eqs-po-root')) return true; var sec = mountPoint(); if (!sec) return false; addStyle(); setupDrawer(); root = el('div', 'eqs-po'); root.id = 'eqs-po-root'; // Title: the Quick Ship nav script wraps this in its title panel ("Quick Ship Pre-Owned Furniture") var h1 = el('h1', 'catalog-name', 'Pre-Owned Furniture'); root.appendChild(h1); var layout = el('div', 'eqs-po-layout'), side = el('aside', 'eqs-po-side'), main = el('div', 'eqs-po-main'); side.appendChild(el('div', 'eqs-po-side-head', 'Filter Products')); var clear = el('button', 'eqs-po-clear', 'Clear Filters'); clear.type = 'button'; side.appendChild(clear); var find = el('div', 'eqs-po-find'); findInput = el('input'); findInput.type = 'search'; findInput.placeholder = 'Search pre-owned by brand, product type, or feature'; findInput.setAttribute('aria-label', 'Search pre-owned furniture'); find.appendChild(findInput); catBox = el('div', 'eqs-po-sec'); catBox.appendChild(el('h5', '', 'Category')); side.appendChild(catBox); brandBox = el('div', 'eqs-po-sec eqs-po-brands'); brandBox.appendChild(el('h5', '', 'Brand')); side.appendChild(brandBox); var stockSec = el('div', 'eqs-po-sec'); stockSec.appendChild(el('h5', '', 'Availability')); stockBtn = el('button', 'eqs-po-opt'); stockBtn.type = 'button'; stockBtn.setAttribute('aria-pressed', 'false'); stockBtn.append(el('span', 'eqs-po-optname', 'Reported in stock'), el('span', 'eqs-po-optcount', '')); stockSec.appendChild(stockBtn); side.appendChild(stockSec); side.appendChild(el('div', 'eqs-po-note', 'Quantities are reported by our partner and subject to confirmation.')); var bar = el('div', 'eqs-po-bar'); found = el('div', 'eqs-po-found'); var tools = el('div', 'eqs-po-tools'), sortLab = el('label', '', 'Sort by'), sort = el('select'); sortLab.setAttribute('for', 'eqs-po-sort'); sort.id = 'eqs-po-sort'; [['featured', 'Featured'], ['avail', 'Most Available'], ['az', 'Name A to Z']].forEach(function (o) { var op = el('option', '', o[1]); op.value = o[0]; sort.appendChild(op); }); var openList = el('button', 'eqs-po-openlist'); openList.type = 'button'; openList.append(svg(ICON_QUOTE), document.createTextNode('View Quote List ('), el('span', 'eqs-po-count', '0'), document.createTextNode(')')); openList.addEventListener('click', openDrawer); tools.append(sortLab, sort, openList); bar.append(found, find, tools); grid = el('div', 'eqs-po-grid'); moreBtn = el('button', 'eqs-po-more', 'Show More Products'); moreBtn.type = 'button'; moreBtn.style.display = 'none'; main.append(bar, grid, moreBtn); // Use the page's own filter column (like the other Quick Ship category pages) when it is there var fc = sec.querySelector('.filter-container'); if (fc) { Array.prototype.forEach.call(fc.children, function (k) { k.classList.add('eqs-po-hidden'); }); fc.appendChild(side); root.appendChild(main); } else { layout.append(side, main); root.appendChild(layout); } var nf = document.querySelector('.noprodutctfound'); if (nf && nf.parentNode) nf.parentNode.insertBefore(root, nf); else sec.appendChild(root); var loading = el('div', 'eqs-po-msg'); loading.append(el('strong', '', 'Loading Pre-Owned Furniture'), document.createTextNode('Connecting to partner inventory...')); grid.appendChild(loading); clear.addEventListener('click', function () { state.q = ''; state.cat = ''; state.brands = []; state.stock = false; state.limit = 24; findInput.value = ''; draw(); }); findInput.addEventListener('input', function () { state.q = findInput.value.toLowerCase().trim(); state.limit = 24; draw(); }); stockBtn.addEventListener('click', function () { state.stock = !state.stock; state.limit = 24; draw(); }); sort.addEventListener('change', function () { state.sort = sort.value; state.limit = 24; draw(); }); moreBtn.addEventListener('click', function () { state.limit += 24; draw(); }); updateCount(); return true; } function buildCategories() { catBox.querySelectorAll('.eqs-po-opt').forEach(function (b) { b.remove(); }); var counts = {}; products.forEach(function (p) { counts[p.cat] = (counts[p.cat] || 0) + 1; }); CATS.filter(function (c) { return counts[c]; }).forEach(function (c) { var b = el('button', 'eqs-po-opt'); b.type = 'button'; b.dataset.cat = c; b.setAttribute('aria-pressed', 'false'); b.append(el('span', 'eqs-po-optname', c), el('span', 'eqs-po-optcount', '(' + counts[c] + ')')); // one choice at a time, like the other Quick Ship filter panels b.addEventListener('click', function () { state.cat = state.cat === c ? '' : c; state.limit = 24; draw(); }); catBox.appendChild(b); }); buildBrands(); stockBtn.querySelector('.eqs-po-optcount').textContent = '(' + products.filter(function (p) { return p.quantity > 0; }).length + ')'; } function buildBrands() { brandBox.querySelectorAll('.eqs-po-opt,.eqs-po-morebrands').forEach(function (b) { b.remove(); }); var counts = {}; products.forEach(function (p) { if (p.brand) counts[p.brand] = (counts[p.brand] || 0) + 1; }); var names = Object.keys(counts).sort(function (a, b) { return counts[b] - counts[a] || a.localeCompare(b); }); names.forEach(function (n, i) { var b = el('button', 'eqs-po-opt'); b.type = 'button'; b.dataset.brand = n; b.setAttribute('aria-pressed', 'false'); if (i >= BRAND_TOP) b.classList.add('eqs-po-extra'); b.append(el('span', 'eqs-po-optname', n), el('span', 'eqs-po-optcount', '(' + counts[n] + ')')); // several brands can be picked at once b.addEventListener('click', function () { var k = state.brands.indexOf(n); if (k === -1) state.brands.push(n); else state.brands.splice(k, 1); state.limit = 24; draw(); }); brandBox.appendChild(b); }); if (names.length > BRAND_TOP) { var m = el('button', 'eqs-po-morebrands'); m.type = 'button'; m.addEventListener('click', function () { state.showAllBrands = !state.showAllBrands; draw(); }); brandBox.appendChild(m); } } function markAdded() { var skus = list.map(function (x) { return x.sku; }); document.querySelectorAll('.eqs-po-card').forEach(function (c) { var b = c.querySelector('.eqs-po-add'), on = skus.indexOf(c.dataset.sku) !== -1; b.classList.toggle('eqs-po-added', on); b.lastChild.textContent = on ? 'Added to Quote' : 'Add to Quote'; }); } function card(p) { var c = el('article', 'eqs-po-card'); c.dataset.sku = p.sku; var imgB = el('button', 'eqs-po-img'); imgB.type = 'button'; imgB.setAttribute('aria-label', 'Quick view ' + p.title); var im = el('img'); im.alt = p.title; im.loading = 'lazy'; im.src = safeImage(p.image) || ''; imgB.appendChild(im); imgB.addEventListener('click', function () { quickView(p); }); var top = el('div', 'eqs-po-top'), avail = el('span', 'eqs-po-avail', p.quantity > 0 ? p.quantity + ' available' : 'Check availability'); if (!(p.quantity > 0)) avail.classList.add('eqs-po-out'); top.append(el('span', 'eqs-po-tag', 'Pre-Owned'), avail); var title = el('button', 'eqs-po-title', p.title); title.type = 'button'; title.title = p.title; title.addEventListener('click', function () { quickView(p); }); var sku = el('div', 'eqs-po-sku'); sku.append(el('b', '', 'Item Code: '), document.createTextNode(p.sku)); var desc = el('div', 'eqs-po-desc', p.description || ''); var det = el('button', 'eqs-po-details'); det.type = 'button'; det.append(svg(ICON_PHOTO), document.createTextNode('View Details & Photos')); det.setAttribute('aria-label', 'View details and photos for ' + p.title); det.addEventListener('click', function () { quickView(p); }); var addB = el('button', 'eqs-po-add'); addB.type = 'button'; addB.append(svg(ICON_QUOTE), document.createTextNode('Add to Quote')); addB.addEventListener('click', function () { add(p); }); c.append(imgB, top, title, sku, desc, det, addB); return c; } function draw() { if (!grid) return; var q = state.q; var rows = products.filter(function (p) { return (!q || (p.title + ' ' + p.brand + ' ' + p.sku + ' ' + p.description).toLowerCase().indexOf(q) !== -1) && (!state.brands.length || state.brands.indexOf(p.brand) !== -1) && (!state.cat || p.cat === state.cat) && (!state.stock || p.quantity > 0); }); if (state.sort === 'avail') rows = rows.slice().sort(function (a, b) { return b.quantity - a.quantity; }); if (state.sort === 'az') rows = rows.slice().sort(function (a, b) { return a.title.localeCompare(b.title); }); found.replaceChildren(el('b', '', rows.length), document.createTextNode(' items found')); catBox.querySelectorAll('.eqs-po-opt').forEach(function (b) { b.setAttribute('aria-pressed', String(b.dataset.cat === state.cat)); }); stockBtn.setAttribute('aria-pressed', String(state.stock)); brandBox.classList.toggle('eqs-po-allbrands', state.showAllBrands); brandBox.querySelectorAll('.eqs-po-opt').forEach(function (b) { b.setAttribute('aria-pressed', String(state.brands.indexOf(b.dataset.brand) !== -1)); }); var mb = brandBox.querySelector('.eqs-po-morebrands'); if (mb) mb.textContent = state.showAllBrands ? 'Show fewer brands' : 'Show all ' + brandBox.querySelectorAll('.eqs-po-opt').length + ' brands'; grid.replaceChildren(); if (!rows.length) { var m = el('div', 'eqs-po-msg'); m.append(el('strong', '', 'No matching products'), document.createTextNode('Try another search or clear the filters.')); grid.appendChild(m); } rows.slice(0, state.limit).forEach(function (p) { grid.appendChild(card(p)); }); moreBtn.style.display = rows.length > state.limit ? 'block' : 'none'; markAdded(); updateCount(); } function load() { fetch(FEED_URL, { mode: 'cors' }).then(function (r) { if (!r.ok) throw Error('HTTP ' + r.status); return r.json(); }).then(function (data) { if (!data || !Array.isArray(data.posts)) throw Error('Missing posts array'); products = data.posts.map(function (p) { var o = { title: txt(p.title), sku: String(p.sku || '').trim(), quantity: Math.max(0, Number(p.quantity) || 0), description: txt(p.description), image: imgUrl(p.featured_image), additionalImages: extraImages(p.additional_images) }; o.cat = category(o); o.brand = brandOf(o); return o; }).filter(function (p) { return p.sku && p.title; }); buildCategories(); draw(); }).catch(function (e) { console.warn('[EQS PRE-OWNED] feed load failed', e); if (grid) { grid.replaceChildren(); var m = el('div', 'eqs-po-msg'); m.append(el('strong', '', 'Pre-owned inventory is temporarily unavailable'), document.createTextNode('Please refresh the page or contact ' + FALLBACK_QUOTE_EMAIL + '.')); grid.appendChild(m); } }); } function start() { if (build()) { load(); return; } var tries = 0, t = setInterval(function () { tries++; if (build()) { clearInterval(t); load(); } else if (tries > 40) clearInterval(t); }, 250); } window.EQS_PO = { active: true, version: VERSION, open: openDrawer, status: function () { return { version: VERSION, products: products.length, cards: document.querySelectorAll('.eqs-po-card').length, quoteItems: count() }; } }; if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true }); else start(); })();