Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function renderResults(report) {
if (typeof window !== 'undefined') window.VinWorkspace?.reportUpdated(report);
window.ReportTabs?.reportUpdated(report); // tab bar over the report (public/report-tabs.js)
window.Market?.render(report); // Price tab: local asking prices and cars for sale (public/market.js)
window.TiresTab?.render(report); // Tires tab: size and pressures up top (public/tires-tab.js)
}

// ── Hero ──
Expand Down
7 changes: 5 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

<link rel="stylesheet" href="/style.css?v=13c097d98bdb">
<link rel="stylesheet" href="/research/research.css?v=4f6e097847a7">
<link rel="stylesheet" href="/market.css?v=39fb69054e3e">
<link rel="stylesheet" href="/market.css?v=4326c0a5b8ec">

</head>
<body class="workspace"><a class="skip-link" href="#main">Skip to workspace</a>
Expand Down Expand Up @@ -129,11 +129,14 @@
<div class="report-tabs" role="tablist" aria-label="Report sections">
<button type="button" role="tab" id="tab-sheet" data-report-tab="sheet" aria-selected="true">Overview</button>
<button type="button" role="tab" id="tab-price" data-report-tab="price" aria-selected="false" tabindex="-1">Price<span id="tab-price-figure" class="tab-figure" hidden></span></button>
<button type="button" role="tab" id="tab-tires" data-report-tab="tires" aria-selected="false" tabindex="-1">Tires</button>
<button type="button" role="tab" id="tab-safety" data-report-tab="safety" aria-selected="false" tabindex="-1">Safety<span id="tab-safety-figure" class="tab-figure" hidden></span></button>
<button type="button" role="tab" id="tab-specs" data-report-tab="specs" aria-selected="false" tabindex="-1">Specs</button>
<button type="button" role="tab" id="tab-all" data-report-tab="all" aria-selected="false" tabindex="-1">All</button>
</div>
</div>
<!-- Tires tab: figures above the sheet's own tire section (public/tires-tab.js) -->
<div id="tires-quick" class="tires-quick"></div>
<!-- Car information sheet: one printable page that opens the report (public/car-sheet.js) -->
<article id="car-sheet" class="car-sheet" aria-labelledby="vehicle-title">
<section id="vehicle-hero" class="vehicle-hero sheet-head">
Expand Down Expand Up @@ -456,4 +459,4 @@ <h2 id="settings-title" class="modal-title">Report Settings</h2>
</div>
</div>

