]> git.saurik.com Git - cydia.git/commitdiff
Reworked how ratings integrate.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 30 Dec 2008 01:14:28 +0000 (01:14 +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.app/star.png [new file with mode: 0644]
Cydia.mm

index b5f457b1ac43e9c52bd4fdab228c1530d5b2b614..098f377f946c86f0a58471056b0c78fc0b0e6952 100644 (file)
@@ -287,15 +287,6 @@ $.inject({
         }
     },
 
-    display: {
-        get: function (node) {
-            return node.style.display;
-        },
-        set: function (node, value) {
-            node.style.display = value;
-        }
-    },
-
     html: {
         get: function (node) {
             return node.innerHTML;
@@ -466,7 +457,6 @@ $.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;
index ae602b7d34c3c25135d87df60bea4bb057612839..3e634752582ced9def5c186172988c3c28b4235d 100644 (file)
             if (count++ != 0)
                 return;
             $("#depiction-load").remove();
-            $.each($("#depiction-src"), function (node) {
-                node.style.display = "block";
-            });
+            $("#depiction-src").css("display" "block");
         }
 
         var remove = function() {
-            $(".description").display("block");
+            $(".description").css("display", "block");
             $(".depiction").remove();
         }
     </script>
 
         #boundry {
             float: left;
-            width: 60px;
+            width: 64px;
         }
 
         #icon {
-            height: 59px;
-            max-width: 60px;
-            width: auto;
+            background-position: center center;
+            background-repeat: no-repeat;
+            -webkit-border-radius: 9px;
+            height: 64px;
+            width: 64px;
         }
 
+        /* XXX: this style is out of date */
         #reflection {
             height: 59px;
             max-width: 60px;
@@ -92,7 +93,7 @@
             width: auto;
         }
 
-        #id {
+        #id, #author, #maintainer, #sponsor {
             white-space: nowrap;
         }
 
 
         #header > div {
             padding: 0;
-            margin-left: 2px;
         }
 
         #content {
-            margin: auto 0;
+            padding: 5px;
             position: absolute;
-            left: 72px;
-            width: 237px;
+            left: 77px;
+            width: 232px;
         }
 
         #lower {
-            margin: 10px 5px;
+            margin: 0px 5px;
         }
 
         #name {
-            margin: 7px 5px;
+            margin-bottom: 10px;
             font-weight: bold;
+            font-size: 17px;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
         }
 
         #latest {
             float: left;
         }
 
-        #rating {
+        a[href].rating {
+            background: 105px 7px no-repeat url(menes/chevron.png);
+        }
+
+        .rating {
+            /*border: 1px solid #999999;*/
+            -webkit-border-radius: 6px;
+            padding: 7px 7px;
+            margin: -7px 0px;
             float: right;
-            margin-top: -7px;
-            width: 130px;
+            width: 124px;
         }
 
-        #description {
-            background-color: #c7ced5;
-            border-bottom: 1px solid #999999;
-            border-top: 1px solid #999999;
-            font-size: 16px;
-            margin: 9px 10px;
-            padding: 10px;
+        .rating .back,
+        .rating .fore,
+        .rating .star {
+            background: url(star.png);
+            height: 16px;
+        }
+
+        .rating .back,
+        .rating .fore {
+            width: 80px;
+        }
+
+        .rating .star {
+            display: inline-block;
+            width: 16px;
+        }
+
+        .rating .back {
+            opacity: 0.2;
+        }
+
+        .rating .fore {
+            /*border-right: 1px solid #999999;*/
+            position: absolute;
+        }
+    
+        .rating .text {
+            display: inline-block;
+            color: #4d4d70;
+            margin: 0 6px;
+            vertical-align: top;
+        }
+
+        #rating-none,
+        #rating-done {
+            display: none;
         }
     </style>
 </head><body class="pinstripe">
 <fieldset id="header">
     <div class="clearfix">
         <div id="boundry">
-            <img id="icon"/>
+            <div id="icon"></div>
             <!--img id="reflection"/-->
         </div>
 
         <div id="content">
             <div id="name"></div>
