]>
Commit | Line | Data |
---|---|---|
1 | var picinfo = {}; | |
2 | if ("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 | }); | |
10 | localStorage.picsorter_picinfo = JSON.stringify(picinfo); | |
11 | ||
12 | var exposure = 20; | |
13 | var zoom = "sm/"; | |
14 | var input_index = -1; | |
15 | ||
16 | ||
17 | function setpic() { | |
18 | if ("exposure" in picinfo[files[input_index]]) { | |
19 | exposure = picinfo[files[input_index]].exposure; | |
20 | } else { | |
21 | picinfo[files[input_index]].exposure = exposure; | |
22 | localStorage.picsorter_picinfo = JSON.stringify(picinfo); | |
23 | } | |
24 | $("#pic").attr("src", zoom + exposure + "/" + files[input_index]); | |
25 | } | |
26 | ||
27 | function say(message) { | |
28 | $("#message").text(message).removeClass("fade"); | |
29 | setTimeout(function() { $("#message").addClass("fade"); }, 1); | |
30 | } | |
31 | ||
32 | function toggle_zoom() { | |
33 | if (zoom) { | |
34 | zoom = ""; | |
35 | } else { | |
36 | zoom = "sm/"; | |
37 | } | |
38 | setpic(); | |
39 | } | |
40 | ||
41 | function move_to_nondeleted(direction) { | |
42 | do { | |
43 | input_index += direction; | |
44 | } while (picinfo[files[input_index]].deleted); | |
45 | say(input_index); | |
46 | setpic(); | |
47 | } | |
48 | ||
49 | function mark_deleted() { | |
50 | picinfo[files[input_index]].deleted = 1; | |
51 | localStorage.picsorter_picinfo = JSON.stringify(picinfo); | |
52 | say("Deleted"); | |
53 | } | |
54 | ||
55 | function mark_not_deleted() { | |
56 | delete picinfo[files[input_index]].deleted; | |
57 | localStorage.picsorter_picinfo = JSON.stringify(picinfo); | |
58 | say("Undeleted"); | |
59 | } | |
60 | ||
61 | function change_exposure(amount) { | |
62 | exposure += amount; | |
63 | picinfo[files[input_index]].exposure = exposure; | |
64 | setpic(); | |
65 | var display_exposure = (exposure / 4) - 3.5; | |
66 | say((display_exposure >= 0 ? "+" : "") + display_exposure); | |
67 | } | |
68 | ||
69 | $(function() { | |
70 | move_to_nondeleted(1); | |
71 | }); | |
72 | ||
73 | Mousetrap.bind('z', toggle_zoom); | |
74 | Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); }); | |
75 | Mousetrap.bind('n', function() { move_to_nondeleted(1); }); | |
76 | Mousetrap.bind('p', function() { move_to_nondeleted(-1); }); | |
77 | Mousetrap.bind('N', function() { input_index ++; say(input_index); setpic(); }); | |
78 | Mousetrap.bind('P', function() { input_index --; say(input_index); setpic(); }); | |
79 | Mousetrap.bind('b', function() { change_exposure(1); }); | |
80 | Mousetrap.bind('d', function() { change_exposure(-1); }); | |
81 | Mousetrap.bind('x', mark_deleted); | |
82 | Mousetrap.bind('X', mark_not_deleted); |