Tiered goals: ordered milestones with unlocks, tier-aware goal bar, TIER UNLOCKED alerts, next-unlock line
- Tiers\TierPolicy (pure), TierRepository (atomic reached marking), Tiers\Recorder hooked before close-at-target - Admin tiers screen; goal target derived from the final tier - Overlay goal widget shows Tier N of M and fills within the tier; alert pill; donate form 'Next unlock' - Installer DB_VERSION 4 (sg_goal_tiers) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39840a20d7
commit
4c379a0245
20 files changed
+1089
-14
No files matched your search
@@ -35,3 +35,6 @@
|
||||
.sg-donate label.sg-inline input[type=checkbox]{flex:none;width:22px;height:22px;margin:0}
|
||||
.sg-donate .sg-cover{gap:.25rem}
|
||||
.sg-donate .sg-act-title,.sg-donate .sg-act-desc,.sg-donate .sg-tip,.sg-donate .sg-msg,.sg-donate .sg-total{overflow-wrap:anywhere}
|
||||
|
||||
.sg-donate .sg-next-unlock{margin:0 0 .9rem;padding:.5rem .75rem;border:1px solid rgba(128,128,128,.5);border-left-width:4px;border-radius:.4rem;font-weight:600;line-height:1.4;overflow-wrap:anywhere}
|
||||
.sg-donate .sg-next-unlock[hidden]{display:none}
|
||||
+14
-2
@@ -82,6 +82,18 @@
|
||||
var status = el('div', { 'class': 'sg-msg', role: 'status' });
|
||||
var buttons = el('div', { 'class': 'sg-buttons' });
|
||||
|
||||
// "Next unlock" line for tiered goals (server computes title + remaining minor units per goal).
|
||||
var nextLine = el('p', { 'class': 'sg-next-unlock', 'aria-live': 'polite' });
|
||||
nextLine.hidden = true;
|
||||
function showNext() {
|
||||
var n = state.goal.nextUnlock;
|
||||
if (!n || !n.title || !(n.remaining_minor > 0)) { nextLine.hidden = true; nextLine.textContent = ''; return; }
|
||||
nextLine.textContent = String(T.nextUnlock || 'Next unlock: %1$s \u2014 %2$s to go')
|
||||
.replace('%1$s', function () { return n.title; })
|
||||
.replace('%2$s', function () { return fmt(n.remaining_minor, state.goal.exp, state.goal.currency); });
|
||||
nextLine.hidden = false;
|
||||
}
|
||||
root.appendChild(nextLine);
|
||||
if (goals.length > 1) { root.appendChild(row([el('label', { 'for': uid + '-goal', text: T.goal }), goalSel])); }
|
||||
root.appendChild(row([el('label', { text: T.amount }), presetBox, el('label', { 'class': 'sg-sub', 'for': uid + '-amt', text: T.customAmount || 'Or enter your own amount' }), amount, hint]));
|
||||
var nameRow = row([el('label', { 'for': uid + '-name', text: T.name }), name]);
|
||||
@@ -223,9 +235,9 @@
|
||||
|
||||
goalSel.addEventListener('change', function () {
|
||||
state.goal = goals.filter(function (g) { return String(g.id) === goalSel.value; })[0] || goals[0];
|
||||
buildPresets(); refresh(); renderButtons();
|
||||
showNext(); buildPresets(); refresh(); renderButtons();
|
||||
});
|
||||
buildPresets(); refresh(); renderButtons();
|
||||
showNext(); buildPresets(); refresh(); renderButtons();
|
||||
}
|
||||
|
||||
function boot() { Array.prototype.forEach.call(document.querySelectorAll('.sg-donate'), init); }
|
||||
|
||||
Reference in new issue
Block a user