]>
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 | "description": "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 | 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 | ||
52 | var special_ = function () { | |
53 | if (package == null) | |
54 | return; | |
55 | ||
56 | var id = package.id; | |
57 | var idc = encodeURIComponent(id); | |
58 | var name = package.name; | |
59 | var icon = 'cydia://package-icon/' + idc; | |
60 | var api = 'http://cydia.saurik.com/api/'; | |
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(cache(api + 'package/' + idc), 'GET', {}, null, { | |
73 | success: function (value) { | |
74 | value = eval(value); | |
75 | ||
76 | if (typeof value.rating == "undefined") | |
77 | $(".rating").addClass("deleted"); | |
78 | else { | |
79 | $("#rating-load").addClass("deleted"); | |
80 | $("#rating-href").href(value.reviews); | |
81 | ||
82 | var none = $("#rating-none"); | |
83 | var done = $("#rating-done"); | |
84 | ||
85 | if (value.rating == null) { | |
86 | none.css("display", "block"); | |
87 | } else { | |
88 | done.css("display", "block"); | |
89 | ||
90 | $("#rating-value").css('width', 16 * value.rating); | |
91 | } | |
92 | } | |
93 | ||
94 | if (typeof value.icon != "undefined" && value.icon != null) { | |
95 | var icon = $("#icon"); | |
96 | var thumb = $("#thumb"); | |
97 | ||
98 | icon[0].className = 'flip-180'; | |
99 | thumb[0].className = 'flip-360'; | |
100 | ||
101 | thumb.css("background-image", 'url("' + value.icon + '")'); | |
102 | ||
103 | setTimeout(function () { | |
104 | icon.addClass("deleted"); | |
105 | thumb[0].className = 'flip-0'; | |
106 | }, 2000); | |
107 | } | |
108 | }, | |
109 | ||
110 | failure: function (status) { | |
111 | $(".rating").addClass("deleted"); | |
112 | } | |
113 | }); | |
114 | ||
115 | $("#settings").href("cydia://package-settings/" + idc); | |
116 | ||
117 | var mode = package.mode; | |
118 | if (mode == null) | |
119 | $(".mode").addClass("deleted"); | |
120 | else { | |
121 | $("#mode").html(cydia.localize(mode)); | |
122 | $("#mode-src").src("Modes/" + mode + ".png"); | |
123 | } | |
124 | ||
125 | var warnings = package.warnings; | |
126 | var length = warnings == null ? 0 : warnings.length; | |
127 | if (length == 0) | |
128 | $(".warnings").addClass("deleted"); | |
129 | else { | |
130 | var parent = $("#warnings"); | |
131 | var child = $("#warning"); | |
132 | ||
133 | for (var i = 0; i != length; ++i) { | |
134 | var clone = child.clone(true); | |
135 | clone.addClass("inserted"); | |
136 | parent.append(clone); | |
137 | clone.xpath("./div/label").html($.xml(warnings[i])); | |
138 | } | |
139 | ||
140 | child.addClass("deleted"); | |
141 | } | |
142 | ||
143 | var applications = package.applications; | |
144 | var length = applications == null ? 0 : applications.length; | |
145 | ||
146 | var child = $("#application"); | |
147 | ||
148 | /*if (length != 0) { | |
149 | var parent = $("#actions"); | |
150 | ||
151 | for (var i = 0; i != length; ++i) { | |
152 | var application = applications[i]; | |
153 | var clone = child.clone(true); | |
154 | parent.append(clone); | |
155 | clone.href("cydia://launch/" + application[0]); | |
156 | clone.xpath("label").html("Run " + $.xml(application[1])); | |
157 | clone.xpath("img").src(application[2]); | |
158 | } | |
159 | }*/ | |
160 | ||
161 | child.addClass("deleted"); | |
162 | ||
163 | var commercial = package.hasTag('cydia::commercial'); | |
164 | if (!commercial) | |
165 | $(".commercial").addClass("deleted"); | |
166 | ||
167 | var _console = package.hasTag('purpose::console'); | |
168 | if (!_console) | |
169 | $(".console").addClass("deleted"); | |
170 | ||
171 | var author = package.author; | |
172 | if (author == null) | |
173 | $(".author").addClass("deleted"); | |
174 | else { | |
175 | space("#author", author.name, 160); | |
176 | if (author.address == null) | |
177 | $("#author-icon").addClass("deleted"); | |
178 | else { | |
179 | var support = package.support; | |
180 | if (support == null) | |
181 | $("#author-href").href("mailto:" + author.address + "?subject=" + regarding("A")); | |
182 | else | |
183 | $("#author-href").href(support); | |
184 | } | |
185 | } | |
186 | ||
187 | //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html"); | |
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.description; | |
206 | if (description == null) | |
207 | description = package.tagline; | |
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.section; | |
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 | |
250 | $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding("M")); | |
251 | } | |
252 | ||
253 | var sponsor = package.sponsor; | |
254 | if (sponsor == null) | |
255 | $(".sponsor").addClass("deleted"); | |
256 | else { | |
257 | space("#sponsor", sponsor.name, 152); | |
258 | $("#sponsor-href").href(sponsor.address); | |
259 | } | |
260 | ||
261 | var source = package.source; | |
262 | if (source == null) { | |
263 | $(".source").addClass("deleted"); | |
264 | $(".trusted").addClass("deleted"); | |
265 | } else { | |
266 | var host = source.host; | |
267 | ||
268 | $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); | |
269 | $("#source-name").html(source.name); | |
270 | ||
271 | if (source.trusted) | |
272 | $("#trusted").href("cydia://package-signature/" + idc); | |
273 | else | |
274 | $(".trusted").addClass("deleted"); | |
275 | ||
276 | var description = source.description; | |
277 | if (description == null) | |
278 | $(".source-description").addClass("deleted"); | |
279 | else | |
280 | $("#source-description").html(description); | |
281 | } | |
282 | }; | |
283 | ||
284 | $(special_); | |
285 | ||
286 | var special = function () { | |
287 | $(".deleted").removeClass("deleted"); | |
288 | $(".inserted").remove(); | |
289 | ||
290 | $("#icon")[0].className = 'flip-0'; | |
291 | $("#thumb")[0].className = 'flip-180'; | |
292 | ||
293 | /* XXX: this could be better */ | |
294 | $("#rating-none").css("display", "none"); | |
295 | $("#rating-done").css("display", "none"); | |
296 | ||
297 | var depiction = $("#depiction-src"); | |
298 | ||
299 | depiction[0].outerHTML = '<iframe' + | |
300 | ' class="depiction"' + | |
301 | ' id="depiction-src"' + | |
302 | ' frameborder="0"' + | |
303 | ' width="320"' + | |
304 | ' height="0"' + | |
305 | ' target="_top"' + | |
306 | ' onload_="loaded()"' + | |
307 | '></iframe>'; | |
308 | ||
309 | special_(); | |
310 | }; | |
311 | ||
312 | cydia.setSpecial(special); |