mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-23 12:36:21 -04:00
Let the user choose the archive he wants to use, among the ones found on
the sdcard
This commit is contained in:
parent
9eb9e9c01a
commit
69256e089c
@ -42,20 +42,17 @@ License:
|
||||
|
||||
<h1>Evopedia</h1>
|
||||
<input type="button" id="showHideAbout" value="About" />
|
||||
<div id="about">
|
||||
<div id="about" style="display: none;">
|
||||
This is a preliminary work on the port of Evopedia (offline wikipedia reader) in HTML5/Javascript, with Firefox OS as the primary target
|
||||
<br />
|
||||
The original application is at <a href="http://www.evopedia.info/">http://www.evopedia.info/</a>
|
||||
<br />
|
||||
<br />
|
||||
To use it, you have to first download locally a dump from <a href="http://dumpathome.evopedia.info/dumps/finished">http://dumpathome.evopedia.info/dumps/finished</a> (with a Bittorrent client), and select some of the dowloaded files below.
|
||||
<br />
|
||||
I have tested it with the <a href="http://evopedia.info/dumps/wikipedia_small_2010-08-14.torrent">small dump (2010-08-14)</a>, the <a href="http://evopedia.info/dumps/wikipedia_fr_2013-02-16.torrent">French dump (2013-02-16)</a>, the <a href="http://evopedia.info/dumps/wikipedia_frwiktionary_2011-03-16.torrent">French wiktionary dump (2011-03-16)</a> and the <a href="http://evopedia.info/dumps/wikipedia_en_2012-02-11.torrent">English dump (2012-02-11)</a>
|
||||
<br />
|
||||
To use it, you have to first download locally a dump from <a href="http://dumpathome.evopedia.info/dumps/finished">http://dumpathome.evopedia.info/dumps/finished</a> (with a Bittorrent client).
|
||||
<br />
|
||||
<ul>
|
||||
<li>On desktops, it works on recent Firefox and Chrome, and maybe on other browsers</li>
|
||||
<li>On the Firefos OS simulator, you have to put the archive files in a "fake-sdcard/evopedia" folder of your firefox profile (ex : ~/.mozilla/firefox/xxxx.default/extensions/r2d2b2g@mozilla.org/profile/fake-sdcard). It looks for evopedia/*/titles.idx in it. You also need to install the application from the dashboard of the simulator instead of accessing via the browser (due to security restrictions in Firefox OS : only certified webapps can access the sdcard)</li>
|
||||
<li>On desktops, it works on recent Firefox and Chrome, and maybe on other browsers. In this case, you have to select manually some files from your dump</li>
|
||||
<li>On the Firefos OS simulator, you have to put the archive files in a "fake-sdcard/evopedia" folder of your firefox profile (ex : ~/.mozilla/firefox/xxxx.default/extensions/r2d2b2g@mozilla.org/profile/fake-sdcard). It looks for evopedia/*/titles.idx in it. You need to install the application from the dashboard of the simulator (due to security restrictions in Firefox OS : only certified webapps can access the sdcard)</li>
|
||||
<li>On a real Firefox OS device, you also have to put the archive files in an "evopedia" directory at the root of your sdcard, so that it finds a file /evopedia/*/titles.idx on it</li>
|
||||
</ul>
|
||||
<br />
|
||||
@ -64,7 +61,6 @@ License:
|
||||
<li>The performance has to be optimized when reading an article</li>
|
||||
<li>Some searches (for example with prefix "a" on the French dump) do not give any result even if they should</li>
|
||||
<li>In some cases, the links inside an article do not work, or do not lead to the right article</li>
|
||||
<li>On a real device, reading an article sometimes crashes because it loads too many things in memory</li>
|
||||
<li>It is hardly usable on a device because the buttons and inputs are too small</li>
|
||||
</ul>
|
||||
<br />
|
||||
@ -74,6 +70,12 @@ License:
|
||||
id="titleFile" /><br /> Please select the files wikipedia_*.dat
|
||||
from the same dump :<br /> <input type="file" id="dataFiles" multiple />
|
||||
</div>
|
||||
<div id="scanningForArchives" style="display: none;">
|
||||
<br /> Scanning your sdcard for archives... Please wait
|
||||
</div>
|
||||
<div id="chooseArchiveFromLocalStorage" style="display: none;">
|
||||
<br /> Please select the archive you want to use : <select id="archiveList"></select>
|
||||
</div>
|
||||
<br /> Find titles starting with :
|
||||
<input type="text" id="prefix" value="" />
|
||||
<input type="button" id="searchTitles" value="Search titles" />
|
||||
|
@ -50,8 +50,9 @@ define(function(require) {
|
||||
|
||||
if (storage != null) {
|
||||
// If DeviceStorage is available, we look for archives in it
|
||||
$('#scanningForArchives').show();
|
||||
var directory = 'evopedia';
|
||||
evopedia.LocalArchive.scanForArchives(storage,directory,selectFirstArchive);
|
||||
evopedia.LocalArchive.scanForArchives(storage,directory,populateDropDownListOfArchives);
|
||||
}
|
||||
else {
|
||||
// If DeviceStorage is not available, we display the file select components
|
||||
@ -66,12 +67,35 @@ define(function(require) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Selects the first archive found on device storage
|
||||
* Populate the drop-down list of titles with the given list
|
||||
*/
|
||||
function selectFirstArchive(archiveDirectories) {
|
||||
function populateDropDownListOfArchives(archiveDirectories) {
|
||||
$('#scanningForArchives').hide();
|
||||
$('#chooseArchiveFromLocalStorage').show();
|
||||
var comboArchiveList = document.getElementById('archiveList');
|
||||
comboArchiveList.options.length = 0;
|
||||
for (var i=0; i<archiveDirectories.length; i++) {
|
||||
var archiveDirectory = archiveDirectories[i];
|
||||
comboArchiveList.options[i] = new Option (archiveDirectory, archiveDirectory);
|
||||
}
|
||||
$('#archiveList').on('change', setLocalArchiveFromArchiveList);
|
||||
if (archiveDirectories.length>0) {
|
||||
// Set the localArchive from the first result
|
||||
setLocalArchiveFromArchiveList();
|
||||
}
|
||||
else {
|
||||
alert("No Evopedia archive found in your sdcard. Please see 'About' for more info");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the localArchive from the selected archive in the drop-down list
|
||||
*/
|
||||
function setLocalArchiveFromArchiveList() {
|
||||
var archiveDirectory = $('#archiveList').val();
|
||||
localArchive = new evopedia.LocalArchive();
|
||||
localArchive.readTitleFile(storage, archiveDirectories[0]);
|
||||
localArchive.readDataFiles(storage, archiveDirectories[0], 0);
|
||||
localArchive.readTitleFile(storage, archiveDirectory);
|
||||
localArchive.readDataFiles(storage, archiveDirectory, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,6 +107,9 @@ define(function(require) {
|
||||
$('#titleFile').on('change', setLocalArchiveFromFileSelect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the localArchive from the File selects populated by user
|
||||
*/
|
||||
function setLocalArchiveFromFileSelect() {
|
||||
dataFiles=document.getElementById('dataFiles').files;
|
||||
titleFile=document.getElementById('titleFile').files[0];
|
||||
|
@ -445,7 +445,6 @@ define(function(require) {
|
||||
|
||||
// We want to return the directory where titles.idx is stored
|
||||
var directory = fileName.substring(0, fileName.lastIndexOf('/'));
|
||||
console.log(directory);
|
||||
directories.push(directory);
|
||||
cursor.continue();
|
||||
}
|
||||
@ -455,12 +454,17 @@ define(function(require) {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility function : return true if the given string ends with the suffix
|
||||
* @param str
|
||||
* @param suffix
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function endsWith(str, suffix) {
|
||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Title class : defines the title of an article and some methods to manipulate it
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user