mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-14 14:58:35 -04:00
Support geo-location references in German and English Wikivoyage
Former-commit-id: 6134f63df2aa1f7c86441239481b9452847e03f1 [formerly 637f74e66e22ed2651f558d2cc85d8b0d12003ef] Former-commit-id: 199b5adc29adfdf7629ca5b14a726684bedd270d
This commit is contained in:
parent
73ee351ae5
commit
07644bdf87
@ -1730,12 +1730,19 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'abstractFile
|
||||
// Scroll the iframe to its top
|
||||
$("#articleContent").contents().scrollTop(0);
|
||||
|
||||
//Fast-attach Wikivoyage POI IDs to the POI Href field without using extremely slow jQuery
|
||||
var regexpGeoLocation = /(href\s?=\s?")geo:([^,]+),([^"]+)("[^>]+?(?:data-zoom[^"]+"([^"]+))?[^>]+>)[^<]+(<\/a>[\s\S]+?<span\b(?=[^>]+listing-name)[\s\S]+?id\s?=\s?")([^"]+)/ig;
|
||||
htmlArticle = htmlArticle.replace(regexpGeoLocation, function (match, p1, p2, p3, p4, p5, p6, p7, p8) {
|
||||
return p1 + "bingmaps:?collection=point." + p2 + "_" + p3 + "_" +
|
||||
encodeURIComponent(p7.replace(/_/g, " ")).replace(/\.(\w\w)/g, "%$1") +
|
||||
(p5 ? "\&lvl=" + p5 : "") + p4.replace(/style\s?="\s?background:[^"]+"\s?/i, "") + '<img alt="Map marker" title="Show this place on a map" src="../img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;" >' + p6 + p7;
|
||||
//Adapt German Wikivoyage POI data format
|
||||
var regexpGeoLocationDE = /<span\s+class\s?=\s?"[^"]+?listing-coordinates[\s\S]+?latitude">([^<]+)[\s\S]+?longitude">([^<]+)<[\s\S]+?(<span[^>]+listing-name[^>]+>([^<]+)<\/span>)/ig;
|
||||
htmlArticle = htmlArticle.replace(regexpGeoLocationDE, function (match, latitude, longitude, href, id) {
|
||||
return '<a href="bingmaps:?collection=point.' + latitude + '_' + longitude + '_' + encodeURIComponent(id.replace(/_/g, " ")) +
|
||||
'">\r\n<img alt="Map marker" title="Diesen Ort auf einer Karte zeigen" src="../img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;" />\r\n</a>' + href;
|
||||
});
|
||||
|
||||
//Adapt English Wikivoyage POI data format
|
||||
var regexpGeoLocationEN = /(href\s?=\s?")geo:([^,]+),([^"]+)("[^>]+?(?:data-zoom[^"]+"([^"]+))?[^>]+>)[^<]+(<\/a>[\s\S]+?<span\b(?=[^>]+listing-name)[\s\S]+?id\s?=\s?")([^"]+)/ig;
|
||||
htmlArticle = htmlArticle.replace(regexpGeoLocationEN, function (match, p1, latitude, longitude, p4, p5, p6, id) {
|
||||
return p1 + "bingmaps:?collection=point." + latitude + "_" + longitude + "_" +
|
||||
encodeURIComponent(id.replace(/_/g, " ")).replace(/\.(\w\w)/g, "%$1") +
|
||||
(p5 ? "\&lvl=" + p5 : "") + p4.replace(/style\s?="\s?background:[^"]+"\s?/i, "") + '<img alt="Map marker" title="Show this place on a map" src="../img/icons/map_marker-18px.png" style="position:relative !important;top:-5px !important;" >' + p6 + id;
|
||||
});
|
||||
|
||||
//Inject htmlArticle into iframe
|
||||
|
Loading…
x
Reference in New Issue
Block a user