2016-06-30 12:01:48 -07:00
|
|
|
|
define(['appStorage', 'shell'], function (appStorage, shell) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
var supporterPlaybackKey = 'lastSupporterPlaybackMessage4';
|
2015-05-17 18:27:48 -07:00
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
function validatePlayback(resolve, reject) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-07-26 22:03:34 -07:00
|
|
|
|
if (pluginSecurityInfo.IsMBSupporter) {
|
2015-12-30 13:25:17 -07:00
|
|
|
|
resolve();
|
2015-05-16 12:09:02 -07:00
|
|
|
|
} else {
|
|
|
|
|
|
2015-07-26 22:03:34 -07:00
|
|
|
|
var lastMessage = parseInt(appStorage.getItem(supporterPlaybackKey) || '0');
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-07-26 22:03:34 -07:00
|
|
|
|
if (!lastMessage) {
|
|
|
|
|
|
|
|
|
|
// Don't show on the very first playback attempt
|
|
|
|
|
appStorage.setItem(supporterPlaybackKey, new Date().getTime());
|
2015-12-30 13:25:17 -07:00
|
|
|
|
resolve();
|
2015-05-16 12:09:02 -07:00
|
|
|
|
}
|
2016-03-02 11:42:39 -07:00
|
|
|
|
else if ((new Date().getTime() - lastMessage) > 259200000) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
showPlaybackOverlay(resolve, reject);
|
2015-07-26 22:03:34 -07:00
|
|
|
|
} else {
|
2015-12-30 13:25:17 -07:00
|
|
|
|
resolve();
|
2015-05-16 12:09:02 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-26 22:03:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-26 21:52:50 -07:00
|
|
|
|
function getSubscriptionBenefits() {
|
|
|
|
|
|
|
|
|
|
var list = [];
|
|
|
|
|
|
|
|
|
|
list.push({
|
|
|
|
|
name: Globalize.translate('CoverArt'),
|
|
|
|
|
icon: 'photo',
|
|
|
|
|
text: Globalize.translate('CoverArtFeatureDescription')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
list.push({
|
|
|
|
|
name: Globalize.translate('HeaderFreeApps'),
|
|
|
|
|
icon: 'check',
|
|
|
|
|
text: Globalize.translate('FreeAppsFeatureDescription')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (Dashboard.capabilities().SupportsSync) {
|
|
|
|
|
list.push({
|
|
|
|
|
name: Globalize.translate('HeaderMobileSync'),
|
|
|
|
|
icon: 'sync',
|
|
|
|
|
text: Globalize.translate('MobileSyncFeatureDescription')
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
list.push({
|
|
|
|
|
name: Globalize.translate('HeaderCinemaMode'),
|
|
|
|
|
icon: 'movie',
|
|
|
|
|
text: Globalize.translate('CinemaModeFeatureDescription')
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSubscriptionBenefitHtml(item) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
html += '<paper-icon-item>';
|
|
|
|
|
|
|
|
|
|
html += '<paper-fab mini style="background-color:#52B54B;" icon="' + item.icon + '" item-icon></paper-fab>';
|
|
|
|
|
|
|
|
|
|
html += '<paper-item-body three-line>';
|
|
|
|
|
html += '<a class="clearLink" href="https://emby.media/premiere" target="_blank">';
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
html += item.name;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div secondary style="white-space:normal;">';
|
|
|
|
|
html += item.text;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
html += '</paper-item-body>';
|
|
|
|
|
|
|
|
|
|
html += '</paper-icon-item>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
function showPlaybackOverlay(resolve, reject) {
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-06-04 20:50:07 -07:00
|
|
|
|
require(['dialogHelper', 'paper-fab', 'paper-item-body', 'paper-icon-item', 'emby-button'], function (dialogHelper) {
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
var dlg = dialogHelper.createDialog({
|
2016-06-18 13:31:22 -07:00
|
|
|
|
size: 'fullscreen-border',
|
|
|
|
|
removeOnClose: true
|
2016-01-30 13:59:09 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dlg.classList.add('ui-body-b');
|
|
|
|
|
dlg.classList.add('background-theme-b');
|
|
|
|
|
dlg.classList.add('popupEditor');
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
html += '<h2 class="dialogHeader">';
|
2016-01-30 13:59:09 -07:00
|
|
|
|
html += '<paper-fab icon="arrow-back" mini class="btnCancelSupporterInfo" tabindex="-1"></paper-fab>';
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '</h2>';
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-01-30 13:59:09 -07:00
|
|
|
|
html += '<div class="readOnlyContent" style="margin:0 auto 0;color:#fff;padding:1em;">';
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '<h1>' + Globalize.translate('HeaderTryEmbyPremiere') + '</h1>';
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '<p>' + Globalize.translate('MessageDidYouKnowCinemaMode') + '</p>';
|
|
|
|
|
html += '<p>' + Globalize.translate('MessageDidYouKnowCinemaMode2') + '</p>';
|
2015-11-26 21:52:50 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '<br/>';
|
2015-11-26 21:52:50 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '<h1>' + Globalize.translate('HeaderBenefitsEmbyPremiere') + '</h1>';
|
2015-11-26 21:52:50 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '<div class="paperList">';
|
|
|
|
|
html += getSubscriptionBenefits().map(getSubscriptionBenefitHtml).join('');
|
|
|
|
|
html += '</div>';
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '<br/>';
|
|
|
|
|
|
2016-06-18 13:31:22 -07:00
|
|
|
|
html += '<a class="clearLink" href="http://emby.media/premiere" target="_blank"><button is="emby-button" type="button" class="raised submit block" autoFocus><i class="md-icon">check</i><span>' + Globalize.translate('ButtonBecomeSupporter') + '</span></button></a>';
|
|
|
|
|
html += '<button is="emby-button" type="button" class="raised subdued block btnCancelSupporterInfo" style="background:#444;"><i class="md-icon">close</i><span>' + Globalize.translate('ButtonClosePlayVideo') + '</span></button>';
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
html += '</div>';
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
document.body.appendChild(dlg);
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
// Has to be assigned a z-index after the call to .open()
|
2016-03-22 10:46:57 -07:00
|
|
|
|
dlg.addEventListener('close', function (e) {
|
2015-11-29 12:51:45 -07:00
|
|
|
|
appStorage.setItem(supporterPlaybackKey, new Date().getTime());
|
2015-12-30 13:25:17 -07:00
|
|
|
|
resolve();
|
2015-11-29 12:51:45 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.open(dlg);
|
2015-11-29 12:51:45 -07:00
|
|
|
|
|
2016-06-18 13:31:22 -07:00
|
|
|
|
var onCancelClick = function () {
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.close(dlg);
|
2016-06-18 13:31:22 -07:00
|
|
|
|
};
|
|
|
|
|
var i, length;
|
|
|
|
|
var elems = dlg.querySelectorAll('.btnCancelSupporterInfo');
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
elems[i].addEventListener('click', onCancelClick);
|
|
|
|
|
}
|
2015-07-26 22:03:34 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
function validateSync(resolve, reject) {
|
2015-07-29 19:08:35 -07:00
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
Dashboard.getPluginSecurityInfo().then(function (pluginSecurityInfo) {
|
2015-07-29 19:08:35 -07:00
|
|
|
|
|
|
|
|
|
if (pluginSecurityInfo.IsMBSupporter) {
|
2015-12-30 13:25:17 -07:00
|
|
|
|
resolve();
|
2015-07-29 19:08:35 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
ApiClient.getRegistrationInfo('Sync').then(function (registrationInfo) {
|
2015-07-29 19:08:35 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
if (registrationInfo.IsRegistered) {
|
2015-12-30 13:25:17 -07:00
|
|
|
|
resolve();
|
2015-07-29 19:08:35 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
2015-10-01 09:28:24 -07:00
|
|
|
|
message: Globalize.translate('HeaderSyncRequiresSupporterMembership') + '<br/><p><a href="http://emby.media/premiere" target="_blank">' + Globalize.translate('ButtonLearnMore') + '</a></p>',
|
2015-12-14 08:43:03 -07:00
|
|
|
|
title: Globalize.translate('HeaderSync'),
|
2015-12-30 13:25:17 -07:00
|
|
|
|
callback: reject
|
2015-07-29 19:08:35 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-11-29 12:51:45 -07:00
|
|
|
|
}, function () {
|
2015-07-29 19:08:35 -07:00
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
reject();
|
2015-07-29 19:08:35 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
|
|
|
|
|
Dashboard.alert({
|
|
|
|
|
message: Globalize.translate('ErrorValidatingSupporterInfo')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-26 22:03:34 -07:00
|
|
|
|
window.RegistrationServices = {
|
|
|
|
|
renderPluginInfo: function (page, pkg, pluginSecurityInfo) {
|
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
require(['jQuery'], function ($) {
|
|
|
|
|
if (pkg.isPremium) {
|
|
|
|
|
$('.premiumPackage', page).show();
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
// Fill in registration info
|
|
|
|
|
var regStatus = "";
|
|
|
|
|
if (pkg.isRegistered) {
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
regStatus += "<p style='color:green;'>";
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
regStatus += Globalize.translate('MessageFeatureIncludedWithSupporter');
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
} else {
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
var expDateTime = new Date(pkg.expDate).getTime();
|
|
|
|
|
var nowTime = new Date().getTime();
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
if (expDateTime <= nowTime) {
|
|
|
|
|
regStatus += "<p style='color:red;'>";
|
|
|
|
|
regStatus += Globalize.translate('MessageTrialExpired');
|
2016-06-30 12:01:48 -07:00
|
|
|
|
} else if (expDateTime > new Date(1970, 1, 1).getTime()) {
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
regStatus += "<p style='color:blue;'>";
|
|
|
|
|
regStatus += Globalize.translate('MessageTrialWillExpireIn').replace('{0}', Math.round(expDateTime - nowTime) / (86400000));
|
|
|
|
|
}
|
2015-07-26 22:03:34 -07:00
|
|
|
|
}
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
regStatus += "</p>";
|
|
|
|
|
$('#regStatus', page).html(regStatus);
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
if (pluginSecurityInfo.IsMBSupporter) {
|
|
|
|
|
$('#regInfo', page).html(pkg.regInfo || "");
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
$('.premiumDescription', page).hide();
|
|
|
|
|
$('.supporterDescription', page).hide();
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
if (pkg.price > 0) {
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
$('.premiumHasPrice', page).show();
|
|
|
|
|
$('#featureId', page).val(pkg.featureId);
|
|
|
|
|
$('#featureName', page).val(pkg.name);
|
|
|
|
|
$('#amount', page).val(pkg.price);
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
$('#regPrice', page).html("<h3>" + Globalize.translate('ValuePriceUSD').replace('{0}', "$" + pkg.price.toFixed(2)) + "</h3>");
|
|
|
|
|
$('#ppButton', page).hide();
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
var url = "https://mb3admin.com/admin/service/user/getPayPalEmail?id=" + pkg.owner;
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
fetch(url).then(function (response) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
return response.json();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
}).then(function (dev) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
if (dev.payPalEmail) {
|
|
|
|
|
$('#payPalEmail', page).val(dev.payPalEmail);
|
|
|
|
|
$('#ppButton', page).show();
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2015-11-26 21:52:50 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
// Supporter-only feature
|
|
|
|
|
$('.premiumHasPrice', page).hide();
|
|
|
|
|
}
|
2015-07-26 22:03:34 -07:00
|
|
|
|
} else {
|
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
if (pkg.price) {
|
|
|
|
|
$('.premiumDescription', page).show();
|
|
|
|
|
$('.supporterDescription', page).hide();
|
|
|
|
|
$('#regInfo', page).html("");
|
2015-07-26 22:03:34 -07:00
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('.premiumDescription', page).hide();
|
|
|
|
|
$('.supporterDescription', page).show();
|
|
|
|
|
$('#regInfo', page).html("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#ppButton', page).hide();
|
2015-07-26 22:03:34 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-06 17:44:15 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('.premiumPackage', page).hide();
|
2015-05-16 12:09:02 -07:00
|
|
|
|
}
|
2016-06-06 17:44:15 -07:00
|
|
|
|
});
|
2015-07-26 22:03:34 -07:00
|
|
|
|
},
|
2015-05-16 12:09:02 -07:00
|
|
|
|
|
2015-07-26 22:03:34 -07:00
|
|
|
|
validateFeature: function (name) {
|
2015-05-22 12:16:14 -07:00
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
if (name == 'playback') {
|
|
|
|
|
validatePlayback(resolve, reject);
|
|
|
|
|
} else if (name == 'livetv') {
|
|
|
|
|
resolve();
|
|
|
|
|
} else if (name == 'sync') {
|
|
|
|
|
validateSync(resolve, reject);
|
|
|
|
|
} else {
|
|
|
|
|
resolve();
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-06-30 12:01:48 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showPremiereInfo: function () {
|
|
|
|
|
shell.openUrl('https://emby.media/premiere');
|
2015-07-26 22:03:34 -07:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-26 11:28:04 -07:00
|
|
|
|
return window.RegistrationServices;
|
2016-03-07 12:13:58 -07:00
|
|
|
|
});
|