]> git.saurik.com Git - cydia.git/blobdiff - Cydia.app/menes/menes.js
Checkpoint, I think I released this.
[cydia.git] / Cydia.app / menes / menes.js
index 70c5c47be61d6622f9517c31b170f451d9e5da0f..2ca5d7dee23606152548f3b6be3db58d2573e437 100644 (file)
@@ -190,19 +190,46 @@ $.prototype = {
         });
     },
 
-    append: function (html) {
+    append: function (children) {
+        if ($.type(children) == "string")
+            $.each(this, function (node) {
+                var doc = $.document(node);
+
+                // XXX: implement wrapper system
+                var div = doc.createElement("div");
+                div.innerHTML = children;
+
+                while (div.childNodes.length != 0) {
+                    var child = div.childNodes[0];
+                    node.appendChild(child);
+                }
+            });
+        else
+            $.each(this, function (node) {
+                $.each(children, function (child) {
+                    node.appendChild(child);
+                });
+            });
+    },
+
+    xpath: function (expression) {
+        var value = $([]);
+
         $.each(this, function (node) {
             var doc = $.document(node);
+            var results = doc.evaluate(expression, node, null, XPathResult.ANY_TYPE, null);
+            var result;
+            while (result = results.iterateNext())
+                value.add([result]);
+        });
 
-            // XXX: implement wrapper system
-            var div = doc.createElement("div");
-            div.innerHTML = html;
+        return value;
+    },
 
-            while (div.childNodes.length != 0) {
-                var child = div.childNodes[0];
-                node.appendChild(child);
-            }
-        });
+    clone: function (deep) {
+        return $($.map(this, function (node) {
+            return node.cloneNode(deep);
+        }));
     },
 
     descendants: function (expression) {