/* ============================================================ ConcreteQuantity: single-page patch for 5 missing tools ------------------------------------------------------------ WHY THIS FILE EXISTS The shared V6 script only builds 12 tools. The batch 2 (P3) script does contain builders for patio, sidewalk, sonotube, countertop and sealer, but on these 5 standalone pages no calculator form renders at all (verified live 26 Oct 2026). This patch is self contained: it builds the form itself when #ccSingle is empty and window.CC_SINGLE is one of the 5 tools. It does not modify V6, P3 or P4, and it never builds a second panel if one already exists. DEPLOY CONSTRAINT (read before deploying): Do NOT also add the batch2-tools.js script tag to these 5 pages while this patch is present, or two calculator panels will render. This patch replaces P3 on these pages. MARKUP CONVENTIONS (same classes V6 uses, so the existing V6 stylesheet styles this patch with no new CSS): .cc-panel, .cc-phead, .cc-formula, .cc-grid, .cc-field, .cc-unitrow, .cc-funit, .cc-quickbtns, .cc-out, .cc-results, .cc-netwaste, .cc-nwcol, .cc-sub, .cc-working, .cc-note, .cc-actions, .cc-reset, .cc-error, .cc-empty, .wasteSel, .wasteCustom, .curSym CONSTANTS (site standards, same as V6 and P3): 27 ft3 per yd3; 80 lb bag = 0.60 ft3; 60 lb = 0.45 ft3; 40 lb = 0.30 ft3; 50 lb = 0.375 ft3 (V6/P3); 25 kg = 0.0117 m3; 20 kg = 0.0094 m3; density 150 lb/ft3 (2400 kg/m3); 1 gallon = 3.78541 litres; countertop mix 0.43 ft3 per 47 lb bag. ============================================================ */ (function(){ "use strict"; /* ---------- shared helpers (mirrors V6) ---------- */ function num(v){ v = parseFloat(v); return (isFinite(v) && v > 0) ? v : 0; } function ceilSafe(x){ return Math.ceil(x - 1e-9) || 0; } function fmt(v, d){ if(!isFinite(v)) return '0'; var s = v.toFixed(d === undefined ? 2 : d); if(s.indexOf('.') >= 0) s = s.replace(/\.?0+$/, ''); return s; } function esc(s){ return String(s).replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } var TO_FT = { ft:1, 'in':1/12, m:3.28084, cm:0.0328084, mm:0.00328084 }; var TO_IN = { 'in':1, ft:12, m:39.3701, cm:0.393701, mm:0.0393701 }; function toFt(v, u){ v = parseFloat(v); if(!isFinite(v)) return 0; return v * (TO_FT[u] || 1); } function toIn(v, u){ v = parseFloat(v); if(!isFinite(v)) return 0; return v * (TO_IN[u] || 1); } function convertVal(v, fromU, toU, kind){ v = parseFloat(v); if(!isFinite(v)) return ''; var base = (kind === 'len') ? TO_FT : TO_IN; var out = v * (base[fromU] || 1) / (base[toU] || 1); return String(Math.round(out * 10000) / 10000); } var BAG = { b80:0.60, b60:0.45, b50:0.375, b40:0.30 }; var BAGKG = { k25:0.0117, k20:0.0094 }; function bagsNeeded(ft3){ ft3 = num(ft3); return { b80:ceilSafe(ft3/BAG.b80), b60:ceilSafe(ft3/BAG.b60), b50:ceilSafe(ft3/BAG.b50), b40:ceilSafe(ft3/BAG.b40) }; } function bagsNeededM3(m3){ m3 = num(m3); return { k25:ceilSafe(m3/BAGKG.k25), k20:ceilSafe(m3/BAGKG.k20) }; } function weightLb(ft3){ return num(ft3) * 150; } function weightKg(m3){ return num(m3) * 2400; } function trucks(yd3){ return ceilSafe(num(yd3) / 10); } /* ---------- field markup (mirrors V6 fieldHTML) ---------- */ function unitSelectHTML(fieldId, kind, defUnit){ var list = (kind === 'len' || kind === 'sm') ? ['ft','in','m','cm','mm'] : (kind === 'yd3' ? ['yd3','m3','ft3'] : []); if(!list.length) return ''; var opts = ''; list.forEach(function(u){ opts += ''; }); return ''; } function fieldHTML(f){ var isDim = (f.kind === 'len' || f.kind === 'sm' || f.kind === 'yd3'); var sel = isDim ? unitSelectHTML(f.id, f.kind, f.defUnit || 'ft') : ''; var suffix = (f.kind === 'usd') ? '$' : ''; var quick = ''; if(f.quick && f.quick.length){ quick = '
'; f.quick.forEach(function(q){ quick += ''; }); quick += '
'; } var hide = f.hideShape ? ' data-hideshape="' + f.hideShape + '"' : ''; return '
' + '
' + (sel || suffix) + '
' + quick + '
'; } function wasteRowHTML(defWaste){ return '
' + '
' + '
'; } function priceFieldHTML(id, label, ph){ return '
' + '
' + '$
'; } function readWaste(panel){ var wcus = panel.querySelector('.wasteCustom'); var wv = wcus ? parseFloat(wcus.value) : NaN; if(isFinite(wv) && wv > 0) return Math.min(wv, 100); var wsel = panel.querySelector('.wasteSel'); return wsel ? (parseFloat(wsel.value) || 0) : 0; } function readVals(panel){ var vals = {}, units = {}; panel.querySelectorAll('input[data-fid]').forEach(function(inp){ var fid = inp.getAttribute('data-fid'); vals[fid] = inp.value.trim(); var sel = panel.querySelector('select.cc-funit[data-funit="' + fid + '"]'); units[fid] = sel ? sel.value : null; }); return { vals: vals, units: units }; } /* ---------- calculation cores (ported from the proven P3 implementations and checked against each page's own worked examples; see the test harness for the vectors) ---------- */ function calcPatio(o){ /* o: {l,w} ft, {dia} ft (circle), {l2,w2} ft (L piece 2), {t} in, {shape}, {slope} in per ft, {waste} %, {price} per yd3 */ var shape = o.shape || 'rect'; var area; if(shape === 'circle'){ var r = (o.dia || 0) / 2; area = Math.PI * r * r; } else if(shape === 'lshape'){ area = (o.l || 0) * (o.w || 0) + (o.l2 || 0) * (o.w2 || 0); } else { area = (o.l || 0) * (o.w || 0); } var netFt3 = area * ((o.t || 0) / 12); var w = 1 + (o.waste || 0) / 100; var wFt3 = netFt3 * w; var bags = bagsNeeded(wFt3), bagsM = bagsNeededM3(wFt3 * 0.0283168466); /* Control joints: published rule is spacing in feet 2 to 3 times the slab thickness in inches. Joint lines below are counted at the 3x (maximum) spacing, capped at 15 ft, as in P3. */ var spacing = Math.min(15, 3 * (o.t || 4)); var jointsFt = 0, jointCount = 0; if(shape === 'circle'){ jointCount = 2; jointsFt = 2 * (o.dia || 0); } else { var nL = Math.ceil((o.l || 0) / spacing) || 1, nW = Math.ceil((o.w || 0) / spacing) || 1; jointsFt = (nL - 1) * (o.w || 0) + (nW - 1) * (o.l || 0); jointCount = (nL - 1) + (nW - 1); } /* Drainage fall runs over the patio length; for a circle the diameter is the run (P3 used length only, which is 0 for a circle, so this is a deliberate, documented deviation). */ var runFt = (shape === 'circle') ? (o.dia || 0) : (o.l || 0); var dropIn = runFt * (o.slope || 0.25); return { area: area, netFt3: netFt3, netYd3: netFt3 / 27, netM3: netFt3 * 0.0283168466, wasteFt3: wFt3, wasteYd3: wFt3 / 27, wasteM3: wFt3 * 0.0283168466, bags: bags, bagsM: bagsM, bagsNet: bagsNeeded(netFt3), bagsNetM: bagsNeededM3(netFt3 * 0.0283168466), weightLb: weightLb(netFt3), weightWasteLb: weightLb(wFt3), weightKg: weightKg(netFt3 * 0.0283168466), weightWasteKg: weightKg(wFt3 * 0.0283168466), trucks: trucks(wFt3 / 27), trucksNet: trucks(netFt3 / 27), jointSpacing: spacing, jointsFt: jointsFt, jointCount: jointCount, dropIn: dropIn, cost: (o.price || 0) > 0 ? (wFt3 / 27) * (o.price || 0) : 0 }; } function calcSidewalk(o){ /* o: {l,w} ft, {t} in, {waste} %, {price} per yd3 */ var area = (o.l || 0) * (o.w || 0); var netFt3 = area * ((o.t || 0) / 12); var w = 1 + (o.waste || 0) / 100; var wFt3 = netFt3 * w; var bags = bagsNeeded(wFt3), bagsM = bagsNeededM3(wFt3 * 0.0283168466); /* Square panels: joint spacing matches the walk width. */ var joints = ceilSafe((o.l || 0) / (o.w || 1)); var meshFt2 = area * 1.10; /* 10% overlap allowance */ return { area: area, netFt3: netFt3, netYd3: netFt3 / 27, netM3: netFt3 * 0.0283168466, wasteFt3: wFt3, wasteYd3: wFt3 / 27, wasteM3: wFt3 * 0.0283168466, bags: bags, bagsM: bagsM, bagsNet: bagsNeeded(netFt3), bagsNetM: bagsNeededM3(netFt3 * 0.0283168466), weightLb: weightLb(netFt3), weightWasteLb: weightLb(wFt3), weightKg: weightKg(netFt3 * 0.0283168466), weightWasteKg: weightKg(wFt3 * 0.0283168466), joints: joints, jointSpacing: (o.w || 0), meshFt2: meshFt2, cost: (o.price || 0) > 0 ? (wFt3 / 27) * (o.price || 0) : 0 }; } function calcSonotube(o){ /* o: {dia} in, {depth} in, {n} piers, {gravel} bool (adds 6 in), {frost} in (0 = not set), {waste} %, {priceBag} per 80 lb bag. Page rule: with the gravel option on, the concrete volume is worked out over the full depth PLUS 6 in (a 48 in tube is calculated over 54 in). */ var depthIn = (o.depth || 0) + (o.gravel ? 6 : 0); var perFt3 = Math.PI * Math.pow(((o.dia || 0) / 2) / 12, 2) * (depthIn / 12); var totalFt3 = perFt3 * (o.n || 0); var w = 1 + (o.waste || 0) / 100; var wFt3 = totalFt3 * w; var bags = bagsNeeded(wFt3), bagsM = bagsNeededM3(wFt3 * 0.0283168466); return { depthIn: depthIn, perFt3: perFt3, perYd3: perFt3 / 27, totalFt3: totalFt3, totalYd3: totalFt3 / 27, totalM3: totalFt3 * 0.0283168466, wasteFt3: wFt3, wasteYd3: wFt3 / 27, wasteM3: wFt3 * 0.0283168466, bags: bags, bagsM: bagsM, weightLb: weightLb(totalFt3), weightWasteLb: weightLb(wFt3), weightKg: weightKg(totalFt3 * 0.0283168466), belowFrost: (o.frost || 0) > 0 ? (depthIn >= o.frost) : null, tubeBuyLen: depthIn + 12, /* 6 to 12 in longer for levelling; upper end */ bagCost: (o.priceBag || 0) > 0 ? bags.b80 * (o.priceBag || 0) : 0 }; } function calcCountertop(o){ /* o: {l,w} ft, {t} in, {mix} 'ct' (47 lb, 0.43 ft3) or 'std' (80 lb, 0.60 ft3), {waste} %, {priceBag} per bag */ var area = (o.l || 0) * (o.w || 0); var netFt3 = area * ((o.t || 0) / 12); var w = 1 + (o.waste || 0) / 100; var wFt3 = netFt3 * w; var isCt = (o.mix === 'ct'); var yieldFt3 = isCt ? 0.43 : 0.60; var bagLb = isCt ? 47 : 80; var bags = ceilSafe(wFt3 / yieldFt3); var weightPerFt2 = ((o.t || 0) / 12) * 150; return { area: area, netFt3: netFt3, netYd3: netFt3 / 27, netM3: netFt3 * 0.0283168466, wasteFt3: wFt3, wasteYd3: wFt3 / 27, wasteM3: wFt3 * 0.0283168466, bags: bags, bagsNet: ceilSafe(netFt3 / yieldFt3), bagLb: bagLb, yieldFt3: yieldFt3, isCt: isCt, weightLb: weightLb(netFt3), weightWasteLb: weightLb(wFt3), weightKg: weightKg(netFt3 * 0.0283168466), weightWasteKg: weightKg(wFt3 * 0.0283168466), weightPerFt2: weightPerFt2, bagCost: (o.priceBag || 0) > 0 ? bags * (o.priceBag || 0) : 0 }; } function calcSealer(o){ /* o: {l,w} ft, {coats} 1|2, {r1} ft2/gal first coat, {r2} ft2/gal second coat, {priceGal} per gallon */ var area = (o.l || 0) * (o.w || 0); var g1 = area / (o.r1 || 300); var g2 = (o.coats === 2) ? (area / (o.r2 || 450)) : 0; var total = g1 + g2; return { area: area, g1: g1, g2: g2, total: total, litres: total * 3.78541, buckets: ceilSafe(total / 5), /* 5 gallon buckets */ cans: ceilSafe(total), /* 1 gallon cans */ cost: (o.priceGal || 0) > 0 ? total * (o.priceGal || 0) : 0 }; } /* ---------- tool definitions ---------- */ var URLS = { slab:'/slab-concrete-calculator/', footing:'/footing-concrete-calculator/', wall:'/wall-concrete-calculator/', column:'/column-concrete-calculator/', posthole:'/post-hole-concrete-calculator/', circle:'/circular-slab-concrete-calculator/', curb:'/curb-concrete-calculator/', stairs:'/stairs-concrete-calculator/', bags:'/concrete-bag-calculator/', mix:'/concrete-mix-ratio-calculator/', rebar:'/rebar-calculator/', cost:'/concrete-cost-calculator/', driveway:'/driveway-concrete-calculator/', gravel:'/gravel-calculator/', blocks:'/block-wall-calculator/', mortar:'/mortar-calculator/', readymix:'/ready-mix-vs-bags-calculator/', patio:'/patio-concrete-calculator/', sidewalk:'/sidewalk-concrete-calculator/', sonotube:'/sonotube-concrete-calculator/', countertop:'/countertop-concrete-calculator/', sealer:'/concrete-sealer-calculator/', weight:'/concrete-weight-calculator/', truckload:'/concrete-truck-load-calculator/', evaporation:'/concrete-evaporation-rate-calculator/', retainingwall:'/retaining-wall-calculator/', wcratio:'/water-cement-ratio-calculator/' }; var LINKNAMES = { slab:'Slab', footing:'Footing', wall:'Wall', column:'Column', posthole:'Post Holes', circle:'Circle Slab', curb:'Curb', stairs:'Stairs', bags:'Bags', mix:'Mix Ratio', rebar:'Rebar', cost:'Cost', driveway:'Driveway', gravel:'Gravel', blocks:'Block Wall', mortar:'Mortar', readymix:'Ready Mix vs Bags', patio:'Patio', sidewalk:'Sidewalk', sonotube:'Sonotube Piers', countertop:'Countertop', sealer:'Sealer', weight:'Weight', truckload:'Truck Load', evaporation:'Evaporation', retainingwall:'Retaining Wall', wcratio:'W/C Ratio' }; function relatedHTML(ids){ var h = ''; } function verifiedHTML(text){ return '
Last verified: 26 Oct 2026. ' + text + '
'; } function emptyHTML(msg){ return '
' + msg + '
'; } function nwCol(title, rows){ /* rows: [[big, label], ...] rendered as labelled values */ var h = '

' + title + '

'; rows.forEach(function(r){ h += '' + r[0] + ' ' + r[1] + ''; }); return h + '
'; } function allBagsRow(bags, bagsM){ return '
' + bags.b80 + ' x 80 lb' + '' + bags.b60 + ' x 60 lb' + '' + bags.b50 + ' x 50 lb' + '' + bags.b40 + ' x 40 lb' + '' + bagsM.k25 + ' x 25 kg' + '' + bagsM.k20 + ' x 20 kg
'; } function resetHTML(){ return '
' + '
'; } var CUR = '$'; var TOOLS = { patio: { title: 'Patio Concrete Calculator', formula: 'Volume = Patio area x Thickness / 27 (cubic yards)', fields: [ { id:'l', label:'Length', kind:'len', ph:'16', defUnit:'ft', hideShape:'circle' }, { id:'w', label:'Width', kind:'len', ph:'12', defUnit:'ft', hideShape:'circle' }, { id:'dia', label:'Diameter', kind:'len', ph:'12', defUnit:'ft', hideShape:'rect lshape' }, { id:'t', label:'Thickness', kind:'sm', ph:'4', defUnit:'in', quick:[3,4,6] } ], extrasHTML: function(){ return '
' + '
' + '' + '
' + '
' + wasteRowHTML(10) + priceFieldHTML('price', 'Price per yd3', '150'); }, extraFields: [ { id:'l2', label:'Second rectangle length', kind:'len', defUnit:'ft' }, { id:'w2', label:'Second rectangle width', kind:'len', defUnit:'ft' }, { id:'price', label:'Price per yd3', kind:'usd' } ], empty: 'Enter the patio size above.', validate: function(panel, vals){ var s = panel.querySelector('.shapeSel'); var shape = s ? s.value : 'rect'; if(shape === 'circle'){ if(!vals.dia) return this.empty; } else { if(!vals.l || !vals.w) return this.empty; if(shape === 'lshape' && (!vals.l2 || !vals.w2)) return this.empty; } return null; }, syncExtras: function(panel){ var s = panel.querySelector('.shapeSel'); var shape = s ? s.value : 'rect'; panel.querySelectorAll('[data-hideshape]').forEach(function(f){ var hide = f.getAttribute('data-hideshape').split(' '); f.style.display = (hide.indexOf(shape) >= 0) ? 'none' : ''; }); var l2row = panel.querySelector('[data-forl2]'); if(l2row) l2row.style.display = (shape === 'lshape') ? '' : 'none'; }, toImp: function(vals, units){ return { l:toFt(vals.l, units.l), w:toFt(vals.w, units.w), dia:toFt(vals.dia, units.dia), l2:toFt(vals.l2, units.l2), w2:toFt(vals.w2, units.w2), t:toIn(vals.t, units.t), price:num(vals.price) }; }, render: function(imp, vals, units, panel, waste){ var ssel = panel.querySelector('.shapeSel'); var shape = ssel ? ssel.value : 'rect'; var slopeSel = panel.querySelector('.slopeSel'); var slope = slopeSel ? (parseFloat(slopeSel.value) || 0.25) : 0.25; var imp2 = imp; imp2.shape = shape; imp2.slope = slope; if(shape !== 'lshape'){ imp2.l2 = 0; imp2.w2 = 0; } if(shape !== 'circle'){ imp2.dia = 0; } imp2.waste = waste; var R = calcPatio(imp2); var tIn = imp.t; var h = '

Patio concrete

'; h += nwCol('Net volume', [[fmt(R.netYd3), 'Cubic Yards'], [fmt(R.netM3), 'Cubic Metres'], [R.bagsNet.b80, 'x 80 lb Bags'], [fmt(R.netFt3, 1) + ' ft3', 'volume'], [fmt(R.weightLb, 0) + ' lb', 'weight'], [R.trucksNet, 'truck load' + (R.trucksNet === 1 ? '' : 's')]]); h += nwCol('With ' + waste + '% waste', [[fmt(R.wasteYd3), 'Cubic Yards'], [fmt(R.wasteM3), 'Cubic Metres'], [R.bags.b80, 'x 80 lb Bags'], [fmt(R.wasteFt3, 1) + ' ft3', 'volume'], [fmt(R.weightWasteLb, 0) + ' lb', 'weight']]); h += '
'; h += allBagsRow(R.bags, R.bagsM); h += '
Working: Area = ' + fmt(R.area, 2) + ' ft2, x (' + fmt(tIn, 1) + ' in / 12) = ' + fmt(R.netFt3, 1) + ' ft3, / 27 = ' + fmt(R.netYd3) + ' yd3' + (waste > 0 ? ', x ' + (1 + waste / 100).toFixed(2) + ' waste = ' + fmt(R.wasteYd3) + ' yd3' : '') + '
'; h += '
' + R.jointCount + ' control joint line' + (R.jointCount === 1 ? '' : 's') + ' (at ' + fmt(R.jointSpacing, 1) + ' ft spacing)' + '' + fmt(R.jointsFt, 1) + ' ft of joints' + '' + fmt(2 * tIn, 0) + ' to ' + fmt(3 * tIn, 0) + ' ft joint spacing rule (2 to 3x thickness)' + '' + fmt(R.dropIn, 2) + ' in drainage fall over the length
'; if(R.cost > 0) h += '
' + CUR + fmt(R.cost) + ' estimated material cost
'; h += '

Estimates only. Bag yields per manufacturer specs (80 lb = 0.60 ft3, 60 lb = 0.45 ft3, 40 lb = 0.30 ft3). Cut control joints at least one quarter of the slab thickness deep, and keep panels close to square (no side more than 1.5 times the other). Always confirm the final order with your supplier.

'; h += resetHTML() + '
'; return h; }, links: ['slab','sidewalk','driveway','cost','sonotube','sealer'], verified: 'Patio thickness 4 in typical (minimum 3 to 3.5 in; 3,000 to 4,000 PSI mix). Control joint spacing in feet 2 to 3 times slab thickness in inches, depth at least one quarter of slab thickness. Drainage slope 1/8 to 1/4 in per ft (2% maximum). Bag yields per manufacturer specifications (Quikrete). Density 150 lb/ft3 (2,400 kg/m3).' }, sidewalk: { title: 'Sidewalk and Walkway Concrete Calculator', formula: 'Volume = Length x Width x Thickness / 27 (cubic yards)', fields: [ { id:'l', label:'Length', kind:'len', ph:'50', defUnit:'ft' }, { id:'w', label:'Width', kind:'len', ph:'4', defUnit:'ft' }, { id:'t', label:'Thickness', kind:'sm', ph:'4', defUnit:'in', quick:[3,4,5] } ], extrasHTML: function(){ return '
' + '
' + wasteRowHTML(10) + priceFieldHTML('price', 'Price per yd3', '150'); }, extraFields: [ { id:'price', label:'Price per yd3', kind:'usd' } ], empty: 'Enter the walkway size above.', validate: function(panel, vals){ if(!vals.l || !vals.w || !vals.t) return this.empty; return null; }, toImp: function(vals, units){ return { l:toFt(vals.l, units.l), w:toFt(vals.w, units.w), t:toIn(vals.t, units.t), price:num(vals.price) }; }, render: function(imp, vals, units, panel, waste){ var crossSel = panel.querySelector('.crossSel'); var cross = crossSel ? (parseFloat(crossSel.value) || 2) : 2; imp.waste = waste; var R = calcSidewalk(imp); var h = '

Sidewalk concrete

'; h += nwCol('Net volume', [[fmt(R.netYd3), 'Cubic Yards'], [fmt(R.netM3), 'Cubic Metres'], [R.bagsNet.b80, 'x 80 lb Bags'], [fmt(R.netFt3, 1) + ' ft3', 'volume'], [fmt(R.weightLb, 0) + ' lb', 'weight']]); h += nwCol('With ' + waste + '% waste', [[fmt(R.wasteYd3), 'Cubic Yards'], [fmt(R.wasteM3), 'Cubic Metres'], [R.bags.b80, 'x 80 lb Bags'], [fmt(R.wasteFt3, 1) + ' ft3', 'volume'], [fmt(R.weightWasteLb, 0) + ' lb', 'weight']]); h += '
'; h += allBagsRow(R.bags, R.bagsM); h += '
Working: ' + esc(vals.l) + ' x ' + esc(vals.w) + ' x (' + esc(vals.t) + ' in / 12) = ' + fmt(R.netFt3, 1) + ' ft3, / 27 = ' + fmt(R.netYd3) + ' yd3' + (waste > 0 ? ', x ' + (1 + waste / 100).toFixed(2) + ' waste = ' + fmt(R.wasteYd3) + ' yd3' : '') + '
'; h += '
' + R.joints + ' control joints' + 'every ' + fmt(R.jointSpacing, 1) + ' ft (square panels)' + '' + fmt(R.meshFt2, 1) + ' ft2 wire mesh (10% overlap)' + '' + cross + '% cross slope
'; if(R.cost > 0) h += '
' + CUR + fmt(R.cost) + ' estimated material cost
'; h += '

Estimates only. Bag yields per manufacturer specs (80 lb = 0.60 ft3, 60 lb = 0.45 ft3, 40 lb = 0.30 ft3). Tool or saw-cut the joints at least one quarter of the slab thickness deep. On soft ground or where vehicles will cross, step the thickness up to 5 or 6 in and confirm the final order with your supplier.

'; h += resetHTML() + '
'; return h; }, links: ['slab','patio','driveway','curb','cost','sealer'], verified: 'Sidewalk thickness 4 in typical (minimum 3 in; 3,000 PSI mix). Joint spacing matched to width for square panels. Wire mesh allowance x 1.10. Cross slope 1 to 2% (2% maximum). Bag yields per manufacturer specifications (Quikrete). Density 150 lb/ft3 (2,400 kg/m3).' }, sonotube: { title: 'Sonotube Concrete Pier Calculator', formula: 'Volume per tube = pi x (diameter / 2)^2 x depth (cubic feet)', fields: [ { id:'dia', label:'Tube diameter', kind:'sm', ph:'12', defUnit:'in', quick:[8,10,12,16] }, { id:'depth', label:'Tube depth', kind:'sm', ph:'48', defUnit:'in' }, { id:'n', label:'Number of piers', kind:'num', ph:'8' } ], extrasHTML: function(){ return '
' + '

With this on, the volume is worked out over the full depth plus 6 in, as the page specifies (a 48 in tube is calculated over 54 in).

' + '
' + '
' + '
' + wasteRowHTML(10) + priceFieldHTML('priceBag', 'Price per 80 lb bag', '6'); }, extraFields: [ { id:'frost', label:'Local frost depth', kind:'sm', defUnit:'in' }, { id:'priceBag', label:'Price per 80 lb bag', kind:'usd' } ], empty: 'Enter the tube size and pier count above.', validate: function(panel, vals){ if(!vals.dia || !vals.depth || !vals.n) return this.empty; return null; }, toImp: function(vals, units){ return { dia:toIn(vals.dia, units.dia), depth:toIn(vals.depth, units.depth), n:num(vals.n) || 0, frost:toIn(vals.frost, units.frost), priceBag:num(vals.priceBag) }; }, render: function(imp, vals, units, panel, waste){ var gcb = panel.querySelector('#cc-gravelbase'); var gravel = gcb ? gcb.checked : false; var R = calcSonotube({ dia:imp.dia, depth:imp.depth, n:imp.n, gravel:gravel, frost:imp.frost, waste:waste, priceBag:imp.priceBag }); var perBagsWaste = ceilSafe(R.perFt3 * (1 + waste / 100) / 0.60); var h = '

Sonotube concrete

'; h += nwCol('Per tube', [[fmt(R.perFt3, 2), 'Cubic Feet'], [perBagsWaste, 'x 80 lb Bags (with ' + waste + '%)'], [fmt(R.perYd3, 3) + ' yd3', 'per tube'], ['depth ' + fmt(R.depthIn, 1) + ' in', gravel ? 'incl. 6 in gravel base' : 'no gravel base']]); h += nwCol('All ' + fmt(imp.n, 0) + ' piers, with ' + waste + '% waste', [[fmt(R.wasteYd3), 'Cubic Yards'], [fmt(R.wasteM3), 'Cubic Metres'], [R.bags.b80, 'x 80 lb Bags'], [fmt(R.wasteFt3, 1) + ' ft3', 'volume'], [fmt(R.weightWasteLb, 0) + ' lb', 'weight']]); h += '
'; h += allBagsRow(R.bags, R.bagsM); h += '
Working: Per tube: pi x (' + esc(vals.dia) + ' in / 2 / 12)^2 x (' + fmt(R.depthIn, 1) + ' in / 12) = ' + fmt(R.perFt3, 2) + ' ft3.' + ' Total: ' + fmt(R.perFt3, 2) + ' x ' + fmt(imp.n, 0) + ' = ' + fmt(R.totalFt3, 2) + ' ft3, / 27 = ' + fmt(R.totalYd3) + ' yd3' + (waste > 0 ? ', x ' + (1 + waste / 100).toFixed(2) + ' waste = ' + fmt(R.wasteYd3) + ' yd3' : '') + '
'; if(R.belowFrost === false){ h += '

Warning: the tube depth (' + fmt(R.depthIn, 1) + ' in) is shallower than the frost depth you entered. IRC R403.1.4 requires exterior footings to extend below the local frost line. Confirm the required depth with your building department.

'; } else if(R.belowFrost === true){ h += '

Good: the tube depth (' + fmt(R.depthIn, 1) + ' in) reaches below the frost depth you entered.

'; } h += '
Buy ' + fmt(R.tubeBuyLen, 0) + ' in tube length per pier (depth + 12 in for levelling)
'; if(R.bagCost > 0) h += '
' + CUR + fmt(R.bagCost) + ' estimated 80 lb bag cost
'; h += '

Estimates only. Bag yields per manufacturer specs (80 lb = 0.60 ft3, 60 lb = 0.45 ft3, 40 lb = 0.30 ft3). Sonotube is a brand name for cardboard pier forms (also called concrete tube or pier form). This sizes the concrete only: pier diameter, spacing and reinforcement for structural loads must be confirmed with your local code or a qualified professional.

'; h += resetHTML() + '
'; return h; }, links: ['posthole','footing','column','cost','patio','sidewalk'], verified: 'Tube volume per SlabCalc (12 in x 48 in tube holds 3.14 ft3; about 6 bags of 80 lb with 10% waste). Common diameters 8 to 24 in; 10 to 12 in for standard deck posts. Frost line per IRC R403.1.4 (near zero in the Deep South, 48 to 60 in in northern states). Gravel base allowance 6 in. Tube length buy allowance 6 to 12 in. Bag yields per manufacturer specifications (Quikrete). Density 150 lb/ft3 (2,400 kg/m3).' }, countertop: { title: 'Concrete Countertop Calculator', formula: 'Volume = Length x Width x Thickness (cubic feet); bags = volume / bag yield', fields: [ { id:'l', label:'Length', kind:'len', ph:'8', defUnit:'ft' }, { id:'w', label:'Width', kind:'len', ph:'2', defUnit:'ft' }, { id:'t', label:'Thickness', kind:'sm', ph:'1.5', defUnit:'in', quick:[1.5,2] } ], extrasHTML: function(){ return '
' + '
' + wasteRowHTML(10) + priceFieldHTML('priceBag', 'Price per bag', '7'); }, extraFields: [ { id:'priceBag', label:'Price per bag', kind:'usd' } ], empty: 'Enter the countertop size above.', validate: function(panel, vals){ if(!vals.l || !vals.w || !vals.t) return this.empty; return null; }, toImp: function(vals, units){ return { l:toFt(vals.l, units.l), w:toFt(vals.w, units.w), t:toIn(vals.t, units.t), priceBag:num(vals.priceBag) }; }, render: function(imp, vals, units, panel, waste){ var msel = panel.querySelector('.mixSel'); var mix = msel ? msel.value : 'ct'; var R = calcCountertop({ l:imp.l, w:imp.w, t:imp.t, mix:mix, waste:waste, priceBag:imp.priceBag }); var mixName = R.isCt ? 'countertop mix (0.43 ft3 per 47 lb bag)' : 'standard 80 lb mix (0.60 ft3 per bag)'; var h = '

Countertop concrete

'; h += nwCol('Net volume', [[fmt(R.netFt3, 2), 'Cubic Feet'], [fmt(R.netYd3, 3), 'Cubic Yards'], [R.bagsNet, 'x ' + R.bagLb + ' lb Bags'], [fmt(R.weightLb, 0) + ' lb', 'net weight'], [fmt(R.weightPerFt2, 2) + ' lb per ft2', 'slab weight']]); h += nwCol('With ' + waste + '% waste', [[fmt(R.wasteFt3, 2), 'Cubic Feet'], [fmt(R.wasteYd3, 3), 'Cubic Yards'], [R.bags, 'x ' + R.bagLb + ' lb Bags'], [fmt(R.weightWasteLb, 0) + ' lb', 'weight with waste']]); h += '
'; h += '
Working: ' + esc(vals.l) + ' x ' + esc(vals.w) + ' = ' + fmt(R.area, 1) + ' ft2, x (' + esc(vals.t) + ' in / 12) = ' + fmt(R.netFt3, 2) + ' ft3.' + ' Bags: ' + fmt(R.wasteFt3, 2) + ' ft3 (with waste) / ' + fmt(R.yieldFt3, 2) + ' = ' + R.bags + ' bags of ' + mixName + '.
'; h += '
' + fmt(R.weightPerFt2, 2) + ' lb per ft2 (check your cabinets can carry this)
'; if(R.bagCost > 0) h += '
' + CUR + fmt(R.bagCost) + ' estimated bag cost
'; h += '

Estimates only. Concrete countertops are heavy: at 1.5 to 2 in they weigh about 19 to 25 lb per square foot, so confirm your cabinets and floor can carry the load before you pour. Cast at 1.5 to 2 in; seal the finished top with a food-safe sealer and reseal every 2 to 3 years. Confirm bag counts with your supplier.

'; h += resetHTML() + '
'; return h; }, links: ['slab','mix','bags','patio','cost','sealer'], verified: 'Standard thickness 1.5 to 2 in; minimum 1.5 in. Countertop mix coverage 0.43 ft3 per 47 lb bag (can be cast as thin as 1 in). Typical weight 19 to 25 lb per ft2 at 1.5 to 2 in. Standard 80 lb bag yield 0.60 ft3 per QUIKRETE. Density 150 lb/ft3 (2,400 kg/m3).' }, sealer: { title: 'Concrete Sealer Coverage Calculator', formula: 'Gallons = surface area / coverage rate per coat (sum both coats)', fields: [ { id:'l', label:'Length', kind:'len', ph:'20', defUnit:'ft' }, { id:'w', label:'Width', kind:'len', ph:'40', defUnit:'ft' } ], extrasHTML: function(){ return '
' + '
' + '
' + '
' + 'ft2/gal
' + '
' + '
' + 'ft2/gal
' + priceFieldHTML('priceGal', 'Price per gallon', ''); }, extraFields: [ { id:'r1', label:'First coat coverage', kind:'num' }, { id:'r2', label:'Second coat coverage', kind:'num' }, { id:'priceGal', label:'Price per gallon', kind:'usd' } ], empty: 'Enter the surface size above.', validate: function(panel, vals){ if(!vals.l || !vals.w) return this.empty; return null; }, toImp: function(vals, units){ function rate(v, d){ v = parseFloat(v); return (isFinite(v) && v > 0) ? v : d; } return { l:toFt(vals.l, units.l), w:toFt(vals.w, units.w), r1:rate(vals.r1, 300), r2:rate(vals.r2, 450), priceGal:num(vals.priceGal) }; }, render: function(imp, vals, units, panel, waste){ var csel = panel.querySelector('.coatsSel'); var coats = csel ? (parseInt(csel.value, 10) === 1 ? 1 : 2) : 2; var R = calcSealer({ l:imp.l, w:imp.w, coats:coats, r1:imp.r1, r2:imp.r2, priceGal:imp.priceGal }); var h = '

Sealer needed

'; h += nwCol('First coat (' + fmt(imp.r1, 0) + ' ft2/gal)', [[fmt(R.g1), 'Gallons'], [fmt(R.g1 * 3.78541), 'Litres'], [fmt(R.area, 0) + ' ft2', 'surface area']]); if(coats === 2){ h += nwCol('Second coat (' + fmt(imp.r2, 0) + ' ft2/gal)', [[fmt(R.g2), 'Gallons'], [fmt(R.g2 * 3.78541), 'Litres'], ['apply after the first coat is tack free', 'timing']]); } else { h += nwCol('One coat selected', [[fmt(R.total), 'Gallons total'], [fmt(R.litres), 'Litres'], ['two coats protect better', 'note']]); } h += '
'; h += '
' + fmt(R.total) + ' gallons total' + '' + fmt(R.litres) + ' litres' + '' + R.buckets + ' five gallon bucket' + (R.buckets === 1 ? '' : 's') + '' + '' + R.cans + ' 1 gallon can' + (R.cans === 1 ? '' : 's') + '
'; h += '
Working: ' + fmt(R.area, 0) + ' ft2 / ' + fmt(imp.r1, 0) + ' ft2/gal = ' + fmt(R.g1) + ' gal first coat' + (coats === 2 ? ', + ' + fmt(R.area, 0) + ' ft2 / ' + fmt(imp.r2, 0) + ' ft2/gal = ' + fmt(R.g2) + ' gal second coat' : '') + ' = ' + fmt(R.total) + ' gal total (' + fmt(R.litres) + ' litres).
'; if(R.cost > 0) h += '
' + CUR + fmt(R.cost) + ' estimated material cost
'; h += '

Estimates only. Coverage varies with surface texture, porosity and weather: check the rate on your product label and adjust the fields above. Seal concrete that is at least 28 days old. Keep foot traffic off for 24 hours and vehicles off for 72 hours after sealing.

'; h += resetHTML() + '
'; return h; }, links: ['patio','driveway','sidewalk','slab','cost','weight'], verified: 'First coat 250 to 350 ft2 per gallon on broomed concrete (300 to 450 troweled); second coat 300 to 600 ft2 per gallon. Tool defaults 300 ft2/gal first coat, 450 ft2/gal second coat (midpoints of the published bands); both adjustable. Seal at 28 days. 1 gallon = 3.78541 litres.' } }; /* ---------- panel build, calc wiring, toggles, boot ---------- */ function calcPanel(tool, panel){ var box = panel.querySelector('.cc-out'); if(!box) return; if(tool.syncExtras) tool.syncExtras(panel); var rv = readVals(panel); var verr = tool.validate ? tool.validate(panel, rv.vals) : null; if(verr){ box.innerHTML = emptyHTML(verr); return; } var imp = tool.toImp(rv.vals, rv.units); var waste = readWaste(panel); var html = tool.render(imp, rv.vals, rv.units, panel, waste); html += relatedHTML(tool.links) + verifiedHTML(tool.verified); box.innerHTML = html; var rb = box.querySelector('[data-act="reset"]'); if(rb) rb.addEventListener('click', function(){ panel.querySelectorAll('input').forEach(function(i){ if(i.type === 'checkbox'){ i.checked = false; } else { i.value = ''; } }); calcPanel(tool, panel); }); } function wireSelectConvert(panel, tool){ panel.querySelectorAll('select.cc-funit').forEach(function(sel){ sel.addEventListener('change', function(){ var fid = sel.getAttribute('data-funit'); var inp = panel.querySelector('input[data-fid="' + fid + '"]'); if(!inp || !inp.value){ calcPanel(tool, panel); return; } var field = null; (tool.fields || []).concat(tool.extraFields || []).forEach(function(f){ if(f.id === fid) field = f; }); if(!field) return; var oldU = sel.getAttribute('data-prev') || field.defUnit || 'ft'; var newU = sel.value; if(oldU !== newU) inp.value = convertVal(inp.value, oldU, newU, field.kind); sel.setAttribute('data-prev', newU); calcPanel(tool, panel); }); sel.setAttribute('data-prev', sel.value); }); } function wireQuick(panel, tool){ panel.querySelectorAll('[data-quick]').forEach(function(b){ b.addEventListener('click', function(){ var fid = b.getAttribute('data-qfid'); var inp = panel.querySelector('input[data-fid="' + fid + '"]'); var sel = panel.querySelector('select.cc-funit[data-funit="' + fid + '"]'); if(!inp) return; var qv = b.getAttribute('data-quick'); if(sel && (sel.value === 'm' || sel.value === 'cm' || sel.value === 'mm')){ var cm = parseFloat(qv) * 2.54; if(sel.value === 'm') inp.value = fmt(cm / 100, 3); else if(sel.value === 'cm') inp.value = fmt(cm, 1); else inp.value = fmt(cm * 10, 0); } else { inp.value = qv; if(sel) sel.value = 'in'; } panel.querySelectorAll('[data-qfid="' + fid + '"]').forEach(function(x){ x.classList.remove('on'); }); b.classList.add('on'); calcPanel(tool, panel); }); }); } /* Header unit toggle, P3 style: convert every length/thickness/ volume field by its data-kind, flip its unit select, and keep data-prev in step. Price, waste, shape and count fields are never touched. */ function wireHeaderToggle(panel, tool){ var ui = document.getElementById('p3uImp'), um = document.getElementById('p3uMet'); function apply(target){ panel.querySelectorAll('select.cc-funit').forEach(function(sel){ var fid = sel.getAttribute('data-funit'); var inp = panel.querySelector('input[data-fid="' + fid + '"]'); if(!inp) return; var kind = inp.getAttribute('data-kind'); var tgt = null; if(target === 'imp'){ if(kind === 'len') tgt = 'ft'; else if(kind === 'sm') tgt = 'in'; else if(kind === 'yd3') tgt = 'yd3'; } else { if(kind === 'len') tgt = 'm'; else if(kind === 'sm') tgt = 'cm'; else if(kind === 'yd3') tgt = 'm3'; } if(!tgt) return; if(inp.value) inp.value = convertVal(inp.value, sel.value, tgt, kind); sel.value = tgt; sel.setAttribute('data-prev', tgt); }); if(ui) ui.classList.toggle('on', target === 'imp'); if(um) um.classList.toggle('on', target === 'met'); calcPanel(tool, panel); } if(ui) ui.onclick = function(){ apply('imp'); }; if(um) um.onclick = function(){ apply('met'); }; /* Currency button: cycle the symbol used by price displays. */ var uc = document.getElementById('p3uCur'); function paintCur(){ if(uc) uc.textContent = (CUR === '£' ? '£ GBP' : (CUR === '€' ? '€ EUR' : '$ USD')); panel.querySelectorAll('.curSym').forEach(function(s){ s.textContent = CUR; }); } if(uc) uc.onclick = function(){ CUR = (CUR === '$') ? '£' : ((CUR === '£') ? '€' : '$'); paintCur(); calcPanel(tool, panel); }; paintCur(); } function buildPanel(tool, id){ var p = document.createElement('div'); p.className = 'cc-panel on'; p.id = 'ccp-' + id; p.setAttribute('role', 'tabpanel'); var inner = '

' + tool.title + '

' + tool.formula + '

' + '
'; tool.fields.forEach(function(f){ inner += fieldHTML(f); }); inner += '
'; if(tool.extrasHTML) inner += tool.extrasHTML(); inner += '
'; p.innerHTML = inner; p.querySelectorAll('input,select').forEach(function(el){ el.addEventListener('input', function(){ calcPanel(tool, p); }); el.addEventListener('change', function(){ calcPanel(tool, p); }); }); wireSelectConvert(p, tool); wireQuick(p, tool); wireHeaderToggle(p, tool); calcPanel(tool, p); return p; } var PATCH_TOOLS = ['patio', 'sidewalk', 'sonotube', 'countertop', 'sealer']; var built = false; function boot(){ if(built) return; var id = (typeof window !== 'undefined') ? window.CC_SINGLE : null; if(!id || PATCH_TOOLS.indexOf(id) < 0) return; var tool = TOOLS[id]; if(!tool) return; var c = document.getElementById('ccSingle'); if(!c) return; /* Never build a second panel if one already exists (V6, P3 or P4 got there first). */ if(c.querySelector('.cc-panel')) return; if(document.getElementById('ccp-' + id)) return; c.appendChild(buildPanel(tool, id)); built = true; } if(typeof document !== 'undefined'){ if(document.readyState === 'loading'){ document.addEventListener('DOMContentLoaded', boot); } boot(); } /* Node test hook (no-op in browsers). */ if(typeof module !== 'undefined' && module.exports){ module.exports = { calcPatio: calcPatio, calcSidewalk: calcSidewalk, calcSonotube: calcSonotube, calcCountertop: calcCountertop, calcSealer: calcSealer, fmt: fmt, ceilSafe: ceilSafe, convertVal: convertVal, toFt: toFt, toIn: toIn, num: num }; } })();