From a6146cd77e678153ef4f29f4178b495edfd4a92f Mon Sep 17 00:00:00 2001 From: Gwyneth Llewelyn Date: Wed, 17 Apr 2024 21:48:11 +0100 Subject: [PATCH] Docs: Added more explanatory notes --- tests/test.css | 1 + tests/test.html | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/tests/test.css b/tests/test.css index 8bafdf8..ba51993 100644 --- a/tests/test.css +++ b/tests/test.css @@ -16,6 +16,7 @@ h1 { p { color: darkslategray; + padding-bottom: 0.5em; } /* CSS below comes from phpBB3 directly */ diff --git a/tests/test.html b/tests/test.html index 1e9d166..e881ef2 100644 --- a/tests/test.html +++ b/tests/test.html @@ -2,6 +2,7 @@ Test page + @@ -12,10 +13,46 @@ -

Fake phpBB3 Page

-

- Saves unsaved text to localStorage. Submit does nothing, but the script should clear both the storage and the textarea

-
+

Fake phpBB3 Page

+
+

Instructions

+

+ Saves unsaved text to localStorage. +

+

+ To test, just type something either on the subject input box, or on the textarea for the content below, and press the Submit button. +

+

+ When clicking Submit for the first time, this will refresh the page, clear local storage, and force the page to go to tag #theTitle (the first heading), which will be appended to the URL. This is not the expected result, but it's the best one can do, taking into consideration that there is no real web server to submit anything to. +

+

+ Instead, we're "pretending" that there was a server redirecting us to a new page (which just happens to be this very same one). But everything only happens on the browser. +

+

+ However, from the second time onwards, when pressing the Submit button again, the URL will keep the tag appended to the end. Since the local storage is designed to use the URL as a key, it will be with this URL that a new entry will be sent to the local storage. +

+

+ There will be now a new entry on local storage, while the first one (because we have pressed Submit) will be deleted from it. +

+

+ You can now move away from the page, close the tab, reopen it, etc. In theory, the URL with the tag at the end will retain the local storage until you press Submit again. It should even resist a browser crash. It'll stay there technically "forever" (in practice, if you come back after a year, local storage will be deleted by then — it's hard-coded). +

+

Notes

+

+ Note that the saving only occurs after the first key press (on either field). +

+

+ Manually clearing the textarea (where the main content is) will also remove the entry in local storage (this is similar to other environments which implement similar features), thus allowing a "fresh start", so to speak. +

+

+ The content of both fields gets updated every ten seconds (also hard-coded), which is a reasonable trade-off, considering the typing speed of most humans, and the need to conserve resources. There is no "versioning", only the last state is saved (again, to prevent memory to be exhausted). After the Submit button gets pressed, not only the local storage is cleaned, but the timer also gets removed, thus restoring everything to the state it was before. +

+

+ There is no limit in how many pages can be open with half-written posts all the time, although pages with exactly the same URL will retrieve the same content from the local storage. This means that you cannot prepare two posts on the same thread using the same browser 😄 +

+
+
+