]> git.saurik.com Git - cydia.git/commitdiff
Refactoring ratings rendering.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 29 Dec 2008 22:47:18 +0000 (22:47 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:09:33 +0000 (07:09 +0000)
Cydia.app/menes/menes.js
Cydia.app/package.html
Cydia.app/package.js
Cydia.mm
control

index 2ca5d7dee23606152548f3b6be3db58d2573e437..b5f457b1ac43e9c52bd4fdab228c1530d5b2b614 100644 (file)
@@ -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);
+            }
         }
     };
 
index f9ec648108e4fe537a24897e240da486a13ea809..ae602b7d34c3c25135d87df60bea4bb057612839 100644 (file)
                 <div id="latest"></div>
 
                 <iframe
+                    onload="rating_()"
                     class="rating"
                     id="rating"
                     frameborder="0"
     width="320"
     height="0"
     target="_top"
-    onLoad_="loaded()"
+    onload_="loaded()"
 ></iframe></div>
 
 <!--hr id="lower-bar" class="depiction"/-->
 <fieldset class="installed">
     <div>
         <img class="icon" src="version.png"/><div>
-        <label>&nbsp;</label>
+        <label>Version</label>
         <label id="installed"></label>
     </div></div>
 
index 3e7c9ca34375160d909c08189682fc2058932da0..679d1832c42e00e821d76b3b600a1cbb6ebffd77 100644 (file)
@@ -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);
 
index 6e31c06b7c6b0b233d8f4023b712eb3bc093c30a..d07e85f47ad16350c7976d34f65b5037e35b6877 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -257,7 +257,7 @@ extern NSString * const kCAFilterNearest;
 
 #define lprintf(args...) fprintf(stderr, args)
 
-#define ForRelease 1
+#define ForRelease 0
 #define ForSaurik (1 && !ForRelease)
 #define IgnoreInstall (0 && !ForRelease)
 #define RecycleWebViews 0
@@ -6976,6 +6976,7 @@ id Dealloc_(id self, SEL selector) {
 }*/
 
 int main(int argc, char *argv[]) { _pooled
+    _trace();
     class_addMethod(objc_getClass("DOMNodeList"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &DOMNodeList$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
 
     bool substrate(false);
@@ -7062,11 +7063,15 @@ int main(int argc, char *argv[]) { _pooled
         Indices_ = [[NSMutableDictionary alloc] init];*/
 
     Indices_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
-        //@"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/server/rating/@", @"Rating",
+        @"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/rating/@", @"Rating",
         //@"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/repotag/@", @"RepoTag",
     nil];
 
-    if ((Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"]) == NULL)
+    _trace();
+    Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"];
+    _trace();
+
+    if (Metadata_ == NULL)
         Metadata_ = [[NSMutableDictionary alloc] initWithCapacity:2];
     else {
         Settings_ = [Metadata_ objectForKey:@"Settings"];
@@ -7103,8 +7108,11 @@ int main(int argc, char *argv[]) { _pooled
     /*if (substrate && access("/Library/MobileSubstrate/MobileSubstrate.dylib", F_OK) == 0)
         dlopen("/Library/MobileSubstrate/MobileSubstrate.dylib", RTLD_LAZY | RTLD_GLOBAL);*/
 
-    if (access("/User", F_OK) != 0)
+    if (access("/User", F_OK) != 0) {
+        _trace();
         system("/usr/libexec/cydia/firmware.sh");
+        _trace();
+    }
 
     _assert([[NSFileManager defaultManager]
         createDirectoryAtPath:@"/var/cache/apt/archives/partial"
@@ -7129,6 +7137,7 @@ int main(int argc, char *argv[]) { _pooled
     UIApplicationUseLegacyEvents(YES);
     UIKeyboardDisableAutomaticAppearance();
 
+    _trace();
     int value = UIApplicationMain(argc, argv, @"Cydia", @"Cydia");
 
     CGColorSpaceRelease(space_);
diff --git a/control b/control
index 6c73b1c6ee9cd04a4e2dfaa7f2944cdae95aaff5..c51234a800b78c33f710d0bdd1fd894700b39c1a 100644 (file)
--- a/control
+++ b/control
@@ -4,7 +4,7 @@ Priority: required
 Section: Packaging
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 1.0.2677-38
+Version: 1.0.2678-38
 Replaces: com.sosiphone.addcydia
 Depends: apt, darwintools, pcre, shell-cmds
 Conflicts: com.sosiphone.addcydia