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