2016-03-18 21:26:17 -07:00
|
|
|
|
define(['fetchHelper', 'jQuery'], function (fetchHelper, $) {
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
function load(page) {
|
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();
|
|
|
|
|
});
|
2016-03-13 13:12:42 -07:00
|
|
|
|
}
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
function loadUserInfo(page) {
|
2013-09-14 14:19:32 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
Dashboard.getPluginSecurityInfo().then(function (info) {
|
2014-01-02 14:21:06 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
if (info.IsMBSupporter) {
|
|
|
|
|
$('.supporterContainer', page).addClass('hide');
|
2014-05-18 12:58:42 -07:00
|
|
|
|
} else {
|
2016-03-13 13:12:42 -07:00
|
|
|
|
$('.supporterContainer', page).removeClass('hide');
|
2014-05-18 12:58:42 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2016-03-13 13:12:42 -07:00
|
|
|
|
}
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
function retrieveSupporterKey() {
|
2013-09-26 08:30:47 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-02 14:21:06 -07:00
|
|
|
|
var form = this;
|
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
var email = $('#txtEmail', form).val();
|
2013-09-26 08:30:47 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
|
2015-12-23 10:46:01 -07:00
|
|
|
|
console.log(url);
|
2016-03-13 13:12:42 -07:00
|
|
|
|
fetchHelper.ajax({
|
|
|
|
|
|
|
|
|
|
url: url,
|
|
|
|
|
type: 'POST',
|
|
|
|
|
dataType: 'json'
|
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
2013-09-26 08:30:47 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
if (result.Success) {
|
2016-02-24 23:38:12 -07:00
|
|
|
|
require(['toast'], function (toast) {
|
2016-03-13 13:12:42 -07:00
|
|
|
|
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
|
2016-02-24 23:38:12 -07:00
|
|
|
|
});
|
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;
|
2016-03-13 13:12:42 -07:00
|
|
|
|
}
|
2014-05-18 12:58:42 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
var SupporterKeyPage = {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
updateSupporterKey: function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
var form = this;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
var key = $('#txtSupporterKey', form).val();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
var info = {
|
|
|
|
|
SupporterKey: key
|
|
|
|
|
};
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
ApiClient.updatePluginSecurityInfo(info).then(function () {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
Dashboard.resetPluginSecurityInfo();
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-02-20 18:33:05 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
if (key) {
|
2016-02-21 15:17:38 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('MessageKeyUpdated'),
|
|
|
|
|
title: Globalize.translate('HeaderConfirmation')
|
|
|
|
|
});
|
2016-02-21 15:17:38 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
} else {
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('MessageKeyRemoved'),
|
|
|
|
|
title: Globalize.translate('HeaderConfirmation')
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-02-21 15:17:38 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
var page = $(form).parents('.page')[0];
|
2016-02-21 15:17:38 -07:00
|
|
|
|
|
2016-03-13 13:12:42 -07: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 15:17:38 -07:00
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', "#supporterKeyPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
2016-03-13 13:12:42 -07:00
|
|
|
|
$('#supporterKeyForm', this).on('submit', SupporterKeyPage.updateSupporterKey);
|
|
|
|
|
$('#lostKeyForm', this).on('submit', retrieveSupporterKey);
|
|
|
|
|
$('#linkKeysForm', this).on('submit', SupporterKeyPage.linkSupporterKeys);
|
2016-02-21 15:17:38 -07:00
|
|
|
|
|
|
|
|
|
$('.benefits', page).html(Globalize.translate('HeaderSupporterBenefit', '<a href="http://emby.media/premiere" target="_blank">', '</a>'));
|
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#supporterKeyPage", function () {
|
|
|
|
|
var page = this;
|
|
|
|
|
loadUserInfo(page);
|
2016-03-13 13:12:42 -07:00
|
|
|
|
load(page);
|
2016-02-21 15:17:38 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-03-13 13:12:42 -07:00
|
|
|
|
});
|