diff --git a/www/js/app.js b/www/js/app.js index 051e1c46..a7cba562 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -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]+?]+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, "") + 'Map marker' + p6 + p7; + //Adapt German Wikivoyage POI data format + var regexpGeoLocationDE = /([^<]+)[\s\S]+?longitude">([^<]+)<[\s\S]+?(]+listing-name[^>]+>([^<]+)<\/span>)/ig; + htmlArticle = htmlArticle.replace(regexpGeoLocationDE, function (match, latitude, longitude, href, id) { + return '\r\nMap marker\r\n' + href; + }); + + //Adapt English Wikivoyage POI data format + var regexpGeoLocationEN = /(href\s?=\s?")geo:([^,]+),([^"]+)("[^>]+?(?:data-zoom[^"]+"([^"]+))?[^>]+>)[^<]+(<\/a>[\s\S]+?]+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, "") + 'Map marker' + p6 + id; }); //Inject htmlArticle into iframe