]> git.scottworley.com Git - picsort/blame - picsorter.js
Bind keys directly where possible
[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
16function toggle_zoom() {
17 if (zoom) {
18 zoom = "";
19 } else {
20 zoom = "sm/";
21 }
ac4559ea 22 setpic();
97c26a9c
SW
23}
24
2d325f41 25function move_to_nondeleted(direction) {
2d325f41
SW
26 do {
27 input_index += direction;
d1309d5a 28 } while (files[input_index] in picsorter_deleted);
2d325f41
SW
29}
30
31function mark_deleted() {
d1309d5a
SW
32 picsorter_deleted[files[input_index]] = 1;
33 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
2d325f41
SW
34}
35
36function mark_not_deleted() {
d1309d5a
SW
37 delete picsorter_deleted[files[input_index]];
38 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
2d325f41
SW
39}
40
5d9946cb 41$(function() {
ed9d7c54 42 setpic();
e18c13a6 43});
ecb5b4ef 44
ac4559ea 45Mousetrap.bind('z', toggle_zoom);
9952a1a7 46Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
2d325f41
SW
47Mousetrap.bind('n', function() { move_to_nondeleted(1); setpic(); });
48Mousetrap.bind('p', function() { move_to_nondeleted(-1); setpic(); });
49Mousetrap.bind('N', function() { input_index ++; setpic(); });
50Mousetrap.bind('P', function() { input_index --; setpic(); });
a997ffc4
SW
51Mousetrap.bind('b', function() { exposure ++; setpic(); });
52Mousetrap.bind('d', function() { exposure --; setpic(); });
ac4559ea
SW
53Mousetrap.bind('x', mark_deleted);
54Mousetrap.bind('X', mark_not_deleted);