Finesse update UI

Former-commit-id: 70fd8157f9c57e442f13bbd5a214ac24b023f137 [formerly ad22beb69aba82ee7aeacf217fd8dc453d3c6f70 [formerly 5b498658350c906284e6cd90ce852b27b6e44c5c]]
Former-commit-id: 09254c74995e891eddac4d029360fc6bfe2b9b6d [formerly 6bee3287991cc7a0e73c42b4dd9b24cf4917b19e]
Former-commit-id: 62e34ca29085aeebf59e719ecb09c12a62d6034e
This commit is contained in:
Jaifroid 2022-06-05 20:55:06 +01:00
parent 0afca34ce8
commit 2d9618acb3
2 changed files with 24 additions and 12 deletions

View File

@ -657,13 +657,14 @@
<h2 style="margin-top:0;">Configuration</h2> <h2 style="margin-top:0;">Configuration</h2>
<div id="alertBoxPersistent"></div> <div id="alertBoxPersistent"></div>
<p id="usage" style="margin: 1em auto 1em;">For <b>instructions</b> and <b>usage guide</b>, please see the <a href="#" class="aboutLink"><b>About tab</b> <span class="glyphicon glyphicon-info-sign"></span></a> (top right).</p> <p id="usage" style="margin: 1em auto 1em;">For <b>instructions</b> and <b>usage guide</b>, please see the <a href="#" class="aboutLink"><b>About tab</b> <span class="glyphicon glyphicon-info-sign"></span></a> (top right).</p>
<p>App version: <b><span class="version"></span></b> <span id="updateCheck">[<a class="unhideLibrary" href="#btnRescanDeviceStorage">check for updates</a>]</span> </p>
<p class="packagedInfo" style="display: none; margin-top: 1em;"> <p class="packagedInfo" style="display: none; margin-top: 1em;">
Packaged ZIM archive: <b><span class="fileVersion"></span></b> Packaged ZIM archive: <b><span class="fileVersion"></span></b>
<button style="display:none;" id="reloadPackagedArchive" type="button" class="btn btn-primary btn-xs">Reload</button> <button style="display:none;" id="reloadPackagedArchive" type="button" class="btn btn-primary btn-xs">Reload</button>
</p> </p>
<p id="currentArchive" style="display: none;"></p> <p id="currentArchive" style="display: none;"></p>
<p id="downloadLinksText"> <p id="downloadLinksText">
<a id="otherLangs" href="#btnRescanDeviceStorage"><i>Download more archives from the <b>Archive Library</b>.</i></a> <a class="unhideLibrary" href="#btnRescanDeviceStorage"><i>Download more archives from the <b>Archive Library</b>.</i></a>
</p> </p>
<p></p> <p></p>
</div> </div>
@ -739,7 +740,7 @@
<label class="checkbox"> <label class="checkbox">
<input type="checkbox" name="allowInternetAccess" id="allowInternetAccessCheck"> <input type="checkbox" name="allowInternetAccess" id="allowInternetAccessCheck">
<span class="checkmark"></span> <span class="checkmark"></span>
<b>Allow Internet access?</b> <span id="updateStatus">(and check for updates)</span> <b>Allow Internet access?</b> <span id="updateStatus">and <b>check for updates</b></span>
</label> </label>
</div> </div>
<div id="downloadLinks" style="display: none;"></div> <div id="downloadLinks" style="display: none;"></div>

View File

@ -837,7 +837,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
} }
} }
// Check for upgrade of PWA // Check for upgrade of PWA
if (!params.upgradeNeeded && /PWA/.test(params.appType) && activeBtn === 'btnConfigure') { if (!params.upgradeNeeded && /^(?!.*Electron).*PWA/.test(params.appType) && activeBtn === 'btnConfigure') {
caches.keys().then(function (keyList) { caches.keys().then(function (keyList) {
var cachePrefix = cache.APPCACHE.replace(/^([^\d]+).+/, '$1'); var cachePrefix = cache.APPCACHE.replace(/^([^\d]+).+/, '$1');
document.getElementById('alertBoxPersistent').innerHTML = ''; document.getElementById('alertBoxPersistent').innerHTML = '';
@ -867,6 +867,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
} }
// Check for GitHub and Electron updates // Check for GitHub and Electron updates
var updateCheck = document.getElementById('updateCheck');
if (params.allowInternetAccess) updateCheck.style.display = 'none';
function checkUpdateServer() { function checkUpdateServer() {
if (!params.allowInternetAccess) { if (!params.allowInternetAccess) {
console.log("The update check was blocked because the user has not allowed Internet access.") console.log("The update check was blocked because the user has not allowed Internet access.")
@ -882,7 +884,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
updater.getLatestUpdates(function (tag, url, releases) { updater.getLatestUpdates(function (tag, url, releases) {
var updateSpan = document.getElementById('updateStatus'); var updateSpan = document.getElementById('updateStatus');
if (!tag) { if (!tag) {
updateSpan.innerHTML = '[ <b><i>App is up to date</i></b> ]'; var upToDate = '[&nbsp;<b><i>Latest&nbsp;version</i></b>&nbsp;]';
updateCheck.style.display = 'inline';
updateCheck.innerHTML = upToDate;
updateSpan.innerHTML = upToDate;
console.log('No new update was found.'); console.log('No new update was found.');
return; return;
} }
@ -1233,6 +1238,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
checkUpdateServer(); checkUpdateServer();
} }
settingsStore.setItem('allowInternetAccess', params.allowInternetAccess, Infinity); settingsStore.setItem('allowInternetAccess', params.allowInternetAccess, Infinity);
library.style.borderColor = '';
library.style.borderStyle = '';
}); });
$('input:checkbox[name=cssCacheMode]').on('change', function (e) { $('input:checkbox[name=cssCacheMode]').on('change', function (e) {
params.cssCache = this.checked ? true : false; params.cssCache = this.checked ? true : false;
@ -1806,16 +1813,20 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'cache', 'images
settingsStore.setItem('useMathJax', params.useMathJax, Infinity); settingsStore.setItem('useMathJax', params.useMathJax, Infinity);
params.themeChanged = true; params.themeChanged = true;
}); });
document.getElementById('otherLangs').addEventListener('click', function () { var library = document.getElementById('libraryArea');
if (!params.showFileSelectors) document.getElementById('displayFileSelectorsCheck').click(); var unhideArchiveLibraryAnchors = document.getElementsByClassName("unhideLibrary");
var library = document.getElementById('libraryArea'); for (var i = 0; i < unhideArchiveLibraryAnchors.length; i++) {
library.style.borderColor = 'red'; unhideArchiveLibraryAnchors[i].addEventListener('click', function () {
library.style.borderStyle = 'solid'; if (!params.showFileSelectors) document.getElementById('displayFileSelectorsCheck').click();
document.getElementById('downloadTrigger').addEventListener('mousedown', function () { library.style.borderColor = 'red';
library.style.borderColor = ''; library.style.borderStyle = 'solid';
library.style.borderStyle = '';
}); });
}
document.getElementById('downloadTrigger').addEventListener('mousedown', function () {
library.style.borderColor = '';
library.style.borderStyle = '';
}); });
$('input:checkbox[name=displayFileSelectors]').on('change', function (e) { $('input:checkbox[name=displayFileSelectors]').on('change', function (e) {
params.showFileSelectors = this.checked ? true : false; params.showFileSelectors = this.checked ? true : false;
document.getElementById('rescanStorage').style.display = "block"; document.getElementById('rescanStorage').style.display = "block";