Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrienko/preservejs
A lame form value preservation script
https://github.com/andrienko/preservejs
Last synced: 7 days ago
JSON representation
A lame form value preservation script
- Host: GitHub
- URL: https://github.com/andrienko/preservejs
- Owner: andrienko
- Created: 2014-11-24T10:25:08.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-24T10:27:05.000Z (almost 10 years ago)
- Last Synced: 2023-08-19T23:21:46.714Z (about 1 year ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PreserveJS
===
Hello. This one is a tiny library that helps you to save entered values of HTML elements.
It is actually pretty lame.This helps to not lose form values on tab close/page reload. If you need something super-stable -- write your own.
Usage
---
All you have to do is add the script in your html file:
And then add the "preserve" property to any html element:
This will save element value every time it changes, in a localstorage.Preservation ID
---Values are saved in an identifier which, if no value for "preserve" attribute is set, is generated, url- and
elementID-dependant. You can alter this by specifying the value for preserve attribute
Preservation ID generation
---
By default the values are saved by a key formed from current url + hash symbol + id or name of element. (Name is used
if id is empty). Say, for this:
The value, on http://localhost/preserve will be saved in a key called `localhost/preserve#checkit`. This means that, say,
on http://localhost/preserve?mode=gallery page it will not be preserved, even if input has same id.Future Plans
---- Support for select multiple
Warning
---
LocalStorage is limited to 5MB. So maybe consider not using this for large input fields etc.