mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Small fixes for random article feature + cosmetic changes
Anyway, the article feature does not work all the time currently.
This commit is contained in:
parent
87a85d8e11
commit
8dd14095e6
1211
www/js/app.js
1211
www/js/app.js
File diff suppressed because it is too large
Load Diff
@ -24,8 +24,6 @@ define(function(require) {
|
|||||||
|
|
||||||
// Module dependencies
|
// Module dependencies
|
||||||
var normalize_string = require('normalize_string');
|
var normalize_string = require('normalize_string');
|
||||||
var utf8 = require('utf8');
|
|
||||||
var evopediaTitle = require('title');
|
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
var geometry = require('geometry');
|
var geometry = require('geometry');
|
||||||
var jQuery = require('jquery');
|
var jQuery = require('jquery');
|
||||||
@ -110,7 +108,7 @@ define(function(require) {
|
|||||||
currentLocalArchiveInstance.readDataFilesFromStorage(storage, directory,
|
currentLocalArchiveInstance.readDataFilesFromStorage(storage, directory,
|
||||||
index + 1);
|
index + 1);
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
// TODO there must be a better to way to detect a FileNotFound
|
// TODO there must be a better way to detect a FileNotFound
|
||||||
if (error != "NotFoundError") {
|
if (error != "NotFoundError") {
|
||||||
alert("Error reading data file " + index + " in directory "
|
alert("Error reading data file " + index + " in directory "
|
||||||
+ directory + " : " + error);
|
+ directory + " : " + error);
|
||||||
@ -141,7 +139,7 @@ define(function(require) {
|
|||||||
currentLocalArchiveInstance.readCoordinateFilesFromStorage(storage, directory,
|
currentLocalArchiveInstance.readCoordinateFilesFromStorage(storage, directory,
|
||||||
index + 1);
|
index + 1);
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
// TODO there must be a better to way to detect a FileNotFound
|
// TODO there must be a better way to detect a FileNotFound
|
||||||
if (error != "NotFoundError") {
|
if (error != "NotFoundError") {
|
||||||
alert("Error reading coordinates file " + index + " in directory "
|
alert("Error reading coordinates file " + index + " in directory "
|
||||||
+ directory + " : " + error);
|
+ directory + " : " + error);
|
||||||
@ -372,6 +370,8 @@ define(function(require) {
|
|||||||
var iterator = new titleIterators.SequentialTitleIterator(that, offset);
|
var iterator = new titleIterators.SequentialTitleIterator(that, offset);
|
||||||
// call advance twice because we are probably not at the beginning
|
// call advance twice because we are probably not at the beginning
|
||||||
// of a title
|
// of a title
|
||||||
|
// TODO : we need to find a better way to reach the beginning of the title
|
||||||
|
// As it is now, the first advance() can fail on utf8 decoding
|
||||||
return iterator.advance().then(function() {
|
return iterator.advance().then(function() {
|
||||||
return iterator.advance();
|
return iterator.advance();
|
||||||
});
|
});
|
||||||
@ -842,7 +842,7 @@ define(function(require) {
|
|||||||
return storage.scanForDirectoriesContainingFile('titles.idx')
|
return storage.scanForDirectoriesContainingFile('titles.idx')
|
||||||
.then(function(dirs) {
|
.then(function(dirs) {
|
||||||
jQuery.merge(directories, dirs);
|
jQuery.merge(directories, dirs);
|
||||||
return true
|
return true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
jQuery.when.apply(null, promises).then(function() {
|
jQuery.when.apply(null, promises).then(function() {
|
||||||
@ -880,7 +880,7 @@ define(function(require) {
|
|||||||
if (this.normalizedTitles === true) {
|
if (this.normalizedTitles === true) {
|
||||||
return normalize_string.normalizeString;
|
return normalize_string.normalizeString;
|
||||||
} else {
|
} else {
|
||||||
return function(string) { return string; }
|
return function(string) { return string; };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ define(['utf8', 'title', 'util', 'jquery'], function(utf8, evopediaTitle, util,
|
|||||||
return util.readFileSlice(this._titleFile, this._offset,
|
return util.readFileSlice(this._titleFile, this._offset,
|
||||||
this._offset + MAX_TITLE_LENGTH).then(function(byteArray) {
|
this._offset + MAX_TITLE_LENGTH).then(function(byteArray) {
|
||||||
var newLineIndex = 15;
|
var newLineIndex = 15;
|
||||||
while (newLineIndex < byteArray.length && byteArray[newLineIndex] != 10) {
|
while (newLineIndex < byteArray.length && byteArray[newLineIndex] !== 10) {
|
||||||
newLineIndex++;
|
newLineIndex++;
|
||||||
}
|
}
|
||||||
var encodedTitle = byteArray.subarray(0, newLineIndex);
|
var encodedTitle = byteArray.subarray(0, newLineIndex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user