]> git.scottworley.com Git - picsort/blame_incremental - picsorter.js
Move deletion data into a generic 'picinfo' store
[picsort] / picsorter.js
... / ...
CommitLineData
1var picinfo = {};
2if ("picsorter_picinfo" in localStorage) {
3 picinfo = JSON.parse(localStorage.picsorter_picinfo);
4}
5$.each(files, function(i, f) {
6 if (!(f in picinfo)) {
7 picinfo[f] = {};
8 }
9});
10localStorage.picsorter_picinfo = JSON.stringify(picinfo);
11
12var exposure = 20;
13var zoom = "sm/";
14var input_index = -1;
15move_to_nondeleted(1);
16
17
18function setpic() {
19 $("#pic").attr("src", zoom + exposure + "/" + files[input_index]);
20}
21
22function say(message) {
23 $("#message").text(message).removeClass("fade");
24 setTimeout(function() { $("#message").addClass("fade"); }, 1);
25}
26
27function say_exposure() {
28 var e = (exposure / 4) - 3.5;
29 say((e >= 0 ? "+" : "") + e);
30}
31
32function toggle_zoom() {
33 if (zoom) {
34 zoom = "";
35 } else {
36 zoom = "sm/";
37 }
38 setpic();
39}
40
41function move_to_nondeleted(direction) {
42 do {
43 input_index += direction;
44 } while (picinfo[files[input_index]].deleted);
45 say(input_index);
46}
47
48function mark_deleted() {
49 picinfo[files[input_index]].deleted = 1;
50 localStorage.picsorter_picinfo = JSON.stringify(picinfo);
51 say("Deleted");
52}
53
54function mark_not_deleted() {
55 delete picinfo[files[input_index]].deleted;
56 localStorage.picsorter_picinfo = JSON.stringify(picinfo);
57 say("Undeleted");
58}
59
60$(function() {
61 setpic();
62});
63
64Mousetrap.bind('z', toggle_zoom);
65Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
66Mousetrap.bind('n', function() { move_to_nondeleted(1); setpic(); });
67Mousetrap.bind('p', function() { move_to_nondeleted(-1); setpic(); });
68Mousetrap.bind('N', function() { input_index ++; say(input_index); setpic(); });
69Mousetrap.bind('P', function() { input_index --; say(input_index); setpic(); });
70Mousetrap.bind('b', function() { exposure ++; say_exposure(); setpic(); });
71Mousetrap.bind('d', function() { exposure --; say_exposure(); setpic(); });
72Mousetrap.bind('x', mark_deleted);
73Mousetrap.bind('X', mark_not_deleted);