-
-            <div id="lower">
-                <div id="latest"></div>
-
-                <iframe
-                    onload="rating_()"
-                    class="rating"
-                    id="rating"
-                    frameborder="0"
-                    height="0"
-                    target="_top"
-                    src="loading.html"
-                ></iframe>
-            </div>
+            <div id="latest"></div>
+
+            <a class="rating" id="rating-href">
+                <div id="rating-none">
+                    <div class="star"></div><div class="text">Not Rated</div>
+                </div><div id="rating-done">
+                    <div class="fore" id="rating-value"></div>
+                    <div class="back"></div>
+                </div>
+            </a>
         </div>
     </div>
 </fieldset>
 
 <!--hr id="lower-bar" class="depiction"/-->
 
-<div id="description" class="description"></div>
+<block class="description"><p id="description"></p></block>
 
 <fieldset class="description homepage">
     <a class="homepage" id="homepage-href">
index 679d1832c42e00e821d76b3b600a1cbb6ebffd77..71ac849b063735ce9a65bebccabe4c16fa333e52 100644 (file)
@@ -29,22 +29,47 @@ function space(selector, html, max) {
     var width = node.width();
     if (width > max) {
         var spacing = (max - node.width()) / (html.length - 1) + "px";
-        console.log(width + " " + max + " " + spacing);
         node.css("letter-spacing", spacing);
     }
 }
 
-var rated = 0;
+$(function () {
+    var id = package.id;
+    var idc = encodeURIComponent(id);
+    var name = package.name;
+    var regarding = encodeURIComponent("Cydia/APT: " + name);
+    var icon = 'cydia://package-icon/' + idc;
+    var icon = 'http://cydia.saurik.com/thumb/net.ispazio.deeptheme.png';
+
+    $("#icon").css("background-image", 'url("' + icon + '")');
+    $("#reflection").src("cydia://package-icon/" + idc);
+
+    $("#name").html(name);
+    space("#latest", package.latest, 96);
 
-var rating = function () {
     var rating = package.rating;
     if (rating == null)
         $(".rating").remove();
     else {
-        rating = 'fail.html';
-        $.xhr('_' + rating, 'GET', {}, null, {
+        $.xhr(rating, 'GET', {}, null, {
             success: function (value) {
-                document.getElementById("rating").contentWindow.document.write(value);
+                value = eval(value);
+
+                $("#rating-load").remove();
+                $("#rating-href").href(value.reviews);
+
+                var none = $("#rating-none");
+                var done = $("#rating-done");
+
+                if (value.rating == null) {
+                    done.remove();
+                    none.css("display", "block");
+                } else {
+                    none.remove();
+                    done.css("display", "block");
+
+                    $("#rating-value").css('width', 16 * value.rating);
+                }
             },
 
             failure: function (status) {
@@ -52,30 +77,6 @@ var rating = function () {
             }
         });
     }
-};
-
-var rating_ = function() {
-    if (rated == 0)
-        rated = 1;
-    else if (rated == 1) {
-        rating();
-        rated = -1;
-    }
-};
-
-$(function () {
-    var id = package.id;
-    var idc = encodeURIComponent(id);
-    var name = package.name;
-    var regarding = encodeURIComponent("Cydia/APT: " + name);
-
-    $("#icon").src("cydia://package-icon/" + idc);
-    $("#reflection").src("cydia://package-icon/" + idc);
-
-    $("#name").html(name);
-    space("#latest", package.latest, 93);
-
-    rating_();
 
     $("#settings").href("cydia://package-settings/" + idc);
 
@@ -147,7 +148,7 @@ $(function () {
     if (depiction == null)
         $(".depiction").remove();
     else {
-        $(".description").display("none");
+        $(".description").css("display", "none");
         $("#depiction-src").src(depiction);
     }
 
diff --git a/Cydia.app/star.png b/Cydia.app/star.png
new file mode 100644 (file)
index 0000000..b67a56c
Binary files /dev/null and b/Cydia.app/star.png differ
index d07e85f47ad16350c7976d34f65b5037e35b6877..6f80b37c9d99184620bd04bf3e276dd2f6ee6e8b 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -1840,7 +1840,7 @@ class Progress :
 
 - (NSString *) rating {
     if (NSString *rating = [Indices_ objectForKey:@"Rating"])
-        return [rating stringByReplacingOccurrencesOfString:@"@P" withString:[id_ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+        return [rating stringByReplacingOccurrencesOfString:@"@" withString:[id_ stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
     else
         return nil;
 }