mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Some more fixes in the search algorithm
This commit is contained in:
parent
5457ab0f51
commit
ecf48a0d41
@ -76,8 +76,6 @@ define(function (require) {
|
||||
localArchive.findTitlesWithPrefix("Am", callbackFunction);
|
||||
});
|
||||
|
||||
//TODO check findTitlesWithPrefix
|
||||
|
||||
// Create a title instance for the Article 'Abraham'
|
||||
var titleAbraham = new evopedia.Title();
|
||||
titleAbraham.archive = localArchive;
|
||||
@ -89,7 +87,23 @@ define(function (require) {
|
||||
titleAbraham.titleOffset = 57;
|
||||
|
||||
// TODO check parseTitle for Abraham, and for another one with escape characters
|
||||
// TODO check getTitleByName
|
||||
|
||||
asyncTest("check getTitleByName with accents : Diego Velázquez", function() {
|
||||
var callbackFunction = function(titleList) {
|
||||
ok (titleList && titleList.length==1,"One title found");
|
||||
equal(titleList[0].name,"Diego_Velázquez","Name of the title is correct");
|
||||
start();
|
||||
};
|
||||
localArchive.getTitleByName("Diego Velázquez",callbackFunction);
|
||||
});
|
||||
asyncTest("check getTitleByName with quote : Hundred Years' War", function() {
|
||||
var callbackFunction = function(titleList) {
|
||||
ok (titleList && titleList.length==1,"One title found");
|
||||
equal(titleList[0].name,"Hundred_Years'_War","Name of the title is correct");
|
||||
start();
|
||||
};
|
||||
localArchive.getTitleByName("Hundred Years' War",callbackFunction);
|
||||
});
|
||||
|
||||
test("check parseTitleFromId", function() {
|
||||
var titleId = "small|2010-08-14|0|57|Abraham|2364940|127640|10071";
|
||||
|
@ -127,6 +127,8 @@ define(function(require) {
|
||||
*/
|
||||
function populateDropDownListOfTitles(titleList) {
|
||||
var comboTitleList = document.getElementById('titleList');
|
||||
// Remove previous results
|
||||
comboTitleList.options.length = 0;
|
||||
for (var i=0; i<titleList.length; i++) {
|
||||
var title = titleList[i];
|
||||
comboTitleList.options[i] = new Option (title.name, title.toStringId());
|
||||
|
@ -258,10 +258,17 @@ define(function(require) {
|
||||
var currentLocalArchiveInstance = this;
|
||||
var normalizedPrefix = remove_diacritics.normalizeString(prefix).replace(" ","_").toLowerCase();
|
||||
this.recursivePrefixSearch(reader, normalizedPrefix, 0, titleFileSize, function(titleOffset) {
|
||||
// TODO 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) {
|
||||
currentLocalArchiveInstance.getTitlesStartingAtOffset(titleOffset, 50, callbackFunction);
|
||||
currentLocalArchiveInstance.getTitlesStartingAtOffset(titleOffset, 50, function(titleList){
|
||||
var i = 0;
|
||||
for (i=0; i<titleList.length;i++) {
|
||||
var titleName = titleList[i].name;
|
||||
var normalizedTitleName = remove_diacritics.normalizeString(titleName).toLowerCase();
|
||||
if (normalizedTitleName.length<normalizedPrefix.length || normalizedTitleName.substring(0,normalizedPrefix.length)!=normalizedPrefix) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
callbackFunction(titleList.slice(0,i));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user