1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/supporterkeypage.js

167 lines
4.1 KiB
JavaScript
Raw Normal View History

2013-02-20 20:33:05 -05:00
var SupporterKeyPage = {
onPageShow: function () {
2014-01-02 16:21:06 -05:00
SupporterKeyPage.load(this);
2013-02-20 20:33:05 -05:00
},
2014-01-02 16:21:06 -05:00
load: function (page) {
2014-05-18 15:58:42 -04:00
2013-02-20 20:33:05 -05:00
Dashboard.showLoadingMsg();
ApiClient.getPluginSecurityInfo().done(function (info) {
2014-05-18 15:58:42 -04:00
2013-02-20 20:33:05 -05:00
$('#txtSupporterKey', page).val(info.SupporterKey);
2014-01-02 16:21:06 -05:00
2014-05-18 15:58:42 -04:00
if (info.SupporterKey && !info.IsMBSupporter) {
$('#txtSupporterKey', page).addClass("invalidEntry");
$('.notSupporter', page).show();
} else {
$('#txtSupporterKey', page).removeClass("invalidEntry");
$('.notSupporter', page).hide();
}
2014-05-18 15:58:42 -04:00
2013-02-20 20:33:05 -05:00
Dashboard.hideLoadingMsg();
});
},
2014-05-18 15:58:42 -04:00
2013-02-20 20:33:05 -05:00
updateSupporterKey: function () {
Dashboard.showLoadingMsg();
2014-01-02 16:21:06 -05:00
var form = this;
2014-05-18 15:58:42 -04:00
2014-01-02 16:21:06 -05:00
var key = $('#txtSupporterKey', form).val();
2013-02-20 20:33:05 -05:00
2014-05-18 15:58:42 -04:00
var info = {
SupporterKey: key
};
2013-02-20 20:33:05 -05:00
2014-05-18 15:58:42 -04:00
ApiClient.updatePluginSecurityInfo(info).done(function () {
2014-01-02 16:21:06 -05:00
2014-05-18 15:58:42 -04:00
Dashboard.resetPluginSecurityInfo();
Dashboard.hideLoadingMsg();
2014-01-02 16:21:06 -05:00
2014-05-18 15:58:42 -04:00
if (key) {
2014-05-18 15:58:42 -04:00
Dashboard.alert({
2014-05-30 15:23:56 -04:00
message: Globalize.translate('MessageKeyUpdated'),
title: Globalize.translate('HeaderConfirmation')
2014-05-18 15:58:42 -04:00
});
2014-01-02 16:21:06 -05:00
2014-05-18 15:58:42 -04:00
} else {
Dashboard.alert({
2014-05-30 15:23:56 -04:00
message: Globalize.translate('MessageKeyRemoved'),
title: Globalize.translate('HeaderConfirmation')
2014-05-18 15:58:42 -04:00
});
}
var page = $(form).parents('.page');
SupporterKeyPage.load(page);
});
2013-02-20 20:33:05 -05:00
return false;
},
2014-05-18 15:58:42 -04:00
linkSupporterKeys: function () {
Dashboard.showLoadingMsg();
2014-01-02 16:21:06 -05:00
var form = this;
var email = $('#txtNewEmail', form).val();
var newkey = $('#txtNewKey', form).val();
var oldkey = $('#txtOldKey', form).val();
var info = {
email: email,
newkey: newkey,
oldkey: oldkey
};
var url = "http://mb3admin.com/admin/service/supporter/linkKeys";
console.log(url);
$.post(url, info).done(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
2014-05-30 15:23:56 -04:00
Dashboard.alert(Globalize.translate('MessageKeysLinked'));
} else {
Dashboard.showError(result.ErrorMessage);
}
console.log(result);
});
return false;
},
2014-05-18 15:58:42 -04:00
2013-02-20 20:33:05 -05:00
retrieveSupporterKey: function () {
Dashboard.showLoadingMsg();
2014-01-02 16:21:06 -05:00
var form = this;
2013-02-20 20:33:05 -05:00
2014-01-02 16:21:06 -05:00
var email = $('#txtEmail', form).val();
2013-02-20 20:33:05 -05:00
2014-05-18 15:58:42 -04:00
var url = "http://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
2013-02-20 20:33:05 -05:00
console.log(url);
$.post(url).done(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
2014-05-30 15:23:56 -04:00
Dashboard.alert(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
2013-02-20 20:33:05 -05:00
} else {
Dashboard.showError(result.ErrorMessage);
}
console.log(result);
});
return false;
}
};
2014-01-02 16:21:06 -05:00
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
2015-03-17 01:58:29 -04:00
(function () {
function loadConnectSupporters(page) {
$('.linkSupporterKeyMessage', page).html(Globalize.translate('MessageLinkYourSupporterKey', 5));
Dashboard.suppressAjaxErrors = true;
ApiClient.ajax({
type: "GET",
url: ApiClient.getUrl('Connect/Supporters'),
dataType: "json",
error: function () {
// Don't show normal dashboard errors
},
enableGlobalAjaxListener: false
}).done(function () {
}).fail(function () {
$('.supporters', page).html('<p>' + Globalize.translate('MessageErrorLoadingSupporterInfo') + '</p>');
}).always(function () {
Dashboard.suppressAjaxErrors = false;
});
}
$(document).on('pageshow', "#supporterKeyPage", function () {
var page = this;
loadConnectSupporters(page);
});
})();