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) {
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getPluginSecurityInfo().then(function (info) {
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
$('#txtSupporterKey', page).val(info.SupporterKey);
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2014-05-18 12:58:42 -07:00
|
|
|
|
if (info.SupporterKey && !info.IsMBSupporter) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
page.querySelector('#txtSupporterKey').classList.add('invalidEntry');
|
2013-07-14 15:01:02 -07:00
|
|
|
|
$('.notSupporter', page).show();
|
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
page.querySelector('#txtSupporterKey').classList.remove('invalidEntry');
|
2013-07-14 15:01:02 -07:00
|
|
|
|
$('.notSupporter', page).hide();
|
|
|
|
|
}
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
updateSupporterKey: function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-02 14:21:06 -07:00
|
|
|
|
var form = this;
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2014-01-02 14:21:06 -07:00
|
|
|
|
var key = $('#txtSupporterKey', form).val();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2014-05-18 12:58:42 -07:00
|
|
|
|
var info = {
|
|
|
|
|
SupporterKey: key
|
|
|
|
|
};
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updatePluginSecurityInfo(info).then(function () {
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2014-05-18 12:58:42 -07:00
|
|
|
|
Dashboard.resetPluginSecurityInfo();
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2014-05-18 12:58:42 -07:00
|
|
|
|
if (key) {
|
2013-09-14 14:19:32 -07:00
|
|
|
|
|
2014-05-18 12:58:42 -07:00
|
|
|
|
Dashboard.alert({
|
2014-05-30 12:23:56 -07:00
|
|
|
|
message: Globalize.translate('MessageKeyUpdated'),
|
|
|
|
|
title: Globalize.translate('HeaderConfirmation')
|
2014-05-18 12:58:42 -07:00
|
|
|
|
});
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2014-05-18 12:58:42 -07:00
|
|
|
|
} else {
|
|
|
|
|
Dashboard.alert({
|
2014-05-30 12:23:56 -07:00
|
|
|
|
message: Globalize.translate('MessageKeyRemoved'),
|
|
|
|
|
title: Globalize.translate('HeaderConfirmation')
|
2014-05-18 12:58:42 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var page = $(form).parents('.page')[0];
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
|
|
|
|
SupporterKeyPage.load(page);
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2013-09-26 08:30:47 -07:00
|
|
|
|
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();
|
2013-09-26 08:30:47 -07:00
|
|
|
|
|
|
|
|
|
var info = {
|
|
|
|
|
email: email,
|
|
|
|
|
newkey: newkey,
|
|
|
|
|
oldkey: oldkey
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-19 11:27:55 -07:00
|
|
|
|
var url = "https://mb3admin.com/admin/service/supporter/linkKeys";
|
2015-12-23 10:46:01 -07:00
|
|
|
|
console.log(url);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
$.post(url, info).then(function (res) {
|
2013-09-26 08:30:47 -07:00
|
|
|
|
var result = JSON.parse(res);
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
if (result.Success) {
|
2016-02-24 23:38:12 -07:00
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(Globalize.translate('MessageKeysLinked'));
|
|
|
|
|
});
|
2013-09-26 08:30:47 -07:00
|
|
|
|
} else {
|
2016-02-24 23:38:12 -07:00
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(result.ErrorMessage);
|
|
|
|
|
});
|
2013-09-26 08:30:47 -07:00
|
|
|
|
}
|
2015-12-23 10:46:01 -07:00
|
|
|
|
console.log(result);
|
2013-09-26 08:30:47 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
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
|
|
|
|
|
2016-01-19 11:27:55 -07:00
|
|
|
|
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
|
2015-12-23 10:46:01 -07:00
|
|
|
|
console.log(url);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
$.post(url).then(function (res) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
var result = JSON.parse(res);
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
if (result.Success) {
|
2016-02-24 23:38:12 -07:00
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
} else {
|
2016-02-24 23:38:12 -07:00
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(result.ErrorMessage);
|
|
|
|
|
});
|
2013-02-20 18:33:05 -07:00
|
|
|
|
}
|
2015-12-23 10:46:01 -07:00
|
|
|
|
console.log(result);
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2016-02-21 15:17:38 -07:00
|
|
|
|
$(document).on('pageshow', "#supporterKeyPage", SupporterKeyPage.onPageShow);
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
|
|
function loadUserInfo(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.getPluginSecurityInfo().then(function (info) {
|
|
|
|
|
|
|
|
|
|
if (info.IsMBSupporter) {
|
|
|
|
|
$('.supporterContainer', page).addClass('hide');
|
|
|
|
|
} else {
|
|
|
|
|
$('.supporterContainer', page).removeClass('hide');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', "#supporterKeyPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
$('#supporterKeyForm').on('submit', SupporterKeyPage.updateSupporterKey);
|
|
|
|
|
$('#lostKeyForm').on('submit', SupporterKeyPage.retrieveSupporterKey);
|
|
|
|
|
$('#linkKeysForm').on('submit', SupporterKeyPage.linkSupporterKeys);
|
|
|
|
|
|
|
|
|
|
$('.benefits', page).html(Globalize.translate('HeaderSupporterBenefit', '<a href="http://emby.media/premiere" target="_blank">', '</a>'));
|
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#supporterKeyPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
loadUserInfo(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})();
|