X-Git-Url: http://git.scottworley.com/picsort/blobdiff_plain/755cf903798da9f7772c504f01af9e6fdd388052..59a0fba182b1c592474e3c3c01730917b51828ea:/picsorter.js diff --git a/picsorter.js b/picsorter.js index ec63cbc..24cc893 100644 --- a/picsorter.js +++ b/picsorter.js @@ -40,7 +40,12 @@ function setpic() { } else { display_filename = zoom + files[input_index]; } - $("#pic").attr("src", display_filename); + var $pic = $("#pic"); + $pic.attr("src", display_filename); + $pic.removeClass("rot90 rot180 rot270"); + if ("rotate" in picinfo[files[input_index]]) { + $pic.addClass("rot" + picinfo[files[input_index]].rotate); + } } function say(message) { @@ -117,6 +122,18 @@ function change_exposure(amount) { say((display_exposure >= 0 ? "+" : "") + display_exposure); } +function rotate() { + var rotation = picinfo[files[input_index]].rotate || 0; + rotation = (rotation + 90) % 360; + if (rotation > 1e-5) { + picinfo[files[input_index]].rotate = rotation; + } else { + delete picinfo[files[input_index]].rotate; + } + save_picinfo(); + setpic(); +} + function set_name() { var name_input = $("#name").hide().get(0); var name = name_input.value; @@ -143,4 +160,5 @@ Mousetrap.bind(['b', 'k'], function() { change_exposure(1); }); Mousetrap.bind(['d', 'j'], function() { change_exposure(-1); }); Mousetrap.bind('x', mark_deleted); Mousetrap.bind('X', mark_not_deleted); +Mousetrap.bind('r', rotate); Mousetrap.bind('c', function() { $("#name").show().focus(); return false; });