Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Utils.promise((resolve, reject) => {
try {
Object.keys(window.localStorage)
.filter(keyName => keyName.indexOf(keyPrefix) === 0)
.forEach((keyName, index) => {
const key = keyName.replace(keyPrefix, '');
Storage.get(key).then((value) => {
callback(key, value, index);
});
});
resolve();
} catch (e) {
reject(e);
}
});
},
saveHistory() {
const router = this;
router.view.history = router.history;
if (router.params.pushState) {
window.localStorage[`f7router-${router.view.id}-history`] = JSON.stringify(router.history);
}
}
get(form) {
const app = this;
let formId = form;
const $formEl = $(form);
if ($formEl.length && $formEl.is('form') && $formEl.attr('id')) {
formId = $formEl.attr('id');
}
if (window.localStorage[`f7form-${formId}`]) {
return JSON.parse(window.localStorage[`f7form-${formId}`]);
}
if (app.form.data[`form-${formId}`]) {
return app.form.data[`form-${formId}`];
}
return undefined;
},
remove(form) {
saveHistory() {
const router = this;
router.view.history = router.history;
if (router.params.pushState) {
window.localStorage[`f7router-${router.view.id}-history`] = JSON.stringify(router.history);
}
}
restoreHistory() {
const router = this;
if (router.params.pushState && window.localStorage[`f7router-${router.view.id}-history`]) {
router.history = JSON.parse(window.localStorage[`f7router-${router.view.id}-history`]);
router.view.history = router.history;
}
}
get(form) {
const app = this;
let formId = form;
const $formEl = $(form);
if ($formEl.length && $formEl.is('form') && $formEl.attr('id')) {
formId = $formEl.attr('id');
}
try {
if (window.localStorage[`f7form-${formId}`]) {
return JSON.parse(window.localStorage[`f7form-${formId}`]);
}
} catch (e) {
throw e;
}
if (app.form.data[`form-${formId}`]) {
return app.form.data[`form-${formId}`];
}
return undefined;
},
remove(form) {
return new Promise((resolve, reject) => {
try {
const keys = Object.keys(window.localStorage)
.filter(keyName => keyName.indexOf(keyPrefix) === 0)
.map(keyName => keyName.replace(keyPrefix, ''));
resolve(keys);
} catch (e) {
reject(e);
}
});
},
return new Promise((resolve, reject) => {
try {
const value = JSON.parse(window.localStorage.getItem(`${keyPrefix}${key}`));
resolve(value);
} catch (e) {
reject(e);
}
});
},
restoreHistory() {
const router = this;
if (router.params.pushState && window.localStorage[`f7router-${router.view.id}-history`]) {
router.history = JSON.parse(window.localStorage[`f7router-${router.view.id}-history`]);
router.view.history = router.history;
}
}
restoreHistory() {
const router = this;
if (router.params.pushState && window.localStorage[`f7router-${router.view.id}-history`]) {
router.history = JSON.parse(window.localStorage[`f7router-${router.view.id}-history`]);
router.view.history = router.history;
}
}