Closed bwl21 closed 6 years ago
You know there are two storage areas: local and session.
The session storage is destroyed when the browser tab is closed.
The local storage remains forever, but may be explicitly destroyed.
The problem is that the browsers load all local storage areas at startup time, on the contrary of the cookies which are loaded when required.
An other problem is that you reload the area each time the source is changed. This implies extra (useless) memory transfers.
Also, you lose the location of the source when this one was loaded by File->Load.
A better solution would be to ask the user to save the source when the page is about to be destroyed.
In the same way, a button could permit the user to save the source in, either the local storage, or a cookie, or a clipboard, or ...
Personnaly, I save the test examples in the clipboard before reloading the page in Vivaldi. Palemoon does not destroy the source on page reload.
I was using your function assuming thats it uses localstorage. My primary Intention was to simply have the ABC Code back after a refresh. So even session storage would do it.
I did not observe any problem with saving in every change. But we could save on every render operation.
As I never opened a file i was not aware of the filename issue. But we could keep this in localstorage as well, maybe as another entry. On the other hand, Copy Paste does not maintain filename either.
I guess palemoon maintain input as unprocessed form and keeps the content. I Never managed to apply my own behavior in beforeunload event. It does not catch a crash anyhow.
So i Think ja proposal is a simple solution to an annoying problem.
The local storage values remain forever in the browser data. From my tests with a local http server, I cannot remove these data using the browser settings (delete cookies - the local server is not in the list).
Well, instead of changing the edit.js source, you may use a bookmarklet. This one works fine for me:
javascript:var%20v=storage(true,'abc-source');
if(v)elt_ref.source.value=v;
function%20src_change(){
storage(true,'abc-source',elt_ref.source.value);
clearTimeout(timer);if(!playing)timer=setTimeout(render,2000)
};void(0)
(you call it after starting my editor)
I did not really get your root concern with the proposed solution.
Maybe abc has another quality than a setting. But localstorage is bound to the url, so I don't think it is a problem.
If you consider saving entered abc in localstorage as harmful, we could add an preference option to control the saving. When disabling, you can simply clear the entry in localstorage (localStorage.removeItem('abc-source')
). You could even add an option "clear localstorage" which removes all entries (localStorage.clear()
)
I tried the bookmarklet but I think it is not sufficient. After reloading the page I have to click it again to get the abc code back and activate the saving. So the bookmarklet helps me when I refresh the page without saving the abc to the clipboard.
To be honest, I personally do not like bookmarklets anyhow, they pollute my bookmarkbar, are visible on every page, the code is not provided by the server ...
Now, I would say, if you absolutely want this feature, you have all the sources, write your own editor! (in fact, you just have to add a Githubissues.
While testing with edit-1.xhtml, whenever i reload the page (e.g. due to a switch to another commit) i have to reenter the abc code.
I therefore added a feature that edit-1.xhtml restores the latest abc-text upon reload. This also helps, if the user occasionally has left the page in the browser, or restarts after a crash.
Would be glad if you could merge this. Maybe it makes sense to add a preference which toggles this feature.