]> git.saurik.com Git - cydia.git/blob - Cydia.app/package.js
Initial implementation of rating reports.
[cydia.git] / Cydia.app / package.js
1 /*var package = {
2 "name": "MobileTerminal",
3 "latest": "286u-5",
4 "author": {
5 "name": "Allen Porter",
6 "address": "allen.porter@gmail.com"
7 },
8 //"depiction": "http://planet-iphones.com/repository/info/chromium1.3.php",
9 "depiction": "http://cydia.saurik.com/terminal.html",
10 "description": "this is a sample description",
11 "homepage": "http://cydia.saurik.com/terminal.html",
12 "installed": "286u-4",
13 "id": "mobileterminal",
14 "section": "Terminal Support",
15 "size": 552*1024,
16 "maintainer": {
17 "name": "Jay Freeman",
18 "address": "saurik@saurik.com"
19 },
20 "source": {
21 "name": "Telesphoreo Tangelo",
22 "description": "Distribution of Unix Software for the iPhone"
23 }
24 };*/
25
26 function space(selector, html, max) {
27 var node = $(selector);
28 node.html(html);
29 var width = node.width();
30 if (width > max) {
31 var spacing = (max - node.width()) / (html.length - 1) + "px";
32 console.log(width + " " + max + " " + spacing);
33 node.css("letter-spacing", spacing);
34 }
35 }
36
37 $(function () {
38 var id = package.id;
39 var idc = encodeURIComponent(id);
40 var name = package.name;
41 var regarding = encodeURIComponent("Cydia/APT: " + name);
42
43 $("#icon").src("cydia://package-icon/" + idc);
44 $("#reflection").src("cydia://package-icon/" + idc);
45
46 $("#name").html(name);
47 space("#latest", package.latest, 93);
48
49 $("#rating").src("http://cydia.saurik.com/test_.html");
50
51 $("#settings").href("cydia://package-settings/" + idc);
52
53 var warnings = package.warnings;
54 var length = warnings == null ? 0 : warnings.length;
55 if (length == 0)
56 $(".warnings").remove();
57 else {
58 var parent = $("#warnings");
59 var child = $("#warning");
60 child.remove();
61
62 for (var i = 0; i != length; ++i) {
63 var clone = child.clone(true);
64 parent.append(clone);
65 clone.xpath("label").html($.xml(warnings[i]));
66 }
67 }
68
69 var applications = package.applications;
70 var length = applications == null ? 0 : applications.length;
71
72 var child = $("#application");
73 child.remove();
74
75 /*if (length != 0) {
76 var parent = $("#actions");
77
78 for (var i = 0; i != length; ++i) {
79 var application = applications[i];
80 var clone = child.clone(true);
81 parent.append(clone);
82 clone.href("cydia://launch/" + application[0]);
83 clone.xpath("label").html("Run " + $.xml(application[1]));
84 clone.xpath("img").src(application[2]);
85 }
86 }*/
87
88 var purposes = package.purposes;
89 var commercial = false;
90 var _console = false;
91 if (purposes != null)
92 for (var i = 0, e = purposes.length; i != e; ++i) {
93 var purpose = purposes[i];
94 if (purpose == "commercial")
95 commercial = true;
96 else if (purpose == "console")
97 _console = true;
98 }
99 if (!commercial)
100 $(".commercial").remove();
101 if (!_console)
102 $(".console").remove();
103
104 var author = package.author;
105 if (author == null)
106 $(".author").remove();
107 else {
108 $("#author").html(author.name);
109 if (author.address == null)
110 $("#author-icon").remove();
111 else
112 $("#author-href").href("mailto:" + author.address + "?subject=" + regarding);
113 }
114
115 //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html");
116
117 var depiction = package.depiction;
118 if (depiction == null)
119 $(".depiction").remove();
120 else {
121 $(".description").display("none");
122 $("#depiction-src").src(depiction);
123 }
124
125 var description = package.description;
126 if (description == null)
127 description = package.tagline;
128 else
129 description = description.replace(/\n/g, "<br/>");
130 $("#description").html(description);
131
132 var homepage = package.homepage;
133 if (homepage == null)
134 $(".homepage").remove();
135 else
136 $("#homepage-href").href(homepage);
137
138 var installed = package.installed;
139 if (installed == null)
140 $(".installed").remove();
141 else {
142 $("#installed").html(installed);
143 $("#files-href").href("cydia://files/" + idc);
144 }
145
146 space("#id", id, 238);
147
148 var section = package.section;
149 if (section == null)
150 $(".section").remove();
151 else {
152 $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section));
153 $("#section").html(section);
154 }
155
156 var size = package.size;
157 if (size == 0)
158 $(".size").remove();
159 else
160 $("#size").html(size / 1024 + " kB");
161
162 var maintainer = package.maintainer;
163 if (maintainer == null)
164 $(".maintainer").remove();
165 else {
166 $("#maintainer").html(maintainer.name);
167 if (maintainer.address == null)
168 $("#maintainer-icon").remove();
169 else
170 $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding);
171 }
172
173 var sponsor = package.sponsor;
174 if (sponsor == null)
175 $(".sponsor").remove();
176 else {
177 $("#sponsor").html(sponsor.name);
178 $("#sponsor-href").href(sponsor.address);
179 }
180
181 var source = package.source;
182 if (source == null) {
183 $(".source").remove();
184 $(".trusted").remove();
185 } else {
186 var host = source.host;
187
188 $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host));
189 $("#source-name").html(source.name);
190
191 if (source.trusted)
192 $("#trusted").href("cydia://package-signature/" + idc);
193 else
194 $(".trusted").remove();
195
196 var description = source.description;
197 if (description == null)
198 $(".source-description").remove();
199 else
200 $("#source-description").html(description);
201 }
202 });