]> git.scottworley.com Git - picsort/blame_incremental - picsorter.js
Save per-pic exposures
[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;
15
16
17function 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
27function say(message) {
28 $("#message").text(message).removeClass("fade");
29 setTimeout(function() { $("#message").addClass("fade"); }, 1);
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 setpic();
47}
48
49function mark_deleted() {
50 picinfo[files[input_index]].deleted = 1;
51 localStorage.picsorter_picinfo = JSON.stringify(picinfo);
52 say("Deleted");
53}
54
55function mark_not_deleted() {
56 delete picinfo[files[input_index]].deleted;
57 localStorage.picsorter_picinfo = JSON.stringify(picinfo);
58 say("Undeleted");
59}
60
61function 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
73Mousetrap.bind('z', toggle_zoom);
74Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
75Mousetrap.bind('n', function() { move_to_nondeleted(1); });
76Mousetrap.bind('p', function() { move_to_nondeleted(-1); });
77Mousetrap.bind('N', function() { input_index ++; say(input_index); setpic(); });
78Mousetrap.bind('P', function() { input_index --; say(input_index); setpic(); });
79Mousetrap.bind('b', function() { change_exposure(1); });
80Mousetrap.bind('d', function() { change_exposure(-1); });
81Mousetrap.bind('x', mark_deleted);
82Mousetrap.bind('X', mark_not_deleted);