Spaces:
Running
Running
Deploy sumbloom
Browse files- game.js +21 -7
- index.html +3 -3
game.js
CHANGED
|
@@ -27,14 +27,28 @@
|
|
| 27 |
};
|
| 28 |
}
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
mode = "daily";
|
| 32 |
-
|
|
|
|
| 33 |
puzzle = makePuzzle("daily:" + dateStr);
|
| 34 |
state = load("day:" + dateStr, null);
|
| 35 |
if (!state || !state.rounds || state.rounds.length !== 5) state = freshState();
|
| 36 |
active = firstOpen();
|
| 37 |
-
el("puzzle-label").textContent = "Daily #" + puzzleNo(dateStr) + " · " + dateStr;
|
| 38 |
el("btn-mode").textContent = "Practice mode";
|
| 39 |
render();
|
| 40 |
}
|
|
@@ -181,7 +195,7 @@
|
|
| 181 |
// ---------- stats ----------
|
| 182 |
function recordStats() {
|
| 183 |
var st = load("stats", { played: 0, streak: 0, maxStreak: 0, last: null, total: 0, perfect: 0, dist: {} });
|
| 184 |
-
if (st.last === dateStr) return;
|
| 185 |
var score = totalStars();
|
| 186 |
var y = new Date(); y.setDate(y.getDate() - 1);
|
| 187 |
st.streak = st.last === todayStr(y) ? st.streak + 1 : 1;
|
|
@@ -303,13 +317,13 @@
|
|
| 303 |
});
|
| 304 |
|
| 305 |
// expose for tests
|
| 306 |
-
window.Sumbloom = { makePuzzle: makePuzzle, apply: apply, puzzleNo: puzzleNo, state: function () { return state; }, puzzle: function () { return puzzle; } };
|
| 307 |
|
| 308 |
document.addEventListener("visibilitychange", function () {
|
| 309 |
-
if (!document.hidden && mode === "daily" && todayStr() !== dateStr) { closeModal(); startDaily(); }
|
| 310 |
});
|
| 311 |
|
| 312 |
-
startDaily();
|
| 313 |
if (!load("seenHelp", false)) { save("seenHelp", true); showHelp(); }
|
| 314 |
|
| 315 |
if ("serviceWorker" in navigator && location.protocol === "https:") {
|
|
|
|
| 27 |
};
|
| 28 |
}
|
| 29 |
|
| 30 |
+
// ?date=YYYY-MM-DD opens that day's daily (archive links from cybermaxtools.com/games/sumbloom/daily/<date>/).
|
| 31 |
+
// Only real past dailies (#1 = 2026-09-24 up to today); anything else is ignored and today's puzzle opens.
|
| 32 |
+
function dateParam(search) {
|
| 33 |
+
var d = null;
|
| 34 |
+
try { d = new URLSearchParams(search).get("date"); } catch (e) { return null; }
|
| 35 |
+
if (!d || !/^\d{4}-\d{2}-\d{2}$/.test(d)) return null;
|
| 36 |
+
var t = new Date(d + "T00:00:00Z");
|
| 37 |
+
if (isNaN(t.getTime()) || t.toISOString().slice(0, 10) !== d) return null;
|
| 38 |
+
if (puzzleNo(d) < 1 || d >= todayStr()) return null;
|
| 39 |
+
return d;
|
| 40 |
+
}
|
| 41 |
+
var pastDay = null;
|
| 42 |
+
|
| 43 |
+
function startDaily(day) {
|
| 44 |
mode = "daily";
|
| 45 |
+
pastDay = day || null;
|
| 46 |
+
dateStr = pastDay || todayStr();
|
| 47 |
puzzle = makePuzzle("daily:" + dateStr);
|
| 48 |
state = load("day:" + dateStr, null);
|
| 49 |
if (!state || !state.rounds || state.rounds.length !== 5) state = freshState();
|
| 50 |
active = firstOpen();
|
| 51 |
+
el("puzzle-label").textContent = "Daily #" + puzzleNo(dateStr) + " · " + dateStr + (pastDay ? " (archive)" : "");
|
| 52 |
el("btn-mode").textContent = "Practice mode";
|
| 53 |
render();
|
| 54 |
}
|
|
|
|
| 195 |
// ---------- stats ----------
|
| 196 |
function recordStats() {
|
| 197 |
var st = load("stats", { played: 0, streak: 0, maxStreak: 0, last: null, total: 0, perfect: 0, dist: {} });
|
| 198 |
+
if (st.last === dateStr || pastDay) return; // an archive day never changes the streak
|
| 199 |
var score = totalStars();
|
| 200 |
var y = new Date(); y.setDate(y.getDate() - 1);
|
| 201 |
st.streak = st.last === todayStr(y) ? st.streak + 1 : 1;
|
|
|
|
| 317 |
});
|
| 318 |
|
| 319 |
// expose for tests
|
| 320 |
+
window.Sumbloom = { makePuzzle: makePuzzle, apply: apply, puzzleNo: puzzleNo, dateParam: dateParam, state: function () { return state; }, puzzle: function () { return puzzle; } };
|
| 321 |
|
| 322 |
document.addEventListener("visibilitychange", function () {
|
| 323 |
+
if (!document.hidden && mode === "daily" && !pastDay && todayStr() !== dateStr) { closeModal(); startDaily(); }
|
| 324 |
});
|
| 325 |
|
| 326 |
+
startDaily(dateParam(location.search));
|
| 327 |
if (!load("seenHelp", false)) { save("seenHelp", true); showHelp(); }
|
| 328 |
|
| 329 |
if ("serviceWorker" in navigator && location.protocol === "https:") {
|
index.html
CHANGED
|
@@ -22,7 +22,7 @@
|
|
| 22 |
</script>
|
| 23 |
<link rel="stylesheet" href="style.css">
|
| 24 |
</head>
|
| 25 |
-
<body>
|
| 26 |
<header class="bar">
|
| 27 |
<button class="icon-btn" id="btn-help" aria-label="How to play">?</button>
|
| 28 |
<h1 class="logo"><span class="logo-mark" aria-hidden="true">✿</span> Sumbloom</h1>
|
|
@@ -78,7 +78,7 @@
|
|
| 78 |
<a href="https://cybermax-tools-cybermax.static.hf.space/profit-margin-calculator/index.html" target="_blank" rel="noopener">Profit Margin Calculator</a>
|
| 79 |
<a href="https://cybermax-tools-cybermax.static.hf.space/salary-to-hourly-calculator/index.html" target="_blank" rel="noopener">Salary to Hourly Calculator</a>
|
| 80 |
<a href="https://huggingface.co/spaces/CyberMax-tools/cybermax" target="_blank" rel="noopener">All CyberMax tools</a>
|
| 81 |
-
<a href="https://
|
| 82 |
</div>
|
| 83 |
<div class="copy">© 2026 CyberMax. All rights reserved.</div>
|
| 84 |
</footer>
|
|
@@ -94,5 +94,5 @@
|
|
| 94 |
<script src="puzzle.js"></script>
|
| 95 |
<script src="game.js"></script>
|
| 96 |
<!-- cm:hf-upgrade-foot --><div id="cm-hf-up" hidden style="max-width:980px;margin:24px auto 12px;padding:0 16px;text-align:center;font:13px/1.5 system-ui,-apple-system,Segoe UI,sans-serif;color:#64748b">Free tool by <a href="https://huggingface.co/spaces/CyberMax-tools/cybermax" target="_blank" rel="noopener" style="color:inherit">CyberMax</a> · Need more? <a href="https://data.cybermaxtools.com/buy/sumbloom-book?s=hf-space-sumbloom" target="_blank" rel="noopener" style="color:#0284c7;font-weight:600">Printable Sumbloom puzzle book: 120 number puzzles with answers →</a></div><script>(function(){if(/\.static\.hf\.space$/.test(location.hostname)){var d=document.getElementById("cm-hf-up");if(d)d.hidden=false}})()</script><!-- /cm:hf-upgrade-foot -->
|
| 97 |
-
<
|
| 98 |
</html>
|
|
|
|
| 22 |
</script>
|
| 23 |
<link rel="stylesheet" href="style.css">
|
| 24 |
</head>
|
| 25 |
+
<body>
|
| 26 |
<header class="bar">
|
| 27 |
<button class="icon-btn" id="btn-help" aria-label="How to play">?</button>
|
| 28 |
<h1 class="logo"><span class="logo-mark" aria-hidden="true">✿</span> Sumbloom</h1>
|
|
|
|
| 78 |
<a href="https://cybermax-tools-cybermax.static.hf.space/profit-margin-calculator/index.html" target="_blank" rel="noopener">Profit Margin Calculator</a>
|
| 79 |
<a href="https://cybermax-tools-cybermax.static.hf.space/salary-to-hourly-calculator/index.html" target="_blank" rel="noopener">Salary to Hourly Calculator</a>
|
| 80 |
<a href="https://huggingface.co/spaces/CyberMax-tools/cybermax" target="_blank" rel="noopener">All CyberMax tools</a>
|
| 81 |
+
<a href="https://cybermaxtools.com/store/?utm_source=sumbloom&utm_medium=more-from" target="_blank" rel="noopener">CyberMax Store · paid products, API plans & bundles</a>
|
| 82 |
</div>
|
| 83 |
<div class="copy">© 2026 CyberMax. All rights reserved.</div>
|
| 84 |
</footer>
|
|
|
|
| 94 |
<script src="puzzle.js"></script>
|
| 95 |
<script src="game.js"></script>
|
| 96 |
<!-- cm:hf-upgrade-foot --><div id="cm-hf-up" hidden style="max-width:980px;margin:24px auto 12px;padding:0 16px;text-align:center;font:13px/1.5 system-ui,-apple-system,Segoe UI,sans-serif;color:#64748b">Free tool by <a href="https://huggingface.co/spaces/CyberMax-tools/cybermax" target="_blank" rel="noopener" style="color:inherit">CyberMax</a> · Need more? <a href="https://data.cybermaxtools.com/buy/sumbloom-book?s=hf-space-sumbloom" target="_blank" rel="noopener" style="color:#0284c7;font-weight:600">Printable Sumbloom puzzle book: 120 number puzzles with answers →</a></div><script>(function(){if(/\.static\.hf\.space$/.test(location.hostname)){var d=document.getElementById("cm-hf-up");if(d)d.hidden=false}})()</script><!-- /cm:hf-upgrade-foot -->
|
| 97 |
+
</body>
|
| 98 |
</html>
|