(function () { var supporterPlaybackKey = 'lastSupporterPlaybackMessage2'; function validatePlayback(deferred) { Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { if (pluginSecurityInfo.IsMBSupporter) { deferred.resolve(); } else { var lastMessage = parseInt(appStorage.getItem(supporterPlaybackKey) || '0'); if (!lastMessage) { // Don't show on the very first playback attempt appStorage.setItem(supporterPlaybackKey, new Date().getTime()); deferred.resolve(); } else if ((new Date().getTime() - lastMessage) > 345600000) { showPlaybackOverlay(deferred); } else { deferred.resolve(); } } }); } function showPlaybackOverlay(deferred) { require(['paperbuttonstyle']); var html = ''; html += '
'; html += '
'; html += '
'; html += '

' + Globalize.translate('HeaderTryCinemaMode') + '

'; html += '

' + Globalize.translate('MessageDidYouKnowCinemaMode') + '

'; html += '

' + Globalize.translate('MessageDidYouKnowCinemaMode2') + '

'; html += '
'; html += '' + Globalize.translate('ButtonBecomeSupporter') + ''; html += '' + Globalize.translate('ButtonClosePlayVideo') + ''; html += '
'; html += '
'; html += '
'; $(document.body).append(html); $('.btnCancelSupporterInfo').on('click', function () { $('.supporterInfoOverlay').remove(); appStorage.setItem(supporterPlaybackKey, new Date().getTime()); deferred.resolve(); }); } function validateSync(deferred) { Dashboard.getPluginSecurityInfo().done(function (pluginSecurityInfo) { if (pluginSecurityInfo.IsMBSupporter) { deferred.resolve(); return; } Dashboard.showLoadingMsg(); ApiClient.getRegistrationInfo('Sync').done(function (registrationInfo) { Dashboard.hideLoadingMsg(); if (registrationInfo.IsRegistered) { deferred.resolve(); return; } Dashboard.alert({ message: Globalize.translate('HeaderSyncRequiresSupporterMembership') + '

' + Globalize.translate('ButtonLearnMore') + '

', title: Globalize.translate('HeaderSync') }); }).fail(function () { Dashboard.hideLoadingMsg(); Dashboard.alert({ message: Globalize.translate('ErrorValidatingSupporterInfo') }); }); }); } window.RegistrationServices = { renderPluginInfo: function (page, pkg, pluginSecurityInfo) { if (pkg.isPremium) { $('.premiumPackage', page).show(); // Fill in registration info var regStatus = ""; if (pkg.isRegistered) { regStatus += "

"; regStatus += Globalize.translate('MessageFeatureIncludedWithSupporter'); } else { var expDateTime = new Date(pkg.expDate).getTime(); var nowTime = new Date().getTime(); if (expDateTime <= nowTime) { regStatus += "

"; regStatus += Globalize.translate('MessageTrialExpired'); } else if (expDateTime > new Date(1970, 1, 1).getTime()) { regStatus += "

"; regStatus += Globalize.translate('MessageTrialWillExpireIn').replace('{0}', Math.round(expDateTime - nowTime) / (86400000)); } } regStatus += "

"; $('#regStatus', page).html(regStatus); if (pluginSecurityInfo.IsMBSupporter) { $('#regInfo', page).html(pkg.regInfo || ""); $('.premiumDescription', page).hide(); $('.supporterDescription', page).hide(); if (pkg.price > 0) { $('.premiumHasPrice', page).show(); $('#featureId', page).val(pkg.featureId); $('#featureName', page).val(pkg.name); $('#amount', page).val(pkg.price); $('#regPrice', page).html("

" + Globalize.translate('ValuePriceUSD').replace('{0}', "$" + pkg.price.toFixed(2)) + "

"); var url = "http://mb3admin.com/admin/service/user/getPayPalEmail?id=" + pkg.owner; $.getJSON(url).done(function (dev) { if (dev.payPalEmail) { $('#payPalEmail', page).val(dev.payPalEmail); } else { $('#ppButton', page).hide(); } }); } else { // Supporter-only feature $('.premiumHasPrice', page).hide(); } } else { if (pkg.price) { $('.premiumDescription', page).show(); $('.supporterDescription', page).hide(); $('#regInfo', page).html(""); } else { $('.premiumDescription', page).hide(); $('.supporterDescription', page).show(); $('#regInfo', page).html(""); } $('#ppButton', page).hide(); } } else { $('.premiumPackage', page).hide(); } }, validateFeature: function (name) { var deferred = DeferredBuilder.Deferred(); if (name == 'playback') { validatePlayback(deferred); } else if (name == 'livetv') { deferred.resolve(); } else if (name == 'sync') { validateSync(deferred); } else { deferred.resolve(); } return deferred.promise(); } }; })();