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

123 lines
3.3 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();
2015-12-14 10:43:03 -05:00
ApiClient.getPluginSecurityInfo().then(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) {
2015-06-28 10:45:21 -04:00
page.querySelector('#txtSupporterKey').classList.add('invalidEntry');
$('.notSupporter', page).show();
} else {
2015-06-28 10:45:21 -04:00
page.querySelector('#txtSupporterKey').classList.remove('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
2015-12-14 10:43:03 -05:00
ApiClient.updatePluginSecurityInfo(info).then(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
});
}
2015-12-14 10:43:03 -05:00
var page = $(form).parents('.page')[0];
2014-05-18 15:58:42 -04:00
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
};
2016-01-19 13:27:55 -05:00
var url = "https://mb3admin.com/admin/service/supporter/linkKeys";
2015-12-23 12:46:01 -05:00
console.log(url);
2015-12-14 10:43:03 -05:00
$.post(url, info).then(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 {
2015-12-14 10:43:03 -05:00
Dashboard.alert(result.ErrorMessage);
}
2015-12-23 12:46:01 -05:00
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
2016-01-19 13:27:55 -05:00
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
2015-12-23 12:46:01 -05:00
console.log(url);
2015-12-14 10:43:03 -05:00
$.post(url).then(function (res) {
2013-02-20 20:33:05 -05:00
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 {
2015-12-14 10:43:03 -05:00
Dashboard.alert(result.ErrorMessage);
2013-02-20 20:33:05 -05:00
}
2015-12-23 12:46:01 -05:00
console.log(result);
2013-02-20 20:33:05 -05:00
});
return false;
}
};
2016-02-18 14:15:26 -05:00
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);