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