MCPcopy Index your code
hub / github.com/FThompson/FormPersistence.js / load

Function load

form-persistence.js:246–258  ·  view source on GitHub ↗

* Loads a given form from local or session storage, optionally with given special value handling functions. * Does nothing if no saved values are found. * * @param {HTMLFormElement} form The form to load saved values into. * @param {Object} options Options object con

(form, options)

Source from the content-addressed store, hash-verified

244 * is excluded if the function returns true.
245 */
246 function load(form, options) {
247 let defaults = {
248 uuid: null,
249 useSessionStorage: false
250 }
251 let config = Object.assign({}, defaults, options)
252 let storage = config.useSessionStorage ? sessionStorage : localStorage
253 let json = storage.getItem(getStorageKey(form, config.uuid))
254 if (json) {
255 let data = JSON.parse(json)
256 deserialize(form, data, options)
257 }
258 }
259
260 /**
261 * Clears a given form's data from local or session storage.

Callers 1

persistFunction · 0.85

Calls 2

getStorageKeyFunction · 0.85
deserializeFunction · 0.85

Tested by

no test coverage detected