(function () { function isAndroid() { return $.browser.android; } function getPremiumUnlockFeatureId() { if (isAndroid()) { return "com.mb.android.unlock"; } return 'appunlock'; } function validatePlayback(deferred) { // Don't require validation on android if (isAndroid()) { deferred.resolve(); return; } validateFeature(getPremiumUnlockFeatureId(), deferred); } function validateLiveTV(deferred) { if (!isAndroid()) { deferred.resolve(); return; } validateFeature(getPremiumUnlockFeatureId(), deferred); } function validateServerManagement(deferred) { deferred.resolve(); } function getRegistrationInfo(feature, enableSupporterUnlock) { if (!enableSupporterUnlock) { var deferred = $.Deferred(); deferred.resolveWith(null, [{}]); return deferred.promise(); } return ConnectionManager.getRegistrationInfo(feature, ApiClient); } var validatedFeatures = []; function validateFeature(id, deferred) { if (validatedFeatures.indexOf(id) != -1) { deferred.resolve(); return; } var info = IapManager.getProductInfo(id) || {}; if (info.owned) { notifyServer(id); validatedFeatures.push(id); deferred.resolve(); return; } var productInfo = { enableSupporterUnlock: true, enableAppUnlock: IapManager.isPurchaseAvailable(id), id: id, price: info.price }; var prefix = isAndroid() ? 'android' : 'ios'; // Get supporter status getRegistrationInfo(prefix + 'appunlock', productInfo.enableSupporterUnlock).done(function (registrationInfo) { if (registrationInfo.IsRegistered) { validatedFeatures.push(id); deferred.resolve(); return; } showInAppPurchaseInfo(productInfo, registrationInfo, deferred); }).fail(function () { deferred.reject(); }); } function notifyServer(id) { if (!$.browser.android) { return; } HttpClient.send({ type: "POST", url: "https://mb3admin.com/admin/service/appstore/addDeviceFeature", data: { deviceId: ConnectionManager.deviceId(), feature: 'com.mb.android.unlock' }, contentType: 'application/x-www-form-urlencoded; charset=UTF-8', headers: { "X-EMBY-TOKEN": "EMBY_DEVICE" } }).done(function (result) { Logger.log('addDeviceFeature succeeded'); }).fail(function () { Logger.log('addDeviceFeature failed'); }); } function getInAppPurchaseElement(info) { cancelInAppPurchase(); var html = ''; html += '
'; var showSupporterInfo = info.enableSupporterUnlock && !$.browser.safari; if (showSupporterInfo && info.enableAppUnlock) { html += Globalize.translate('MessageUnlockAppWithPurchaseOrSupporter'); } else if (showSupporterInfo) { html += Globalize.translate('MessageUnlockAppWithSupporter'); } else if (info.enableAppUnlock) { html += Globalize.translate('MessageUnlockAppWithPurchase'); } else { html += ''; html += Globalize.translate('MessagePaymentServicesUnavailable'); html += ''; } html += '
'; if (showSupporterInfo) { html += ''; html += Globalize.translate('MessageToValidateSupporter'); html += '
'; } if (info.enableAppUnlock) { var unlockText = Globalize.translate('ButtonUnlockWithPurchase'); if (info.price) { unlockText = Globalize.translate('ButtonUnlockPrice', info.price); } html += '';
html += '
';
html += '
';
html += '
';
html += '