]>
git.scottworley.com Git - picsort/blob - picsorter.js
b1c1bdf5b726220f97adf9af55c47d533f21d6ec
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
);
32 if (endsWith(files
[input_index
], ".NEF")) {
33 if ("exposure" in picinfo
[files
[input_index
]]) {
34 exposure
= picinfo
[files
[input_index
]].exposure
;
36 picinfo
[files
[input_index
]].exposure
= exposure
;
39 display_filename
= zoom
+ exposure
+ "/" + stripFromEnd(files
[input_index
], ".NEF") + ".jpeg";
41 display_filename
= zoom
+ files
[input_index
];
43 $("#pic").attr("src", display_filename
);
46 function say(message
) {
47 $("#message").text(message
).removeClass("fade");
48 setTimeout(function() { $("#message").addClass("fade"); }, 1);
51 function toggle_zoom() {
60 function move_to_nondeleted(direction
) {
62 input_index
+= direction
;
63 } while (picinfo
[files
[input_index
]].deleted
);
64 say(input_index
+ " " + (picinfo
[files
[input_index
]].name
|| ""));
68 function mark_deleted() {
69 picinfo
[files
[input_index
]].deleted
= 1;
74 function mark_not_deleted() {
75 delete picinfo
[files
[input_index
]].deleted
;
80 function change_exposure(amount
) {
82 picinfo
[files
[input_index
]].exposure
= exposure
;
85 var display_exposure
= (exposure
/ 4) - 3.5;
86 say((display_exposure
>= 0 ? "+" : "") + display_exposure
);
90 var name_input
= $("#name").hide().get(0);
91 var name
= name_input
.value
;
92 name_input
.value
= "";
93 picinfo
[files
[input_index
]].name
= name
;
99 $("#name").hide().on("keyup", function(e
) { e
.which
== 13 && set_name(); });
100 move_to_nondeleted(1);
103 Mousetrap
.bind('z', toggle_zoom
);
104 Mousetrap
.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
105 Mousetrap
.bind(['n', 'l'], function() { move_to_nondeleted(1); });
106 Mousetrap
.bind(['p', 'h'], function() { move_to_nondeleted(-1); });
107 Mousetrap
.bind(['N', 'L'], function() { input_index
++; say(input_index
); setpic(); });
108 Mousetrap
.bind(['P', 'H'], function() { input_index
--; say(input_index
); setpic(); });
109 Mousetrap
.bind(['b', 'k'], function() { change_exposure(1); });
110 Mousetrap
.bind(['d', 'j'], function() { change_exposure(-1); });
111 Mousetrap
.bind('x', mark_deleted
);
112 Mousetrap
.bind('X', mark_not_deleted
);
113 Mousetrap
.bind('c', function() { $("#name").show().focus(); return false; });