Merge from DIMP, fix syntax.
authorJan Schneider <jan@horde.org>
Wed, 18 Feb 2009 10:21:32 +0000 (11:21 +0100)
committerJan Schneider <jan@horde.org>
Wed, 18 Feb 2009 10:21:32 +0000 (11:21 +0100)
kronolith/js/src/kronolith.js

index cfe6fcc..5f15024 100644 (file)
@@ -1007,15 +1007,18 @@ Element.addMethods({
 
 /* Create some utility functions. */
 Object.extend(Array.prototype, {
+    // Need our own diff() function because prototypejs's without() function
+    // does not handle array input.
+    diff: function(values)
+    {
+        return this.select(function(value) {
+            return !values.include(value);
+        });
+    },
     numericSort: function()
     {
-        return this.sort(function(a, b) {
-            if (a > b) {
-                return 1;
-            } else if (a < b) {
-                return -1;
-            }
-            return 0;
+        return this.collect(Number).sort(function(a,b) {
+            return (a > b) ? 1 : ((a < b) ? -1 : 0);
         });
     }
 });
@@ -1076,7 +1079,7 @@ Object.extend(Date.prototype, {
      *
      * @return string  Date and time.
      */
-    dateString()
+    dateString: function()
     {
         return this.toString('yyyyMMdd');
     }