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