]> git.scottworley.com Git - picsort/commitdiff
Move deletion data into a generic 'picinfo' store
authorScott Worley <scottworley@scottworley.com>
Fri, 28 Feb 2014 08:47:53 +0000 (00:47 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 28 Feb 2014 08:47:53 +0000 (00:47 -0800)
This will also store other data, like name and exposure level.

picsorter.js

index d3f50ccdf5701a68a6372bd3dc199860cb1bfdd1..ae4c8377453caa1c1d80d6456b8d3d4de6dbd572 100644 (file)
@@ -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");
 }