mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Filter article names that really start with the prefix (has to be improved with a normalizer before comparing strings)
This commit is contained in:
parent
66e42247ff
commit
6c5020b42a
@ -245,7 +245,7 @@ function readTitlesBeginningAtIndexStartingWithPrefix(titleFile,prefix,startInde
|
||||
newLineIndex++;
|
||||
}
|
||||
var i = newLineIndex;
|
||||
var titleNumber=-1;
|
||||
var titleNumber=0;
|
||||
var comboTitleList = document.getElementById('titleList');
|
||||
while (i<byteArray.length && titleNumber<50) {
|
||||
// Look for the index of the next NewLine
|
||||
@ -262,13 +262,13 @@ function readTitlesBeginningAtIndexStartingWithPrefix(titleFile,prefix,startInde
|
||||
|
||||
var title = evopedia.Title.parseTitle(encodedTitle, new evopedia.LocalArchive(), i);
|
||||
|
||||
// Skip the first title
|
||||
if (titleNumber>=0 && title) {
|
||||
// TODO : check if the title starts with prefix, and return if it does not
|
||||
// Skip the titles that do not start with the prefix
|
||||
// TODO use a normalizer to compare the strings
|
||||
if (title && title.getReadableName().toLowerCase().indexOf(prefix.toLowerCase())==0) {
|
||||
comboTitleList.options[titleNumber] = new Option (title.name, title.fileNr + "|" + title.blockStart + "|" + title.blockOffset + "|" + title.articleLength);
|
||||
debug("Title : startIndex = " + i + " endIndex = " + newLineIndex + " title.name = " + title.name + " title.fileNr = " + title.fileNr + " title.blockStart = " + title.blockStart + " title.blockOffset = " + title.blockOffset + " title.articleLength = " + title.articleLength);
|
||||
debug("Title : startIndex = " + i + " endIndex = " + newLineIndex + title.toString());
|
||||
titleNumber++;
|
||||
}
|
||||
titleNumber++;
|
||||
i=newLineIndex+1;
|
||||
}
|
||||
// Update the offsets, as if the first item of the list was selected by the user
|
||||
|
@ -38,7 +38,9 @@ define(function(require) {
|
||||
*/
|
||||
function LocalArchive() {
|
||||
this.directory = null;
|
||||
this.titleFile = null;
|
||||
this.titleFile = null;
|
||||
this.date = null;
|
||||
this.language = null;
|
||||
}
|
||||
|
||||
|
||||
@ -55,6 +57,10 @@ define(function(require) {
|
||||
this.titleOffset = null;
|
||||
this.titleEntryLength = null;
|
||||
};
|
||||
|
||||
Title.prototype.getReadableName = function() {
|
||||
return this.name.replace("_"," ");
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@ -119,6 +125,13 @@ define(function(require) {
|
||||
return utf8ByteArrayToString(encodedTitle, 15, len);
|
||||
};
|
||||
|
||||
Title.prototype.toStringId = function(){
|
||||
return this.archive.language + "_" + this.archive.date + "_" + this.titleOffset;
|
||||
};
|
||||
Title.prototype.toString = function(){
|
||||
return "title.id = " + this.toStringId() + "title.name = " + this.name + " title.fileNr = " + this.fileNr + " title.blockStart = " + this.blockStart + " title.blockOffset = " + this.blockOffset + " title.articleLength = " + this.articleLength;
|
||||
};
|
||||
|
||||
/**
|
||||
* Functions and classes exposed by this module
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user