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