Prefix private variables with an underscore. Fixes #72

This commit is contained in:
mossroy 2014-03-21 13:46:57 +01:00
parent 2d4e949367
commit 9e9d9ea45b
5 changed files with 1639 additions and 1640 deletions

View File

@ -58,7 +58,7 @@ define(function(require) {
equal(titleList.length, 4, "4 titles found, as requested");
var indexAbraham = -1;
for (var i = 0; i < titleList.length; i++) {
if (titleList[i] && titleList[i].name === "Abraham") {
if (titleList[i] && titleList[i]._name === "Abraham") {
indexAbraham = i;
}
}
@ -66,10 +66,10 @@ define(function(require) {
var firstTitleName = "not found";
var secondTitleName = "not found";
if (titleList.length >= 1 && titleList[0]) {
firstTitleName = titleList[0].name;
firstTitleName = titleList[0]._name;
}
if (titleList.length >= 2 && titleList[1]) {
secondTitleName = titleList[1].name;
secondTitleName = titleList[1]._name;
}
equal(firstTitleName, "Abbasid_Caliphate", "First article name is 'Abbasid_Caliphate'");
equal(secondTitleName, "Abortion", "Second article name is 'Abortion'");
@ -85,10 +85,10 @@ define(function(require) {
var firstTitleName = "not found";
var secondTitleName = "not found";
if (titleList.length >= 1 && titleList[0]) {
firstTitleName = titleList[0].name;
firstTitleName = titleList[0]._name;
}
if (titleList.length >= 2 && titleList[1]) {
secondTitleName = titleList[1].name;
secondTitleName = titleList[1]._name;
}
equal(firstTitleName, "Amazon_River", "First article name is 'Amazon_River'");
equal(secondTitleName, "American_Civil_War", "Second article name is 'American_Civil_War'");
@ -100,19 +100,19 @@ define(function(require) {
// Create a title instance for the Article 'Abraham'
var titleAbraham = new evopediaTitle.Title();
titleAbraham.archive = localArchive;
titleAbraham.articleLength = 10071;
titleAbraham.blockOffset = 127640;
titleAbraham.blockStart = 2364940;
titleAbraham.fileNr = 0;
titleAbraham.name = "Abraham";
titleAbraham.titleOffset = 57;
titleAbraham._archive = localArchive;
titleAbraham._articleLength = 10071;
titleAbraham._blockOffset = 127640;
titleAbraham._blockStart = 2364940;
titleAbraham._fileNr = 0;
titleAbraham._name = "Abraham";
titleAbraham._titleOffset = 57;
asyncTest("check getTitleByName with accents : Diego Velázquez", function() {
expect(2);
var callbackFunction = function(title) {
ok(title !== null, "Title found");
equal(title.name, "Diego_Velázquez", "Name of the title is correct");
equal(title._name, "Diego_Velázquez", "Name of the title is correct");
start();
};
localArchive.getTitleByName("Diego_Velázquez", callbackFunction);
@ -121,7 +121,7 @@ define(function(require) {
expect(2);
var callbackFunction = function(title) {
ok(title !== null, "Title found");
equal(title.name, "Hundred_Years'_War", "Name of the title is correct");
equal(title._name, "Hundred_Years'_War", "Name of the title is correct");
start();
};
localArchive.getTitleByName("Hundred_Years'_War", callbackFunction);
@ -159,7 +159,7 @@ define(function(require) {
};
var callbackTitleFound = function(title) {
ok(title !== null, "Title found");
equal(title.name, "AIDS", "Name of the title is correct");
equal(title._name, "AIDS", "Name of the title is correct");
localArchive.readArticle(title, callbackArticleRead);
};
localArchive.getTitleByName("AIDS", callbackTitleFound);
@ -308,13 +308,13 @@ define(function(require) {
var titleAlps = null;
for (var i=0; i<titleList.length; i++) {
var title = titleList[i];
if (title.name === "Danube") {
if (title._name === "Danube") {
titleDanube = title;
}
else if (title.name === "Paris") {
else if (title._name === "Paris") {
titleParis = title;
}
else if (title.name === "Alps") {
else if (title._name === "Alps") {
titleAlps = title;
}
}
@ -348,7 +348,7 @@ define(function(require) {
var titleLondon = null;
for (var i=0; i<titleList.length; i++) {
var title = titleList[i];
if (title.name === "London") {
if (title._name === "London") {
titleLondon = title;
}
}
@ -374,7 +374,7 @@ define(function(require) {
var titleAmsterdam = null;
for (var i=0; i<titleList.length; i++) {
var title = titleList[i];
if (title.name === "Amsterdam") {
if (title._name === "Amsterdam") {
titleAmsterdam = title;
}
}
@ -397,7 +397,7 @@ define(function(require) {
expect(2);
var callbackRandomTitleFound = function(title) {
ok(title !== null, "One title should be found");
ok(title.name !== null, "The random title should have a name" );
ok(title._name !== null, "The random title should have a name" );
start();
};

View File

@ -62,7 +62,7 @@ define(function(require) {
return false;
});
$('#prefix').on('keyup', function(e) {
if (localArchive !== null && localArchive.titleFile !== null) {
if (localArchive !== null && localArchive._titleFile !== null) {
onKeyUpPrefix(e);
$('#geolocationProgress').hide();
}
@ -322,7 +322,7 @@ define(function(require) {
$('#searchingForTitles').show();
$('#configuration').hide();
$('#articleContent').empty();
if (localArchive !== null && localArchive.titleFile !== null) {
if (localArchive !== null && localArchive._titleFile !== null) {
localArchive.findTitlesWithPrefix(prefix.trim(), MAX_SEARCH_RESULT_SIZE, populateListOfTitles);
} else {
$('#searchingForTitles').hide();
@ -404,7 +404,7 @@ define(function(require) {
$("#titleList").empty();
findTitleFromTitleIdAndLaunchArticleRead(titleId);
var title = evopediaTitle.Title.parseTitleId(localArchive, titleId);
pushBrowserHistoryState(title.name);
pushBrowserHistoryState(title._name);
$("#prefix").val("");
return false;
}
@ -416,12 +416,12 @@ define(function(require) {
* @param {type} titleId
*/
function findTitleFromTitleIdAndLaunchArticleRead(titleId) {
if (localArchive.dataFiles && localArchive.dataFiles.length > 0) {
if (localArchive._dataFiles && localArchive._dataFiles.length > 0) {
var title = evopediaTitle.Title.parseTitleId(localArchive, titleId);
$("#articleName").html(title.name);
$("#articleName").html(title._name);
$("#readingArticle").show();
$("#articleContent").html("");
if (title.fileNr === 255) {
if (title._fileNr === 255) {
localArchive.resolveRedirect(title, readArticle);
}
else {
@ -438,7 +438,7 @@ define(function(require) {
* @param {type} title
*/
function readArticle(title) {
if (title.fileNr === 255) {
if (title._fileNr === 255) {
localArchive.resolveRedirect(title, readArticle);
}
else {
@ -571,7 +571,7 @@ define(function(require) {
$('#configuration').hide();
$('#titleList').hide();
$('#articleContent').empty();
if (localArchive !== null && localArchive.titleFile !== null) {
if (localArchive !== null && localArchive._titleFile !== null) {
var longitude = $('#longitude').val();
var latitude = $('#latitude').val();
var maxDistance = $('#maxDistance').val();
@ -659,7 +659,7 @@ define(function(require) {
alert("Error finding random article.");
}
else {
$("#articleName").html(title.name);
$("#articleName").html(title._name);
$("#readingArticle").show();
$("#articleContent").html("");
readArticle(title);

View File

@ -49,15 +49,15 @@ define(function(require) {
* LocalArchive class : defines a wikipedia dump on the filesystem
*/
function LocalArchive() {
this.dataFiles = new Array();
this.coordinateFiles = new Array();
this.titleFile = null;
this.mathIndexFile = null;
this.mathDataFile = null;
this.date = null;
this.language = null;
this.titleSearchFile = null;
this.normalizedTitles = true;
this._dataFiles = new Array();
this._coordinateFiles = new Array();
this._titleFile = null;
this._mathIndexFile = null;
this._mathDataFile = null;
this._date = null;
this._language = null;
this._titleSearchFile = null;
this._normalizedTitles = true;
};
@ -71,12 +71,12 @@ define(function(require) {
LocalArchive.prototype.readTitleFilesFromStorage = function(storage, directory) {
var currentLocalArchiveInstance = this;
storage.get(directory + 'titles.idx').then(function(file) {
currentLocalArchiveInstance.titleFile = file;
currentLocalArchiveInstance._titleFile = file;
}, function(error) {
alert("Error reading title file in directory " + directory + " : " + error);
});
storage.get(directory + 'titles_search.idx').then(function(file) {
currentLocalArchiveInstance.titleSearchFile = file;
currentLocalArchiveInstance._titleSearchFile = file;
}, function(error) {
// Do nothing : this file is not mandatory in an archive
});
@ -132,7 +132,7 @@ define(function(require) {
}
storage.get(directory + 'coordinates_' + prefixedFileNumber
+ '.idx').then(function(file) {
currentLocalArchiveInstance.coordinateFiles[index - 1] = file;
currentLocalArchiveInstance._coordinateFiles[index - 1] = file;
currentLocalArchiveInstance.readCoordinateFilesFromStorage(storage, directory,
index + 1);
}, function(error) {
@ -179,14 +179,14 @@ define(function(require) {
if (normalizedTitlesRegex.exec(metadata)) {
var normalizedTitlesInt = normalizedTitlesRegex.exec(metadata)[1];
if (normalizedTitlesInt === "0") {
currentLocalArchiveInstance.normalizedTitles = false;
currentLocalArchiveInstance._normalizedTitles = false;
}
else {
currentLocalArchiveInstance.normalizedTitles = true;
currentLocalArchiveInstance._normalizedTitles = true;
}
}
else {
currentLocalArchiveInstance.normalizedTitles = true;
currentLocalArchiveInstance._normalizedTitles = true;
}
};
reader.readAsText(file);
@ -199,8 +199,8 @@ define(function(require) {
LocalArchive.prototype.initializeFromArchiveFiles = function(archiveFiles) {
var dataFileRegex = /^wikipedia_(\d\d).dat$/;
var coordinateFileRegex = /^coordinates_(\d\d).idx$/;
this.dataFiles = new Array();
this.coordinateFiles = new Array();
this._dataFiles = new Array();
this._coordinateFiles = new Array();
for (var i=0; i<archiveFiles.length; i++) {
var file = archiveFiles[i];
if (file) {
@ -208,28 +208,28 @@ define(function(require) {
this.readMetadataFile(file);
}
else if (file.name === "titles.idx") {
this.titleFile = file;
this._titleFile = file;
}
else if (file.name === "titles_search.idx") {
this.titleSearchFile = file;
this._titleSearchFile = file;
}
else if (file.name === "math.idx") {
this.mathIndexFile = file;
this._mathIndexFile = file;
}
else if (file.name === "math.dat") {
this.mathDataFile = file;
this._mathDataFile = file;
}
else {
var coordinateFileNr = coordinateFileRegex.exec(file.name);
if (coordinateFileNr && coordinateFileNr.length > 0) {
var intFileNr = 1 * coordinateFileNr[1];
this.coordinateFiles[intFileNr - 1] = file;
this._coordinateFiles[intFileNr - 1] = file;
}
else {
var dataFileNr = dataFileRegex.exec(file.name);
if (dataFileNr && dataFileNr.length > 0) {
var intFileNr = 1 * dataFileNr[1];
this.dataFiles[intFileNr] = file;
this._dataFiles[intFileNr] = file;
}
}
}
@ -341,12 +341,12 @@ define(function(require) {
var normalize = this.getNormalizeFunction();
var normalizedTitleName = normalize(titleName);
titleIterators.findPrefixOffset(this.titleFile, titleName, normalize).then(function(offset) {
titleIterators.findPrefixOffset(this._titleFile, titleName, normalize).then(function(offset) {
var iterator = new titleIterators.SequentialTitleIterator(that, offset);
function check(title) {
if (title === null || normalize(title.name) !== normalizedTitleName) {
if (title === null || normalize(title._name) !== normalizedTitleName) {
return null;
} else if (title.name === titleName) {
} else if (title._name === titleName) {
return title;
} else {
return iterator.advance().then(check);
@ -362,9 +362,9 @@ define(function(require) {
*/
LocalArchive.prototype.getRandomTitle = function(callbackFunction) {
var that = this;
var offset = Math.floor(Math.random() * this.titleFile.size);
var offset = Math.floor(Math.random() * this._titleFile.size);
jQuery.when().then(function() {
return util.readFileSlice(that.titleFile, offset,
return util.readFileSlice(that._titleFile, offset,
offset + titleIterators.MAX_TITLE_LENGTH).then(function(byteArray) {
// Let's find the next newLine
var newLineIndex = 0;
@ -389,7 +389,7 @@ define(function(require) {
var normalize = this.getNormalizeFunction();
prefix = normalize(prefix);
titleIterators.findPrefixOffset(this.titleFile, prefix, normalize).then(function(offset) {
titleIterators.findPrefixOffset(this._titleFile, prefix, normalize).then(function(offset) {
var iterator = new titleIterators.SequentialTitleIterator(that, offset);
function addNext() {
if (titles.length >= maxSize) {
@ -399,7 +399,7 @@ define(function(require) {
if (title === null)
return jQuery.Deferred().resolve(titles, maxSize);
// check whether this title really starts with the prefix
var name = normalize(title.name);
var name = normalize(title._name);
if (name.length < prefix.length || name.substring(0, prefix.length) !== prefix)
return jQuery.Deferred().resolve(titles, maxSize);
titles.push(title);
@ -422,28 +422,28 @@ define(function(require) {
var dataFile = null;
var prefixedFileNumber = "";
if (title.fileNr < 10) {
prefixedFileNumber = "0" + title.fileNr;
if (title._fileNr < 10) {
prefixedFileNumber = "0" + title._fileNr;
} else {
prefixedFileNumber = title.fileNr;
prefixedFileNumber = title._fileNr;
}
var expectedFileName = "wikipedia_" + prefixedFileNumber + ".dat";
// Find the good dump file
for (var i = 0; i < this.dataFiles.length; i++) {
var fileName = this.dataFiles[i].name;
for (var i = 0; i < this._dataFiles.length; i++) {
var fileName = this._dataFiles[i].name;
// Check if the fileName ends with the expected file name (in case
// of DeviceStorage usage, the fileName is prefixed by the
// directory)
if (fileName.match(expectedFileName + "$") == expectedFileName) {
dataFile = this.dataFiles[i];
dataFile = this._dataFiles[i];
}
}
if (!dataFile) {
// TODO can probably be replaced by some error handler at window level
alert("Oops : some files seem to be missing in your archive. Please report this problem to us by email (see About section), with the names of the archive and article, and the following info : "
+ "File number " + title.fileNr + " not found");
throw new Error("File number " + title.fileNr + " not found");
+ "File number " + title._fileNr + " not found");
throw new Error("File number " + title._fileNr + " not found");
} else {
var reader = new FileReader();
// Read the article in the dataFile, starting with a chunk of CHUNK_SIZE
@ -486,11 +486,11 @@ define(function(require) {
case "result":
var htmlArticles = event.data.msg;
// Start reading at offset, and keep length characters
var htmlArticle = htmlArticles.substring(title.blockOffset,
title.blockOffset + title.articleLength);
if (htmlArticle.length >= title.articleLength) {
var htmlArticle = htmlArticles.substring(title._blockOffset,
title._blockOffset + title._articleLength);
if (htmlArticle.length >= title._articleLength) {
// Keep only length characters
htmlArticle = htmlArticle.substring(0, title.articleLength);
htmlArticle = htmlArticle.substring(0, title._articleLength);
// Decode UTF-8 encoding
htmlArticle = decodeURIComponent(escape(htmlArticle));
callbackFunction(title, htmlArticle);
@ -522,7 +522,7 @@ define(function(require) {
callbackFunction("Error : " + e);
}
};
var blob = dataFile.slice(title.blockStart, title.blockStart
var blob = dataFile.slice(title._blockStart, title._blockStart
+ readLength);
// Read in the image file as a binary string.
@ -539,9 +539,9 @@ define(function(require) {
LocalArchive.prototype.loadMathImage = function(hexString, callbackFunction) {
var entrySize = 16 + 4 + 4;
var lo = 0;
var hi = this.mathIndexFile.size / entrySize;
var hi = this._mathIndexFile.size / entrySize;
var mathDataFile = this.mathDataFile;
var mathDataFile = this._mathDataFile;
this.findMathDataPosition(hexString, lo, hi, function(pos, length) {
var reader = new FileReader();
@ -578,7 +578,7 @@ define(function(require) {
alert('Math image file read cancelled');
};
var mid = Math.floor((lo + hi) / 2);
var blob = this.mathIndexFile.slice(mid * entrySize, (mid + 1) * entrySize);
var blob = this._mathIndexFile.slice(mid * entrySize, (mid + 1) * entrySize);
var currentLocalArchiveInstance = this;
reader.onload = function(e) {
var byteArray = new Uint8Array(e.target.result);
@ -619,20 +619,20 @@ define(function(require) {
if (byteArray.length === 0) {
// TODO can probably be replaced by some error handler at window level
alert("Oops : there seems to be something wrong in your archive. Please report it to us by email or through Github (see About section), with the names of the archive and article and the following info : "
+ "Unable to find redirected article for title " + title.name + " : offset " + title.blockStart + " not found in title file");
throw new Error("Unable to find redirected article for title " + title.name + " : offset " + title.blockStart + " not found in title file");
+ "Unable to find redirected article for title " + title._name + " : offset " + title._blockStart + " not found in title file");
throw new Error("Unable to find redirected article for title " + title._name + " : offset " + title._blockStart + " not found in title file");
}
var redirectedTitle = title;
redirectedTitle.fileNr = 1 * byteArray[2];
redirectedTitle.blockStart = util.readIntegerFrom4Bytes(byteArray, 3);
redirectedTitle.blockOffset = util.readIntegerFrom4Bytes(byteArray, 7);
redirectedTitle.articleLength = util.readIntegerFrom4Bytes(byteArray, 11);
redirectedTitle._fileNr = 1 * byteArray[2];
redirectedTitle._blockStart = util.readIntegerFrom4Bytes(byteArray, 3);
redirectedTitle._blockOffset = util.readIntegerFrom4Bytes(byteArray, 7);
redirectedTitle._articleLength = util.readIntegerFrom4Bytes(byteArray, 11);
callbackFunction(redirectedTitle);
};
// Read only the 16 necessary bytes, starting at title.blockStart
var blob = this.titleFile.slice(title.blockStart, title.blockStart + 16);
var blob = this._titleFile.slice(title._blockStart, title._blockStart + 16);
// Read in the file as a binary string
reader.readAsArrayBuffer(blob);
};
@ -656,7 +656,7 @@ define(function(require) {
}
var normalizedRectangle = rect.normalized();
var titlePositionsFound = new Array();
for (var i = 0; i < this.coordinateFiles.length; i++) {
for (var i = 0; i < this._coordinateFiles.length; i++) {
callbackCounterForTitlesInCoordsSearch++;
LocalArchive.getTitlesInCoordsInt(this, i, 0, normalizedRectangle, GLOBE_RECTANGLE, maxTitles, titlePositionsFound, callbackFunction, LocalArchive.callbackGetTitlesInCoordsInt);
}
@ -857,7 +857,7 @@ define(function(require) {
// TODO : This should be improved by reading the file in 2 steps :
// - first read the selector
// - then read the coordinates (reading only the exact necessary bytes)
var blob = localArchive.coordinateFiles[coordinateFileIndex].slice(coordFilePos, coordFilePos + 22*65535);
var blob = localArchive._coordinateFiles[coordinateFileIndex].slice(coordFilePos, coordFilePos + 22*65535);
// Read in the file as a binary string
reader.readAsArrayBuffer(blob);
@ -897,7 +897,7 @@ define(function(require) {
* @returns normalized string, or same string if archive is not compatible
*/
LocalArchive.prototype.normalizeStringIfCompatibleArchive = function(string) {
if (this.normalizedTitles === true) {
if (this._normalizedTitles === true) {
return normalize_string.normalizeString(string);
}
else {
@ -910,7 +910,7 @@ define(function(require) {
* If it is not, returns the identity function.
*/
LocalArchive.prototype.getNormalizeFunction = function() {
if (this.normalizedTitles === true) {
if (this._normalizedTitles === true) {
return normalize_string.normalizeString;
} else {
return function(string) { return string; };

View File

@ -29,19 +29,18 @@ define(function(require) {
* Title class : defines the title of an article and some methods to manipulate it
*/
function Title() {
this.name = null;
this.fileNr = null;
this.blockStart = null;
this.blockOffset = null;
this.articleLength = null;
this.archive = null;
this.titleOffset = null;
this.titleEntryLength = null;
}
;
this._name = null;
this._fileNr = null;
this._blockStart = null;
this._blockOffset = null;
this._articleLength = null;
this._archive = null;
this._titleOffset = null;
this._titleEntryLength = null;
};
Title.prototype.getReadableName = function() {
return this.name.replace(/_/g, " ");
return this._name.replace(/_/g, " ");
};
@ -60,16 +59,16 @@ define(function(require) {
throw new Error("Error while parsing an encoded title line un title File : titleOffset cannot be negative (was " + titleOffset + ")");
}
var t = new Title();
t.archive = archive;
t.titleOffset = titleOffset;
t._archive = archive;
t._titleOffset = titleOffset;
if (encodedTitle === null || encodedTitle.length < 15)
return null;
if (encodedTitle[encodedTitle.length - 1] == '\n') {
t.titleEntryLength = encodedTitle.length;
t._titleEntryLength = encodedTitle.length;
} else {
t.titleEntryLength = encodedTitle.length + 1;
t._titleEntryLength = encodedTitle.length + 1;
}
var escapedEncodedTitle = new Uint8Array(encodedTitle);
@ -81,12 +80,12 @@ define(function(require) {
escapedEncodedTitle[i + 2] = 10; // Corresponds to \n
}
t.fileNr = 1 * escapedEncodedTitle[2];
t.blockStart = util.readIntegerFrom4Bytes(escapedEncodedTitle, 3);
t.blockOffset = util.readIntegerFrom4Bytes(escapedEncodedTitle, 7);
t.articleLength = util.readIntegerFrom4Bytes(escapedEncodedTitle, 11);
t._fileNr = 1 * escapedEncodedTitle[2];
t._blockStart = util.readIntegerFrom4Bytes(escapedEncodedTitle, 3);
t._blockOffset = util.readIntegerFrom4Bytes(escapedEncodedTitle, 7);
t._articleLength = util.readIntegerFrom4Bytes(escapedEncodedTitle, 11);
t.name = Title.parseNameOnly(escapedEncodedTitle);
t._name = Title.parseNameOnly(escapedEncodedTitle);
return t;
};
@ -114,13 +113,13 @@ define(function(require) {
Title.parseTitleId = function(localArchive, titleId) {
var title = new Title();
var idParts = titleId.split("|");
title.archive = localArchive;
title.fileNr = parseInt(idParts[2], 10);
title.titleOffset = parseInt(idParts[3], 10);
title.name = idParts[4];
title.blockStart = parseInt(idParts[5], 10);
title.blockOffset = parseInt(idParts[6], 10);
title.articleLength = parseInt(idParts[7], 10);
title._archive = localArchive;
title._fileNr = parseInt(idParts[2], 10);
title._titleOffset = parseInt(idParts[3], 10);
title._name = idParts[4];
title._blockStart = parseInt(idParts[5], 10);
title._blockOffset = parseInt(idParts[6], 10);
title._articleLength = parseInt(idParts[7], 10);
return title;
};
@ -130,15 +129,15 @@ define(function(require) {
* @returns {String}
*/
Title.prototype.toStringId = function() {
return this.archive.language + "|" + this.archive.date + "|" + this.fileNr + "|"
+ this.titleOffset + "|" + this.name + "|" + this.blockStart + "|" + this.blockOffset + "|" + this.articleLength;
return this._archive.language + "|" + this._archive.date + "|" + this._fileNr + "|"
+ this._titleOffset + "|" + this._name + "|" + this._blockStart + "|" + this._blockOffset + "|" + this._articleLength;
};
/**
* Serialize the title in a readable way
*/
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;
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;
};
/**

View File

@ -34,10 +34,10 @@ define(['utf8', 'title', 'util', 'jquery'], function(utf8, evopediaTitle, util,
* @param offset
*/
function SequentialTitleIterator(archive, offset) {
this._titleFile = archive.titleFile;
this._titleFile = archive._titleFile;
this._archive = archive;
this._offset = offset;
this.title = null;
this._title = null;
};
/**
* Advances to the next title (or the first), if possible.
@ -46,8 +46,8 @@ define(['utf8', 'title', 'util', 'jquery'], function(utf8, evopediaTitle, util,
*/
SequentialTitleIterator.prototype.advance = function() {
if (this._offset >= this._titleFile.size) {
this.title = null;
return jQuery.when(this.title);
this._title = null;
return jQuery.when(this._title);
}
var that = this;
return util.readFileSlice(this._titleFile, this._offset,