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