]> git.scottworley.com Git - picsort/blame_incremental - picsorter.js
Bind keys directly where possible
[picsort] / picsorter.js
... / ...
CommitLineData
1if (!("picsorter_deleted" in localStorage)) {
2 localStorage.picsorter_deleted = JSON.stringify({});
3}
4var picsorter_deleted = JSON.parse(localStorage.picsorter_deleted);
5
6var exposure = 20;
7var zoom = "sm/";
8var input_index = -1;
9move_to_nondeleted(1);
10
11
12function setpic() {
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 }
22 setpic();
23}
24
25function move_to_nondeleted(direction) {
26 do {
27 input_index += direction;
28 } while (files[input_index] in picsorter_deleted);
29}
30
31function mark_deleted() {
32 picsorter_deleted[files[input_index]] = 1;
33 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
34}
35
36function mark_not_deleted() {
37 delete picsorter_deleted[files[input_index]];
38 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
39}
40
41$(function() {
42 setpic();
43});
44
45Mousetrap.bind('z', toggle_zoom);
46Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
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(); });
51Mousetrap.bind('b', function() { exposure ++; setpic(); });
52Mousetrap.bind('d', function() { exposure --; setpic(); });
53Mousetrap.bind('x', mark_deleted);
54Mousetrap.bind('X', mark_not_deleted);