]>
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", | |
6f1a15d9 | 10 | "description": "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"; | |
32 | console.log(width + " " + max + " " + spacing); | |
33 | node.css("letter-spacing", spacing); | |
34 | } | |
35 | } | |
36 | ||
6f1a15d9 JF |
37 | $(function () { |
38 | var id = package.id; | |
affeffc7 | 39 | var idc = encodeURIComponent(id); |
6f1a15d9 JF |
40 | var name = package.name; |
41 | var regarding = encodeURIComponent("Cydia/APT: " + name); | |
42 | ||
affeffc7 | 43 | $("#icon").src("cydia://package-icon/" + idc); |
770f2a8e JF |
44 | $("#reflection").src("cydia://package-icon/" + idc); |
45 | ||
6f1a15d9 | 46 | $("#name").html(name); |
365d45da JF |
47 | space("#latest", package.latest, 93); |
48 | ||
680eb135 JF |
49 | var rating = package.rating; |
50 | if (rating == null) | |
51 | $(".rating").remove(); | |
22f8bed9 JF |
52 | else { |
53 | $.xhr(rating, 'GET', {}, null, { | |
54 | success: function (value) { | |
55 | document.getElementById("rating").contentWindow.document.write(value); | |
56 | } | |
57 | }); | |
58 | } | |
6f1a15d9 | 59 | |
770f2a8e JF |
60 | $("#settings").href("cydia://package-settings/" + idc); |
61 | ||
affeffc7 JF |
62 | var warnings = package.warnings; |
63 | var length = warnings == null ? 0 : warnings.length; | |
64 | if (length == 0) | |
65 | $(".warnings").remove(); | |
66 | else { | |
67 | var parent = $("#warnings"); | |
68 | var child = $("#warning"); | |
69 | child.remove(); | |
70 | ||
71 | for (var i = 0; i != length; ++i) { | |
72 | var clone = child.clone(true); | |
73 | parent.append(clone); | |
aa5d0de7 | 74 | clone.xpath("./div/label").html($.xml(warnings[i])); |
affeffc7 JF |
75 | } |
76 | } | |
77 | ||
78 | var applications = package.applications; | |
79 | var length = applications == null ? 0 : applications.length; | |
770f2a8e JF |
80 | |
81 | var child = $("#application"); | |
82 | child.remove(); | |
83 | ||
84 | /*if (length != 0) { | |
affeffc7 | 85 | var parent = $("#actions"); |
affeffc7 JF |
86 | |
87 | for (var i = 0; i != length; ++i) { | |
88 | var application = applications[i]; | |
89 | var clone = child.clone(true); | |
90 | parent.append(clone); | |
91 | clone.href("cydia://launch/" + application[0]); | |
92 | clone.xpath("label").html("Run " + $.xml(application[1])); | |
93 | clone.xpath("img").src(application[2]); | |
affeffc7 | 94 | } |
770f2a8e JF |
95 | }*/ |
96 | ||
97 | var purposes = package.purposes; | |
98 | var commercial = false; | |
99 | var _console = false; | |
100 | if (purposes != null) | |
101 | for (var i = 0, e = purposes.length; i != e; ++i) { | |
102 | var purpose = purposes[i]; | |
103 | if (purpose == "commercial") | |
104 | commercial = true; | |
105 | else if (purpose == "console") | |
106 | _console = true; | |
107 | } | |
108 | if (!commercial) | |
109 | $(".commercial").remove(); | |
110 | if (!_console) | |
111 | $(".console").remove(); | |
affeffc7 | 112 | |
6f1a15d9 JF |
113 | var author = package.author; |
114 | if (author == null) | |
115 | $(".author").remove(); | |
116 | else { | |
4bcbe7f9 | 117 | space("#author", author.name, 160); |
affeffc7 JF |
118 | if (author.address == null) |
119 | $("#author-icon").remove(); | |
120 | else | |
121 | $("#author-href").href("mailto:" + author.address + "?subject=" + regarding); | |
6f1a15d9 JF |
122 | } |
123 | ||
affeffc7 | 124 | //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html"); |
7d2ac47f | 125 | |
25a2158d | 126 | var depiction = package.depiction; |
7d2ac47f | 127 | if (depiction == null) |
25a2158d | 128 | $(".depiction").remove(); |
7d2ac47f JF |
129 | else { |
130 | $(".description").display("none"); | |
131 | $("#depiction-src").src(depiction); | |
25a2158d | 132 | } |
6f1a15d9 | 133 | |
7d2ac47f JF |
134 | var description = package.description; |
135 | if (description == null) | |
136 | description = package.tagline; | |
137 | else | |
138 | description = description.replace(/\n/g, "<br/>"); | |
139 | $("#description").html(description); | |
140 | ||
6f1a15d9 JF |
141 | var homepage = package.homepage; |
142 | if (homepage == null) | |
143 | $(".homepage").remove(); | |
144 | else | |
25a2158d | 145 | $("#homepage-href").href(homepage); |
6f1a15d9 JF |
146 | |
147 | var installed = package.installed; | |
148 | if (installed == null) | |
149 | $(".installed").remove(); | |
150 | else { | |
151 | $("#installed").html(installed); | |
affeffc7 | 152 | $("#files-href").href("cydia://files/" + idc); |
6f1a15d9 JF |
153 | } |
154 | ||
00e2109e | 155 | space("#id", id, 220); |
6f1a15d9 JF |
156 | |
157 | var section = package.section; | |
158 | if (section == null) | |
159 | $(".section").remove(); | |
dec6029f JF |
160 | else { |
161 | $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section)); | |
162 | $("#section").html(section); | |
163 | } | |
6f1a15d9 JF |
164 | |
165 | var size = package.size; | |
166 | if (size == 0) | |
167 | $(".size").remove(); | |
168 | else | |
169 | $("#size").html(size / 1024 + " kB"); | |
170 | ||
171 | var maintainer = package.maintainer; | |
172 | if (maintainer == null) | |
173 | $(".maintainer").remove(); | |
174 | else { | |
4bcbe7f9 | 175 | space("#maintainer", maintainer.name, 153); |
affeffc7 JF |
176 | if (maintainer.address == null) |
177 | $("#maintainer-icon").remove(); | |
178 | else | |
179 | $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding); | |
6f1a15d9 JF |
180 | } |
181 | ||
dddbc481 | 182 | var sponsor = package.sponsor; |
dc6e62a4 JF |
183 | if (sponsor == null) |
184 | $(".sponsor").remove(); | |
185 | else { | |
4bcbe7f9 | 186 | space("#sponsor", sponsor.name, 152); |
25a2158d | 187 | $("#sponsor-href").href(sponsor.address); |
dc6e62a4 JF |
188 | } |
189 | ||
6f1a15d9 | 190 | var source = package.source; |
25a2158d | 191 | if (source == null) { |
6f1a15d9 | 192 | $(".source").remove(); |
25a2158d JF |
193 | $(".trusted").remove(); |
194 | } else { | |
16f2786b JF |
195 | var host = source.host; |
196 | ||
197 | $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host)); | |
dddbc481 JF |
198 | $("#source-name").html(source.name); |
199 | ||
5e09ff3b | 200 | if (source.trusted) |
770f2a8e | 201 | $("#trusted").href("cydia://package-signature/" + idc); |
5e09ff3b | 202 | else |
25a2158d JF |
203 | $(".trusted").remove(); |
204 | ||
dddbc481 JF |
205 | var description = source.description; |
206 | if (description == null) | |
207 | $(".source-description").remove(); | |
208 | else | |
209 | $("#source-description").html(description); | |
210 | } | |
6f1a15d9 | 211 | }); |