summaryrefslogtreecommitdiff
path: root/Cydia.app/menes/menes.js
diff options
context:
space:
mode:
Diffstat (limited to 'Cydia.app/menes/menes.js')
-rw-r--r--Cydia.app/menes/menes.js51
1 files changed, 49 insertions, 2 deletions
diff --git a/Cydia.app/menes/menes.js b/Cydia.app/menes/menes.js
index f0070bc..f314227 100644
--- a/Cydia.app/menes/menes.js
+++ b/Cydia.app/menes/menes.js
@@ -5,7 +5,6 @@ var _assert = function (expr) {
throw message;
}
}
-
// Compatibility {{{
if (typeof Array.prototype.push != "function")
Array.prototype.push = function (value) {
@@ -39,6 +38,16 @@ var $ = function (arg, doc) {
}
};
+$.xml = function (value) {
+ return value
+ .replace(/&/, "&")
+ .replace(/</, "&lt;")
+ .replace(/>/, "&gt;")
+ .replace(/"/, "&quot;")
+ .replace(/'/, "&apos;")
+ ;
+}
+
$.type = function (value) {
var type = typeof value;
@@ -120,7 +129,7 @@ $.prototype = {
},
append: function (html) {
- $.each(this, function (node) {
+ $.each(this, $.type(html) == "string" ? function (node) {
var doc = $.document(node);
// XXX: implement wrapper system
@@ -131,9 +140,19 @@ $.prototype = {
var child = div.childNodes[0];
node.appendChild(child);
}
+ } : function (node) {
+ $.each(html, function (value) {
+ node.appendChild(value);
+ });
});
},
+ clone: function (deep) {
+ return $($.map(this, function (node) {
+ return node.cloneNode(deep);
+ }));
+ },
+
descendants: function (expression) {
var descendants = $([]);
@@ -154,6 +173,25 @@ $.prototype = {
return $($.map(this, function (node) {
return node.parentNode;
}));
+ },
+
+ xpath: function (expression) {
+ var value = $([]);
+
+ $.each(this, function (node) {
+ var doc = $.document(node);
+ var result = doc.evaluate(expression, node, null, XPathResult.ANY_TYPE, null);
+
+ if (result.resultType == XPathResult.UNORDERED_NODE_ITERATOR_TYPE)
+ for (;;) {
+ var next = result.iterateNext();
+ if (next == null)
+ break;
+ value.add([next]);
+ }
+ });
+
+ return value;
}
};
@@ -212,6 +250,15 @@ $.inject({
}
},
+ id: {
+ get: function (node) {
+ return node.id;
+ },
+ set: function (node, value) {
+ node.id = value;
+ }
+ },
+
src: {
get: function (node) {
return node.src;