]> git.scottworley.com Git - picsort/blame_incremental - picsorter.js
Don't start on a deleted picture.
[picsort] / picsorter.js
... / ...
CommitLineData
1if (!("picsorter_deleted" in localStorage)) {
2 localStorage.picsorter_deleted = JSON.stringify({});
3}
4var picsorter_deleted = JSON.parse(localStorage.picsorter_deleted);
5
6var exposure = 20;
7var zoom = "sm/";
8var input_index = -1;
9move_to_nondeleted(1);
10
11
12function setpic() {
13 $("#pic").attr("src", zoom + exposure + "/" + files[input_index]);
14}
15
16function toggle_zoom() {
17 if (zoom) {
18 zoom = "";
19 } else {
20 zoom = "sm/";
21 }
22}
23
24function move_to_nondeleted(direction) {
25 do {
26 input_index += direction;
27 } while (files[input_index] in picsorter_deleted);
28}
29
30function mark_deleted() {
31 picsorter_deleted[files[input_index]] = 1;
32 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
33}
34
35function mark_not_deleted() {
36 delete picsorter_deleted[files[input_index]];
37 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
38}
39
40$(function() {
41 setpic();
42});
43
44Mousetrap.bind('z', function() { toggle_zoom(); setpic(); });
45Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
46Mousetrap.bind('n', function() { move_to_nondeleted(1); setpic(); });
47Mousetrap.bind('p', function() { move_to_nondeleted(-1); setpic(); });
48Mousetrap.bind('N', function() { input_index ++; setpic(); });
49Mousetrap.bind('P', function() { input_index --; setpic(); });
50Mousetrap.bind('b', function() { exposure ++; setpic(); });
51Mousetrap.bind('d', function() { exposure --; setpic(); });
52Mousetrap.bind('x', function() { mark_deleted(); });
53Mousetrap.bind('X', function() { mark_not_deleted(); });