mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-24 04:54:51 -04:00
Keep the last selected archive in a cookie, when DeviceStorage is enabled
Fixes #50
This commit is contained in:
parent
f4e0ee33c4
commit
7335e8b98c
14
js/app.js
14
js/app.js
@ -148,11 +148,16 @@ define(function(require) {
|
||||
}
|
||||
$('#archiveList').on('change', setLocalArchiveFromArchiveList);
|
||||
if (archiveDirectories.length > 0) {
|
||||
// Set the localArchive from the first result
|
||||
var lastSelectedArchive = cookies.getItem("lastSelectedArchive");
|
||||
if (lastSelectedArchive) {
|
||||
// Attempt to select the corresponding item in the list
|
||||
$("#archiveList").val(lastSelectedArchive);
|
||||
}
|
||||
// Set the localArchive as the last selected (or the first one if it has never been selected)
|
||||
setLocalArchiveFromArchiveList();
|
||||
}
|
||||
else {
|
||||
alert("No Evopedia archive found in your sdcard. Please see 'About' for more info");
|
||||
alert("No Evopedia archive found in your sdcard. Please see 'About' for more info. Also check that your device is not connected to a computer through USB device storage (which locks the sdcard content)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,6 +168,7 @@ define(function(require) {
|
||||
var archiveDirectory = $('#archiveList').val();
|
||||
localArchive = new evopediaArchive.LocalArchive();
|
||||
localArchive.initializeFromDeviceStorage(storage, archiveDirectory);
|
||||
cookies.setItem("lastSelectedArchive",archiveDirectory,Infinity);
|
||||
// The archive is set : go back to home page to start searching
|
||||
$("#btnHome").click();
|
||||
}
|
||||
@ -252,12 +258,12 @@ define(function(require) {
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function handleTitleClick(event) {
|
||||
if (localArchive.language === "small" && !cookies.getItem("warned_small_archive")) {
|
||||
if (localArchive.language === "small" && !cookies.getItem("warnedSmallArchive")) {
|
||||
// The user selected the "small" archive, which is quite incomplete
|
||||
// So let's display a warning to the user
|
||||
alert("You selected the 'small' archive. This archive is OK for testing, but be aware that very few hyperlinks in the articles will work because it's only a very small subset of the English dump.");
|
||||
// We will not display this warning again for one day
|
||||
cookies.setItem("warned_small_archive",true,86400);
|
||||
cookies.setItem("warnedSmallArchive",true,86400);
|
||||
}
|
||||
|
||||
var titleId = event.target.getAttribute("titleId");
|
||||
|
Loading…
x
Reference in New Issue
Block a user