diff --git a/www/js/app.js b/www/js/app.js index a2d6f753..5593300a 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -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=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 diff --git a/www/js/lib/evopedia.js b/www/js/lib/evopedia.js index 37653918..32332e16 100644 --- a/www/js/lib/evopedia.js +++ b/www/js/lib/evopedia.js @@ -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 */