mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-23 04:28:30 -04:00
Merge branch 'master' of github.com:mossroy/evopedia-html5
This commit is contained in:
commit
16ca75ae47
@ -110,16 +110,18 @@ define(['zimfile', 'zimDirEntry', 'util'],
|
||||
var that = this;
|
||||
util.binarySearch(0, this._file.articleCount, function(i) {
|
||||
return that._file.dirEntryByTitleIndex(i).then(function(dirEntry) {
|
||||
if (dirEntry.title == "")
|
||||
return -1; // ZIM sorts empty titles (assets) to the end
|
||||
return prefix < dirEntry.title ? -1 : 1;
|
||||
});
|
||||
}, true).then(function(firstIndex) {
|
||||
//@todo do not add titles that do not have the right prefix
|
||||
var titles = [];
|
||||
var addTitles = function(index) {
|
||||
if (index >= firstIndex + resultSize || index >= that._file.articleCount)
|
||||
return titles;
|
||||
return that._file.dirEntryByTitleIndex(index).then(function(dirEntry) {
|
||||
titles.push(that._dirEntryToTitleObject(dirEntry));
|
||||
if (dirEntry.title.slice(0, prefix.length) == prefix)
|
||||
titles.push(that._dirEntryToTitleObject(dirEntry));
|
||||
return addTitles(index + 1);
|
||||
});
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user