diff --git a/KiwixWebApp.jsproj b/KiwixWebApp.jsproj
index eb25890f..557a85d1 100644
--- a/KiwixWebApp.jsproj
+++ b/KiwixWebApp.jsproj
@@ -60,7 +60,7 @@
We could not find the archive ' + lastSelectedArchive + '!
Please select its location...
'; - if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') - message += 'Note: If you drag-drop an archive into this UWP app, then it will have to be dragged again each time you launch the app. Try double-clicking on the archive instead, or select it using the controls on this page.
'; - document.getElementById('alert-content').innerHTML = message; - $('#alertModal').off('hide.bs.modal'); - $('#alertModal').on('hide.bs.modal', function () { - displayFileSelect(); - }); - $('#alertModal').modal({ - backdrop: 'static', - keyboard: true - }); - if (document.getElementById('configuration').style.display == 'none') - document.getElementById('btnConfigure').click(); + // We can't find lastSelectedArchive in the archive list + // Let's first check if this is a Store UWP/PWA that has a different archive package from that indicated in init.js + if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined' && + params.storedFile === params.packagedFile && cookies.getItem('lastSelectedArchive') !== params.storedFile) { + // We didn't pick this file previously, so select first one in list + params.fileVersion = archiveDirectories[0]; + params.packagedFile = params.fileVersion; + params.storedFile = params.fileVersion; + setLocalArchiveFromArchiveList(params.fileVersion); + } else { + // It's genuinely no longer available, so let's ask the user to pick it + var message = 'We could not find the archive ' + lastSelectedArchive + '!
Please select its location...
'; + if (typeof Windows !== 'undefined' && typeof Windows.Storage !== 'undefined') + message += 'Note: If you drag-drop an archive into this UWP app, then it will have to be dragged again each time you launch the app. Try double-clicking on the archive instead, or select it using the controls on this page.
'; + document.getElementById('alert-content').innerHTML = message; + $('#alertModal').off('hide.bs.modal'); + $('#alertModal').on('hide.bs.modal', function () { + displayFileSelect(); + }); + $('#alertModal').modal({ + backdrop: 'static', + keyboard: true + }); + if (document.getElementById('configuration').style.display == 'none') + document.getElementById('btnConfigure').click(); + } } } } else { @@ -2013,6 +2030,9 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'utf8', 'images', 'cooki function loadPackagedArchive() { // Reload any ZIM files in local storage (whcih the user can't otherwise select with the filepicker) if (params.localStorage) { + // Reset params.packagedFile to its original value, in case we manipulated it previously + params.packagedFile = params.originalPackagedFile; + params.pickedFile = ''; params.storedFile = params.packagedFile || ''; params.pickedFolder = params.localStorage; scanUWPFolderforArchives(params.localStorage); diff --git a/www/js/init.js b/www/js/init.js index c03eb605..652b96d1 100644 --- a/www/js/init.js +++ b/www/js/init.js @@ -33,7 +33,7 @@ var state = {}; var params = {}; params['version'] = "0.9.9.97 Beta"; //DEV: This value is compared to the cookie "version" in order to show first-time info, and the cookie is updated in app.js params['packagedFile'] = "wikipedia_en_ray_charles.zim"; //For packaged Kiwix JS (e.g. with Wikivoyage file), set this to the filename (for split files, give the first chunk *.zimaa) and place file(s) in default storage -params['archivePath'] = "archive"; //The directory containing the packaged archive(s) (relative to app's root directory) +params['archivePath'] = "archives"; //The directory containing the packaged archive(s) (relative to app's root directory) params['fileVersion'] = "wikipedia_en_ray_charles_maxi_2019-08.zim (14-Aug-2019)"; //Use generic name for actual file, and give version here params['cachedStartPage'] = false; //If you have cached the start page for quick start, give its URI here params['kiwixDownloadLink'] = "https://download.kiwix.org/zim/"; //Include final slash @@ -66,7 +66,8 @@ params['storedFile'] = getCookie('lastSelectedArchive') || params['packagedFile' params.storedFile = launchArguments ? launchArguments.files[0].name : params.storedFile; params['storedFilePath'] = getCookie('lastSelectedArchivePath'); params.storedFilePath = params.storedFilePath ? decodeURIComponent(params.storedFilePath) : params.archivePath + '/' + params.packagedFile; -params.storedFilePath = launchArguments ? launchArguments.files[0].path || '' : params.storedFilePath; +params.storedFilePath = launchArguments ? launchArguments.files[0].path || '' : params.storedFilePath; +params.originalPackagedFile = params.packagedFile; params['falFileToken'] = params['falFileToken'] || "zimfile"; //UWP support params['falFolderToken'] = params['falFolderToken'] || "zimfilestore"; //UWP support params['localStorage'] = params['localStorage'] || ""; @@ -125,33 +126,21 @@ document.getElementById('hideToolbarsCheck').indeterminate = params.hideToolbars document.getElementById('hideToolbarsCheck').readOnly = params.hideToolbars === "top"; document.getElementById('hideToolbarsState').innerHTML = (params.hideToolbars === "top" ? "top" : params.hideToolbars ? "both" : "never"); -var versionSpans = document.getElementsByClassName('version'); -for (var i = 0; i < versionSpans.length; i++) { - versionSpans[i].innerHTML = i ? params.version : params.version.replace(/\s+.*$/, ""); -} -var fileVersionDivs = document.getElementsByClassName('fileVersion'); -for (i = 0; i < fileVersionDivs.length; i++) { - fileVersionDivs[i].innerHTML = i ? params.fileVersion.replace(/\s+.+$/, "") : params.fileVersion; -} -document.getElementById('logUpdate').innerHTML = document.getElementById('update').innerHTML.match(/