set dirty if users edited, warning message if change slice while dirty
[plstackapi.git] / planetstack / core / xoslib / static / js / xoslib / xos-util.js
index 1d135f4..1c42e26 100644 (file)
@@ -93,6 +93,24 @@ function array_diff(a1, a2)
   return diff;\r
 }
 
+function array_subtract(a1, a2)
+{
+    result=[]
+    for (index in a1) {
+        value = a1[index];
+        if (!$.inArray(value, a2) >= 0) {
+            result.push(value);
+        }
+    }
+    return result;
+}
+
+function array_same_elements(arr1, arr2)
+{
+    // return true if arrays have same elements, even if order is different
+    return ($(arr1).not(arr2).length == 0 && $(arr2).not(arr1).length == 0);
+}
+
 function array_pair_lookup(x, names, values)
 {
     for (index in values) {
@@ -100,7 +118,7 @@ function array_pair_lookup(x, names, values)
             return names[index];
         }
     }
-    return undefined;
+    return "object #" + x;
 }
 
 function all_options(selector) {
@@ -111,3 +129,10 @@ function all_options(selector) {
     });
     return result;
 }
+
+function make_same_width(containerSelector, itemSelector) {
+    var maxWidth = 0;
+    $(containerSelector).find(itemSelector).each( function(index) { maxWidth = Math.max(maxWidth, $(this).width()); });\r
+    console.log(maxWidth);\r
+    $(containerSelector).find(itemSelector).each( function(index) { $(this).width(maxWidth); });
+}