aboutsummaryrefslogtreecommitdiffstats
path: root/source/moduleManagerDesktop.js
blob: 0bd63c0b2badf85978e95c3b6354048ede0f6c63 (plain) (blame)
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
enyo.kind({
    name: "biblez.moduleManagerDesktop",
    kind: "enyo.FittableRows",
    fit: true,
    events: {
        onBack: "",
        onInstalled: ""
    },
    components: [
        {name: "messagePopup", kind: "onyx.Popup", scrim: true, centered: true, floating: true, classes: "message-popup"},
        {name: "scrim", kind: "onyx.Scrim", classes: "onyx-scrim-translucent"},
        {kind: "onyx.MoreToolbar", components: [
            {kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"},
            {content: $L("Module Manager")}
            //{kind: "onyx.IconButton", src: "assets/delete.png", ontap: "clearDB"}
        ]},
        {classes: "center", components: [
            {content: $L("Download a zipped module from one of the following repositories:")},
            {allowHtml: true, content: "<ul><li><a target='_blank' href='http://www.crosswire.org/sword/modules/ModDisp.jsp?modType=Bibles'>CrossWire Main</a></li>" +
                                        "<li><a target='_blank' href='http://www.crosswire.org/sword/modules/ModDisp.jsp?modType=Bibles&av=true'>CrossWire av11n</a></li>" +
                                        "<li><a target='_blank' href='http://www.crosswire.org/sword/modules/ModDisp.jsp?modType=Bibles&beta=true'>CrossWire Beta</a></li></ul>"
            },
            {content: $L("To install the module, select the module file!")},
            {kind: "onyx.Input", type: "file", id: "files", name: "files[]", onchange: "installModule"},
            {tag: "br"},
            {kind: "onyx.Spinner", name: "spinner", showing: false, classes: "onyx-light center"}
        ]}
    ],

    lang: [],
    started: false,
    repos: [],
    modules: [],
    langModules: [],
    currentModule: null,

    handleBack: function() {
        this.doBack();
    },

    installModule: function (inSender, inEvent) {
        this.$.spinner.start();
        sword.installMgr.installModule(inEvent.target.files[0], enyo.bind(this, function (inError, inModule) {
            if (!inError) {
                this.doInstalled();
                this.$.spinner.stop();
                this.handleError("Installed Module!");
            } else {
                this.handleError((inError.message) ? inError.message : inError);
            }
        }));
    },

    clearDB: function () {
        sword.dataMgr.clearDatabase();
    },

    handleError: function (inMessage) {
        if (inMessage.message)
            inMessage = inMessage.message;
        this.$.messagePopup.setContent(inMessage);
        this.$.messagePopup.show();
    }
});