]>
Commit | Line | Data |
---|---|---|
6f1a15d9 JF |
1 | /*var package = { |
2 | "name": "MobileTerminal", | |
3 | "latest": "286u-5", | |
4 | "author": { | |
5 | "name": "Allen Porter", | |
6 | "address": "allen.porter@gmail.com" | |
7 | }, | |
7d2ac47f JF |
8 | //"depiction": "http://planet-iphones.com/repository/info/chromium1.3.php", |
9 | "depiction": "http://cydia.saurik.com/terminal.html", | |
eef4ccaf | 10 | "longDescription": "this is a sample description", |
7d2ac47f | 11 | "homepage": "http://cydia.saurik.com/terminal.html", |
6f1a15d9 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": { | |
dddbc481 JF |
21 | "name": "Telesphoreo Tangelo", |
22 | "description": "Distribution of Unix Software for the iPhone" | |
6f1a15d9 JF |
23 | } |
24 | };*/ | |
25 | ||
365d45da JF |
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"; | |
365d45da JF |
32 | node.css("letter-spacing", spacing); |
33 | } | |
34 | } | |
35 | ||
59c6ae22 JF |
36 | function cache(url) { |
37 | return url.replace('://', '://ne.edgecastcdn.net/8003A4/'); | |
38 | } | |
39 | ||
40 | var swap_, swap = function (on, off, time) { | |
41 | setTimeout(swap_(on, off, time), time); | |
42 | }; | |
43 | ||
44 | swap_ = 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 | ||
f79a4512 JF |
52 | var special_ = function () { |
53 | if (package == null) | |
54 | return; | |
55 | ||
c37ef8c8 JF |
56 | var id = package.id; |
57 | var idc = encodeURIComponent(id); | |
58 | var name = package.name; | |
c37ef8c8 | 59 | var icon = 'cydia://package-icon/' + idc; |
59c6ae22 | 60 | var api = 'http://cydia.saurik.com/api/'; |
c37ef8c8 | 61 | |
043e6a2e JF |
62 | var support = package.support; |
63 | ||
dc63e78f JF |
64 | var regarding = function (type) { |
65 | return encodeURIComponent("Cydia/APT(" + type + "): " + name); | |
66 | }; | |
67 | ||
c37ef8c8 | 68 | $("#icon").css("background-image", 'url("' + icon + '")'); |
dc63e78f | 69 | //$("#reflection").src("cydia://package-icon/" + idc); |
c37ef8c8 JF |
70 | |
71 | $("#name").html(name); | |
72 | space("#latest", package.latest, 96); | |
d6dad1b4 | 73 | |
3bd1c2a2 | 74 | $.xhr(cache(api + 'package/' + idc), 'GET', {}, null, { |
59c6ae22 JF |
75 | success: function (value) { |
76 | value = eval(value); | |
c37ef8c8 | 77 | |
670a0494 JF |
78 | if (typeof value.notice == "undefined") |
79 | $(".notice").addClass("deleted"); | |
80 | else | |
b2d2f219 | 81 | $("#notice-src").src(value.notice); |
670a0494 | 82 | |
49775c7b | 83 | if (typeof value.rating == "undefined") |
f79a4512 | 84 | $(".rating").addClass("deleted"); |
49775c7b | 85 | else { |
f79a4512 | 86 | $("#rating-load").addClass("deleted"); |
49775c7b | 87 | $("#rating-href").href(value.reviews); |
c37ef8c8 | 88 | |
49775c7b JF |
89 | var none = $("#rating-none"); |
90 | var done = $("#rating-done"); | |
c37ef8c8 | 91 | |
49775c7b | 92 | if (value.rating == null) { |
49775c7b JF |
93 | none.css("display", "block"); |
94 | } else { | |
49775c7b | 95 | done.css("display", "block"); |
c37ef8c8 | 96 | |
49775c7b JF |
97 | $("#rating-value").css('width', 16 * value.rating); |
98 | } | |
d6dad1b4 | 99 | } |
59c6ae22 JF |
100 | |
101 | if (typeof value.icon != "undefined" && value.icon != null) { | |
102 | var icon = $("#icon"); | |
103 | var thumb = $("#thumb"); | |
49775c7b | 104 | |
59c6ae22 JF |
105 | icon[0].className = 'flip-180'; |
106 | thumb[0].className = 'flip-360'; | |
49775c7b | 107 | |
59c6ae22 JF |
108 | thumb.css("background-image", 'url("' + value.icon + '")'); |
109 | ||
110 | setTimeout(function () { | |
f79a4512 | 111 | icon.addClass("deleted"); |
59c6ae22 JF |
112 | thumb[0].className = 'flip-0'; |
113 | }, 2000); | |
114 | } | |
115 | }, | |
116 | ||
117 | failure: function (status) { | |
f79a4512 | 118 | $(".rating").addClass("deleted"); |
59c6ae22 JF |
119 | } |
120 | }); | |
6f1a15d9 | 121 | |
770f2a8e JF |
122 | $("#settings").href("cydia://package-settings/" + idc); |
123 | ||
dc63e78f JF |
124 | var mode = package.mode; |
125 | if (mode == null) | |
f79a4512 | 126 | $(".mode").addClass("deleted"); |
dc63e78f | 127 | else { |
f79a4512 | 128 | $("#mode").html(cydia.localize(mode)); |
dc63e78f JF |
129 | $("#mode-src").src("Modes/" + mode + ".png"); |
130 | } | |
131 | ||
affeffc7 JF |
132 | var warnings = package.warnings; |
133 | var length = warnings == null ? 0 : warnings.length; | |
134 | if (length == 0) | |
f79a4512 | 135 | $(".warnings").addClass("deleted"); |
affeffc7 JF |
136 | else { |
137 | var parent = $("#warnings"); | |
138 | var child = $("#warning"); | |
affeffc7 JF |
139 | |
140 | for (var i = 0; i != length; ++i) { | |
141 | var clone = child.clone(true); | |
f79a4512 | 142 | clone.addClass("inserted"); |
affeffc7 | 143 | parent.append(clone); |
aa5d0de7 | 144 | clone.xpath("./div/label").html($.xml(warnings[i])); |
affeffc7 | 145 | } |
f79a4512 JF |
146 | |
147 | child.addClass("deleted"); | |
affeffc7 JF |
148 | } |
149 | ||
150 | var applications = package.applications; | |
151 | var length = applications == null ? 0 : applications.length; | |
770f2a8e JF |
152 | |
153 | var child = $("#application"); | |
770f2a8e JF |
154 | |
155 | /*if (length != 0) { | |
affeffc7 | 156 | var parent = $("#actions"); |
affeffc7 JF |
157 | |
158 | for (var i = 0; i != length; ++i) { | |
159 | var application = applications[i]; | |
160 | var clone = child.clone(true); | |
161 | parent.append(clone); | |
162 | clone.href("cydia://launch/" + application[0]); | |
163 | clone.xpath("label").html("Run " + $.xml(application[1])); | |
164 | clone.xpath("img").src(application[2]); | |
affeffc7 | 165 | } |
770f2a8e JF |
166 | }*/ |
167 | ||
f79a4512 JF |
168 | child.addClass("deleted"); |
169 | ||
3bd1c2a2 | 170 | var commercial = package.hasTag('cydia::commercial'); |
770f2a8e | 171 | if (!commercial) |
f79a4512 | 172 | $(".commercial").addClass("deleted"); |
3bd1c2a2 JF |
173 | |
174 | var _console = package.hasTag('purpose::console'); | |
770f2a8e | 175 | if (!_console) |
f79a4512 | 176 | $(".console").addClass("deleted"); |
affeffc7 | 177 | |
6f1a15d9 JF |
178 | var author = package.author; |
179 | if (author == null) | |
f79a4512 | 180 | $(".author").addClass("deleted"); |
6f1a15d9 | 181 | else { |
4bcbe7f9 | 182 | space("#author", author.name, 160); |
affeffc7 | 183 | if (author.address == null) |
f79a4512 | 184 | $("#author-icon").addClass("deleted"); |
043e6a2e JF |
185 | else if (support == null) |
186 | $("#author-href").href("mailto:" + author.address + "?subject=" + regarding("A")); | |
187 | else | |
188 | $("#author-href").href(support); | |
6f1a15d9 JF |
189 | } |
190 | ||
3bd1c2a2 JF |
191 | /*var store = commercial; |
192 | if (!store) | |
f79a4512 | 193 | $(".activation").addClass("deleted"); |
3bd1c2a2 JF |
194 | else { |
195 | var activation = api + 'activation/' + idc; | |
196 | $("#activation-src").src(activation); | |
197 | }*/ | |
198 | ||
25a2158d | 199 | var depiction = package.depiction; |
7d2ac47f | 200 | if (depiction == null) |
f79a4512 | 201 | $(".depiction").addClass("deleted"); |
7d2ac47f | 202 | else { |
f79a4512 | 203 | $(".description").addClass("deleted"); |
b2d2f219 | 204 | $("#depiction-src").src(depiction); |
25a2158d | 205 | } |
6f1a15d9 | 206 | |
eef4ccaf | 207 | var description = package.longDescription; |
7d2ac47f | 208 | if (description == null) |
eef4ccaf | 209 | description = package.shortDescription; |
7d2ac47f JF |
210 | else |
211 | description = description.replace(/\n/g, "<br/>"); | |
212 | $("#description").html(description); | |
213 | ||
6f1a15d9 JF |
214 | var homepage = package.homepage; |
215 | if (homepage == null) | |
f79a4512 | 216 | $(".homepage").addClass("deleted"); |
6f1a15d9 | 217 | else |
25a2158d | 218 | $("#homepage-href").href(homepage); |
6f1a15d9 JF |
219 | |
220 | var installed = package.installed; | |
221 | if (installed == null) | |
f79a4512 | 222 | $(".installed").addClass("deleted"); |
6f1a15d9 JF |
223 | else { |
224 | $("#installed").html(installed); | |
affeffc7 | 225 | $("#files-href").href("cydia://files/" + idc); |
6f1a15d9 JF |
226 | } |
227 | ||
00e2109e | 228 | space("#id", id, 220); |
6f1a15d9 | 229 | |
fc0a472b | 230 | var section = package.longSection; |
6f1a15d9 | 231 | if (section == null) |
f79a4512 | 232 | $(".section").addClass("deleted"); |
dec6029f JF |
233 | else { |
234 | $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section)); | |
235 | $("#section").html(section); | |
236 | } | |
6f1a15d9 JF |
237 | |
238 | var size = package.size; | |
239 | if (size == 0) | |
f79a4512 | 240 | $(".size").addClass("deleted"); |
6f1a15d9 JF |
241 | else |
242 | $("#size").html(size / 1024 + " kB"); | |
243 | ||
244 | var maintainer = package.maintainer; | |
245 | if (maintainer == null) | |
f79a4512 | 246 | $(".maintainer").addClass("deleted"); |
6f1a15d9 | 247 | else { |
4bcbe7f9 | 248 | space("#maintainer", maintainer.name, 153); |
affeffc7 | 249 | if (maintainer.address == null) |
f79a4512 | 250 | $("#maintainer-icon").addClass("deleted"); |
043e6a2e | 251 | else if (support == null) |
dc63e78f | 252 | $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding("M")); |
043e6a2e JF |
253 | else |
254 | $("#maintainer-href").href(support); | |
6f1a15d9 JF |
255 | } |
256 | ||
dddbc481 | 257 | var sponsor = package.sponsor; |
dc6e62a4 | 258 | if (sponsor == null) |
f79a4512 | 259 | $(".sponsor").addClass("deleted"); |
dc6e62a4 | 260 | else { |
4bcbe7f9 | 261 | space("#sponsor", sponsor.name, 152); |
25a2158d | 262 | $("#sponsor-href").href(sponsor.address); |
dc6e62a4 JF |
263 | } |
264 | ||
6f1a15d9 | 265 | var source = package.source; |
25a2158d | 266 | if (source == null) { |
f79a4512 JF |
267 | $(".source").addClass("deleted"); |
268 | $(".trusted").addClass("deleted"); | |
25a2158d | 269 | } else { |
16f2786b JF |
270 | var host = source.host; |
271 | ||
272 | $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); | |
dddbc481 JF |
273 | $("#source-name").html(source.name); |
274 | ||
5e09ff3b | 275 | if (source.trusted) |
770f2a8e | 276 | $("#trusted").href("cydia://package-signature/" + idc); |
5e09ff3b | 277 | else |
f79a4512 | 278 | $(".trusted").addClass("deleted"); |
25a2158d | 279 | |
dddbc481 JF |
280 | var description = source.description; |
281 | if (description == null) | |
f79a4512 | 282 | $(".source-description").addClass("deleted"); |
dddbc481 JF |
283 | else |
284 | $("#source-description").html(description); | |
285 | } | |
f79a4512 JF |
286 | }; |
287 | ||
288 | $(special_); | |
289 | ||
290 | var special = function () { | |
291 | $(".deleted").removeClass("deleted"); | |
292 | $(".inserted").remove(); | |
293 | ||
294 | $("#icon")[0].className = 'flip-0'; | |
295 | $("#thumb")[0].className = 'flip-180'; | |
296 | ||
297 | /* XXX: this could be better */ | |
70d45c1e | 298 | $("#rating-href").href(null); |
f79a4512 JF |
299 | $("#rating-none").css("display", "none"); |
300 | $("#rating-done").css("display", "none"); | |
301 | ||
670a0494 JF |
302 | var notice = $("#notice-src"); |
303 | ||
304 | notice[0].outerHTML = '<iframe' + | |
305 | ' class="notice"' + | |
306 | ' id="notice-src"' + | |
307 | ' frameborder="0"' + | |
308 | ' width="320"' + | |
309 | ' height="0"' + | |
310 | ' target="_top"' + | |
311 | '></iframe>'; | |
312 | ||
f79a4512 JF |
313 | var depiction = $("#depiction-src"); |
314 | ||
315 | depiction[0].outerHTML = '<iframe' + | |
316 | ' class="depiction"' + | |
317 | ' id="depiction-src"' + | |
318 | ' frameborder="0"' + | |
319 | ' width="320"' + | |
320 | ' height="0"' + | |
321 | ' target="_top"' + | |
b2d2f219 | 322 | ' onload_="loaded()"' + |
f79a4512 JF |
323 | '></iframe>'; |
324 | ||
325 | special_(); | |
326 | }; | |
327 | ||
328 | cydia.setSpecial(special); |