]>
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 | 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 | ||
2634b249 | 48 | $(function () { |
f79a4512 JF |
49 | if (package == null) |
50 | return; | |
51 | ||
c37ef8c8 JF |
52 | var id = package.id; |
53 | var idc = encodeURIComponent(id); | |
54 | var name = package.name; | |
c37ef8c8 | 55 | var icon = 'cydia://package-icon/' + idc; |
65c27c56 | 56 | |
59c6ae22 | 57 | var api = 'http://cydia.saurik.com/api/'; |
65c27c56 | 58 | var capi = 'http://cache.cydia.saurik.com/api/'; |
c37ef8c8 | 59 | |
043e6a2e JF |
60 | var support = package.support; |
61 | ||
dc63e78f JF |
62 | var regarding = function (type) { |
63 | return encodeURIComponent("Cydia/APT(" + type + "): " + name); | |
64 | }; | |
65 | ||
c37ef8c8 | 66 | $("#icon").css("background-image", 'url("' + icon + '")'); |
dc63e78f | 67 | //$("#reflection").src("cydia://package-icon/" + idc); |
c37ef8c8 JF |
68 | |
69 | $("#name").html(name); | |
70 | space("#latest", package.latest, 96); | |
d6dad1b4 | 71 | |
65c27c56 | 72 | $.xhr(capi + 'package/' + idc, 'GET', {}, null, { |
59c6ae22 JF |
73 | success: function (value) { |
74 | value = eval(value); | |
c37ef8c8 | 75 | |
670a0494 JF |
76 | if (typeof value.notice == "undefined") |
77 | $(".notice").addClass("deleted"); | |
78 | else | |
b2d2f219 | 79 | $("#notice-src").src(value.notice); |
670a0494 | 80 | |
49775c7b | 81 | if (typeof value.rating == "undefined") |
f79a4512 | 82 | $(".rating").addClass("deleted"); |
49775c7b | 83 | else { |
f79a4512 | 84 | $("#rating-load").addClass("deleted"); |
49775c7b | 85 | $("#rating-href").href(value.reviews); |
c37ef8c8 | 86 | |
49775c7b JF |
87 | var none = $("#rating-none"); |
88 | var done = $("#rating-done"); | |
c37ef8c8 | 89 | |
49775c7b | 90 | if (value.rating == null) { |
49775c7b JF |
91 | none.css("display", "block"); |
92 | } else { | |
49775c7b | 93 | done.css("display", "block"); |
c37ef8c8 | 94 | |
49775c7b JF |
95 | $("#rating-value").css('width', 16 * value.rating); |
96 | } | |
d6dad1b4 | 97 | } |
59c6ae22 JF |
98 | |
99 | if (typeof value.icon != "undefined" && value.icon != null) { | |
100 | var icon = $("#icon"); | |
101 | var thumb = $("#thumb"); | |
49775c7b | 102 | |
59c6ae22 JF |
103 | icon[0].className = 'flip-180'; |
104 | thumb[0].className = 'flip-360'; | |
49775c7b | 105 | |
59c6ae22 JF |
106 | thumb.css("background-image", 'url("' + value.icon + '")'); |
107 | ||
108 | setTimeout(function () { | |
f79a4512 | 109 | icon.addClass("deleted"); |
59c6ae22 JF |
110 | thumb[0].className = 'flip-0'; |
111 | }, 2000); | |
112 | } | |
113 | }, | |
114 | ||
115 | failure: function (status) { | |
f79a4512 | 116 | $(".rating").addClass("deleted"); |
59c6ae22 JF |
117 | } |
118 | }); | |
6f1a15d9 | 119 | |
770f2a8e JF |
120 | $("#settings").href("cydia://package-settings/" + idc); |
121 | ||
dc63e78f JF |
122 | var mode = package.mode; |
123 | if (mode == null) | |
f79a4512 | 124 | $(".mode").addClass("deleted"); |
dc63e78f | 125 | else { |
f79a4512 | 126 | $("#mode").html(cydia.localize(mode)); |
dc63e78f JF |
127 | $("#mode-src").src("Modes/" + mode + ".png"); |
128 | } | |
129 | ||
affeffc7 JF |
130 | var warnings = package.warnings; |
131 | var length = warnings == null ? 0 : warnings.length; | |
132 | if (length == 0) | |
f79a4512 | 133 | $(".warnings").addClass("deleted"); |
affeffc7 JF |
134 | else { |
135 | var parent = $("#warnings"); | |
136 | var child = $("#warning"); | |
affeffc7 JF |
137 | |
138 | for (var i = 0; i != length; ++i) { | |
139 | var clone = child.clone(true); | |
f79a4512 | 140 | clone.addClass("inserted"); |
affeffc7 | 141 | parent.append(clone); |
aa5d0de7 | 142 | clone.xpath("./div/label").html($.xml(warnings[i])); |
affeffc7 | 143 | } |
f79a4512 JF |
144 | |
145 | child.addClass("deleted"); | |
affeffc7 JF |
146 | } |
147 | ||
148 | var applications = package.applications; | |
149 | var length = applications == null ? 0 : applications.length; | |
770f2a8e JF |
150 | |
151 | var child = $("#application"); | |
770f2a8e JF |
152 | |
153 | /*if (length != 0) { | |
affeffc7 | 154 | var parent = $("#actions"); |
affeffc7 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]); | |
affeffc7 | 163 | } |
770f2a8e JF |
164 | }*/ |
165 | ||
f79a4512 JF |
166 | child.addClass("deleted"); |
167 | ||
3bd1c2a2 | 168 | var commercial = package.hasTag('cydia::commercial'); |
770f2a8e | 169 | if (!commercial) |
f79a4512 | 170 | $(".commercial").addClass("deleted"); |
3bd1c2a2 JF |
171 | |
172 | var _console = package.hasTag('purpose::console'); | |
770f2a8e | 173 | if (!_console) |
f79a4512 | 174 | $(".console").addClass("deleted"); |
affeffc7 | 175 | |
6f1a15d9 JF |
176 | var author = package.author; |
177 | if (author == null) | |
f79a4512 | 178 | $(".author").addClass("deleted"); |
6f1a15d9 | 179 | else { |
4bcbe7f9 | 180 | space("#author", author.name, 160); |
affeffc7 | 181 | if (author.address == null) |
f79a4512 | 182 | $("#author-icon").addClass("deleted"); |
043e6a2e JF |
183 | else if (support == null) |
184 | $("#author-href").href("mailto:" + author.address + "?subject=" + regarding("A")); | |
185 | else | |
186 | $("#author-href").href(support); | |
6f1a15d9 JF |
187 | } |
188 | ||
3bd1c2a2 JF |
189 | /*var store = commercial; |
190 | if (!store) | |
f79a4512 | 191 | $(".activation").addClass("deleted"); |
3bd1c2a2 JF |
192 | else { |
193 | var activation = api + 'activation/' + idc; | |
194 | $("#activation-src").src(activation); | |
195 | }*/ | |
196 | ||
25a2158d | 197 | var depiction = package.depiction; |
b9ada469 | 198 | if (depiction != null) { |
f79a4512 | 199 | $(".description").addClass("deleted"); |
b2d2f219 | 200 | $("#depiction-src").src(depiction); |
b9ada469 JF |
201 | } else { |
202 | $(".depiction").addClass("deleted"); | |
6f1a15d9 | 203 | |
b9ada469 JF |
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 | } | |
7d2ac47f | 215 | |
6f1a15d9 JF |
216 | var homepage = package.homepage; |
217 | if (homepage == null) | |
f79a4512 | 218 | $(".homepage").addClass("deleted"); |
6f1a15d9 | 219 | else |
25a2158d | 220 | $("#homepage-href").href(homepage); |
6f1a15d9 JF |
221 | |
222 | var installed = package.installed; | |
223 | if (installed == null) | |
f79a4512 | 224 | $(".installed").addClass("deleted"); |
6f1a15d9 JF |
225 | else { |
226 | $("#installed").html(installed); | |
affeffc7 | 227 | $("#files-href").href("cydia://files/" + idc); |
6f1a15d9 JF |
228 | } |
229 | ||
00e2109e | 230 | space("#id", id, 220); |
6f1a15d9 | 231 | |
fc0a472b | 232 | var section = package.longSection; |
6f1a15d9 | 233 | if (section == null) |
f79a4512 | 234 | $(".section").addClass("deleted"); |
dec6029f JF |
235 | else { |
236 | $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section)); | |
237 | $("#section").html(section); | |
238 | } | |
6f1a15d9 JF |
239 | |
240 | var size = package.size; | |
241 | if (size == 0) | |
f79a4512 | 242 | $(".size").addClass("deleted"); |
6f1a15d9 JF |
243 | else |
244 | $("#size").html(size / 1024 + " kB"); | |
245 | ||
246 | var maintainer = package.maintainer; | |
247 | if (maintainer == null) | |
f79a4512 | 248 | $(".maintainer").addClass("deleted"); |
6f1a15d9 | 249 | else { |
4bcbe7f9 | 250 | space("#maintainer", maintainer.name, 153); |
affeffc7 | 251 | if (maintainer.address == null) |
f79a4512 | 252 | $("#maintainer-icon").addClass("deleted"); |
043e6a2e | 253 | else if (support == null) |
dc63e78f | 254 | $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding("M")); |
043e6a2e JF |
255 | else |
256 | $("#maintainer-href").href(support); | |
6f1a15d9 JF |
257 | } |
258 | ||
dddbc481 | 259 | var sponsor = package.sponsor; |
dc6e62a4 | 260 | if (sponsor == null) |
f79a4512 | 261 | $(".sponsor").addClass("deleted"); |
dc6e62a4 | 262 | else { |
4bcbe7f9 | 263 | space("#sponsor", sponsor.name, 152); |
25a2158d | 264 | $("#sponsor-href").href(sponsor.address); |
dc6e62a4 JF |
265 | } |
266 | ||
6f1a15d9 | 267 | var source = package.source; |
25a2158d | 268 | if (source == null) { |
f79a4512 JF |
269 | $(".source").addClass("deleted"); |
270 | $(".trusted").addClass("deleted"); | |
25a2158d | 271 | } else { |
16f2786b JF |
272 | var host = source.host; |
273 | ||
274 | $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); | |
dddbc481 JF |
275 | $("#source-name").html(source.name); |
276 | ||
5e09ff3b | 277 | if (source.trusted) |
770f2a8e | 278 | $("#trusted").href("cydia://package-signature/" + idc); |
5e09ff3b | 279 | else |
f79a4512 | 280 | $(".trusted").addClass("deleted"); |
25a2158d | 281 | |
dddbc481 JF |
282 | var description = source.description; |
283 | if (description == null) | |
f79a4512 | 284 | $(".source-description").addClass("deleted"); |
dddbc481 | 285 | else |
b9ada469 | 286 | $("#source-description").html($.xml(description)); |
dddbc481 | 287 | } |
2634b249 | 288 | }); |