X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/fd7853a6d1e9ce1485eaedd132eb94c64a70ce77..600d005d49301ddd53415f53ee43606d355d4d9d:/Cydia.app/menes/menes.js diff --git a/Cydia.app/menes/menes.js b/Cydia.app/menes/menes.js index 8148d8d9..dc210bb4 100644 --- a/Cydia.app/menes/menes.js +++ b/Cydia.app/menes/menes.js @@ -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) { @@ -260,12 +287,12 @@ $.inject({ } }, - display: { + height: { get: function (node) { - return node.style.display; + return node.height; }, set: function (node, value) { - node.style.display = value; + node.height = value; } }, @@ -439,9 +466,19 @@ $.xhr = function (url, method, headers, data, events) { events = {}; xhr.onreadystatechange = function () { - if (xhr.readyState == 4) - if (events.complete != null) - events.complete(xhr.responseText); + if (xhr.readyState == 4) { + var status = xhr.status; + var text = xhr.responseText; + if (events.response != null) + events.response(status, text); + if (status == 200) { + if (events.success != null) + events.success(text); + } else { + if (events.failure != null) + events.failure(status); + } + } }; xhr.send(data);