]> git.scottworley.com Git - picsort/blame - picsorter.js
Add exposure level chattiness
[picsort] / picsorter.js
CommitLineData
2d325f41
SW
1if (!("picsorter_deleted" in localStorage)) {
2 localStorage.picsorter_deleted = JSON.stringify({});
3}
d1309d5a 4var picsorter_deleted = JSON.parse(localStorage.picsorter_deleted);
2d325f41 5
ca898dc7
SW
6var exposure = 20;
7var zoom = "sm/";
8var input_index = -1;
9move_to_nondeleted(1);
10
11
ed9d7c54 12function setpic() {
9952a1a7
SW
13 $("#pic").attr("src", zoom + exposure + "/" + files[input_index]);
14}
15
9c7566e1
SW
16function say(message) {
17 $("#message").text(message).removeClass("fade");
18 setTimeout(function() { $("#message").addClass("fade"); }, 1);
19}
20
ca26d0d7
SW
21function say_exposure() {
22 var e = (exposure / 4) - 3.5;
23 say((e >= 0 ? "+" : "") + e);
24}
25
9952a1a7
SW
26function toggle_zoom() {
27 if (zoom) {
28 zoom = "";
29 } else {
30 zoom = "sm/";
31 }
ac4559ea 32 setpic();
97c26a9c
SW
33}
34
2d325f41 35function move_to_nondeleted(direction) {
2d325f41
SW
36 do {
37 input_index += direction;
d1309d5a 38 } while (files[input_index] in picsorter_deleted);
9c7566e1 39 say(input_index);
2d325f41
SW
40}
41
42function mark_deleted() {
d1309d5a
SW
43 picsorter_deleted[files[input_index]] = 1;
44 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
9c7566e1 45 say("Deleted");
2d325f41
SW
46}
47
48function mark_not_deleted() {
d1309d5a
SW
49 delete picsorter_deleted[files[input_index]];
50 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
9c7566e1 51 say("Undeleted");
2d325f41
SW
52}
53
5d9946cb 54$(function() {
ed9d7c54 55 setpic();
e18c13a6 56});
ecb5b4ef 57
ac4559ea 58Mousetrap.bind('z', toggle_zoom);
9952a1a7 59Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
2d325f41
SW
60Mousetrap.bind('n', function() { move_to_nondeleted(1); setpic(); });
61Mousetrap.bind('p', function() { move_to_nondeleted(-1); setpic(); });
9c7566e1
SW
62Mousetrap.bind('N', function() { input_index ++; say(input_index); setpic(); });
63Mousetrap.bind('P', function() { input_index --; say(input_index); setpic(); });
ca26d0d7
SW
64Mousetrap.bind('b', function() { exposure ++; say_exposure(); setpic(); });
65Mousetrap.bind('d', function() { exposure --; say_exposure(); setpic(); });
ac4559ea
SW
66Mousetrap.bind('x', mark_deleted);
67Mousetrap.bind('X', mark_not_deleted);