diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2008-12-29 22:47:18 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2010-09-30 07:09:33 +0000 |
commit | d6dad1b433cca3973dcb114c69e389b2ecb765fd (patch) | |
tree | b3ebb116e558e6eedfc5073947032e9c31e7a647 /Cydia.app | |
parent | 374f3d18f0a8adefbb9eca5292ebef10935c09a5 (diff) |
Refactoring ratings rendering.
Diffstat (limited to 'Cydia.app')
-rw-r--r-- | Cydia.app/menes/menes.js | 9 | ||||
-rw-r--r-- | Cydia.app/package.html | 5 | ||||
-rw-r--r-- | Cydia.app/package.js | 40 |
3 files changed, 40 insertions, 14 deletions
diff --git a/Cydia.app/menes/menes.js b/Cydia.app/menes/menes.js index 2ca5d7d..b5f457b 100644 --- a/Cydia.app/menes/menes.js +++ b/Cydia.app/menes/menes.js @@ -466,14 +466,19 @@ $.xhr = function (url, method, headers, data, events) { events = {}; xhr.onreadystatechange = function () { + console.log(xhr.readyState); if (xhr.readyState == 4) { var status = xhr.status; var text = xhr.responseText; if (events.response != null) events.response(status, text); - if (events.success != null) - if (status == 200) + if (status == 200) { + if (events.success != null) events.success(text); + } else { + if (events.failure != null) + events.failure(status); + } } }; diff --git a/Cydia.app/package.html b/Cydia.app/package.html index f9ec648..ae602b7 100644 --- a/Cydia.app/package.html +++ b/Cydia.app/package.html @@ -159,6 +159,7 @@ <div id="latest"></div> <iframe + onload="rating_()" class="rating" id="rating" frameborder="0" @@ -226,7 +227,7 @@ width="320" height="0" target="_top" - onLoad_="loaded()" + onload_="loaded()" ></iframe></div> <!--hr id="lower-bar" class="depiction"/--> @@ -244,7 +245,7 @@ <fieldset class="installed"> <div> <img class="icon" src="version.png"/><div> - <label> </label> + <label>Version</label> <label id="installed"></label> </div></div> diff --git a/Cydia.app/package.js b/Cydia.app/package.js index 3e7c9ca..679d183 100644 --- a/Cydia.app/package.js +++ b/Cydia.app/package.js @@ -34,6 +34,35 @@ function space(selector, html, max) { } } +var rated = 0; + +var rating = function () { + var rating = package.rating; + if (rating == null) + $(".rating").remove(); + else { + rating = 'fail.html'; + $.xhr('_' + rating, 'GET', {}, null, { + success: function (value) { + document.getElementById("rating").contentWindow.document.write(value); + }, + + failure: function (status) { + $(".rating").remove(); + } + }); + } +}; + +var rating_ = function() { + if (rated == 0) + rated = 1; + else if (rated == 1) { + rating(); + rated = -1; + } +}; + $(function () { var id = package.id; var idc = encodeURIComponent(id); @@ -46,16 +75,7 @@ $(function () { $("#name").html(name); space("#latest", package.latest, 93); - var rating = package.rating; - if (rating == null) - $(".rating").remove(); - else { - $.xhr(rating, 'GET', {}, null, { - success: function (value) { - document.getElementById("rating").contentWindow.document.write(value); - } - }); - } + rating_(); $("#settings").href("cydia://package-settings/" + idc); |