I want to create plugin mechanizm. It is, you can load js file on my website and run your js "plugin" (function) when this plugin is set to run (toggled as running).
All this I want to do without any server.
I mean, I want to keep in localstorage js files or path to this files.
It looks to be hard to do because js can't easy access files path.
I handle file by <input type="file"/>
And I react on onchange event. I get event where I can find selected file by event.srcElement.files[0]
With that I can create URL of that object by : URL.createObjectURL(event.srcElement.files[0])
And I tried to store that URL in localstorage but this URL is temporary.
Also I tried to store whole event or just file (event.srcElement.files[0]
).
But I need to create string from that if I want to put it to the function .setItem
:
localStorage.setItem("functionURL", JSON.stringify(this.functionURL));
.toString()
creates [Object Event/File]
JSON.stringify()
creates {}
from [Object Event/File]
So, maybe is there a way to somehow remember file which we can use as a function without any server ?