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