fix supporter key page

This commit is contained in:
Luke Pulverenti 2016-03-13 16:12:42 -04:00
parent 4fb729169f
commit db21e17a96
4 changed files with 105 additions and 102 deletions

View File

@ -45,7 +45,7 @@
"tag": "v1.0.11",
"commit": "e3c1ab0c72905b58fb4d9adc2921ea73b5c085a5"
},
"_source": "git://github.com/polymerelements/paper-behaviors.git",
"_source": "git://github.com/PolymerElements/paper-behaviors.git",
"_target": "^1.0.0",
"_originalSource": "polymerelements/paper-behaviors"
"_originalSource": "PolymerElements/paper-behaviors"
}

View File

@ -32,14 +32,14 @@
"iron-test-helpers": "PolymerElements/iron-test-helpers#^1.0.0"
},
"ignore": [],
"homepage": "https://github.com/polymerelements/paper-ripple",
"homepage": "https://github.com/PolymerElements/paper-ripple",
"_release": "1.0.5",
"_resolution": {
"type": "version",
"tag": "v1.0.5",
"commit": "d72e7a9a8ab518b901ed18dde492df3b87a93be5"
},
"_source": "git://github.com/polymerelements/paper-ripple.git",
"_source": "git://github.com/PolymerElements/paper-ripple.git",
"_target": "^1.0.0",
"_originalSource": "polymerelements/paper-ripple"
"_originalSource": "PolymerElements/paper-ripple"
}

View File

@ -1772,6 +1772,7 @@ var AppInfo = {};
}
define("backdrop", [embyWebComponentsBowerPath + "/backdrop/backdrop"], returnFirstDependency);
define("fetchHelper", [embyWebComponentsBowerPath + "/fetchhelper"], returnFirstDependency);
// hack for an android test before browserInfo is loaded
if (Dashboard.isRunningInCordova() && window.MainActivity) {

View File

@ -1,11 +1,6 @@
var SupporterKeyPage = {
onPageShow: function () {
SupporterKeyPage.load(this);
},
load: function (page) {
define(['fetchHelper'], function (fetchHelper) {
function load(page) {
Dashboard.showLoadingMsg();
ApiClient.getPluginSecurityInfo().then(function (info) {
@ -22,7 +17,54 @@
Dashboard.hideLoadingMsg();
});
},
}
function loadUserInfo(page) {
Dashboard.getPluginSecurityInfo().then(function (info) {
if (info.IsMBSupporter) {
$('.supporterContainer', page).addClass('hide');
} else {
$('.supporterContainer', page).removeClass('hide');
}
});
}
function retrieveSupporterKey() {
Dashboard.showLoadingMsg();
var form = this;
var email = $('#txtEmail', form).val();
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
console.log(url);
fetchHelper.ajax({
url: url,
type: 'POST',
dataType: 'json'
}).then(function (result) {
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
});
} else {
require(['toast'], function (toast) {
toast(result.ErrorMessage);
});
}
console.log(result);
});
return false;
}
var SupporterKeyPage = {
updateSupporterKey: function () {
@ -56,7 +98,7 @@
var page = $(form).parents('.page')[0];
SupporterKeyPage.load(page);
load(page);
});
return false;
@ -71,16 +113,21 @@
var newkey = $('#txtNewKey', form).val();
var oldkey = $('#txtOldKey', form).val();
var info = {
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) {
var url = "https://mb3admin.com/admin/service/supporter/linkKeys";
console.log(url);
$.post(url, info).then(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
@ -96,67 +143,22 @@
});
return false;
},
retrieveSupporterKey: function () {
Dashboard.showLoadingMsg();
var form = this;
var email = $('#txtEmail', form).val();
var url = "https://mb3admin.com/admin/service/supporter/retrievekey?email=" + email;
console.log(url);
$.post(url).then(function (res) {
var result = JSON.parse(res);
Dashboard.hideLoadingMsg();
if (result.Success) {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageKeyEmailedTo').replace("{0}", email));
});
} else {
require(['toast'], function (toast) {
toast(result.ErrorMessage);
});
}
console.log(result);
});
return false;
}
};
$(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);
$('#supporterKeyForm', this).on('submit', SupporterKeyPage.updateSupporterKey);
$('#lostKeyForm', this).on('submit', retrieveSupporterKey);
$('#linkKeysForm', this).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);
load(page);
});
})();
});