This is my new blog CMS https://jlelse.blog
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

19 lines
669 B

(function () {
const fc = 'formcache'
Array.from(document.querySelectorAll('form .' + fc)).forEach(element => {
let elementName = fc + '-' + location.pathname + '#' + element.id
// Load from cache
let cached = localStorage.getItem(elementName)
if (cached != null) {
element.value = cached
}
// Auto save to cache
element.addEventListener('input', function () {
localStorage.setItem(elementName, element.value)
})
// Clear on submit
element.form.addEventListener('submit', function () {
localStorage.removeItem(elementName)
})
})
})()