Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1b30572
Keep a pasted link over a waiting save, a size the drawer could not t…
claude Oct 9, 2026
14833dc
Wait for the save before each hop away in the links tests, and follow…
claude Oct 9, 2026
214132f
Merge main f36a654 (#58) into the pasted-link and storage-full fixes
claude Oct 9, 2026
b889fc7
Keep a size the drawer could not take across a reload and Back, and o…
claude Oct 9, 2026
c149524
Merge main a8a8fac (#61, #66) into the pasted-link and storage-full f…
claude Oct 9, 2026
560e3a1
Merge main ef885cf (#67) into the pasted-link and storage-full fixes
claude Oct 9, 2026
cbf4970
Keep a size over the drawer only when the drawer refused it, and offe…
claude Oct 9, 2026
1215858
Merge main e0b67e9 (#68) into the pasted-link and storage-full fixes
claude Oct 9, 2026
e57f471
Merge main 3145cc7 (#71) into the pasted-link and storage-full fixes
claude Oct 9, 2026
984bd8a
Leave on Start fresh as Put back does, so no change saves after the c…
claude Oct 9, 2026
6d99671
Count a refused change from the page's own base, carried with it
claude Oct 9, 2026
23b5376
Merge main f319c83 (#69) into the pasted-link and storage-full fixes
claude Oct 9, 2026
6f2045f
Merge main 5da18ce (#78) into the pasted-link and storage-full fixes
claude Oct 9, 2026
00ccddf
Merge main f9873f5 (#79) into the pasted-link and storage-full fixes
claude Oct 9, 2026
95ba00b
Count a refusal as done once a save carrying it goes through
claude Oct 9, 2026
27af93c
Merge main 88fef25 (#82) into the pasted-link and storage-full fixes
claude Oct 10, 2026
47987bd
Give each page its own refusal ids, and drop them with the refusal
claude Oct 10, 2026
ed19d84
Merge main 326cc48 (#84) into the page-code branch
claude Oct 10, 2026
d231b63
Count each refusal id from its own base
claude Oct 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 282 additions & 41 deletions bins/index.html

Large diffs are not rendered by default.

325 changes: 283 additions & 42 deletions index.html

Large diffs are not rendered by default.

85 changes: 76 additions & 9 deletions src/bins/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -5325,6 +5325,8 @@ function cleanNote(n) {
* stops that being your problem.
*/
let hashSaveT = 0, hashReady = false;
// saves were on when Start fresh left the page, and nothing has left it since (see startFresh)
let freshLeft = false;
/* Kept on this browser, so the work survives arriving without a link.
*
* The address bar already carries the design and a refresh already restores it. What it
Expand All @@ -5345,6 +5347,8 @@ let hashSaveT = 0, hashReady = false;
* when it has done one and offers a way back.
*/
const SAVE_KEY = 'drawerforge:bins:v1';
// this tab's record of a save a pasted link set aside (see pastedFrom), declared here for Start fresh
const PASTED_KEY = SAVE_KEY + ':pasted';
const saveLocal = (h) => {
try { localStorage.setItem(SAVE_KEY, h); }
catch (err) { /* private mode, or the quota is full — losing the save is not worth
Expand All @@ -5357,11 +5361,25 @@ const readLocal = () => { try { return localStorage.getItem(SAVE_KEY) || ''; } c
const isLayoutHash = (h) => /(^|&)[^&=]+=/.test(h);
function startFresh() {
try { localStorage.removeItem(SAVE_KEY); } catch (err) { /* nothing to clear */ }
location.href = location.origin + location.pathname; // drop the hash and reload clean
forgetPasted();
const saving = hashReady || freshLeft; // pressed again before the page goes: as the first press found it
/* Left as Put back leaves, by leaveFor: the page runs on until the bare one arrives, and
a change that landed in between was saved after the clearing, and came back with the
note that it had been restored. */
leaveFor(location.origin + location.pathname); // drop the hash and reload clean
freshLeft = saving; // after leaveFor, which clears it
}
/* Wired here, before the boot below reads any link: a link that throws there must not
also take away the button that gets you out of it, or stop the next link working. */
also take away the button that gets you out of it, or stop the next link working. What
leaveFor stops, hashReady and hashSaveT, is declared above, so it works from here too. */
$('startFresh').addEventListener('click', startFresh);
/* Left by Start fresh and shown again from the back-forward cache, as Back from the fresh
page can be in some browsers: the page is yours again, and saves as it did before, as it
does loaded. Not after Put back or Try anyway, which leave by leaveFor too, even pressed
after Start fresh before the page has gone: loaded, that page is a link again and sets
your layout aside first, and from the cache its first save would go over the layout just
put back. */
addEventListener('pageshow', (e) => { if (e.persisted && freshLeft) { hashReady = true; freshLeft = false; } });
/* A hash this page did not write means someone navigated to a link — pasted a share URL
into the address bar, or picked a bookmark — and changing only the fragment is a
same-document navigation, so nothing re-reads it and the drawer on screen stays put.
Expand Down Expand Up @@ -5430,7 +5448,7 @@ function linkKeys(h, link) {
return [...SHARED_KEYS].filter((k) => k in q && p[k] === q[k]);
}
function leaveFor(url) {
hashReady = false; clearTimeout(hashSaveT); // no save of this page's may land after
hashReady = false; freshLeft = false; clearTimeout(hashSaveT); // no save of this page's may land after
location.href = url;
}
/* Swapped rather than copied over: what is here now goes aside in its place, so putting
Expand All @@ -5446,6 +5464,7 @@ function putBack() {
}
saveLocal(prev);
writeKey(LINKED_KEY, prevLinked);
forgetPasted();
leaveFor(location.href.split('#')[0]); // a bare visit restores it, and says so
}
function tryAnyway() {
Expand Down Expand Up @@ -5507,11 +5526,45 @@ function saveNow() {
drawer the address is at: marked before it, a reload took the save before for its
own, and after another tab put the drawer back to that one, the reload wrote this
page's later change back over it. */
try { history.replaceState(drawers.stamp(h, linkedNow && bootDesc !== null), '', '#' + h); }
catch (err) { /* some browsers refuse replaceState on file:// — a lost URL is not
worth an exception that stops the rest of the page working */ }
if (!pastedOver()) {
try { history.replaceState(drawers.stamp(h, linkedNow && bootDesc !== null), '', '#' + h); }
catch (err) { /* some browsers refuse replaceState on file:// — a lost URL is not
worth an exception that stops the rest of the page working */ }
ownHash = location.hash;
} else {
try { sessionStorage.setItem(PASTED_KEY, JSON.stringify({ save: DRAWERS.fingerprint(h),
at: DRAWERS.fingerprint(ownHash) })); }
catch (err) { /* not kept, Back offers nothing: no worse than before */ }
}
}
}
/* The address as this page last left it: as it arrived, then as each save wrote it. One
that differs, with a layout in it, is a link gone to over this page, pasted or picked
from the bookmarks, whose hashchange (above) has not run yet: a page busy drawing comes
to a save that was waiting first. That save is still made, so the layout the link
replaces holds the change and is set aside with it, but the address is the link's.
Written back over, the hashchange found this page's design there and reloaded that,
and the link was gone. */
let ownHash = null;
const pastedOver = () => ownHash !== null && location.hash !== ownHash &&
isLayoutHash((location.hash || '').replace(/^#/, ''));
/* That save, and the address it left as it was, by fingerprint, for this tab: the layout
the link sets aside is the save, and it is later than the address, which never had the
change. Back to the address offers it, and only it (see `later` below). */
const pastedFrom = (prev) => {
try {
const r = JSON.parse(sessionStorage.getItem(PASTED_KEY) || 'null');
return !!r && !!prev && r.save === DRAWERS.fingerprint(prev) &&
r.at === DRAWERS.fingerprint(location.hash);
} catch (err) { return false; }
};
/* Start fresh and Put back each leave that save behind, and the record goes with them.
Kept past Start fresh, Back to a page at the same address offered the save as the later
layout, though Start fresh came after it. Start fresh works from before the boot reads a
link, so PASTED_KEY is declared with SAVE_KEY, above it. */
function forgetPasted() {
try { sessionStorage.removeItem(PASTED_KEY); } catch (err) { /* nothing kept to forget */ }
}
/* A reload takes the address as it stands when it starts, and the page runs on until the
new one arrives. A save still waiting would land in that gap and record in the saved
drawer a design the reloaded page did not arrive with, and the page came back unsaved.
Expand Down Expand Up @@ -5920,17 +5973,30 @@ let arrivedWith = ''; // the design string this page was opened with
layout was set aside and offered a Put back that brought nothing back. */
let keptAside = false;
if (aside) {
const asideLinked = linkKeys(saved, linked).length ? linked : '';
writeKey(PREV_KEY, saved);
keptAside = readKey(PREV_KEY) === saved;
if (keptAside) writeKey(PREV_LINKED_KEY, linkKeys(saved, linked).length ? linked : '');
if (keptAside) writeKey(PREV_LINKED_KEY, asideLinked);
/* With the record of whether it is a link's refused, the one left from the layout set
aside before would answer for it. That goes, and put back, this one is yours: still
better than not setting it aside (unkept), which keeps it only until the first
change made on the link. */
if (keptAside && readKey(PREV_LINKED_KEY) !== asideLinked) writeKey(PREV_LINKED_KEY, '');
/* Not kept, it is not written over either (unkept), unless a hand-over of your own
brings on anything the other page sets: then the save holds the drawer, bed or the
other page's settings from before, and a bare visit took those back to the other
page. One still carrying someone's link is that link, and your layout is kept. */
else unkept = !handOver || handOver.link.length > 0 || drawers.onlyMine(saved, src);
if (!keptAside) unkept = !handOver || handOver.link.length > 0 || drawers.onlyMine(saved, src);
}
/* Back to your own earlier page over a link's layout, untouched, sets nothing aside: what
the link replaced is aside already. That can be later than the page Back brings: a change
whose save came due as the link was pasted is aside, and in no earlier address (see
pastedOver). So that layout is offered, if it is the one aside and this is the address it
came from, and no other: one aside for any other reason can be older than this page, and
Put back went further back, not on. */
const later = back && savedLinked && pastedFrom(readKey(PREV_KEY)) ? readKey(PREV_KEY) : '';
const canPutBack = (replaces && !kept && (keptAside || (savedLinked && !!readKey(PREV_KEY)))) ||
(back && keptAside);
(back && (keptAside || (!!later && !sameDesign(later, src))));
if (stalled) {
showSetAside('This layout did not finish loading last time, so the page has started ' +
'from its defaults rather than try it again.', canPutBack, true);
Expand Down Expand Up @@ -5971,6 +6037,7 @@ if (pendingNotes) {
}
readControls();
hashReady = true; // loadFromHash has had its say; ours may start
ownHash = location.hash;
initThree();
initMap();
drawLayerTabs();
Expand Down
Loading
Loading