From: Scott Worley Date: Fri, 28 Feb 2014 08:47:53 +0000 (-0800) Subject: Move deletion data into a generic 'picinfo' store X-Git-Url: http://git.scottworley.com/picsort/commitdiff_plain/31092212d9330f6d19ff2d0cc034459ff892e92a?ds=sidebyside;hp=ca26d0d738c3eaa798f3fd53e75756910328fc37 Move deletion data into a generic 'picinfo' store This will also store other data, like name and exposure level. --- diff --git a/picsorter.js b/picsorter.js index d3f50cc..ae4c837 100644 --- a/picsorter.js +++ b/picsorter.js @@ -1,7 +1,13 @@ -if (!("picsorter_deleted" in localStorage)) { - localStorage.picsorter_deleted = JSON.stringify({}); +var picinfo = {}; +if ("picsorter_picinfo" in localStorage) { + picinfo = JSON.parse(localStorage.picsorter_picinfo); } -var picsorter_deleted = JSON.parse(localStorage.picsorter_deleted); +$.each(files, function(i, f) { + if (!(f in picinfo)) { + picinfo[f] = {}; + } +}); +localStorage.picsorter_picinfo = JSON.stringify(picinfo); var exposure = 20; var zoom = "sm/"; @@ -35,19 +41,19 @@ function toggle_zoom() { function move_to_nondeleted(direction) { do { input_index += direction; - } while (files[input_index] in picsorter_deleted); + } while (picinfo[files[input_index]].deleted); say(input_index); } function mark_deleted() { - picsorter_deleted[files[input_index]] = 1; - localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted); + picinfo[files[input_index]].deleted = 1; + localStorage.picsorter_picinfo = JSON.stringify(picinfo); say("Deleted"); } function mark_not_deleted() { - delete picsorter_deleted[files[input_index]]; - localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted); + delete picinfo[files[input_index]].deleted; + localStorage.picsorter_picinfo = JSON.stringify(picinfo); say("Undeleted"); }