<div id="label-modal" class="modal-overlay" hidden><div class="modal" role="dialog" aria-modal="true" aria-labelledby="label-title"><button class="modal-close" id="label-close" type="button" aria-label="Close vehicle label">×</button><h2 id="label-title">Save vehicle</h2><p class="modal-desc" id="label-vin"></p><form id="label-form" class="modal-form"><label>Vehicle label (optional)<input id="vehicle-label" maxlength="200" placeholder="e.g. Family car"></label><p id="label-details" class="small" hidden></p><p id="label-error" class="form-error" role="alert" hidden></p><button type="submit" id="label-submit">Save vehicle</button></form></div></div><div id="delete-modal" class="modal-overlay" hidden><div class="modal" role="dialog" aria-modal="true" aria-labelledby="delete-title"><button class="modal-close" id="delete-close" type="button" aria-label="Close delete account">×</button><h2 id="delete-title">Delete account</h2><p class="modal-desc">This removes your account, saved vehicles and report settings from mcp.vin. It cannot be undone. See the <a href="/privacy/">privacy policy</a>.</p><form id="delete-form" class="modal-form"><label>Password<input id="delete-password" type="password" autocomplete="current-password" required></label><p id="delete-error" class="form-error" role="alert" hidden></p><button type="submit" id="delete-submit">Delete my account</button></form></div></div><div id="toast-container" class="toast-container" role="status" aria-live="polite"></div><script src="/qr.js?v=c715df5c8314"></script><script src="/decode-checks.js?v=247d1255df23"></script><script src="/car-sheet.js?v=978d36ddee3c"></script><script src="/test-vehicle.js?v=f28729b33f39"></script><script src="/more-sources.js?v=176842a973b6"></script><script src="/owner-details.js?v=bb2cee1f7257"></script><script src="/report-tabs.js?v=db79a6491736"></script><script src="/market.js?v=efcbe65bf051"></script><script src="/app.js?v=af9cb17b501d"></script><script type="module" src="/research/research.js?v=81d65af2b9f6"></script><script src="/workspace.js?v=7f8cd6b32bc7"></script></body></html>
<div id="label-modal" class="modal-overlay" hidden><div class="modal" role="dialog" aria-modal="true" aria-labelledby="label-title"><button class="modal-close" id="label-close" type="button" aria-label="Close vehicle label">×</button><h2 id="label-title">Save vehicle</h2><p class="modal-desc" id="label-vin"></p><form id="label-form" class="modal-form"><label>Vehicle label (optional)<input id="vehicle-label" maxlength="200" placeholder="e.g. Family car"></label><p id="label-details" class="small" hidden></p><p id="label-error" class="form-error" role="alert" hidden></p><button type="submit" id="label-submit">Save vehicle</button></form></div></div><div id="delete-modal" class="modal-overlay" hidden><div class="modal" role="dialog" aria-modal="true" aria-labelledby="delete-title"><button class="modal-close" id="delete-close" type="button" aria-label="Close delete account">×</button><h2 id="delete-title">Delete account</h2><p class="modal-desc">This removes your account, saved vehicles and report settings from mcp.vin. It cannot be undone. See the <a href="/privacy/">privacy policy</a>.</p><form id="delete-form" class="modal-form"><label>Password<input id="delete-password" type="password" autocomplete="current-password" required></label><p id="delete-error" class="form-error" role="alert" hidden></p><button type="submit" id="delete-submit">Delete my account</button></form></div></div><div id="toast-container" class="toast-container" role="status" aria-live="polite"></div><script src="/qr.js?v=c715df5c8314"></script><script src="/decode-checks.js?v=247d1255df23"></script><script src="/car-sheet.js?v=978d36ddee3c"></script><script src="/test-vehicle.js?v=f28729b33f39"></script><script src="/more-sources.js?v=176842a973b6"></script><script src="/owner-details.js?v=bb2cee1f7257"></script><script src="/report-tabs.js?v=44fd8090c511"></script><script src="/market.js?v=efcbe65bf051"></script><script src="/tires-tab.js?v=0504b64a7f08"></script><script src="/app.js?v=e460b8473fa2"></script><script type="module" src="/research/research.js?v=81d65af2b9f6"></script><script src="/workspace.js?v=7f8cd6b32bc7"></script></body></html>
28 changes: 24 additions & 4 deletions public/market.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,34 @@
.market{margin:20px 0 36px}
@media screen{
#results[data-tab=sheet] .report-nav-title{display:none}
#results:not([data-tab=sheet]) #car-sheet{display:none}
#results:not([data-tab=sheet],[data-tab=tires]) #car-sheet{display:none}
/* Tires tab: the sheet's own tire section alone, under the figures (public/tires-tab.js) */
#results:not([data-tab=tires]) #tires-quick{display:none}
#results[data-tab=tires] #car-sheet>.sheet-head,#results[data-tab=tires] #car-sheet>.sheet-foot,#results[data-tab=tires] .sheet-body>.sheet-section:not(.sheet-tires){display:none}
#results[data-tab=tires] .sheet-body{display:block}
#results[data-tab=tires] .sheet-tires>h3{display:none}
#results[data-tab=tires] .car-sheet{margin-top:16px}
#results:not([data-tab=price]) #market-panel{display:none}
#results[data-tab=sheet] .cards-grid,#results[data-tab=price] .cards-grid{display:none}
#results[data-tab=sheet] .cards-grid,#results[data-tab=price] .cards-grid,#results[data-tab=tires] .cards-grid{display:none}
#results .car-sheet{margin-top:20px}
#results .cards-grid{margin-top:20px}
#results[data-tab=safety] .cards-grid>.card:not(#card-recalls,#card-safety-ratings,#card-complaints,#card-safety-equip){display:none}
#results[data-tab=safety] .cards-grid>.card{grid-column:1/-1}
#results[data-tab=safety] #card-recalls{order:-1}
#results[data-tab=specs] .cards-grid>.card:is(#card-recalls,#card-safety-ratings,#card-complaints,#card-safety-equip,#card-raw){display:none}
}
@media print{.report-nav,#market-panel{display:none!important}}
@media print{.report-nav,#market-panel,#tires-quick{display:none!important}}

/* ── Tires tab: figures ── */
.tires-quick{margin:20px 0 0}
.tires-quick .eyebrow{margin-bottom:10px}
.tires-tiles{grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr)}
.tires-tiles .market-tile-main b{font-size:clamp(19px,5.4vw,28px);letter-spacing:-.4px;overflow-wrap:anywhere}
.tires-tiles b.tires-two{font-size:18px}
.tires-basis{margin:10px 2px 0;font-size:12px;line-height:1.6;color:var(--text-muted);max-width:760px}
.tires-basis strong{color:var(--text-dim);font-weight:650}
.tires-basis-near{color:var(--orange)}
.tires-basis-near strong{color:var(--orange)}

/* ── Price tab ── */
.market-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;flex-wrap:wrap;margin-bottom:16px}
Expand Down Expand Up @@ -112,7 +129,10 @@
@media(max-width:560px){
.report-nav{margin:14px -16px 0;padding:6px 16px 0}
.report-tabs{margin:0 -16px;padding:0 10px}
.report-tabs button{padding:10px 10px;font-size:13.5px}
.report-tabs button{padding:10px 7px;font-size:13px}
.tab-figure{padding:2px 6px}
.tires-tiles{grid-template-columns:1fr 1fr}
.tires-tiles .market-tile-main{grid-column:1/-1}
.market-head{align-items:stretch;flex-direction:column;gap:12px}
.market-form label{flex:1 1 0}
.market-form input{width:100%}
Expand Down
4 changes: 2 additions & 2 deletions public/report-tabs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Tabs over the VIN report: Overview (the car sheet), Price, Safety, Specs, All data.
/* Tabs over the VIN report: Overview (the car sheet), Price, Tires, Safety, Specs, All.
* One attribute does the work: #results[data-tab]. The style sheet (market.css) shows the matching view on screen;
* print ignores the tabs and prints the full report as before. The choice is kept in the address as ?tab=price,
* because the #hash already names the workspace view. */
const ReportTabs = (() => {
const TABS = ['sheet', 'price', 'safety', 'specs', 'all'];
const TABS = ['sheet', 'price', 'tires', 'safety', 'specs', 'all'];
const listeners = [];
let current = 'sheet';

Expand Down
43 changes: 43 additions & 0 deletions public/tires-tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Tires tab: the quick view above the car sheet's own "Tires and wheels" section.
* The tab shows that section alone (market.css), so its wording, write-in blanks and correction form are the same
* ones as on the sheet. This file adds only the figures up top: tire size and cold pressures of the closest vehicle
* NHTSA tested (report field tire_placard), with how it matches this VIN. The owner's door placard governs. */
const TiresTab = (() => {
const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
const same = v => JSON.stringify([v.tires, v.cold_pressure_psi, v.cold_pressure_kpa]);
const kpa = n => Number.isInteger(n) ? String(n) : String(Math.round(n * 10) / 10);

/** One short sentence on how the tested vehicle matches this VIN; the full wording is in the section below. */
function basisText(group) {
const m = group[0].match || {};
if (!m.kind || m.kind === 'exact') return 'From the vehicle NHTSA tested for this model year.';
if (m.kind === 'different_variant') return 'From a different version NHTSA tested for this model year.';
const years = [...new Set(group.map(x => x.match && x.match.tested_model_year).filter(Boolean))].sort();
return `From NHTSA’s ${years.join(' and ')} test vehicle${years.length > 1 ? 's' : ''}; yours is ${m.vin_model_year}.`;
}

/** The figures block, or '' when NHTSA's test vehicles give no values for this VIN. `tested` = CarSheet.testedPlacards(). */
function quickHtml(tested) {
if (!tested || !tested.length) return '';
const v = tested[0], group = tested.filter(x => same(x) === same(v));
const others = new Set(tested.map(same)).size - 1;
const exact = group.every(x => !x.match || x.match.kind === 'exact');
const size = v.tires.front === v.tires.rear
? `<b>${esc(v.tires.front)}</b><small>front and rear</small>`
: `<b class="tires-two">${esc(v.tires.front)}</b><small>front</small><b class="tires-two">${esc(v.tires.rear)}</b><small>rear</small>`;
const psi = (label, side) => `<div class="market-tile"><span>${label}, cold</span><b>${esc(v.cold_pressure_psi[side])} psi</b><small>${esc(kpa(v.cold_pressure_kpa[side]))} kPa</small></div>`;
return `<div class="market-tiles tires-tiles"><div class="market-tile market-tile-main"><span>Tire size</span>${size}</div>${psi('Front', 'front')}${psi('Rear', 'rear')}</div>
<p class="tires-basis${exact ? '' : ' tires-basis-near'}"><strong>${esc(basisText(group))}</strong> Your door placard governs.${others > 0 ? ` ${others} other tested version${others > 1 ? 's list' : ' lists'} different values below.` : ''}</p>`;
}

function render(report) {
const box = typeof document !== 'undefined' && document.querySelector('#tires-quick');
if (!box) return;
const sheet = typeof window !== 'undefined' && window.CarSheet;
const html = sheet ? quickHtml(sheet.testedPlacards(report?.tire_placard)) : '';
box.innerHTML = `<p class="eyebrow">TIRES</p>${html || '<p class="tires-basis">No tire values from an NHTSA test vehicle for this car. The sizes and pressures are on the placard on the driver’s door pillar.</p>'}`;
}

return { basisText, quickHtml, render };
})();
if (typeof window !== 'undefined') window.TiresTab = TiresTab;
29 changes: 25 additions & 4 deletions tests/market.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ test('Price tab: outage and empty answers say so plainly', () => {

test('report tabs: the tab lives in ?tab= and Overview is the default', () => {
const T = page('report-tabs.js', 'ReportTabs');
assert.deepEqual([...T.TABS], ['sheet', 'price', 'safety', 'specs', 'all']);
assert.deepEqual([...T.TABS], ['sheet', 'price', 'tires', 'safety', 'specs', 'all']);
assert.equal(T.fromSearch('?tab=price'), 'price');
assert.equal(T.fromSearch('?tab=nonsense'), 'sheet');
assert.equal(T.fromSearch(''), 'sheet');
Expand All @@ -110,10 +110,31 @@ test('report tabs: the tab lives in ?tab= and Overview is the default', () => {

test('report page: tab bar, price panel and their scripts are in place; print still shows the whole report', () => {
const html = readFileSync(new URL('../public/index.html', import.meta.url), 'utf8');
for (const tab of ['sheet', 'price', 'safety', 'specs', 'all']) assert.ok(html.includes(`data-report-tab="${tab}"`), tab);
for (const tab of ['sheet', 'price', 'tires', 'safety', 'specs', 'all']) assert.ok(html.includes(`data-report-tab="${tab}"`), tab);
assert.ok(html.includes('id="market-panel"'));
assert.ok(html.indexOf('/report-tabs.js') < html.indexOf('/app.js') && html.indexOf('/market.js') < html.indexOf('/app.js'));
const css = readFileSync(new URL('../public/market.css', import.meta.url), 'utf8');
assert.match(css, /@media screen\{[\s\S]*#results:not\(\[data-tab=sheet\]\) #car-sheet\{display:none\}/); // hiding is screen-only
assert.match(css, /@media print\{\.report-nav,#market-panel\{display:none!important\}\}/);
assert.match(css, /@media screen\{[\s\S]*#results:not\(\[data-tab=sheet\],\[data-tab=tires\]\) #car-sheet\{display:none\}/); // hiding is screen-only
assert.match(css, /@media print\{\.report-nav,#market-panel,#tires-quick\{display:none!important\}\}/);
assert.ok(html.includes('id="tires-quick"') && html.indexOf('/tires-tab.js') < html.indexOf('/app.js'));
});

test('Tires tab: figures come from the closest NHTSA test vehicle, with the match stated and the placard governing', () => {
const T = page('tires-tab.js', 'TiresTab');
const v = {tested_as: '2019 Honda CR-V AWD LX 5-Door MPV', tires: {front: 'P235/65R17 104H', rear: 'P235/65R17 104H'},
cold_pressure_psi: {front: 32, rear: 30}, cold_pressure_kpa: {front: 220, rear: 210}, match: {kind: 'nearest_model_year', tested_model_year: 2019, vin_model_year: 2021}};
const html = T.quickHtml([v]);
assert.match(html, /Tire size<\/span><b>P235\/65R17 104H<\/b><small>front and rear/);
assert.match(html, /Front, cold<\/span><b>32 psi<\/b><small>220 kPa/);
assert.match(html, /Rear, cold<\/span><b>30 psi<\/b><small>210 kPa/);
assert.match(html, /tires-basis-near"><strong>From NHTSA’s 2019 test vehicle; yours is 2021\.<\/strong> Your door placard governs\./); // a mismatch is stated and marked
const exact = T.quickHtml([{...v, match: {kind: 'exact'}}]);
assert.doesNotMatch(exact, /tires-basis-near/);
assert.match(exact, /From the vehicle NHTSA tested for this model year\./);
assert.match(T.quickHtml([{...v, match: {kind: 'different_variant'}}]), /tires-basis-near"><strong>From a different version NHTSA tested for this model year\./);
const staggered = {...v, tested_as: 'Another version', tires: {front: '245/40R19 98Y', rear: '275/35R19 <100Y>'}, cold_pressure_psi: {front: 35, rear: 38}};
const two = T.quickHtml([staggered, v]);
assert.match(two, /245\/40R19 98Y<\/b><small>front<\/small>[\s\S]*275\/35R19 &lt;100Y&gt;<\/b><small>rear/);
assert.match(two, /1 other tested version lists different values below\./);
assert.equal(T.quickHtml([]), ''); // nothing tested: no figures, never a guess
});
Loading