From: Scott Worley Date: Fri, 28 Feb 2014 09:08:19 +0000 (-0800) Subject: save_picinfo() X-Git-Url: http://git.scottworley.com/picsort/commitdiff_plain/01dd04816ae1bec01e224c8cd17e271ec129ad1c?ds=inline save_picinfo() Name this and call it rather than copy/pasting it around. Also, fix a bug where change_exposure() should have been saving picinfo but wasn't. --- diff --git a/picsorter.js b/picsorter.js index abed507..db313d9 100644 --- a/picsorter.js +++ b/picsorter.js @@ -7,7 +7,10 @@ $.each(files, function(i, f) { picinfo[f] = {}; } }); -localStorage.picsorter_picinfo = JSON.stringify(picinfo); +function save_picinfo() { + localStorage.picsorter_picinfo = JSON.stringify(picinfo); +} +save_picinfo(); var exposure = 20; var zoom = "sm/"; @@ -19,7 +22,7 @@ function setpic() { exposure = picinfo[files[input_index]].exposure; } else { picinfo[files[input_index]].exposure = exposure; - localStorage.picsorter_picinfo = JSON.stringify(picinfo); + save_picinfo(); } $("#pic").attr("src", zoom + exposure + "/" + files[input_index]); } @@ -48,19 +51,20 @@ function move_to_nondeleted(direction) { function mark_deleted() { picinfo[files[input_index]].deleted = 1; - localStorage.picsorter_picinfo = JSON.stringify(picinfo); + save_picinfo(); say("Deleted"); } function mark_not_deleted() { delete picinfo[files[input_index]].deleted; - localStorage.picsorter_picinfo = JSON.stringify(picinfo); + save_picinfo(); say("Undeleted"); } function change_exposure(amount) { exposure += amount; picinfo[files[input_index]].exposure = exposure; + save_picinfo(); setpic(); var display_exposure = (exposure / 4) - 3.5; say((display_exposure >= 0 ? "+" : "") + display_exposure);