summaryrefslogtreecommitdiff
path: root/Cydia.app/menes/menes.js
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-10-14 02:59:16 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-09-30 07:08:50 +0000
commitaffeffc797be156742cbd8efe899ba74dd719b0d (patch)
tree3059ee1d346bf0d989b330309e1c80da476192b9 /Cydia.app/menes/menes.js
parentc390d3ab34d681832980e545b276467787a70d0a (diff)
Checkpointing Cydia before futzing with cydia://package-cion/.
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(/&/, "&amp;")
+ .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;