mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Fixes to make it work again on FxOS, and to keep the new structure compatible with unit tests
+ a few cosmetic modifications
This commit is contained in:
parent
3f7abc7a24
commit
84f5ab62a3
@ -2,12 +2,12 @@
|
||||
"version": "1.1.0-SNAPSHOT",
|
||||
"name": "Evopedia",
|
||||
"description": "Offline Wikipedia Viewer",
|
||||
"launch_path": "/index.html",
|
||||
"launch_path": "/www/index.html",
|
||||
"icons": {
|
||||
"16": "/img/icons/evopedia-16.png",
|
||||
"48": "/img/icons/evopedia-48.png",
|
||||
"60": "/img/icons/evopedia-60.png",
|
||||
"128": "/img/icons/evopedia-128.png"
|
||||
"16": "/www/img/icons/evopedia-16.png",
|
||||
"48": "/www/img/icons/evopedia-48.png",
|
||||
"60": "/www/img/icons/evopedia-60.png",
|
||||
"128": "/www/img/icons/evopedia-128.png"
|
||||
},
|
||||
"developer": {
|
||||
"name": "Mossroy <mossroy@free.fr>",
|
||||
|
@ -33,7 +33,7 @@
|
||||
http://requirejs.org/docs/api.html#jsfiles -->
|
||||
<script type="text/javascript"
|
||||
data-main="tests/init.js"
|
||||
src="js/lib/require.js"></script>
|
||||
src="www/js/lib/require.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
@ -21,7 +21,7 @@
|
||||
* along with Evopedia (file LICENSE-GPLv3.txt). If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
require.config({
|
||||
baseUrl: 'js/lib',
|
||||
baseUrl: 'www/js/lib',
|
||||
paths: {
|
||||
'zepto': 'zepto',
|
||||
'jquery': 'jquery-2.0.3',
|
||||
@ -30,4 +30,4 @@ require.config({
|
||||
}
|
||||
});
|
||||
|
||||
requirejs(['../../tests/tests']);
|
||||
requirejs(['../../../tests/tests']);
|
@ -32,17 +32,21 @@ define(function(require) {
|
||||
var titleIterators = require('titleIterators');
|
||||
|
||||
// Declare the webworker that can uncompress with bzip2 algorithm
|
||||
var webworkerBzip2 = new Worker("js/lib/webworker_bzip2.js");
|
||||
var webworkerBzip2;
|
||||
try {
|
||||
// When using the application normally
|
||||
webworkerBzip2 = new Worker("js/lib/webworker_bzip2.js");
|
||||
}
|
||||
catch(e) {
|
||||
// When using unit tests
|
||||
webworkerBzip2 = new Worker("www/js/lib/webworker_bzip2.js");
|
||||
}
|
||||
|
||||
// Size of chunks read in the dump files : 128 KB
|
||||
var CHUNK_SIZE = 131072;
|
||||
// The maximum number of titles that can have the same name after normalizing
|
||||
// This is used by the algorithm that searches for a specific article by its name
|
||||
var MAX_TITLES_WITH_SAME_NORMALIZED_NAME = 30;
|
||||
// Maximum length of a title
|
||||
// 300 bytes is arbitrary : we actually do not really know how long the titles will be
|
||||
// But mediawiki titles seem to be limited to ~200 bytes, so 300 should be more than enough
|
||||
var MAX_TITLE_LENGTH = 300;
|
||||
// A rectangle representing all the earth globe
|
||||
var GLOBE_RECTANGLE = new geometry.rect(-181, -90, 361, 181);
|
||||
|
||||
@ -313,14 +317,15 @@ define(function(require) {
|
||||
*/
|
||||
LocalArchive.prototype.getTitlesStartingAtOffset = function(titleOffset, titleCount, callbackFunction) {
|
||||
var titles = [];
|
||||
var currentLocalArchiveInstance = this;
|
||||
jQuery.when().then(function() {
|
||||
var iterator = new titleIterators.SequentialTitleIterator(this, titleOffset);
|
||||
var iterator = new titleIterators.SequentialTitleIterator(currentLocalArchiveInstance, titleOffset);
|
||||
function addNext() {
|
||||
if (titles.length >= titleCount) {
|
||||
return titles;
|
||||
}
|
||||
return iterator.advance().then(function(title) {
|
||||
if (title == null)
|
||||
if (title === null)
|
||||
return titles;
|
||||
titles.push(title);
|
||||
return addNext();
|
||||
|
@ -30,13 +30,15 @@ define(['utf8', 'title', 'util', 'jquery'], function(utf8, evopediaTitle, util,
|
||||
* Iterates over all titles starting at the given offset.
|
||||
* The asynchronous method advance has to be called before this.title is
|
||||
* valid.
|
||||
* @param archive
|
||||
* @param offset
|
||||
*/
|
||||
function SequentialTitleIterator(archive, offset) {
|
||||
this._titleFile = archive.titleFile;
|
||||
this._archive = archive;
|
||||
this._offset = offset;
|
||||
this.title = null;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Advances to the next title (or the first), if possible.
|
||||
* @returns jQuery promise containing the next title or null if there is no
|
||||
@ -59,12 +61,15 @@ define(['utf8', 'title', 'util', 'jquery'], function(utf8, evopediaTitle, util,
|
||||
that._offset += newLineIndex + 1;
|
||||
return that._title;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Searches for the offset into the given title file where the first title
|
||||
* with the given prefix (or lexicographically larger) is located.
|
||||
* The given function normalize is applied to every title before comparison.
|
||||
* @param titleFile
|
||||
* @param prefix
|
||||
* @param normalize function to be applied to every title before comparison
|
||||
* @returns jQuery promise giving the offset
|
||||
*/
|
||||
function FindPrefixOffset(titleFile, prefix, normalize) {
|
||||
@ -107,7 +112,7 @@ define(['utf8', 'title', 'util', 'jquery'], function(utf8, evopediaTitle, util,
|
||||
return iterate();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return iterate();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user