Automatically launch PWA version if Internet access authorized

Former-commit-id: 16b50df6916087537ae50bb9dcc9598af04a85d0 [formerly 3a1c13f7d549222cc34209b36c4fd479acc35ac3 [formerly bef1bf44afe825732c31754bd33b14394244c5c5]]
Former-commit-id: c52a99ae5274a59ebc8ed1b4fc49fb29249493e1
Former-commit-id: e12450b1a5082e8d01d0843bdf99b2bff937d9ba
This commit is contained in:
Jaifroid 2021-01-30 10:42:55 +00:00
parent 6587cbc927
commit f0043e1e2f
2 changed files with 18 additions and 6 deletions

View File

@ -1556,12 +1556,19 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
goPWA = true;
}
if (goPWA) {
uiUtil.systemAlert(message, 'Warning!', 'Access server', function () {
var launchPWA = function () {
settingsStore.setItem('lastContentInjectionMode', value, Infinity);
params.allowInternetAccess = true;
settingsStore.setItem('allowInternetAccess', params.allowInternetAccess, Infinity);
window.location.href = 'https://kiwix.github.io/kiwix-js-windows/www/index.html?contentInjectionMode=serviceworker';
}, 'Cancel', function () {
};
if (params.allowInternetAccess) {
launchPWA();
} else {
uiUtil.systemAlert(message, 'Warning!', 'Access server', launchPWA, 'Cancel', function () {
document.getElementById('btnConfigure').click();
});
}
} else {
uiUtil.systemAlert(message, 'Information');
}

View File

@ -81,7 +81,11 @@ params['hideActiveContentWarning'] = getSetting('hideActiveContentWarning') != n
params['allowHTMLExtraction'] = getSetting('allowHTMLExtraction') == true;
params['alphaChar'] = getSetting('alphaChar') || 'A'; //Set default start of alphabet string (used by the Archive Index)
params['omegaChar'] = getSetting('omegaChar') || 'Z'; //Set default end of alphabet string
params['contentInjectionMode'] = getSetting('contentInjectionMode') || 'jquery'; //Defaults to jquery mode (widest compatibility)
if (/contentInjectionMode=serviceworker/i.test(window.location.href) && /^http/i.test(window.location.protocol)) {
// We have launched the app from a PWA redirect so set preferred contentInjectionMode (this can be overridden by user below)
params.contentInjectionMode = 'serviceworker';
}
params['contentInjectionMode'] = getSetting('contentInjectionMode') || params.contentInjectionMode || 'jquery'; // Defaults to jquery mode (widest compatibility)
//Do not touch these values unless you know what they do! Some are global variables, some are set programmatically
params['imageDisplayMode'] = params.imageDisplay ? 'progressive' : 'manual';
@ -97,7 +101,7 @@ params['localStorage'] = params['localStorage'] || "";
params['pickedFile'] = launchArguments ? launchArguments.files[0] : "";
params['pickedFolder'] = params['pickedFolder'] || "";
params['themeChanged'] = params['themeChanged'] || false;
params['allowInternetAccess'] = params['allowInternetAccess'] || false; // Do not get value from cookie, should be explicitly set by user on a per-session basis
params['allowInternetAccess'] = getSetting('allowInternetAccess'); // This should only be set by the PWA access permissions box
params['printIntercept'] = false;
params['printInterception'] = false;
params['appIsLaunching'] = true; // Allows some routines to tell if the app has just been launched
@ -126,6 +130,7 @@ if (getSetting('lastPageLoad') === 'failed') {
}
//Initialize checkbox, radio and other values
document.getElementById('allowInternetAccessCheck').checked = params.allowInternetAccess;
document.getElementById('cssCacheModeCheck').checked = params.cssCache;
document.getElementById('imageDisplayModeCheck').checked = params.imageDisplay;
document.getElementById('removePageMaxWidthCheck').checked = params.removePageMaxWidth === true; // Will be false if false or auto