]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | function setpic() { | |
10 | $("#pic").attr("src", zoom + exposure + "/" + files[input_index]); | |
11 | } | |
12 | ||
13 | function toggle_zoom() { | |
14 | if (zoom) { | |
15 | zoom = ""; | |
16 | } else { | |
17 | zoom = "sm/"; | |
18 | } | |
19 | } | |
20 | ||
21 | function move_to_nondeleted(direction) { | |
22 | var deleted = JSON.parse(localStorage.picsorter_deleted); | |
23 | do { | |
24 | input_index += direction; | |
25 | } while (files[input_index] in deleted); | |
26 | } | |
27 | ||
28 | function mark_deleted() { | |
29 | var deleted = JSON.parse(localStorage.picsorter_deleted); | |
30 | deleted[files[input_index]] = 1; | |
31 | localStorage.picsorter_deleted = JSON.stringify(deleted); | |
32 | } | |
33 | ||
34 | function mark_not_deleted() { | |
35 | var deleted = JSON.parse(localStorage.picsorter_deleted); | |
36 | delete deleted[files[input_index]]; | |
37 | localStorage.picsorter_deleted = JSON.stringify(deleted); | |
38 | } | |
39 | ||
40 | $(function() { | |
41 | setpic(); | |
42 | }); | |
43 | ||
44 | Mousetrap.bind('z', function() { toggle_zoom(); setpic(); }); | |
45 | Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); }); | |
46 | Mousetrap.bind('n', function() { move_to_nondeleted(1); setpic(); }); | |
47 | Mousetrap.bind('p', function() { move_to_nondeleted(-1); setpic(); }); | |
48 | Mousetrap.bind('N', function() { input_index ++; setpic(); }); | |
49 | Mousetrap.bind('P', function() { input_index --; setpic(); }); | |
50 | Mousetrap.bind('b', function() { exposure ++; setpic(); }); | |
51 | Mousetrap.bind('d', function() { exposure --; setpic(); }); | |
52 | Mousetrap.bind('x', function() { mark_deleted(); }); | |
53 | Mousetrap.bind('X', function() { mark_not_deleted(); }); |