]> git.scottworley.com Git - picsort/blobdiff - picsorter.js
'r' to Rotate.
[picsort] / picsorter.js
index ec63cbc8fd3d5a64473e0a368ed6579932685cab..24cc8938e054363048ab1159ca805662c86a70eb 100644 (file)
@@ -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; });