]> git.saurik.com Git - cydia.git/blob - MobileCydia.app/package.js
Reload all the crazy different iPad tabs.
[cydia.git] / MobileCydia.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 "longDescription": "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 node.css("letter-spacing", spacing);
33 }
34 }
35
36 var swap_, swap = function (on, off, time) {
37 setTimeout(swap_(on, off, time), time);
38 };
39
40 swap_ = function (on, off, time) {
41 return function () {
42 on.className = 'fade-out';
43 off.className = 'fade-in';
44 swap(off, on, time);
45 };
46 };
47
48 $(function () {
49 if (package == null)
50 return;
51
52 var id = package.id;
53 var idc = encodeURIComponent(id);
54 var name = package.name;
55 var icon = 'cydia://package-icon/' + idc;
56
57 var api = 'http://cydia.saurik.com/api/';
58 var capi = 'http://cache.cydia.saurik.com/api/';
59
60 var support = package.support;
61
62 var regarding = function (type) {
63 return encodeURIComponent("Cydia/APT(" + type + "): " + name);
64 };
65
66 $("#icon").css("background-image", 'url("' + icon + '")');
67 //$("#reflection").src("cydia://package-icon/" + idc);
68
69 $("#name").html($.xml(name));
70 space("#latest", $.xml(package.latest), 96);
71
72 $.xhr(capi + 'package/' + idc, 'GET', {}, null, {
73 success: function (value) {
74 value = eval(value);
75
76 if (typeof value.notice == "undefined")
77 $(".notice").addClass("deleted");
78 else
79 $("#notice-src").src(value.notice);
80
81 if (typeof value.rating == "undefined")
82 $(".rating").addClass("deleted");
83 else {
84 $("#rating-load").addClass("deleted");
85 $("#rating-href").href(value.reviews);
86
87 var none = $("#rating-none");
88 var done = $("#rating-done");
89
90 if (value.rating == null) {
91 none.css("display", "block");
92 } else {
93 done.css("display", "block");
94
95 $("#rating-value").css('width', 16 * value.rating);
96 }
97 }
98
99 if (typeof value.icon != "undefined" && value.icon != null) {
100 var icon = $("#icon");
101 var thumb = $("#thumb");
102
103 icon[0].className = 'flip-180';
104 thumb[0].className = 'flip-360';
105
106 thumb.css("background-image", 'url("' + value.icon + '")');
107
108 setTimeout(function () {
109 icon.addClass("deleted");
110 thumb[0].className = 'flip-0';
111 }, 2000);
112 }
113 },
114
115 failure: function (status) {
116 $(".rating").addClass("deleted");
117 }
118 });
119
120 $("#settings").href("cydia://package-settings/" + idc);
121
122 var mode = package.mode;
123 if (mode == null)
124 $(".mode").addClass("deleted");
125 else {
126 $("#mode").html(cydia.localize(mode));
127 $("#mode-src").src("Modes/" + mode + ".png");
128 }
129
130 var warnings = package.warnings;
131 var length = warnings == null ? 0 : warnings.length;
132 if (length == 0)
133 $(".warnings").addClass("deleted");
134 else {
135 var parent = $("#warnings");
136 var child = $("#warning");
137
138 for (var i = 0; i != length; ++i) {
139 var clone = child.clone(true);
140 clone.addClass("inserted");
141 parent.append(clone);
142 clone.xpath("./div/label").html($.xml(warnings[i]));
143 }
144
145 child.addClass("deleted");
146 }
147
148 var applications = package.applications;
149 var length = applications == null ? 0 : applications.length;
150
151 var child = $("#application");
152
153 /*if (length != 0) {
154 var parent = $("#actions");
155
156 for (var i = 0; i != length; ++i) {
157 var application = applications[i];
158 var clone = child.clone(true);
159 parent.append(clone);
160 clone.href("cydia://launch/" + application[0]);
161 clone.xpath("label").html("Run " + $.xml(application[1]));
162 clone.xpath("img").src(application[2]);
163 }
164 }*/
165
166 child.addClass("deleted");
167
168 var commercial = package.hasTag('cydia::commercial');
169 if (!commercial)
170 $(".commercial").addClass("deleted");
171
172 var _console = package.hasTag('purpose::console');
173 if (!_console)
174 $(".console").addClass("deleted");
175
176 var author = package.author;
177 if (author == null)
178 $(".author").addClass("deleted");
179 else {
180 space("#author", $.xml(author.name), 160);
181 if (author.address == null)
182 $("#author-icon").addClass("deleted");
183 else if (support == null)
184 $("#author-href").href("mailto:" + author.address + "?subject=" + regarding("A"));
185 else
186 $("#author-href").href(support);
187 }
188
189 /*var store = commercial;
190 if (!store)
191 $(".activation").addClass("deleted");
192 else {
193 var activation = api + 'activation/' + idc;
194 $("#activation-src").src(activation);
195 }*/
196
197 var depiction = package.depiction;
198 if (depiction != null) {
199 $(".description").addClass("deleted");
200 $("#depiction-src").src(depiction);
201 } else {
202 $(".depiction").addClass("deleted");
203
204 var description = package.longDescription;
205 if (description == null)
206 description = package.shortDescription;
207
208 if (description == null)
209 $(".description").addClass("deleted");
210 else {
211 description = $.xml(description).replace(/\n/g, "<br/>");
212 $("#description").html(description);
213 }
214 }
215
216 var homepage = package.homepage;
217 if (homepage == null)
218 $(".homepage").addClass("deleted");
219 else
220 $("#homepage-href").href(homepage);
221
222 var installed = package.installed;
223 if (installed == null)
224 $(".installed").addClass("deleted");
225 else {
226 $("#installed").html($.xml(installed));
227 $("#files-href").href("cydia://files/" + idc);
228 }
229
230 space("#id", $.xml(id), 220);
231
232 var section = package.longSection;
233 if (section == null)
234 $(".section").addClass("deleted");
235 else {
236 $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section));
237 $("#section").html($.xml(section));
238 }
239
240 var size = package.size;
241 if (size == 0)
242 $(".size").addClass("deleted");
243 else
244 $("#size").html(size / 1024 + " kB");
245
246 var maintainer = package.maintainer;
247 if (maintainer == null)
248 $(".maintainer").addClass("deleted");
249 else {
250 space("#maintainer", $.xml(maintainer.name), 153);
251 if (maintainer.address == null)
252 $("#maintainer-icon").addClass("deleted");
253 else if (support == null)
254 $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding("M"));
255 else
256 $("#maintainer-href").href(support);
257 }
258
259 var sponsor = package.sponsor;
260 if (sponsor == null)
261 $(".sponsor").addClass("deleted");
262 else {
263 space("#sponsor", $.xml(sponsor.name), 152);
264 $("#sponsor-href").href(sponsor.address);
265 }
266
267 var source = package.source;
268 if (source == null) {
269 $(".source").addClass("deleted");
270 $(".trusted").addClass("deleted");
271 } else {
272 var host = source.host;
273
274 $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host));
275 $("#source-name").html($.xml(source.name));
276
277 if (source.trusted)
278 $("#trusted").href("cydia://package-signature/" + idc);
279 else
280 $(".trusted").addClass("deleted");
281
282 var description = source.description;
283 if (description == null)
284 $(".source-description").addClass("deleted");
285 else
286 $("#source-description").html($.xml(description));
287 }
288 });