(function () { function getRegistrationInfo(feature) { return ConnectionManager.getRegistrationInfo(feature, ApiClient); } function validateFeature(feature, deferred) { var unlockableProduct = IapManager.getProductInfo(feature) || {}; if (unlockableProduct.owned) { deferred.resolve(); return; } var unlockableProductInfo = IapManager.isPurchaseAvailable(feature) ? { enableAppUnlock: true, id: unlockableProduct.id, price: unlockableProduct.price, feature: feature } : null; var prefix = $.browser.android ? 'android' : 'ios'; IapManager.isUnlockedOverride(feature).done(function (isUnlocked) { if (isUnlocked) { deferred.resolve(); return; } function onRegistrationInfoResponse(registrationInfo) { if (registrationInfo.IsRegistered) { deferred.resolve(); return; } IapManager.getSubscriptionOptions().done(function (subscriptionOptions) { if (subscriptionOptions.filter(function (p) { return p.owned; }).length > 0) { deferred.resolve(); return; } var dialogOptions = { title: Globalize.translate('HeaderUnlockApp'), enablePlayMinute: feature == 'playback', feature: feature }; showInAppPurchaseInfo(subscriptionOptions, unlockableProductInfo, dialogOptions, deferred); }); } // Get supporter status getRegistrationInfo(prefix + 'appunlock').done(onRegistrationInfoResponse).fail(function () { onRegistrationInfoResponse({}); }); }); } function cancelInAppPurchase() { var elem = document.querySelector('.inAppPurchaseOverlay'); if (elem) { PaperDialogHelper.close(elem); } } var isCancelled = true; var currentDisplayingProductInfos = []; var currentDisplayingDeferred = null; function clearCurrentDisplayingInfo() { currentDisplayingProductInfos = []; currentDisplayingDeferred = null; } function showInAppPurchaseElement(subscriptionOptions, unlockableProductInfo, dialogOptions, deferred) { cancelInAppPurchase(); // clone currentDisplayingProductInfos = subscriptionOptions.slice(0); if (unlockableProductInfo) { currentDisplayingProductInfos.push(unlockableProductInfo); } var dlg = PaperDialogHelper.createDialog(); var html = ''; html += '