mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-24 04:54:51 -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++;
|
newLineIndex++;
|
||||||
}
|
}
|
||||||
var i = newLineIndex;
|
var i = newLineIndex;
|
||||||
var titleNumber=-1;
|
var titleNumber=0;
|
||||||
var comboTitleList = document.getElementById('titleList');
|
var comboTitleList = document.getElementById('titleList');
|
||||||
while (i<byteArray.length && titleNumber<50) {
|
while (i<byteArray.length && titleNumber<50) {
|
||||||
// Look for the index of the next NewLine
|
// 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);
|
var title = evopedia.Title.parseTitle(encodedTitle, new evopedia.LocalArchive(), i);
|
||||||
|
|
||||||
// Skip the first title
|
// Skip the titles that do not start with the prefix
|
||||||
if (titleNumber>=0 && title) {
|
// TODO use a normalizer to compare the strings
|
||||||
// TODO : check if the title starts with prefix, and return if it does not
|
if (title && title.getReadableName().toLowerCase().indexOf(prefix.toLowerCase())==0) {
|
||||||
comboTitleList.options[titleNumber] = new Option (title.name, title.fileNr + "|" + title.blockStart + "|" + title.blockOffset + "|" + title.articleLength);
|
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;
|
i=newLineIndex+1;
|
||||||
}
|
}
|
||||||
// Update the offsets, as if the first item of the list was selected by the user
|
// Update the offsets, as if the first item of the list was selected by the user
|
||||||
|
@ -39,6 +39,8 @@ define(function(require) {
|
|||||||
function LocalArchive() {
|
function LocalArchive() {
|
||||||
this.directory = null;
|
this.directory = null;
|
||||||
this.titleFile = null;
|
this.titleFile = null;
|
||||||
|
this.date = null;
|
||||||
|
this.language = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,6 +58,10 @@ define(function(require) {
|
|||||||
this.titleEntryLength = null;
|
this.titleEntryLength = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Title.prototype.getReadableName = function() {
|
||||||
|
return this.name.replace("_"," ");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Title instance from an encoded title line from a title file
|
* Creates a Title instance from an encoded title line from a title file
|
||||||
@ -119,6 +125,13 @@ define(function(require) {
|
|||||||
return utf8ByteArrayToString(encodedTitle, 15, len);
|
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
|
* Functions and classes exposed by this module
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user