Fix bugs with backlinks

Former-commit-id: 1ef47c78a3545b017731e91bb2bff422ea8a7a4a [formerly b4c58f8e6c38447facca6db8180e784b42bf7e3e] [formerly 6ef9a48a59d98e9dc45e0950f984b5aaf0b8a57a] [formerly 9a564c9482f32b73b65656ba42760143e483ae21 [formerly 5d69d9fe606df174ad69a8525d939a85289635bc [formerly 7fd26ee7a48ddd067de8692ab5ed1307739d9d46]]]
Former-commit-id: e24100ff705940ad32a2741e035364c2ffc35c3a [formerly 690a2cd1b4f81c0c1d919d18cf713adca11b00df [formerly a825d06aa9734559667e9ae615e41d6bfea6b394]]
Former-commit-id: ef80ae1c9b638a60d6139eaeda1edb8efee65232 [formerly ecad27caff5673d5eefcd7f4394df1be0cb54e14]
Former-commit-id: f44f58462b691f1bf0d7134306fb61dc78dee633
This commit is contained in:
Jaifroid 2021-07-11 12:46:16 +01:00
parent 7b2c29638d
commit e2ba4a1554
6 changed files with 18 additions and 8 deletions

View File

@ -3,9 +3,12 @@
## In progress release 1.4.3
* FEATURE: (Experimental) PWA is paritcipating in File Handling API origin trial
* FEATURE: Search with wildcards '.*', '.+' or regex syntax '(?:my_regular_expression)' so long as search begins with normal alphanumeric string
* FIX: Bug which failed to detect images correctly in a new tab
* FIX: Touch-zoom of contents of iframe no longer blanks part of the display
* FIX: Broken zoom of contents of iframe (with UI buttons) in Internet Explorer
* FIX: Bug setting up backlinks which caused some pages not to load
* FIX: Unhandled exception when cite ref was not found
## Release 1.4.2

View File

@ -4,7 +4,7 @@
// App version number - ENSURE IT MATCHES VALUE IN init.js
// DEV: Changing this will cause the browser to recognize that the Service Worker has changed, and it will download and
// install a new copy
const appVersion = '1.4.3-rc3';
const appVersion = '1.4.3-rc4';
// Kiwix ZIM Archive Download Server in regex form
// DEV: The server URL is defined in init.js, but is not available to us in SW

View File

@ -127,6 +127,8 @@
<li>Fix bug which failed to detect images correctly in new tab</li>
<li>Touch-zoom of contents of iframe no longer blanks part of the display</li>
<li>Fixed broken zoom of contents of iframe (with UI buttons) in Internet Explorer</li>
<li>Enabled search with wildcards '.*', '.+' or regex syntax '(?:my_regular_expression)': <b>NB search must begin with normal alphanumeric string</b></li>
<li>Fixed bug setting up backlinks which caused some pages not to load</li>
</ul>
<p><a href="https://github.com/kiwix/kiwix-js-windows/blob/master/CHANGELOG.md" target="_blank">Full changelog...<img src="I/s/Icon_External_Link.png"></a></p>
</div>

View File

@ -3588,9 +3588,14 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
//Setup endnote backlinks if the ZIM doesn't have any
htmlArticle = htmlArticle.replace(/<li\b[^>]+id=["']cite[-_]note[-_]([^"']+)[^>]+>(?![^/]+?[↑^])/ig, function (match, id) {
var fnSearchRegxp = new RegExp('id=["' + "'](cite[-_]ref[-_]" + id.replace(/[-_()+]/g, "[-_()]+") + '[^"' + "']*)", 'i');
var fnReturnMatch = htmlArticle.match(fnSearchRegxp);
var fnReturnID = fnReturnMatch ? fnReturnMatch[1] : "";
var fnReturnMatch = '';
try {
var fnSearchRegxp = new RegExp('id=["' + "'](cite[-_]ref[-_]" + id.replace(/[-_()+?]/g, "[-_()]+?") + '[^"' + "']*)", 'i');
fnReturnMatch = htmlArticle.match(fnSearchRegxp);
} catch (err) {
console.error('Error constructiong regular expression in app.js', err);
}
var fnReturnID = fnReturnMatch ? fnReturnMatch[1] : '';
return match + '\r\n<a href=\"#' + fnReturnID + '">^&nbsp;</a>';
});
@ -3823,8 +3828,8 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
reference.addEventListener("click", function (obj) {
var refID = obj.target.hash || obj.target.parentNode.hash;
if (!refID) return;
refID = refID.replace(/#/, "");
var refLocation = articleDocument.getElementById(refID);
var refLocation = docBody.querySelector(refID);
if (!refLocation) return;
// In some ZIMs the id is in the parent node or in the parent of the parent
var returnID = obj.target.id || obj.target.parentNode.id || obj.target.parentNode.parentNode.id;
// Add backlink to refLocation if missing

View File

@ -49,7 +49,7 @@ var params = {};
*/
var appstate = {};
/******** UPDATE VERSION IN pwabuilder-sw.js TO MATCH VERSION AND CHECK PWASERVER BELOW!!!!!!! *******/
params['version'] = "1.4.3-rc3"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js
params['version'] = "1.4.3-rc4"; //DEV: Manually update this version when there is a new release: it is compared to the Settings Store "version" in order to show first-time info, and the cookie is updated in app.js
/******* UPDATE THIS ^^^^^^ IN service worker AND PWA-SERVER BELOW !! ********************/
params['packagedFile'] = getSetting('packagedFile') || "wikipedia_en_100_maxi_2021-05.zim"; //For packaged Kiwix JS (e.g. with Wikivoyage file), set this to the filename (for split files, give the first chunk *.zimaa) and place file(s) in default storage
params['archivePath'] = "archives"; //The directory containing the packaged archive(s) (relative to app's root directory)

View File

@ -230,7 +230,7 @@ define(['zimfile', 'zimDirEntry', 'util', 'utf8'],
prefixVariants = prefixVariants.slice(1);
search.resultSize = resultSize - dirEntries.length;
// Search window sets an upper limit on how many matching dirEntries will be scanned in a full index search
var searchWindow = search.rgxPrefix ? 250000 : resultSize;
var searchWindow = search.rgxPrefix ? 10000 * resultSize : resultSize;
that.findDirEntriesWithPrefixCaseSensitive(prefix, searchWindow, search,
function (newDirEntries, idx, interim) {
if (search.status === 'cancelled') return callback([], search.status);