]> git.scottworley.com Git - picsort/commitdiff
I miss ${foo%bar}
authorScott Worley <scottworley@scottworley.com>
Fri, 28 Feb 2014 17:32:51 +0000 (09:32 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 28 Feb 2014 17:32:51 +0000 (09:32 -0800)
picsorter.js

index 70cd2367e7839d26638bb4a6cf3bf1b4daba57a7..2f9df0ce94ee80aa2fa9d0781709df0eb7ddcde0 100644 (file)
@@ -16,6 +16,16 @@ var exposure = 20;
 var zoom = "sm/";
 var input_index = -1;
 
+function endsWith(str, suffix) {
+  return str.indexOf(suffix, str.length - suffix.length) !== -1;
+}
+
+function stripFromEnd(str, suffix) {
+  if (endsWith(str, suffix)) {
+    return str.substr(0, str.length - suffix.length);
+  }
+  return str;
+}
 
 function setpic() {
   if ("exposure" in picinfo[files[input_index]]) {