update live tv loading
This commit is contained in:
parent
28f378f8db
commit
f82049f935
7 changed files with 177 additions and 14 deletions
|
@ -32,6 +32,15 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="channelPaging"></div>
|
<div class="channelPaging"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="guideRequiresUnlock readOnlyContent" style="margin:2em auto;text-align:center;display:none;">
|
||||||
|
<p class="unlockText"></p>
|
||||||
|
<button class="btn btnActionAccent btnUnlockGuide" data-role="none" type="button">
|
||||||
|
<span>
|
||||||
|
${ButtonUnlockGuide}
|
||||||
|
</span>
|
||||||
|
<i class="fa fa-check"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div data-role="popup" id="popupConfig" data-theme="b">
|
<div data-role="popup" id="popupConfig" data-theme="b">
|
||||||
<div class="ui-bar-a" style="text-align: center; padding: 0 20px; position: relative;">
|
<div class="ui-bar-a" style="text-align: center; padding: 0 20px; position: relative;">
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,10 @@
|
||||||
<br />
|
<br />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div class="visualLoginForm" style="display: none; text-align: center;">
|
<div class="visualLoginForm" style="text-align: center;">
|
||||||
<br />
|
<br />
|
||||||
<div id="divUsers" class="itemsContainer"></div>
|
<div id="divUsers" class="itemsContainer"></div>
|
||||||
|
|
||||||
<p class="localhostMessage" style="text-align: center; display: none;">${PasswordLocalhostMessage}</p>
|
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<div class="readOnlyContent" style="margin: 2em auto 0;">
|
<div class="readOnlyContent" style="margin: 2em auto 0;">
|
||||||
|
|
|
@ -403,10 +403,17 @@
|
||||||
|
|
||||||
function reloadPage(page) {
|
function reloadPage(page) {
|
||||||
|
|
||||||
|
$('.guideRequiresUnlock', page).hide();
|
||||||
|
|
||||||
RegistrationServices.validateFeature('livetv').done(function () {
|
RegistrationServices.validateFeature('livetv').done(function () {
|
||||||
reloadPageAfterValidation(page, 1000);
|
reloadPageAfterValidation(page, 1000);
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
reloadPageAfterValidation(page, 3);
|
|
||||||
|
var limit = 5;
|
||||||
|
$('.guideRequiresUnlock', page).show();
|
||||||
|
$('.unlockText', page).html(Globalize.translate('MessageLiveTvGuideRequiresUnlock', limit));
|
||||||
|
|
||||||
|
reloadPageAfterValidation(page, limit);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,6 +465,11 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('.btnUnlockGuide', page).on('click', function () {
|
||||||
|
|
||||||
|
reloadPage(page);
|
||||||
|
});
|
||||||
|
|
||||||
}).on('pageshowready', "#liveTvGuidePage", function () {
|
}).on('pageshowready', "#liveTvGuidePage", function () {
|
||||||
|
|
||||||
var page = this;
|
var page = this;
|
||||||
|
|
|
@ -1827,7 +1827,7 @@ var AppInfo = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Dashboard.isRunningInCordova()) {
|
if (Dashboard.isRunningInCordova()) {
|
||||||
requirejs(['thirdparty/cordova/connectsdk', 'thirdparty/cordova/remotecontrols']);
|
requirejs(['thirdparty/cordova/connectsdk', 'thirdparty/cordova/remotecontrols', 'scripts/registrationservices']);
|
||||||
|
|
||||||
if ($.browser.android) {
|
if ($.browser.android) {
|
||||||
requirejs(['thirdparty/cordova/android/immersive']);
|
requirejs(['thirdparty/cordova/android/immersive']);
|
||||||
|
|
|
@ -671,7 +671,8 @@
|
||||||
Id: foundServer.Id,
|
Id: foundServer.Id,
|
||||||
LocalAddress: foundServer.Address,
|
LocalAddress: foundServer.Address,
|
||||||
Name: foundServer.Name,
|
Name: foundServer.Name,
|
||||||
ManualAddress: convertEndpointAddressToManualAddress(foundServer)
|
ManualAddress: convertEndpointAddressToManualAddress(foundServer),
|
||||||
|
DateLastLocalConnection: new Date().getTime()
|
||||||
};
|
};
|
||||||
|
|
||||||
info.LastConnectionMode = info.ManualAddress ? MediaBrowser.ConnectionMode.Manual : MediaBrowser.ConnectionMode.Local;
|
info.LastConnectionMode = info.ManualAddress ? MediaBrowser.ConnectionMode.Manual : MediaBrowser.ConnectionMode.Local;
|
||||||
|
@ -1223,7 +1224,41 @@
|
||||||
|
|
||||||
self.getRegistrationInfo = function (feature, apiClient) {
|
self.getRegistrationInfo = function (feature, apiClient) {
|
||||||
|
|
||||||
return apiClient.getRegistrationInfo(feature);
|
var deferred = DeferredBuilder.Deferred();
|
||||||
|
|
||||||
|
self.getAvailableServers().done(function (servers) {
|
||||||
|
|
||||||
|
var matchedServers = servers.filter(function (s) {
|
||||||
|
return stringEqualsIgnoreCase(s.Id, apiClient.serverInfo().Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!matchedServers.length) {
|
||||||
|
deferred.resolveWith(null, [{}]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var match = matchedServers[0];
|
||||||
|
|
||||||
|
// 31 days
|
||||||
|
if ((new Date().getTime() - (match.DateLastLocalConnection || 0)) > 2678400000) {
|
||||||
|
deferred.resolveWith(null, [{}]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
apiClient.getRegistrationInfo(feature).done(function (result) {
|
||||||
|
|
||||||
|
deferred.resolveWith(null, [result]);
|
||||||
|
}).fail(function () {
|
||||||
|
|
||||||
|
deferred.reject();
|
||||||
|
});
|
||||||
|
|
||||||
|
}).fail(function () {
|
||||||
|
|
||||||
|
deferred.reject();
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
if (server.LastConnectionMode != null) {
|
if (server.LastConnectionMode != null) {
|
||||||
existing.LastConnectionMode = server.LastConnectionMode;
|
existing.LastConnectionMode = server.LastConnectionMode;
|
||||||
}
|
}
|
||||||
|
existing.DateLastLocalConnection = Math.max(existing.DateLastLocalConnection || 0, server.DateLastLocalConnection || 0);
|
||||||
|
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,16 @@
|
||||||
}, deferred);
|
}, deferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRegistrationInfo(feature, enableSupporterUnlock) {
|
||||||
|
|
||||||
|
if (!enableSupporterUnlock) {
|
||||||
|
var deferred = $.Deferred();
|
||||||
|
deferred.resolveWith(null, [{}]);
|
||||||
|
return deferred.promise();
|
||||||
|
}
|
||||||
|
return ConnectionManager.getRegistrationInfo(feature, ApiClient);
|
||||||
|
}
|
||||||
|
|
||||||
function validateFeature(info, deferred) {
|
function validateFeature(info, deferred) {
|
||||||
|
|
||||||
var products = updatedProducts.filter(function (r) {
|
var products = updatedProducts.filter(function (r) {
|
||||||
|
@ -79,28 +89,126 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var productInfo = {
|
||||||
|
enableSupporterUnlock: isAndroid(),
|
||||||
|
enableAppUnlock: product != null && product.canPurchase
|
||||||
|
};
|
||||||
|
|
||||||
// Get supporter status
|
// Get supporter status
|
||||||
ConnectionManager.getRegistrationInfo('appunlock', ApiClient).done(function (registrationInfo) {
|
getRegistrationInfo('appunlock', productInfo.enableSupporterUnlock).done(function (registrationInfo) {
|
||||||
|
|
||||||
if (registrationInfo.IsRegistered) {
|
if (registrationInfo.IsRegistered) {
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
showInAppPurchaseInfo(info, product, registrationInfo, deferred);
|
showInAppPurchaseInfo(productInfo, registrationInfo, deferred);
|
||||||
|
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
deferred.reject();
|
deferred.reject();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInAppPurchaseInfo(info, product, serverRegistrationInfo, deferred) {
|
function getInAppPurchaseElement(info) {
|
||||||
|
|
||||||
var requiresLocalValidation = serverRegistrationInfo.IsLocalValidationRequired;
|
cancelInAppPurchase();
|
||||||
var canPurchase = product != null && product.canPurchase;
|
|
||||||
|
|
||||||
// Can only purchase if product != null
|
var html = '';
|
||||||
deferred.resolve();
|
html += '<div class="inAppPurchaseOverlay" style="background-image:url(css/images/splash.jpg);top:0;left:0;right:0;bottom:0;position:fixed;background-position:center center;background-size:100% 100%;background-repeat:no-repeat;z-index:999999;">';
|
||||||
|
html += '<div class="inAppPurchaseOverlayInner" style="background:rgba(10,10,10,.8);width:100%;height:100%;color:#eee;">';
|
||||||
|
|
||||||
|
|
||||||
|
html += '<form class="inAppPurchaseForm" style="margin: 0 auto;padding: 30px 1em 0;">';
|
||||||
|
|
||||||
|
html += '<h1 style="color:#fff;">' + Globalize.translate('HeaderUnlockApp') + '</h1>';
|
||||||
|
|
||||||
|
html += '<p style="margin:2em 0;">';
|
||||||
|
|
||||||
|
if (info.enableSupporterUnlock && info.enableAppUnlock) {
|
||||||
|
html += Globalize.translate('MessageUnlockAppWithPurchaseOrSupporter');
|
||||||
|
}
|
||||||
|
else if (info.enableSupporterUnlock) {
|
||||||
|
html += Globalize.translate('MessageUnlockAppWithSupporter');
|
||||||
|
} else if (info.enableAppUnlock) {
|
||||||
|
html += Globalize.translate('MessageUnlockAppWithPurchase');
|
||||||
|
} else {
|
||||||
|
html += '<span style="color:red;">';
|
||||||
|
html += Globalize.translate('MessagePaymentServicesUnavailable');
|
||||||
|
html += '</span>';
|
||||||
|
}
|
||||||
|
html += '</p>';
|
||||||
|
|
||||||
|
if (info.enableSupporterUnlock) {
|
||||||
|
html += '<p style="margin:2em 0;">';
|
||||||
|
html += Globalize.translate('MessageToValidateSupporter');
|
||||||
|
html += '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.enableAppUnlock) {
|
||||||
|
html += '<p style="margin:2em 0;">';
|
||||||
|
html += Globalize.translate('MessageToValidateSupporter');
|
||||||
|
html += '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.enableAppUnlock) {
|
||||||
|
html += '<button class="btn btnActionAccent btnAppUnlock" data-role="none" type="button"><span>' + Globalize.translate('ButtonUnlockWithPurchase') + '</span><i class="fa fa-check"></i></button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.enableSupporterUnlock) {
|
||||||
|
html += '<button class="btn btnSignInSupporter" data-role="none" type="button"><span>' + Globalize.translate('ButtonUnlockWithSupporter') + '</span><i class="fa fa-check"></i></button>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '<button class="btn btnCancel" data-role="none" type="button"><span>' + Globalize.translate('ButtonCancel') + '</span><i class="fa fa-close"></i></button>';
|
||||||
|
|
||||||
|
html += '</form>';
|
||||||
|
|
||||||
|
html += '</div>';
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
$(document.body).append(html);
|
||||||
|
|
||||||
|
return $('.inAppPurchaseOverlay');
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelInAppPurchase() {
|
||||||
|
|
||||||
|
$('.inAppPurchaseOverlay').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showInAppPurchaseInfo(info, serverRegistrationInfo, deferred) {
|
||||||
|
|
||||||
|
var elem = getInAppPurchaseElement(info);
|
||||||
|
|
||||||
|
$('.inAppPurchaseForm', elem).on('submit', function () {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btnCancel', elem).on('click', function () {
|
||||||
|
cancelInAppPurchase();
|
||||||
|
|
||||||
|
// For testing purposes
|
||||||
|
if (!info.enableSupporterUnlock && !info.enableAppUnlock) {
|
||||||
|
deferred.resolve();
|
||||||
|
} else {
|
||||||
|
deferred.reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.btnSignInSupporter', elem).on('click', function () {
|
||||||
|
|
||||||
|
Dashboard.alert({
|
||||||
|
message: 'MessagePleaseSignInLocalNetwork',
|
||||||
|
callback: function () {
|
||||||
|
cancelInAppPurchase();
|
||||||
|
Dashboard.logout();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.btnAppUnlock', elem).on('click', function () {
|
||||||
|
|
||||||
|
alert('coming soon');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.RegistrationServices = {
|
window.RegistrationServices = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue