[object Object]

← back to Wallco Ai

wallco.ai · PDP wall-calculator persists last-used W×H to localStorage[wallco-wall-calc] · restores values on next PDP visit so designers hopping between designs don't retype dimensions · auto-opens the <details> + auto-runs compute() on load if values were stored, so the result is visible immediately · saves on both Calculate-click and field-change (covers half-typed values surviving navigation) · verified PDP /design/72 200 115KB, 9 wiring refs (wallco-wall-calc, wallDetails, persist(), prev=JSON)

869d5a0f485e2f2443827dc08f711bdac20f9e88 · 2026-05-12 10:20:51 -0700 · SteveStudio2

Files touched

Diff

commit 869d5a0f485e2f2443827dc08f711bdac20f9e88
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Tue May 12 10:20:51 2026 -0700

    wallco.ai · PDP wall-calculator persists last-used W×H to localStorage[wallco-wall-calc] · restores values on next PDP visit so designers hopping between designs don't retype dimensions · auto-opens the <details> + auto-runs compute() on load if values were stored, so the result is visible immediately · saves on both Calculate-click and field-change (covers half-typed values surviving navigation) · verified PDP /design/72 200 115KB, 9 wiring refs (wallco-wall-calc, wallDetails, persist(), prev=JSON)
---
 server.js | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/server.js b/server.js
index 45ca914..020bc6b 100644
--- a/server.js
+++ b/server.js
@@ -4105,11 +4105,26 @@ ${htmlHeader('/designs')}
       (function(){
         var btn = document.getElementById('wc-calc');
         if (!btn) return;
+        var wEl = document.getElementById('wc-w');
+        var hEl = document.getElementById('wc-h');
+        var wallDetails = btn.closest('details');
+        // Restore last-used W×H from localStorage so designers don't retype when hopping between PDPs.
+        var prev = null;
+        try { prev = JSON.parse(localStorage.getItem('wallco-wall-calc') || 'null'); } catch(e){}
+        if (prev && isFinite(prev.w) && prev.w > 0) wEl.value = prev.w;
+        if (prev && isFinite(prev.h) && prev.h > 0) hEl.value = prev.h;
+        // If they had previously computed (and the panel is closed by default), auto-open the
+        // details so the populated values are visible at a glance.
+        if (prev && wallDetails && !wallDetails.open) wallDetails.open = true;
+        function persist(){
+          try { localStorage.setItem('wallco-wall-calc', JSON.stringify({ w: parseFloat(wEl.value)||0, h: parseFloat(hEl.value)||0, t: Date.now() })); } catch(e){}
+        }
         function compute() {
-          var w = parseFloat(document.getElementById('wc-w').value);
-          var h = parseFloat(document.getElementById('wc-h').value);
+          var w = parseFloat(wEl.value);
+          var h = parseFloat(hEl.value);
           var box = document.getElementById('wc-result');
           if (!isFinite(w) || !isFinite(h) || w<=0 || h<=0) { box.style.display='block'; box.innerHTML = '<span style="color:#b03a2e">Enter both width and height in feet.</span>'; return; }
+          persist();
           // Read user's chosen panel width (24/27/36) from the existing material picker if present.
           var savedWidth = 24;
           try { var s = JSON.parse(localStorage.getItem('wallco.material') || 'null'); if (s && parseInt(s.w,10)) savedWidth = parseInt(s.w,10); } catch(e){}
@@ -4135,8 +4150,14 @@ ${htmlHeader('/designs')}
             '<p style="margin:10px 0 0;font:11px/1.4 var(--sans);color:var(--ink-faint,#999)">Estimate uses ' + panelWidthInches + '" panel width, 27 ft panel length, 15% match-waste buffer. Final quote depends on substrate + installation. Sample first.</p>';
         }
         btn.addEventListener('click', compute);
-        document.getElementById('wc-w').addEventListener('keyup', function(e){ if (e.key==='Enter') compute(); });
-        document.getElementById('wc-h').addEventListener('keyup', function(e){ if (e.key==='Enter') compute(); });
+        wEl.addEventListener('keyup', function(e){ if (e.key==='Enter') compute(); });
+        hEl.addEventListener('keyup', function(e){ if (e.key==='Enter') compute(); });
+        wEl.addEventListener('change', persist);
+        hEl.addEventListener('change', persist);
+        // If we restored values, auto-compute on PDP load so the result is already visible.
+        if (prev && isFinite(prev.w) && isFinite(prev.h) && prev.w > 0 && prev.h > 0) {
+          compute();
+        }
       })();
       </script>
 

← 3ae8ad8 wallco.ai · home 'Stumble through the catalog' rail gets a c  ·  back to Wallco Ai  ·  wallco.ai · /api/designs/by-color now accepts optional ?with 7cddfa6 →