]> git.saurik.com Git - cydia.git/blob - Cydia.app/package.js
52025a94a3997e56541cb8e8fe1f81db4ed43111
[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 $("#name").html(name);
34 $("#latest").html(package.latest);
35
36 var warnings = package.warnings;
37 var length = warnings == null ? 0 : warnings.length;
38 if (length == 0)
39 $(".warnings").remove();
40 else {
41 var parent = $("#warnings");
42 var child = $("#warning");
43 child.remove();
44
45 for (var i = 0; i != length; ++i) {
46 var clone = child.clone(true);
47 parent.append(clone);
48 clone.xpath("label").html($.xml(warnings[i]));
49 }
50 }
51
52 var applications = package.applications;
53 var length = applications == null ? 0 : applications.length;
54 if (length == 0)
55 $(".applications").remove();
56 else {
57 var parent = $("#actions");
58 var child = $("#application");
59 child.remove();
60
61 for (var i = 0; i != length; ++i) {
62 var application = applications[i];
63 var clone = child.clone(true);
64 parent.append(clone);
65 clone.href("cydia://launch/" + application[0]);
66 clone.xpath("label").html("Run " + $.xml(application[1]));
67 clone.xpath("img").src(application[2]);
68 console.log(0);
69 }
70 }
71
72 var author = package.author;
73 if (author == null)
74 $(".author").remove();
75 else {
76 $("#author").html(author.name);
77 if (author.address == null)
78 $("#author-icon").remove();
79 else
80 $("#author-href").href("mailto:" + author.address + "?subject=" + regarding);
81 }
82
83 //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html");
84
85 var depiction = package.depiction;
86 if (depiction == null)
87 $(".depiction").remove();
88 else {
89 $(".description").display("none");
90 $("#depiction-src").src(depiction);
91 }
92
93 var description = package.description;
94 if (description == null)
95 description = package.tagline;
96 else
97 description = description.replace(/\n/g, "<br/>");
98 $("#description").html(description);
99
100 var homepage = package.homepage;
101 if (homepage == null)
102 $(".homepage").remove();
103 else
104 $("#homepage-href").href(homepage);
105
106 var installed = package.installed;
107 if (installed == null)
108 $(".installed").remove();
109 else {
110 $("#installed").html(installed);
111 $("#files-href").href("cydia://files/" + idc);
112 }
113
114 $("#id").html(id);
115
116 var section = package.section;
117 if (section == null)
118 $(".section").remove();
119 else
120 $("#section").html(package.section);
121
122 var size = package.size;
123 if (size == 0)
124 $(".size").remove();
125 else
126 $("#size").html(size / 1024 + " kB");
127
128 var maintainer = package.maintainer;
129 if (maintainer == null)
130 $(".maintainer").remove();
131 else {
132 $("#maintainer").html(maintainer.name);
133 if (maintainer.address == null)
134 $("#maintainer-icon").remove();
135 else
136 $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding);
137 }
138
139 var sponsor = package.sponsor;
140 if (sponsor == null)
141 $(".sponsor").remove();
142 else {
143 $("#sponsor").html(sponsor.name);
144 $("#sponsor-href").href(sponsor.address);
145 }
146
147 var source = package.source;
148 if (source == null) {
149 $(".source").remove();
150 $(".trusted").remove();
151 } else {
152 $("#source-name").html(source.name);
153
154 if (!source.trusted)
155 $(".trusted").remove();
156
157 var description = source.description;
158 if (description == null)
159 $(".source-description").remove();
160 else
161 $("#source-description").html(description);
162 }
163 });