2016-07-05 14:11:28 -04:00
|
|
|
|
define(['fetchHelper', 'jQuery', 'registrationservices'], function (fetchHelper, $, registrationServices) {
|
2014-05-18 15:58:42 -04:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
function load(page) {
|
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');
|
2013-07-14 18:01:02 -04:00
|
|
|
|
$('.notSupporter', page).show();
|
|
|
|
|
} else {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
page.querySelector('#txtSupporterKey').classList.remove('invalidEntry');
|
2013-07-14 18:01:02 -04:00
|
|
|
|
$('.notSupporter', page).hide();
|
|
|
|
|
}
|
2014-05-18 15:58:42 -04:00
|
|
|
|
|
2013-02-20 20:33:05 -05:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2016-03-13 16:12:42 -04:00
|
|
|
|
}
|
2014-01-02 16:21:06 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
function loadUserInfo(page) {
|
2013-09-14 17:19:32 -04:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
Dashboard.getPluginSecurityInfo().then(function (info) {
|
2014-01-02 16:21:06 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
if (info.IsMBSupporter) {
|
|
|
|
|
$('.supporterContainer', page).addClass('hide');
|
2014-05-18 15:58:42 -04:00
|
|
|
|
} else {
|
2016-03-13 16:12:42 -04:00
|
|
|
|
$('.supporterContainer', page).removeClass('hide');
|
2014-05-18 15:58:42 -04:00
|
|
|
|
}
|
|
|
|
|
});
|
2016-03-13 16:12:42 -04:00
|
|
|
|
}
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
function retrieveSupporterKey() {
|
2013-09-26 11:30:47 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-02 16:21:06 -05:00
|
|
|
|
var form = this;
|
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
var email = $('#txtEmail', form).val();
|
2013-09-26 11:30:47 -04:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
|
2015-12-23 12:46:01 -05:00
|
|
|
|
console.log(url);
|
2016-03-13 16:12:42 -04:00
|
|
|
|
fetchHelper.ajax({
|
2016-06-24 20:29:39 -04:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
url: url,
|
|
|
|
|
type: 'POST',
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
2013-09-26 11:30:47 -04:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
if (result.Success) {
|
2016-02-25 01:38:12 -05:00
|
|
|
|
require(['toast'], function (toast) {
|
2016-03-13 16:12:42 -04:00
|
|
|
|
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
|
2016-02-25 01:38:12 -05:00
|
|
|
|
});
|
2013-09-26 11:30:47 -04:00
|
|
|
|
} else {
|
2016-02-25 01:38:12 -05:00
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(result.ErrorMessage);
|
|
|
|
|
});
|
2013-09-26 11:30:47 -04:00
|
|
|
|
}
|
2015-12-23 12:46:01 -05:00
|
|
|
|
console.log(result);
|
2013-09-26 11:30:47 -04:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
2016-03-13 16:12:42 -04:00
|
|
|
|
}
|
2014-05-18 15:58:42 -04:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
var SupporterKeyPage = {
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
updateSupporterKey: function () {
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
var form = this;
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
var key = $('#txtSupporterKey', form).val();
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
var info = {
|
|
|
|
|
SupporterKey: key
|
|
|
|
|
};
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
ApiClient.updatePluginSecurityInfo(info).then(function () {
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
Dashboard.resetPluginSecurityInfo();
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-02-20 20:33:05 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
if (key) {
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('MessageKeyUpdated'),
|
|
|
|
|
title: Globalize.translate('HeaderConfirmation')
|
|
|
|
|
});
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
} else {
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('MessageKeyRemoved'),
|
|
|
|
|
title: Globalize.translate('HeaderConfirmation')
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
var page = $(form).parents('.page')[0];
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
load(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
linkSupporterKeys: function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
var form = this;
|
|
|
|
|
|
|
|
|
|
var email = $('#txtNewEmail', form).val();
|
|
|
|
|
var newkey = $('#txtNewKey', form).val();
|
|
|
|
|
var oldkey = $('#txtOldKey', form).val();
|
|
|
|
|
|
|
|
|
|
var url = "https://mb3admin.com/admin/service/supporter/linkKeys";
|
|
|
|
|
console.log(url);
|
|
|
|
|
fetchHelper.ajax({
|
|
|
|
|
|
|
|
|
|
url: url,
|
|
|
|
|
type: 'POST',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
query: {
|
|
|
|
|
email: email,
|
|
|
|
|
newkey: newkey,
|
|
|
|
|
oldkey: oldkey
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
if (result.Success) {
|
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(Globalize.translate('MessageKeysLinked'));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(result.ErrorMessage);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
console.log(result);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
2016-07-05 14:11:28 -04:00
|
|
|
|
function onSupporterLinkClick(e) {
|
|
|
|
|
|
|
|
|
|
registrationServices.showPremiereInfo();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-21 17:17:38 -05:00
|
|
|
|
$(document).on('pageinit', "#supporterKeyPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
2016-03-13 16:12:42 -04:00
|
|
|
|
$('#supporterKeyForm', this).on('submit', SupporterKeyPage.updateSupporterKey);
|
|
|
|
|
$('#lostKeyForm', this).on('submit', retrieveSupporterKey);
|
|
|
|
|
$('#linkKeysForm', this).on('submit', SupporterKeyPage.linkSupporterKeys);
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
2016-07-05 14:11:28 -04:00
|
|
|
|
page.querySelector('.benefits').innerHTML = Globalize.translate('HeaderSupporterBenefit', '<a class="lnkPremiere" href="http://emby.media/premiere" target="_blank">', '</a>');
|
|
|
|
|
|
|
|
|
|
page.querySelector('.lnkPremiere').addEventListener('click', onSupporterLinkClick);
|
2016-02-21 17:17:38 -05:00
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#supporterKeyPage", function () {
|
2016-04-13 02:02:07 -04:00
|
|
|
|
|
2016-02-21 17:17:38 -05:00
|
|
|
|
var page = this;
|
|
|
|
|
loadUserInfo(page);
|
2016-03-13 16:12:42 -04:00
|
|
|
|
load(page);
|
2016-02-21 17:17:38 -05:00
|
|
|
|
});
|
|
|
|
|
|
2016-03-13 16:12:42 -04:00
|
|
|
|
});
|