made a function to cleanly cut a string. popcorn-port
authorhamidouk
Fri, 20 Jan 2012 12:20:51 +0100
branchpopcorn-port
changeset 686 f1dbe6a6e740
parent 685 973d9a495d11
child 687 3583e8b447f5
made a function to cleanly cut a string.
src/js/utils.js
--- a/src/js/utils.js	Fri Jan 20 12:20:36 2012 +0100
+++ b/src/js/utils.js	Fri Jan 20 12:20:51 2012 +0100
@@ -165,6 +165,14 @@
   return url;
 };
 
+/** Similar to substr but remove the last word if
+    we're breaking a word in two.
+ */ 
+IriSP.clean_substr = function(str, start, end) {
+  var s = str.substr(start, end).substr(start, end).split(" ");
+  s.pop();
+  return s.join(" ");
+};
 /* for ie compatibility
 if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
    Object.defineProperty=function(obj,prop,desc) {