]> git.saurik.com Git - cydia.git/blame - Cydia.app/package.js
Various HTTP improvements.
[cydia.git] / Cydia.app / package.js
CommitLineData
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
26function 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
ad554f10
JF
37$(function () {
38 var id = package.id;
f464053e 39 var idc = encodeURIComponent(id);
ad554f10
JF
40 var name = package.name;
41 var regarding = encodeURIComponent("Cydia/APT: " + name);
42
f464053e 43 $("#icon").src("cydia://package-icon/" + idc);
dbe0f181
JF
44 $("#reflection").src("cydia://package-icon/" + idc);
45
ad554f10 46 $("#name").html(name);
78b966cc
JF
47 space("#latest", package.latest, 93);
48
cd8bec2f
JF
49 var rating = package.rating;
50 if (rating == null)
51 $(".rating").remove();
52 else
53 $("#rating").src(rating);
ad554f10 54
dbe0f181
JF
55 $("#settings").href("cydia://package-settings/" + idc);
56
f464053e
JF
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;
dbe0f181
JF
75
76 var child = $("#application");
77 child.remove();
78
79 /*if (length != 0) {
f464053e 80 var parent = $("#actions");
f464053e
JF
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]);
f464053e 89 }
dbe0f181
JF
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();
f464053e 107
ad554f10
JF
108 var author = package.author;
109 if (author == null)
110 $(".author").remove();
111 else {
112 $("#author").html(author.name);
f464053e
JF
113 if (author.address == null)
114 $("#author-icon").remove();
115 else
116 $("#author-href").href("mailto:" + author.address + "?subject=" + regarding);
ad554f10
JF
117 }
118
f464053e 119 //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html");
853d14d3 120
0235116c 121 var depiction = package.depiction;
853d14d3 122 if (depiction == null)
0235116c 123 $(".depiction").remove();
853d14d3
JF
124 else {
125 $(".description").display("none");
126 $("#depiction-src").src(depiction);
0235116c 127 }
ad554f10 128
853d14d3
JF
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
ad554f10
JF
136 var homepage = package.homepage;
137 if (homepage == null)
138 $(".homepage").remove();
139 else
0235116c 140 $("#homepage-href").href(homepage);
ad554f10
JF
141
142 var installed = package.installed;
143 if (installed == null)
144 $(".installed").remove();
145 else {
146 $("#installed").html(installed);
f464053e 147 $("#files-href").href("cydia://files/" + idc);
ad554f10
JF
148 }
149
78b966cc 150 space("#id", id, 238);
ad554f10
JF
151
152 var section = package.section;
153 if (section == null)
154 $(".section").remove();
6b4b3bee
JF
155 else {
156 $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section));
157 $("#section").html(section);
158 }
ad554f10
JF
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);
f464053e
JF
171 if (maintainer.address == null)
172 $("#maintainer-icon").remove();
173 else
174 $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding);
ad554f10
JF
175 }
176
1eb0c554 177 var sponsor = package.sponsor;
6bffd7b7
JF
178 if (sponsor == null)
179 $(".sponsor").remove();
180 else {
181 $("#sponsor").html(sponsor.name);
0235116c 182 $("#sponsor-href").href(sponsor.address);
6bffd7b7
JF
183 }
184
ad554f10 185 var source = package.source;
0235116c 186 if (source == null) {
ad554f10 187 $(".source").remove();
0235116c
JF
188 $(".trusted").remove();
189 } else {
18159e09
JF
190 var host = source.host;
191
192 $("#source-src").src("cydia://source-icon/" + encodeURIComponent(host));
1eb0c554
JF
193 $("#source-name").html(source.name);
194
2f4fac47 195 if (source.trusted)
dbe0f181 196 $("#trusted").href("cydia://package-signature/" + idc);
2f4fac47 197 else
0235116c
JF
198 $(".trusted").remove();
199
1eb0c554
JF
200 var description = source.description;
201 if (description == null)
202 $(".source-description").remove();
203 else
204 $("#source-description").html(description);
205 }
ad554f10 206});