]> git.saurik.com Git - cydia.git/blame - Cydia.app/package.js
The syslog is more useful.
[cydia.git] / Cydia.app / package.js
CommitLineData
ad554f10
JF
1/*var package = {
2 "name": "MobileTerminal",
3 "latest": "286u-5",
4 "author": {
5 "name": "Allen Porter",
6 "address": "allen.porter@gmail.com"
7 },
853d14d3
JF
8 //"depiction": "http://planet-iphones.com/repository/info/chromium1.3.php",
9 "depiction": "http://cydia.saurik.com/terminal.html",
ad554f10 10 "description": "this is a sample description",
853d14d3 11 "homepage": "http://cydia.saurik.com/terminal.html",
ad554f10
JF
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": {
1eb0c554
JF
21 "name": "Telesphoreo Tangelo",
22 "description": "Distribution of Unix Software for the iPhone"
ad554f10
JF
23 }
24};*/
25
78b966cc
JF
26function 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";
78b966cc
JF
32 node.css("letter-spacing", spacing);
33 }
34}
35
c3f582af
JF
36function cache(url) {
37 return url.replace('://', '://ne.edgecastcdn.net/8003A4/');
38}
39
40var swap_, swap = function (on, off, time) {
41 setTimeout(swap_(on, off, time), time);
42};
43
44swap_ = function (on, off, time) {
45 return function () {
46 on.className = 'fade-out';
47 off.className = 'fade-in';
48 swap(off, on, time);
49 };
50};
51
2e018aa4
JF
52$(function () {
53 var id = package.id;
54 var idc = encodeURIComponent(id);
55 var name = package.name;
2e018aa4 56 var icon = 'cydia://package-icon/' + idc;
c3f582af 57 var api = 'http://cydia.saurik.com/api/';
2e018aa4 58
3ff1504e
JF
59 var regarding = function (type) {
60 return encodeURIComponent("Cydia/APT(" + type + "): " + name);
61 };
62
2e018aa4 63 $("#icon").css("background-image", 'url("' + icon + '")');
3ff1504e 64 //$("#reflection").src("cydia://package-icon/" + idc);
2e018aa4
JF
65
66 $("#name").html(name);
67 space("#latest", package.latest, 96);
7ec29c77 68
d8d9a65c 69 $.xhr(cache(api + 'package/' + idc), 'GET', {}, null, {
c3f582af
JF
70 success: function (value) {
71 value = eval(value);
2e018aa4 72
81bf90f6
JF
73 if (typeof value.rating == "undefined")
74 $(".rating").remove();
75 else {
76 $("#rating-load").remove();
77 $("#rating-href").href(value.reviews);
2e018aa4 78
81bf90f6
JF
79 var none = $("#rating-none");
80 var done = $("#rating-done");
2e018aa4 81
81bf90f6
JF
82 if (value.rating == null) {
83 done.remove();
84 none.css("display", "block");
85 } else {
86 none.remove();
87 done.css("display", "block");
2e018aa4 88
81bf90f6
JF
89 $("#rating-value").css('width', 16 * value.rating);
90 }
7ec29c77 91 }
c3f582af
JF
92
93 if (typeof value.icon != "undefined" && value.icon != null) {
94 var icon = $("#icon");
95 var thumb = $("#thumb");
81bf90f6 96
c3f582af
JF
97 icon[0].className = 'flip-180';
98 thumb[0].className = 'flip-360';
81bf90f6 99
c3f582af
JF
100 thumb.css("background-image", 'url("' + value.icon + '")');
101
102 setTimeout(function () {
103 icon.css("display", "none");
104 thumb[0].className = 'flip-0';
105 }, 2000);
106 }
107 },
108
109 failure: function (status) {
110 $(".rating").remove();
111 }
112 });
ad554f10 113
dbe0f181
JF
114 $("#settings").href("cydia://package-settings/" + idc);
115
3ff1504e
JF
116 var mode = package.mode;
117 if (mode == null)
118 $(".mode").remove();
119 else {
120 $("#mode").html(mode);
121 $("#mode-src").src("Modes/" + mode + ".png");
122 }
123
f464053e
JF
124 var warnings = package.warnings;
125 var length = warnings == null ? 0 : warnings.length;
126 if (length == 0)
127 $(".warnings").remove();
128 else {
129 var parent = $("#warnings");
130 var child = $("#warning");
131 child.remove();
132
133 for (var i = 0; i != length; ++i) {
134 var clone = child.clone(true);
135 parent.append(clone);
04700693 136 clone.xpath("./div/label").html($.xml(warnings[i]));
f464053e
JF
137 }
138 }
139
140 var applications = package.applications;
141 var length = applications == null ? 0 : applications.length;
dbe0f181
JF
142
143 var child = $("#application");
144 child.remove();
145
146 /*if (length != 0) {
f464053e 147 var parent = $("#actions");
f464053e
JF
148
149 for (var i = 0; i != length; ++i) {
150 var application = applications[i];
151 var clone = child.clone(true);
152 parent.append(clone);
153 clone.href("cydia://launch/" + application[0]);
154 clone.xpath("label").html("Run " + $.xml(application[1]));
155 clone.xpath("img").src(application[2]);
f464053e 156 }
dbe0f181
JF
157 }*/
158
d8d9a65c 159 var commercial = package.hasTag('cydia::commercial');
dbe0f181
JF
160 if (!commercial)
161 $(".commercial").remove();
d8d9a65c
JF
162
163 var _console = package.hasTag('purpose::console');
dbe0f181
JF
164 if (!_console)
165 $(".console").remove();
f464053e 166
ad554f10
JF
167 var author = package.author;
168 if (author == null)
169 $(".author").remove();
170 else {
e52a2683 171 space("#author", author.name, 160);
f464053e
JF
172 if (author.address == null)
173 $("#author-icon").remove();
3ff1504e
JF
174 else {
175 var support = package.support;
176 if (support == null)
177 $("#author-href").href("mailto:" + author.address + "?subject=" + regarding("A"));
178 else
179 $("#author-href").href(support);
180 }
ad554f10
JF
181 }
182
f464053e 183 //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html");
853d14d3 184
d8d9a65c
JF
185 /*var store = commercial;
186 if (!store)
187 $(".activation").remove();
188 else {
189 var activation = api + 'activation/' + idc;
190 $("#activation-src").src(activation);
191 }*/
192
0235116c 193 var depiction = package.depiction;
853d14d3 194 if (depiction == null)
0235116c 195 $(".depiction").remove();
853d14d3 196 else {
2e018aa4 197 $(".description").css("display", "none");
853d14d3 198 $("#depiction-src").src(depiction);
0235116c 199 }
ad554f10 200
853d14d3
JF
201 var description = package.description;
202 if (description == null)
203 description = package.tagline;
204 else
205 description = description.replace(/\n/g, "<br/>");
206 $("#description").html(description);
207
ad554f10
JF
208 var homepage = package.homepage;
209 if (homepage == null)
210 $(".homepage").remove();
211 else
0235116c 212 $("#homepage-href").href(homepage);
ad554f10
JF
213
214 var installed = package.installed;
215 if (installed == null)
216 $(".installed").remove();
217 else {
218 $("#installed").html(installed);
f464053e 219 $("#files-href").href("cydia://files/" + idc);
ad554f10
JF
220 }
221
0a7e5478 222 space("#id", id, 220);
ad554f10
JF
223
224 var section = package.section;
225 if (section == null)
226 $(".section").remove();
6b4b3bee
JF
227 else {
228 $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section));
229 $("#section").html(section);
230 }
ad554f10
JF
231
232 var size = package.size;
233 if (size == 0)
234 $(".size").remove();
235 else
236 $("#size").html(size / 1024 + " kB");
237
238 var maintainer = package.maintainer;
239 if (maintainer == null)
240 $(".maintainer").remove();
241 else {
e52a2683 242 space("#maintainer", maintainer.name, 153);
f464053e
JF
243 if (maintainer.address == null)
244 $("#maintainer-icon").remove();
245 else
3ff1504e 246 $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding("M"));
ad554f10
JF
247 }
248
1eb0c554 249 var sponsor = package.sponsor;
6bffd7b7
JF
250 if (sponsor == null)
251 $(".sponsor").remove();
252 else {
e52a2683 253 space("#sponsor", sponsor.name, 152);
0235116c 254 $("#sponsor-href").href(sponsor.address);
6bffd7b7
JF
255 }
256
ad554f10 257 var source = package.source;
0235116c 258 if (source == null) {
ad554f10 259 $(".source").remove();
0235116c
JF
260 $(".trusted").remove();
261 } else {
18159e09
JF
262 var host = source.host;
263
264 $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host));
1eb0c554
JF
265 $("#source-name").html(source.name);
266
2f4fac47 267 if (source.trusted)
dbe0f181 268 $("#trusted").href("cydia://package-signature/" + idc);
2f4fac47 269 else
0235116c
JF
270 $(".trusted").remove();
271
1eb0c554
JF
272 var description = source.description;
273 if (description == null)
274 $(".source-description").remove();
275 else
276 $("#source-description").html(description);
277 }
ad554f10 278});