Improved local storage handling
This commit is contained in:
parent
34b4eac3c1
commit
491dccbbe9
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015 <name of copyright holder>
|
||||
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
|
||||
* Author: Alex Yatskov <alex@foosoft.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
@ -24,11 +24,14 @@
|
||||
'use strict';
|
||||
|
||||
function setProfileValue(id, value) {
|
||||
localStorage[id] = value;
|
||||
var profile = JSON.parse(localStorage.profile || '{}');
|
||||
profile[id] = value;
|
||||
localStorage.profile = JSON.stringify(profile);
|
||||
}
|
||||
|
||||
function getProfileValue(id) {
|
||||
return localStorage[id] || 0;
|
||||
var profile = JSON.parse(localStorage.profile || '{}');
|
||||
return profile[id] || 0;
|
||||
}
|
||||
|
||||
function addCategory(description) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
|
||||
* Author: Alex Yatskov <alex@foosoft.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
@ -43,7 +44,7 @@
|
||||
$('#profileDlg').on('hidden.bs.modal', onSearch);
|
||||
|
||||
window.accessReview = function(id) {
|
||||
$.getJSON('/access', {id: id, profile: localStorage}, function(results) {
|
||||
$.getJSON('/access', {id: id, profile: getProfile()}, function(results) {
|
||||
if (results.success) {
|
||||
location.replace(results.url);
|
||||
}
|
||||
@ -57,7 +58,7 @@
|
||||
_ctx.query = {
|
||||
features: _ctx.query.features || {},
|
||||
range: { min: -1.0, max: 1.0 },
|
||||
profile: localStorage,
|
||||
profile: getProfile(),
|
||||
walkingDist: parseFloat($('#walkingDist').val()),
|
||||
minScore: parseFloat($('#minScore').val()),
|
||||
hintSteps: parseInt($('#hintSteps').val()),
|
||||
@ -147,6 +148,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getProfile() {
|
||||
return JSON.parse(localStorage.profile || '{}');
|
||||
}
|
||||
|
||||
window.onpopstate = function(state) {
|
||||
if (state.state) {
|
||||
outputSnapshot(state.state, false);
|
||||
|
Loading…
Reference in New Issue
Block a user