diff --git a/client/scripts/profile.js b/client/scripts/profile.js index 1520a02..dc0cd42 100644 --- a/client/scripts/profile.js +++ b/client/scripts/profile.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 + * Copyright (c) 2015 Alex Yatskov * Author: Alex Yatskov * * 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) { diff --git a/client/scripts/search.js b/client/scripts/search.js index c39cd0a..072a27a 100644 --- a/client/scripts/search.js +++ b/client/scripts/search.js @@ -1,5 +1,6 @@ /* * Copyright (c) 2015 Alex Yatskov + * Author: Alex Yatskov * * 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);