]>
Commit | Line | Data |
---|---|---|
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", | |
66abcbb0 | 10 | "longDescription": "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 |
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"; | |
78b966cc JF |
32 | node.css("letter-spacing", spacing); |
33 | } | |
34 | } | |
35 | ||
c3f582af | 36 | function cache(url) { |
daf7f6e2 | 37 | return url.replace('://', '://wpc.03A4.edgecastcdn.net/8003A4/'); |
c3f582af JF |
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 | ||
6932575e JF |
52 | var special_ = function () { |
53 | if (package == null) | |
54 | return; | |
55 | ||
2e018aa4 JF |
56 | var id = package.id; |
57 | var idc = encodeURIComponent(id); | |
58 | var name = package.name; | |
2e018aa4 | 59 | var icon = 'cydia://package-icon/' + idc; |
c3f582af | 60 | var api = 'http://cydia.saurik.com/api/'; |
2e018aa4 | 61 | |
e32f0fcb JF |
62 | var support = package.support; |
63 | ||
3ff1504e JF |
64 | var regarding = function (type) { |
65 | return encodeURIComponent("Cydia/APT(" + type + "): " + name); | |
66 | }; | |
67 | ||
2e018aa4 | 68 | $("#icon").css("background-image", 'url("' + icon + '")'); |
3ff1504e | 69 | //$("#reflection").src("cydia://package-icon/" + idc); |
2e018aa4 JF |
70 | |
71 | $("#name").html(name); | |
72 | space("#latest", package.latest, 96); | |
7ec29c77 | 73 | |
d8d9a65c | 74 | $.xhr(cache(api + 'package/' + idc), 'GET', {}, null, { |
c3f582af JF |
75 | success: function (value) { |
76 | value = eval(value); | |
2e018aa4 | 77 | |
6981ccdf JF |
78 | if (typeof value.notice == "undefined") |
79 | $(".notice").addClass("deleted"); | |
80 | else | |
600b6e78 | 81 | $("#notice-src").src(value.notice); |
6981ccdf | 82 | |
81bf90f6 | 83 | if (typeof value.rating == "undefined") |
6932575e | 84 | $(".rating").addClass("deleted"); |
81bf90f6 | 85 | else { |
6932575e | 86 | $("#rating-load").addClass("deleted"); |
81bf90f6 | 87 | $("#rating-href").href(value.reviews); |
2e018aa4 | 88 | |
81bf90f6 JF |
89 | var none = $("#rating-none"); |
90 | var done = $("#rating-done"); | |
2e018aa4 | 91 | |
81bf90f6 | 92 | if (value.rating == null) { |
81bf90f6 JF |
93 | none.css("display", "block"); |
94 | } else { | |
81bf90f6 | 95 | done.css("display", "block"); |
2e018aa4 | 96 | |
81bf90f6 JF |
97 | $("#rating-value").css('width', 16 * value.rating); |
98 | } | |
7ec29c77 | 99 | } |
c3f582af JF |
100 | |
101 | if (typeof value.icon != "undefined" && value.icon != null) { | |
102 | var icon = $("#icon"); | |
103 | var thumb = $("#thumb"); | |
81bf90f6 | 104 | |
c3f582af JF |
105 | icon[0].className = 'flip-180'; |
106 | thumb[0].className = 'flip-360'; | |
81bf90f6 | 107 | |
c3f582af JF |
108 | thumb.css("background-image", 'url("' + value.icon + '")'); |
109 | ||
110 | setTimeout(function () { | |
6932575e | 111 | icon.addClass("deleted"); |
c3f582af JF |
112 | thumb[0].className = 'flip-0'; |
113 | }, 2000); | |
114 | } | |
115 | }, | |
116 | ||
117 | failure: function (status) { | |
6932575e | 118 | $(".rating").addClass("deleted"); |
c3f582af JF |
119 | } |
120 | }); | |
ad554f10 | 121 | |
dbe0f181 JF |
122 | $("#settings").href("cydia://package-settings/" + idc); |
123 | ||
3ff1504e JF |
124 | var mode = package.mode; |
125 | if (mode == null) | |
6932575e | 126 | $(".mode").addClass("deleted"); |
3ff1504e | 127 | else { |
6932575e | 128 | $("#mode").html(cydia.localize(mode)); |
3ff1504e JF |
129 | $("#mode-src").src("Modes/" + mode + ".png"); |
130 | } | |
131 | ||
f464053e JF |
132 | var warnings = package.warnings; |
133 | var length = warnings == null ? 0 : warnings.length; | |
134 | if (length == 0) | |
6932575e | 135 | $(".warnings").addClass("deleted"); |
f464053e JF |
136 | else { |
137 | var parent = $("#warnings"); | |
138 | var child = $("#warning"); | |
f464053e JF |
139 | |
140 | for (var i = 0; i != length; ++i) { | |
141 | var clone = child.clone(true); | |
6932575e | 142 | clone.addClass("inserted"); |
f464053e | 143 | parent.append(clone); |
04700693 | 144 | clone.xpath("./div/label").html($.xml(warnings[i])); |
f464053e | 145 | } |
6932575e JF |
146 | |
147 | child.addClass("deleted"); | |
f464053e JF |
148 | } |
149 | ||
150 | var applications = package.applications; | |
151 | var length = applications == null ? 0 : applications.length; | |
dbe0f181 JF |
152 | |
153 | var child = $("#application"); | |
dbe0f181 JF |
154 | |
155 | /*if (length != 0) { | |
f464053e | 156 | var parent = $("#actions"); |
f464053e 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]); | |
f464053e | 165 | } |
dbe0f181 JF |
166 | }*/ |
167 | ||
6932575e JF |
168 | child.addClass("deleted"); |
169 | ||
d8d9a65c | 170 | var commercial = package.hasTag('cydia::commercial'); |
dbe0f181 | 171 | if (!commercial) |
6932575e | 172 | $(".commercial").addClass("deleted"); |
d8d9a65c JF |
173 | |
174 | var _console = package.hasTag('purpose::console'); | |
dbe0f181 | 175 | if (!_console) |
6932575e | 176 | $(".console").addClass("deleted"); |
f464053e | 177 | |
ad554f10 JF |
178 | var author = package.author; |
179 | if (author == null) | |
6932575e | 180 | $(".author").addClass("deleted"); |
ad554f10 | 181 | else { |
e52a2683 | 182 | space("#author", author.name, 160); |
f464053e | 183 | if (author.address == null) |
6932575e | 184 | $("#author-icon").addClass("deleted"); |
e32f0fcb JF |
185 | else if (support == null) |
186 | $("#author-href").href("mailto:" + author.address + "?subject=" + regarding("A")); | |
187 | else | |
188 | $("#author-href").href(support); | |
ad554f10 JF |
189 | } |
190 | ||
d8d9a65c JF |
191 | /*var store = commercial; |
192 | if (!store) | |
6932575e | 193 | $(".activation").addClass("deleted"); |
d8d9a65c JF |
194 | else { |
195 | var activation = api + 'activation/' + idc; | |
196 | $("#activation-src").src(activation); | |
197 | }*/ | |
198 | ||
0235116c | 199 | var depiction = package.depiction; |
853d14d3 | 200 | if (depiction == null) |
6932575e | 201 | $(".depiction").addClass("deleted"); |
853d14d3 | 202 | else { |
6932575e | 203 | $(".description").addClass("deleted"); |
600b6e78 | 204 | $("#depiction-src").src(depiction); |
0235116c | 205 | } |
ad554f10 | 206 | |
66abcbb0 | 207 | var description = package.longDescription; |
853d14d3 | 208 | if (description == null) |
66abcbb0 | 209 | description = package.shortDescription; |
853d14d3 JF |
210 | else |
211 | description = description.replace(/\n/g, "<br/>"); | |
212 | $("#description").html(description); | |
213 | ||
ad554f10 JF |
214 | var homepage = package.homepage; |
215 | if (homepage == null) | |
6932575e | 216 | $(".homepage").addClass("deleted"); |
ad554f10 | 217 | else |
0235116c | 218 | $("#homepage-href").href(homepage); |
ad554f10 JF |
219 | |
220 | var installed = package.installed; | |
221 | if (installed == null) | |
6932575e | 222 | $(".installed").addClass("deleted"); |
ad554f10 JF |
223 | else { |
224 | $("#installed").html(installed); | |
f464053e | 225 | $("#files-href").href("cydia://files/" + idc); |
ad554f10 JF |
226 | } |
227 | ||
0a7e5478 | 228 | space("#id", id, 220); |
ad554f10 | 229 | |
3a71abe7 | 230 | var section = package.longSection; |
ad554f10 | 231 | if (section == null) |
6932575e | 232 | $(".section").addClass("deleted"); |
6b4b3bee JF |
233 | else { |
234 | $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section)); | |
235 | $("#section").html(section); | |
236 | } | |
ad554f10 JF |
237 | |
238 | var size = package.size; | |
239 | if (size == 0) | |
6932575e | 240 | $(".size").addClass("deleted"); |
ad554f10 JF |
241 | else |
242 | $("#size").html(size / 1024 + " kB"); | |
243 | ||
244 | var maintainer = package.maintainer; | |
245 | if (maintainer == null) | |
6932575e | 246 | $(".maintainer").addClass("deleted"); |
ad554f10 | 247 | else { |
e52a2683 | 248 | space("#maintainer", maintainer.name, 153); |
f464053e | 249 | if (maintainer.address == null) |
6932575e | 250 | $("#maintainer-icon").addClass("deleted"); |
e32f0fcb | 251 | else if (support == null) |
3ff1504e | 252 | $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding("M")); |
e32f0fcb JF |
253 | else |
254 | $("#maintainer-href").href(support); | |
ad554f10 JF |
255 | } |
256 | ||
1eb0c554 | 257 | var sponsor = package.sponsor; |
6bffd7b7 | 258 | if (sponsor == null) |
6932575e | 259 | $(".sponsor").addClass("deleted"); |
6bffd7b7 | 260 | else { |
e52a2683 | 261 | space("#sponsor", sponsor.name, 152); |
0235116c | 262 | $("#sponsor-href").href(sponsor.address); |
6bffd7b7 JF |
263 | } |
264 | ||
ad554f10 | 265 | var source = package.source; |
0235116c | 266 | if (source == null) { |
6932575e JF |
267 | $(".source").addClass("deleted"); |
268 | $(".trusted").addClass("deleted"); | |
0235116c | 269 | } else { |
18159e09 JF |
270 | var host = source.host; |
271 | ||
272 | $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); | |
1eb0c554 JF |
273 | $("#source-name").html(source.name); |
274 | ||
2f4fac47 | 275 | if (source.trusted) |
dbe0f181 | 276 | $("#trusted").href("cydia://package-signature/" + idc); |
2f4fac47 | 277 | else |
6932575e | 278 | $(".trusted").addClass("deleted"); |
0235116c | 279 | |
1eb0c554 JF |
280 | var description = source.description; |
281 | if (description == null) | |
6932575e | 282 | $(".source-description").addClass("deleted"); |
1eb0c554 JF |
283 | else |
284 | $("#source-description").html(description); | |
285 | } | |
6932575e 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 */ | |
bd8e54e1 | 298 | $("#rating-href").href(null); |
6932575e JF |
299 | $("#rating-none").css("display", "none"); |
300 | $("#rating-done").css("display", "none"); | |
301 | ||
6981ccdf 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 | ||
6932575e 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"' + | |
600b6e78 | 322 | ' onload_="loaded()"' + |
6932575e JF |
323 | '></iframe>'; |
324 | ||
325 | special_(); | |
326 | }; | |
327 | ||
328 | cydia.setSpecial(special); |