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