@@ -1776,6 +1776,54 @@ <h5>Hazard Information</h5>
17761776 el.classList.toggle('htxt-two-col', twoCol);
17771777};
17781778
1779+ // GHS H-statement priority (1 = most critical, 3 = least critical)
1780+ const H_STMT_PRIORITY = (() => {
1781+ const p = {};
1782+ // Priority 1 — fatal acute toxicity, carcinogen/mutagen/repro Cat 1, physical hazards, STOT Cat 1
1783+ [200,201,202,203,204,205,206,207,208,209,210,211,212,
1784+ 220,221,222,223,224,225,226,228,229,230,231,232,
1785+ 240,241,242,250,251,252,260,261,270,271,272,
1786+ 280,281,282,283,284,290,
1787+ 300,301,310,311,330,331,340,350,360,370,372
1788+ ].forEach(n => p[n] = 1);
1789+ // Priority 2 — harmful acute toxicity, serious health effects, aspiration, corrosion
1790+ [302,304,312,314,318,332,334,341,351,361,371,373,400,410
1791+ ].forEach(n => p[n] = 2);
1792+ // Priority 3 — irritation, sensitization, mild/environmental
1793+ [303,313,315,316,317,319,320,333,335,336,362,411,412,413,420
1794+ ].forEach(n => p[n] = 3);
1795+ return p;
1796+ })();
1797+
1798+ function setStickerHazard(hazText) {
1799+ const el = $('s-lbl-hazard');
1800+ if (!el) return;
1801+ if (!hazText) { el.innerHTML = ''; return; }
1802+ const fmt = line => {
1803+ const esc = line.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
1804+ return esc.replace(/^([^–\-\n]*[–-])/, '<strong>$1</strong>');
1805+ };
1806+ const getPriority = line => {
1807+ const m = line.match(/H(\d{3})/i);
1808+ return m ? (H_STMT_PRIORITY[parseInt(m[1])] || 2) : 2;
1809+ };
1810+ const lines = hazText.split('\n').filter(l => l.trim());
1811+ lines.sort((a, b) => getPriority(a) - getPriority(b));
1812+ // Render all lines and let fitText shrink font to 5pt minimum
1813+ el.innerHTML = lines.map(l => `<div class="htxt-line">${fmt(l)}</div>`).join('');
1814+ fitText(el, 5);
1815+ // If still overflowing at 5pt, drop lowest-priority lines until it fits
1816+ if (el.scrollHeight > el.clientHeight + 1) {
1817+ let shown = lines.slice();
1818+ while (shown.length > 1) {
1819+ shown.pop();
1820+ el.innerHTML = shown.map(l => `<div class="htxt-line">${fmt(l)}</div>`).join('') +
1821+ '<div class="htxt-line" style="font-style:italic;color:#555;font-size:5pt">See SDS for complete hazard list</div>';
1822+ if (el.scrollHeight <= el.clientHeight + 1) break;
1823+ }
1824+ }
1825+ }
1826+
17791827function update() {
17801828 // Product
17811829 const productName = $('f-product').value.trim();
@@ -1885,7 +1933,7 @@ <h5>Hazard Information</h5>
18851933 $('f-addppe').placeholder = autoAddl || 'None';
18861934
18871935 // Hazard + precautionary text (combined in compact space)
1888- setHazard('s-lbl-hazard', $('f-hazard').value);
1936+ setStickerHazard( $('f-hazard').value);
18891937
18901938 // Auto-fit text in space-constrained boxes
18911939 fitText($('lbl-product'), 11);
@@ -1904,7 +1952,7 @@ <h5>Hazard Information</h5>
19041952 fitText(el, 5);
19051953 el.style.height = '';
19061954 })();
1907- fitText($('s-lbl-hazard'), 4 );
1955+ fitText($('s-lbl-hazard'), 5 );
19081956
19091957 // Balance hazard/first-aid columns, render hazard, fit both, sync font sizes
19101958 balanceBottomStrip();
0 commit comments