[tw5] GetLocalStorageItem javascript macro

I don’t have much experience with javascript macros, but I know just enough to be dangerous…

So FYI, just a simple javascript macro example for anybody interested in this kind of thing.

See attached text file.

(I’ll follow this up with a link to this Google Post, in case the attachment does not show in TiddlyTalk.)

(Attachment GetLocalStorageItem.js.txt is missing)

https://groups.google.com/g/tiddlywiki/c/mOm62AUaz8c

Even in Google Groups, your attachment is empty. I would recommend pastebin or making a GitHub gist.

Arg, I totally borked the export of that file. (The file on my local drive is empty.)

Thanks for catching that.

Instead, sneak a peek at both javascript macros (GetLocalStorageItem and SetLocalStorageItem) here: https://basicanywheremachine.neocities.org/LocalStoragePrototype.html

That TiddlyWiki is to demonstrate not just local storage in TiddlyWiki, but a way for a BASIC program and a TiddlyWiki instance can exchange data via local storage, as long as they are both in the same domain.

I am assuming that “as long as they are both in the same domain” applies to a googleDrive environment as well as your …neocities… domain. Please let me know if that is NOT a valid assumption. In the mean time, I am going to ponder some “back-up” considerations that are nagging at me.

Cheers,
Hans

I am no internet expert, so not sure if and when I’m using the right language.

Let’s say we have two web pages (say one is some TiddlyWiki, say the other is a TiddlyWiki with BASIC Anywhere Machine). For them (and however many others) to share data via local storage, they must all be in the same origin. That origin could be any web host at all, as long as all the web pages are from the same IP and port (if I understand correctly?)

I’d say as per the Same-origin policy documentation at MDN Web Docs.

If a web browser allows local storage at localhost (i.e. the hard drive on your computer), then all TiddlyWiki instances and whatever other local web pages on your computer are accessing the same local storage.

Something like that …

I think you are other right track.

I’ve even gone so far as to mention aspects of this to Jeremy.

– You received this message because you are subscribed to the Google Groups “TiddlyWiki” group. To unsubscribe from this group and stop receiving emails from it, send an email to . To view this discussion on the web visit .

For storage purposes, you could use IndexedDB and create a database for each wiki isolated by taking the hash of the URL (which is easy to get via JS) and using that for the DB name. It doesn’t really add any security, but it does avoid accidental clobbering. The downside to this approach is you would have to use IndexedDB which is a really horrible and confusing API.