]>
git.scottworley.com Git - picsort/blob - picsorter.js
2f9df0ce94ee80aa2fa9d0781709df0eb7ddcde0
2 if ("picsorter_picinfo" in localStorage
) {
3 picinfo
= JSON
.parse(localStorage
.picsorter_picinfo
);
5 $.each(files
, function(i
, f
) {
10 function save_picinfo() {
11 localStorage
.picsorter_picinfo
= JSON
.stringify(picinfo
);
19 function endsWith(str
, suffix
) {
20 return str
.indexOf(suffix
, str
.length
- suffix
.length
) !== -1;
23 function stripFromEnd(str
, suffix
) {
24 if (endsWith(str
, suffix
)) {
25 return str
.substr(0, str
.length
- suffix
.length
);
31 if ("exposure" in picinfo
[files
[input_index
]]) {
32 exposure
= picinfo
[files
[input_index
]].exposure
;
34 picinfo
[files
[input_index
]].exposure
= exposure
;
37 $("#pic").attr("src", zoom
+ exposure
+ "/" + files
[input_index
]);
40 function say(message
) {
41 $("#message").text(message
).removeClass("fade");
42 setTimeout(function() { $("#message").addClass("fade"); }, 1);
45 function toggle_zoom() {
54 function move_to_nondeleted(direction
) {
56 input_index
+= direction
;
57 } while (picinfo
[files
[input_index
]].deleted
);
58 say(input_index
+ " " + (picinfo
[files
[input_index
]].name
|| ""));
62 function mark_deleted() {
63 picinfo
[files
[input_index
]].deleted
= 1;
68 function mark_not_deleted() {
69 delete picinfo
[files
[input_index
]].deleted
;
74 function change_exposure(amount
) {
76 picinfo
[files
[input_index
]].exposure
= exposure
;
79 var display_exposure
= (exposure
/ 4) - 3.5;
80 say((display_exposure
>= 0 ? "+" : "") + display_exposure
);
84 var name_input
= $("#name").hide().get(0);
85 var name
= name_input
.value
;
86 name_input
.value
= "";
87 picinfo
[files
[input_index
]].name
= name
;
93 $("#name").hide().on("keyup", function(e
) { e
.which
== 13 && set_name(); });
94 move_to_nondeleted(1);
97 Mousetrap
.bind('z', toggle_zoom
);
98 Mousetrap
.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
99 Mousetrap
.bind('n', function() { move_to_nondeleted(1); });
100 Mousetrap
.bind('p', function() { move_to_nondeleted(-1); });
101 Mousetrap
.bind('N', function() { input_index
++; say(input_index
); setpic(); });
102 Mousetrap
.bind('P', function() { input_index
--; say(input_index
); setpic(); });
103 Mousetrap
.bind('b', function() { change_exposure(1); });
104 Mousetrap
.bind('d', function() { change_exposure(-1); });
105 Mousetrap
.bind('x', mark_deleted
);
106 Mousetrap
.bind('X', mark_not_deleted
);
107 Mousetrap
.bind('c', function() { $("#name").show().focus(); return false; });