]>
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", | |
ad554f10 | 10 | "description": "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 | ||
2e018aa4 JF |
52 | $(function () { |
53 | var id = package.id; | |
54 | var idc = encodeURIComponent(id); | |
55 | var name = package.name; | |
56 | var regarding = encodeURIComponent("Cydia/APT: " + name); | |
57 | var icon = 'cydia://package-icon/' + idc; | |
c3f582af | 58 | var api = 'http://cydia.saurik.com/api/'; |
2e018aa4 JF |
59 | |
60 | $("#icon").css("background-image", 'url("' + icon + '")'); | |
61 | $("#reflection").src("cydia://package-icon/" + idc); | |
62 | ||
63 | $("#name").html(name); | |
64 | space("#latest", package.latest, 96); | |
7ec29c77 | 65 | |
c3f582af JF |
66 | $.xhr(api + 'package/' + idc, 'GET', {}, null, { |
67 | success: function (value) { | |
68 | value = eval(value); | |
2e018aa4 | 69 | |
c3f582af | 70 | $("#rating-load").remove(); |
2e018aa4 | 71 | |
c3f582af JF |
72 | var href = $("#rating-href"); |
73 | href.href(value.reviews); | |
2e018aa4 | 74 | |
c3f582af JF |
75 | var none = $("#rating-none"); |
76 | var done = $("#rating-done"); | |
2e018aa4 | 77 | |
c3f582af JF |
78 | if (value.rating == null) { |
79 | done.remove(); | |
80 | none.css("display", "block"); | |
81 | } else { | |
82 | none.remove(); | |
83 | done.css("display", "block"); | |
7ec29c77 | 84 | |
c3f582af | 85 | $("#rating-value").css('width', 16 * value.rating); |
7ec29c77 | 86 | } |
c3f582af JF |
87 | |
88 | if (typeof value.icon != "undefined" && value.icon != null) { | |
89 | var icon = $("#icon"); | |
90 | var thumb = $("#thumb"); | |
91 | icon[0].className = 'flip-180'; | |
92 | thumb[0].className = 'flip-360'; | |
93 | thumb.css("background-image", 'url("' + value.icon + '")'); | |
94 | ||
95 | setTimeout(function () { | |
96 | icon.css("display", "none"); | |
97 | thumb[0].className = 'flip-0'; | |
98 | }, 2000); | |
99 | } | |
100 | }, | |
101 | ||
102 | failure: function (status) { | |
103 | $(".rating").remove(); | |
104 | } | |
105 | }); | |
ad554f10 | 106 | |
dbe0f181 JF |
107 | $("#settings").href("cydia://package-settings/" + idc); |
108 | ||
f464053e JF |
109 | var warnings = package.warnings; |
110 | var length = warnings == null ? 0 : warnings.length; | |
111 | if (length == 0) | |
112 | $(".warnings").remove(); | |
113 | else { | |
114 | var parent = $("#warnings"); | |
115 | var child = $("#warning"); | |
116 | child.remove(); | |
117 | ||
118 | for (var i = 0; i != length; ++i) { | |
119 | var clone = child.clone(true); | |
120 | parent.append(clone); | |
04700693 | 121 | clone.xpath("./div/label").html($.xml(warnings[i])); |
f464053e JF |
122 | } |
123 | } | |
124 | ||
125 | var applications = package.applications; | |
126 | var length = applications == null ? 0 : applications.length; | |
dbe0f181 JF |
127 | |
128 | var child = $("#application"); | |
129 | child.remove(); | |
130 | ||
131 | /*if (length != 0) { | |
f464053e | 132 | var parent = $("#actions"); |
f464053e JF |
133 | |
134 | for (var i = 0; i != length; ++i) { | |
135 | var application = applications[i]; | |
136 | var clone = child.clone(true); | |
137 | parent.append(clone); | |
138 | clone.href("cydia://launch/" + application[0]); | |
139 | clone.xpath("label").html("Run " + $.xml(application[1])); | |
140 | clone.xpath("img").src(application[2]); | |
f464053e | 141 | } |
dbe0f181 JF |
142 | }*/ |
143 | ||
144 | var purposes = package.purposes; | |
145 | var commercial = false; | |
146 | var _console = false; | |
147 | if (purposes != null) | |
148 | for (var i = 0, e = purposes.length; i != e; ++i) { | |
149 | var purpose = purposes[i]; | |
150 | if (purpose == "commercial") | |
151 | commercial = true; | |
152 | else if (purpose == "console") | |
153 | _console = true; | |
154 | } | |
155 | if (!commercial) | |
156 | $(".commercial").remove(); | |
157 | if (!_console) | |
158 | $(".console").remove(); | |
f464053e | 159 | |
ad554f10 JF |
160 | var author = package.author; |
161 | if (author == null) | |
162 | $(".author").remove(); | |
163 | else { | |
e52a2683 | 164 | space("#author", author.name, 160); |
f464053e JF |
165 | if (author.address == null) |
166 | $("#author-icon").remove(); | |
167 | else | |
168 | $("#author-href").href("mailto:" + author.address + "?subject=" + regarding); | |
ad554f10 JF |
169 | } |
170 | ||
f464053e | 171 | //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html"); |
853d14d3 | 172 | |
0235116c | 173 | var depiction = package.depiction; |
853d14d3 | 174 | if (depiction == null) |
0235116c | 175 | $(".depiction").remove(); |
853d14d3 | 176 | else { |
2e018aa4 | 177 | $(".description").css("display", "none"); |
853d14d3 | 178 | $("#depiction-src").src(depiction); |
0235116c | 179 | } |
ad554f10 | 180 | |
853d14d3 JF |
181 | var description = package.description; |
182 | if (description == null) | |
183 | description = package.tagline; | |
184 | else | |
185 | description = description.replace(/\n/g, "<br/>"); | |
186 | $("#description").html(description); | |
187 | ||
ad554f10 JF |
188 | var homepage = package.homepage; |
189 | if (homepage == null) | |
190 | $(".homepage").remove(); | |
191 | else | |
0235116c | 192 | $("#homepage-href").href(homepage); |
ad554f10 JF |
193 | |
194 | var installed = package.installed; | |
195 | if (installed == null) | |
196 | $(".installed").remove(); | |
197 | else { | |
198 | $("#installed").html(installed); | |
f464053e | 199 | $("#files-href").href("cydia://files/" + idc); |
ad554f10 JF |
200 | } |
201 | ||
0a7e5478 | 202 | space("#id", id, 220); |
ad554f10 JF |
203 | |
204 | var section = package.section; | |
205 | if (section == null) | |
206 | $(".section").remove(); | |
6b4b3bee JF |
207 | else { |
208 | $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section)); | |
209 | $("#section").html(section); | |
210 | } | |
ad554f10 JF |
211 | |
212 | var size = package.size; | |
213 | if (size == 0) | |
214 | $(".size").remove(); | |
215 | else | |
216 | $("#size").html(size / 1024 + " kB"); | |
217 | ||
218 | var maintainer = package.maintainer; | |
219 | if (maintainer == null) | |
220 | $(".maintainer").remove(); | |
221 | else { | |
e52a2683 | 222 | space("#maintainer", maintainer.name, 153); |
f464053e JF |
223 | if (maintainer.address == null) |
224 | $("#maintainer-icon").remove(); | |
225 | else | |
226 | $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding); | |
ad554f10 JF |
227 | } |
228 | ||
1eb0c554 | 229 | var sponsor = package.sponsor; |
6bffd7b7 JF |
230 | if (sponsor == null) |
231 | $(".sponsor").remove(); | |
232 | else { | |
e52a2683 | 233 | space("#sponsor", sponsor.name, 152); |
0235116c | 234 | $("#sponsor-href").href(sponsor.address); |
6bffd7b7 JF |
235 | } |
236 | ||
ad554f10 | 237 | var source = package.source; |
0235116c | 238 | if (source == null) { |
ad554f10 | 239 | $(".source").remove(); |
0235116c JF |
240 | $(".trusted").remove(); |
241 | } else { | |
18159e09 JF |
242 | var host = source.host; |
243 | ||
244 | $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); | |
1eb0c554 JF |
245 | $("#source-name").html(source.name); |
246 | ||
2f4fac47 | 247 | if (source.trusted) |
dbe0f181 | 248 | $("#trusted").href("cydia://package-signature/" + idc); |
2f4fac47 | 249 | else |
0235116c JF |
250 | $(".trusted").remove(); |
251 | ||
1eb0c554 JF |
252 | var description = source.description; |
253 | if (description == null) | |
254 | $(".source-description").remove(); | |
255 | else | |
256 | $("#source-description").html(description); | |
257 | } | |
ad554f10 | 258 | }); |