jellyfin-web/dashboard-ui/scripts/supporterkeypage.js

127 lines
3.5 KiB
JavaScript
Raw Normal View History

2013-02-20 18:33:05 -07:00
var SupporterKeyPage = {
onPageShow: function () {
2014-01-02 14:21:06 -07:00
SupporterKeyPage.load(this);
2013-02-20 18:33:05 -07:00
},
2014-01-02 14:21:06 -07:00
load: function (page) {
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
ApiClient.getPluginSecurityInfo().done(function (info) {
2014-01-02 14:21:06 -07:00
2013-02-20 18:33:05 -07:00
$('#txtSupporterKey', page).val(info.SupporterKey);
$('#txtLegacyKey', page).val(info.LegacyKey);
2014-01-02 14:21:06 -07:00
if ((info.LegacyKey || info.SupporterKey) && !info.IsMBSupporter) {
$('#txtSupporterKey', page).addClass("invalidEntry");
$('.notSupporter', page).show();
} else {
$('#txtSupporterKey', page).removeClass("invalidEntry");
$('.notSupporter', page).hide();
}
2014-01-02 14:21:06 -07:00
2013-02-20 18:33:05 -07:00
Dashboard.hideLoadingMsg();
});
},
2013-02-20 18:33:05 -07:00
updateSupporterKey: function () {
Dashboard.showLoadingMsg();
2014-01-02 14:21:06 -07:00
var form = this;
2013-02-20 18:33:05 -07:00
2014-01-02 14:21:06 -07:00
var key = $('#txtSupporterKey', form).val();
var legacyKey = $('#txtLegacyKey', form).val();
2013-02-20 18:33:05 -07:00
var info = {
SupporterKey: key,
LegacyKey: legacyKey
};
2013-03-07 11:45:09 -07:00
ApiClient.updatePluginSecurityInfo(info).done(function () {
2013-02-20 18:33:05 -07:00
Dashboard.resetPluginSecurityInfo();
Dashboard.hideLoadingMsg();
2014-01-02 14:21:06 -07:00
if (key) {
Dashboard.alert({
message: "Thank you. Your supporter key has been updated.",
title: "Confirmation"
});
} else {
Dashboard.alert({
message: "Thank you. Your supporter key has been removed.",
title: "Confirmation"
});
}
2014-01-02 14:21:06 -07:00
var page = $(form).parents('.page');
SupporterKeyPage.load(page);
2013-02-20 18:33:05 -07:00
});
return false;
},
linkSupporterKeys: function () {
Dashboard.showLoadingMsg();
2014-01-02 14:21:06 -07: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) {
Dashboard.alert("Keys Linked.");
} else {
Dashboard.showError(result.ErrorMessage);
}
console.log(result);
});
return false;
},
2013-02-20 18:33:05 -07:00
retrieveSupporterKey: function () {
Dashboard.showLoadingMsg();
2014-01-02 14:21:06 -07:00
var form = this;
2013-02-20 18:33:05 -07:00
2014-01-02 14:21:06 -07:00
var email = $('#txtEmail', form).val();
2013-02-20 18:33:05 -07:00
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;
}
};
2014-01-02 14:21:06 -07:00
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);