]>
git.scottworley.com Git - picsort/blob - picsorter.js
c39e18143941ebf020ed1225d87fa474d4006a7d
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_by_filter(direction
, filter
) {
61 // Keep moving in direction until filter is satisfied
63 input_index
+= direction
;
65 say(input_index
+ " " + (picinfo
[files
[input_index
]].name
|| ""));
68 function move(direction
) {
69 move_by_filter(direction
, function() { return true; });
71 function move_to_nondeleted(direction
) {
72 move_by_filter(direction
, function() {
73 return !("deleted" in picinfo
[files
[input_index
]]); });
75 function move_to_unnamed(direction
) {
76 move_by_filter(direction
, function() {
77 return !("deleted" in picinfo
[files
[input_index
]]) &&
78 !("name" in picinfo
[files
[input_index
]]); });
81 function mark_deleted() {
82 picinfo
[files
[input_index
]].deleted
= 1;
87 function mark_not_deleted() {
88 delete picinfo
[files
[input_index
]].deleted
;
93 function change_exposure(amount
) {
95 picinfo
[files
[input_index
]].exposure
= exposure
;
98 var display_exposure
= (exposure
/ 4) - 3.5;
99 say((display_exposure
>= 0 ? "+" : "") + display_exposure
);
102 function set_name() {
103 var name_input
= $("#name").hide().get(0);
104 var name
= name_input
.value
;
105 name_input
.value
= "";
106 picinfo
[files
[input_index
]].name
= name
;
108 say("Named " + name
);
112 $("#name").hide().on("keyup", function(e
) { e
.which
== 13 && set_name(); });
113 move_to_nondeleted(1);
116 Mousetrap
.bind('z', toggle_zoom
);
117 Mousetrap
.bind('Z', function() { $("#pic").toggleClass("fit_view"); });
118 Mousetrap
.bind(['n', 'l'], function() { move_to_nondeleted(1); });
119 Mousetrap
.bind(['p', 'h'], function() { move_to_nondeleted(-1); });
120 Mousetrap
.bind(['N', 'L'], function() { move_to_unnamed(1); });
121 Mousetrap
.bind(['P', 'H'], function() { move_to_unnamed(-1); });
122 Mousetrap
.bind(['m n', 'm l'], function() { move(1); });
123 Mousetrap
.bind(['m n', 'm h'], function() { move(-1); });
124 Mousetrap
.bind(['b', 'k'], function() { change_exposure(1); });
125 Mousetrap
.bind(['d', 'j'], function() { change_exposure(-1); });
126 Mousetrap
.bind('x', mark_deleted
);
127 Mousetrap
.bind('X', mark_not_deleted
);
128 Mousetrap
.bind('c', function() { $("#name").show().focus(); return false; });