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