aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.WebDashboard/Html/scripts/SupporterKeyPage.js
blob: 88748064f2eac3271cf99ff6c9faeddc2348d66f (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
var SupporterKeyPage = {

    onPageShow: function () {
        SupporterKeyPage.load();
    },

    onPageHide: function () {

    },

    load: function() {
        Dashboard.showLoadingMsg();
        var page = $.mobile.activePage;

        ApiClient.getPluginSecurityInfo().done(function (info) {
            $('#txtSupporterKey', page).val(info.SupporterKey);
            $('#txtLegacyKey', page).val(info.LegacyKey);
            if (info.IsMBSupporter) {
                $('.supporterOnly', page).show();
            } else {
                $('.supporterOnly', page).hide();
            }
            Dashboard.hideLoadingMsg();
        });
    },

    updateSupporterKey: function () {

        Dashboard.showLoadingMsg();
        var page = $.mobile.activePage;
        
        var key = $('#txtSupporterKey', page).val();
        var legacyKey = $('#txtLegacyKey', page).val();

            var info = {
                SupporterKey: key,
                LegacyKey: legacyKey
            };

            ApiClient.updatePluginSecurityInfo(info).done(function () {
                Dashboard.resetPluginSecurityInfo();
                Dashboard.hideLoadingMsg();
                SupporterPage.load();

            });

        return false;
    },
    
    retrieveSupporterKey: function () {

        Dashboard.showLoadingMsg();
        var page = $.mobile.activePage;

        var email = $('#txtEmail', page).val();

        var url = "http://mb3admin.com/admin/service/supporter/retrievekey?email="+email;
        console.log(url);
        $.post(url).done(function (res) {
            var result = JSON.parse(res);
            Dashboard.hideLoadingMsg();
            if (result.Success) {
                Dashboard.alert("Key emailed to "+email);
            } else {
                Dashboard.showError(result.ErrorMessage);
            }
            console.log(result);

        });

        return false;
    }

};

$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow)
    .on('pagehide', "#supporterKeyPage", SupporterKeyPage.onPageHide);