]> git.scottworley.com Git - picsort/blame_incremental - picsorter.js
Keep a local picsorter_deleted too.
[picsort] / picsorter.js
... / ...
CommitLineData
1var exposure = 20;
2var input_index = 0;
3var zoom = "sm/";
4
5if (!("picsorter_deleted" in localStorage)) {
6 localStorage.picsorter_deleted = JSON.stringify({});
7}
8var picsorter_deleted = JSON.parse(localStorage.picsorter_deleted);
9
10function setpic() {
11 $("#pic").attr("src", zoom + exposure + "/" + files[input_index]);
12}
13
14function toggle_zoom() {
15 if (zoom) {
16 zoom = "";
17 } else {
18 zoom = "sm/";
19 }
20}
21
22function move_to_nondeleted(direction) {
23 do {
24 input_index += direction;
25 } while (files[input_index] in picsorter_deleted);
26}
27
28function mark_deleted() {
29 picsorter_deleted[files[input_index]] = 1;
30 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
31}
32
33function mark_not_deleted() {
34 delete picsorter_deleted[files[input_index]];
35 localStorage.picsorter_deleted = JSON.stringify(picsorter_deleted);
36}
37
38$(function() {
39 setpic();
40});
41
42Mousetrap.bind('z', function() { toggle_zoom(); setpic(); });
43Mousetrap.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
44Mousetrap.bind('n', function() { move_to_nondeleted(1); setpic(); });
45Mousetrap.bind('p', function() { move_to_nondeleted(-1); setpic(); });
46Mousetrap.bind('N', function() { input_index ++; setpic(); });
47Mousetrap.bind('P', function() { input_index --; setpic(); });
48Mousetrap.bind('b', function() { exposure ++; setpic(); });
49Mousetrap.bind('d', function() { exposure --; setpic(); });
50Mousetrap.bind('x', function() { mark_deleted(); });
51Mousetrap.bind('X', function() { mark_not_deleted(); });