summaryrefslogtreecommitdiff
path: root/Cydia.app/package.js
blob: 1a8fc92bf8bb76272932081176e22677937c3475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*var package = {
    "name": "MobileTerminal",
    "latest": "286u-5",
    "author": {
        "name": "Allen Porter",
        "address": "allen.porter@gmail.com"
    },
    //"depiction": "http://planet-iphones.com/repository/info/chromium1.3.php",
    "depiction": "http://cydia.saurik.com/terminal.html",
    "description": "this is a sample description",
    "homepage": "http://cydia.saurik.com/terminal.html",
    "installed": "286u-4",
    "id": "mobileterminal",
    "section": "Terminal Support",
    "size": 552*1024,
    "maintainer": {
        "name": "Jay Freeman",
        "address": "saurik@saurik.com"
    },
    "source": {
        "name": "Telesphoreo Tangelo",
        "description": "Distribution of Unix Software for the iPhone"
    }
};*/

$(function () {
    var id = package.id;
    var idc = encodeURIComponent(id);
    var name = package.name;
    var regarding = encodeURIComponent("Cydia/APT: " + name);

    $("#icon").src("cydia://package-icon/" + idc);
    $("#reflection").src("cydia://package-icon/" + idc);

    $("#name").html(name);
    $("#latest").html(package.latest);

    $("#settings").href("cydia://package-settings/" + idc);

    var warnings = package.warnings;
    var length = warnings == null ? 0 : warnings.length;
    if (length == 0)
        $(".warnings").remove();
    else {
        var parent = $("#warnings");
        var child = $("#warning");
        child.remove();

        for (var i = 0; i != length; ++i) {
            var clone = child.clone(true);
            parent.append(clone);
            clone.xpath("label").html($.xml(warnings[i]));
        }
    }

    var applications = package.applications;
    var length = applications == null ? 0 : applications.length;

    var child = $("#application");
    child.remove();

    /*if (length != 0) {
        var parent = $("#actions");

        for (var i = 0; i != length; ++i) {
            var application = applications[i];
            var clone = child.clone(true);
            parent.append(clone);
            clone.href("cydia://launch/" + application[0]);
            clone.xpath("label").html("Run " + $.xml(application[1]));
            clone.xpath("img").src(application[2]);
        }
    }*/

    var purposes = package.purposes;
    var commercial = false;
    var _console = false;
    if (purposes != null)
        for (var i = 0, e = purposes.length; i != e; ++i) {
            var purpose = purposes[i];
            if (purpose == "commercial")
                commercial = true;
            else if (purpose == "console")
                _console = true;
        }
    if (!commercial)
        $(".commercial").remove();
    if (!_console)
        $(".console").remove();

    var author = package.author;
    if (author == null)
        $(".author").remove();
    else {
        $("#author").html(author.name);
        if (author.address == null)
            $("#author-icon").remove();
        else
            $("#author-href").href("mailto:" + author.address + "?subject=" + regarding);
    }

    //$("#notice-src").src("http://saurik.cachefly.net/notice/" + idc + ".html");

    var depiction = package.depiction;
    if (depiction == null)
        $(".depiction").remove();
    else {
        $(".description").display("none");
        $("#depiction-src").src(depiction);
    }

    var description = package.description;
    if (description == null)
        description = package.tagline;
    else
        description = description.replace(/\n/g, "<br/>");
    $("#description").html(description);

    var homepage = package.homepage;
    if (homepage == null)
        $(".homepage").remove();
    else
        $("#homepage-href").href(homepage);

    var installed = package.installed;
    if (installed == null)
        $(".installed").remove();
    else {
        $("#installed").html(installed);
        $("#files-href").href("cydia://files/" + idc);
    }

    var nid = $("#id");
    nid.html(id);
    var width = nid.width();

    var max = 238.0;
    if (width > max) {
        var spacing = (max - nid.width()) / (id.length - 1) + "px";
        nid.css("letter-spacing", spacing);
    }

    var section = package.section;
    if (section == null)
        $(".section").remove();
    else {
        $("#section-src").src("cydia://section-icon/" + encodeURIComponent(section));
        $("#section").html(section);
    }

    var size = package.size;
    if (size == 0)
        $(".size").remove();
    else
        $("#size").html(size / 1024 + " kB");

    var maintainer = package.maintainer;
    if (maintainer == null)
        $(".maintainer").remove();
    else {
        $("#maintainer").html(maintainer.name);
        if (maintainer.address == null)
            $("#maintainer-icon").remove();
        else
            $("#maintainer-href").href("mailto:" + maintainer.address + "?subject=" + regarding);
    }

    var sponsor = package.sponsor;
    if (sponsor == null)
        $(".sponsor").remove();
    else {
        $("#sponsor").html(sponsor.name);
        $("#sponsor-href").href(sponsor.address);
    }

    var source = package.source;
    if (source == null) {
        $(".source").remove();
        $(".trusted").remove();
    } else {
        $("#source-name").html(source.name);

        if (source.trusted)
            $("#trusted").href("cydia://package-signature/" + idc);
        else
            $(".trusted").remove();

        var description = source.description;
        if (description == null)
            $(".source-description").remove();
        else
            $("#source-description").html(description);
    }
});