diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2008-10-14 02:59:16 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-09-30 07:08:50 +0000 |
commit | affeffc797be156742cbd8efe899ba74dd719b0d (patch) | |
tree | 3059ee1d346bf0d989b330309e1c80da476192b9 /Cydia.app/menes/menes.js | |
parent | c390d3ab34d681832980e545b276467787a70d0a (diff) |
Checkpointing Cydia before futzing with cydia://package-cion/.
Diffstat (limited to 'Cydia.app/menes/menes.js')
-rw-r--r-- | Cydia.app/menes/menes.js | 51 |
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(/</, "<") + .replace(/>/, ">") + .replace(/"/, """) + .replace(/'/, "'") + ; +} + $.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; |