Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
if (!mw.loader.getState("theway.utilities")) mw.loader.implement("theway.utilities", ["//de.wikivoyage.org/w/index.php?title=Benutzer:Theway-source/utilities.js&action=raw&ctype=text/javascript"], null, null); mw.loader.using(["theway.utilities"], function () { Debug ("---- mapframe ----"); // global vars gsHrefSmall = ""; gsText2 = ""; goWindow = undefined; gsMapHeight = PreferenceDefault ("mapframe_height", "420"); gsMapWidth = PreferenceDefault ("mapframe_width", "420"); // local vars var sHref, sLocnameUnescape; var sText1, sMapText, sMapFrameLoad, sMapFrameWindow; var oElement, oValues, oLocation = {}; var oGeo = document.getElementById("mw-indicator-i3-geo"); // var oMapPos = document.getElementById('Sehensw.C3.BCrdigkeiten'); // works only if coordinates and propper section exists // if (oGeo && oMapPos) { // if (oMapPos) { if (document.getElementById('Sehensw.C3.BCrdigkeiten') || document.getElementById('St.C3.A4dte')) { var sMapLoad = PreferenceDefault ("mapframe_load"); var iMapArticleMinsize = PreferenceDefault ("mapframe_article_minsize", "2000") * 1; var iContentBytes = jQuery("#mw-content-text").text().length; Debug ("-- mapframe sMapLoad: " + sMapLoad + ", iContentBytes: " + iContentBytes + ", iMapArticleMinsize: " + iMapArticleMinsize); oLocation = LocationCoordinates(); Debug ("-- mapframe 1"); // attach the image at the end of the headline; https:tools.wmflabs.org, http: maps.wikivoyage-ev.org // sHref = 'https://tools.wmflabs.org/wikivoyage/w/poimap2.php?lat=' + sNorth + '&lon=' + sEast + '&lang=de&name=' + sLocname + '&layer=' sHref = 'https://tools.wmflabs.org/wikivoyage/w/poimap2.php?lat=' + oLocation.north + '&lon=' + oLocation.east + '&lang=de&name=' + oLocation.name + '&layer=' + PreferenceDefault("mapframe_layer", "M") + (PreferenceDefault("mapframe_markers", "true") == "true" ? "P" : "") + (PreferenceDefault("mapframe_hill") == "true" ? "S" : "") + (PreferenceDefault("mapframe_boundaries") == "true" ? "B" : "") + (PreferenceDefault("mapframe_cycling") == "true" ? "C" : "") + (PreferenceDefault("mapframe_maplabels") == "true" ? "L" : "") + (PreferenceDefault("mapframe_hiking") == "true" ? "H" : "") + (PreferenceDefault("mapframe_tracks") == "true" ? "T" : "") ; // gsHrefSmall = sHref + '&zoom=' + iMapZoom; // sHrefFull = sHref + '&zoom=' + (iMapZoom+1); gsHrefSmall = sHref + '&zoom=' + oLocation.zoom; sHrefFull = sHref + '&zoom=' + (oLocation.zoom+1); Debug ("-- mapframe 3"); // text for map image 1) without image, 2) with image inside of iframe sLocnameUnescape = unescape(oLocation.name); sText1 = '<a href="/wiki/Datei:Map_icon_long.svg" class="image" style="float:left; margin-right:5px;">' + '<img alt="Karte" src="//upload.wikimedia.org/wikipedia/commons/thumb/6/66/Map_icon_long.svg/250px-Map_icon_long.svg.png" width="66" height="33">' + '</a>' + 'Stadtplan von <i>' + sLocnameUnescape + '</i> von externer Webseite <a href="javascript:MapframeIFrame();">hier</a> laden, in <a class="external text" href="javascript:MapframeWindow("' + gsHrefSmall + '", "' + sLocnameUnescape + '");">separatem Fenster</a> oder als <a class="external text" href="' + sHrefFull + '">Vollansicht</a> zeigen.'; gsText2 = 'Stadtplan von <i>' + sLocnameUnescape + '</i>. Auch als <a class="external text" href="javascript:MapframeWindow("' + gsHrefSmall + '", "' + sLocnameUnescape + '");">separates Fenster</a> oder <a class="external text" href="' + sHrefFull + '">Vollansicht</a>.'; Debug ("-- mapframe 4"); sMapFrameLoad = PreferenceDefault("mapframe_load", ""); sMapFrameWindow = PreferenceDefault("mapframe_window", ""); Debug ("-- mapframe 5"); if (iContentBytes >= iMapArticleMinsize) { Debug ("-- mapframe 4"); if (sMapFrameWindow == "true" && sMapFrameLoad == "true") { MapframeWindow (gsHrefSmall, sLocnameUnescape); } else { Debug ("-- mapframe 6"); sMapText = '<div class="thumb tright"><div class="thumbinner" id=mapinner>' + '<div id="iframemaptext" class="thumbcaption noprint" style="width:' + gsMapWidth + 'px;">' + sText1 + '</div></div></div>'; Debug ("-- mapframe 7"); /* oElement = document.getElementById('mapframe'); Debug ("-- mapframe oElement: " + oElement); Debug ("-- mapframe oElement.getAttribute(): " + oElement.getAttribute("title")); */ Debug ("-- mapframe document.getElementById('mapframe'): " + document.getElementById('mapframe')); if (document.getElementById('mapframe')) { // attach after a element with id "mapframe" Debug ("-- mapframe 8"); jQuery("#mapframe").first().each (function() { // jQuery("#mapframe").each (function() { Debug ("-- mapframe 9"); Debug ("-- mapframe this: " + this); Debug ("-- mapframe this: " + this.getAttribute("title")); Debug ("-- mapframe 9.2"); //Debug ("-- mapframe $this: " + $this); Debug ("-- mapframe $this.attr(href): " + $(this).attr("title")); Debug ("-- mapframe 9.4"); sText1 = $(this).attr("title"); // oValue = JSON.parse(sText1); //Debug ("-- mapframe mapframe_height: " + oValue.mapframe_height); // oValue = JSON.parse("{" + sText1 + "}"); //Debug ("-- mapframe mapframe_height: " + oValue.mapframe_height); oValue = []; oValue.push("{" + sText1 + "}"); Debug ("-- mapframe mapframe_height: " + oValue[0].mapframe_height); Debug ("-- mapframe sText1: " + sText1); $(this).after(sMapText); gsMapWidth = 500; gsMapHeight = 500; sMapFrameLoad = "true"; }); } else // attach after the "Sehenswürdigkeiten" headline // jQuery("#Sehensw\\.C3\\.BCrdigkeiten:parent").parent().after(sMapText); jQuery("#Sehensw\\.C3\\.BCrdigkeiten:parent,#St\\.C3\\.A4dte:parent").first().parent().after(sMapText); if (sMapFrameLoad == "true") { MapframeIFrame(); } // switch other map boxes to off if (PreferenceDefault("mapframe_dynmapoff") == "true") { Debug ("-- mapframe 10"); oElement = jQuery("[class='infobox'] [href*='http://maps.wikivoyage-ev.org']").closest("[class='infobox']"); if (oElement.length > 0) { oElement.attr("style", "display:none;"); } } } } } } ); //---- ---- function MapframeIFrame(){ var oMapInner = document.getElementById("mapinner"); var oIFrameMapText = document.getElementById("iframemaptext"); oIFrameMapText.innerHTML = gsText2; oMapInner.innerHTML = '<iframe id="iframemap" width="' + gsMapWidth + '" height="' + gsMapHeight + '" style="border:0" src="' + gsHrefSmall + '"></iframe>' + oMapInner.innerHTML; } //---- get coordinates and zoom ---- function LocationCoordinates () { Debug ("-- LocationCoordinates --"); var iPos1, iPos2, iPos3, iScale, iContrary; var sHref; var oElement={}, oLocation={}; var iMapZoom = 14; // like <a class="external text" href="http://de.wikivoyage.org/w/index.php?title=Spezial%3AMapsources&params=48.85694_N_2.34126_E_scale:25000&locname=Paris">...</a> oElement = jQuery("[href^='http://de.wikivoyage.org/w/index.php?title=Spezial%3AMapsources']"); Debug ("-- LocationCoordinates 2"); if (oElement.length > 0) { Debug ("-- LocationCoordinates 3"); sHref = oElement.attr("href"); iPos1 = sHref.indexOf("params") + 7; iPos2 = sHref.indexOf("_N_"); iContrary = 1; if (iPos2 == -1) { iPos2 = sHref.indexOf("_S_"); iContrary = -1; } oLocation.north = sHref.slice(iPos1, iPos2) * iContrary; // north coordinate iPos3 = sHref.indexOf("_E_"); iContrary = 1; if (iPos3 == -1) { iPos3 = sHref.indexOf("_W_"); iContrary = -1; } oLocation.east = sHref.slice(iPos2 + 3, iPos3) * iContrary; // east coordinate iPos1 = sHref.indexOf("scale") + 6; iPos2 = sHref.indexOf("&", iPos1); if (iPos2 == -1) iPos2 = 555; iScale = sHref.slice(iPos1, iPos2); // scale value oLocation.zoom = ZoomByScale (iScale); iPos1 = sHref.indexOf("locname") + 8; iPos2 = sHref.indexOf("&", iPos1); if (iPos2 == -1) iPos2 = 555; oLocation.name = sHref.slice(iPos1, iPos2); // location name Debug ("-- LocationCoordinates 9"); Debug ("-- LocationCoordinates oLocation.north: " + oLocation.north + ", oLocation.east: " + oLocation.east); Debug ("-- LocationCoordinates oLocation.scale: " + oLocation.scale + ", oLocation.name: " + oLocation.name); } Debug ("-- LocationCoordinates 10"); // zoom level // zoom factor indirectly by population (unfortunately area don't exist) var sPopulation, xsPopulation, iPopulation; var oQuickBarHeads; if (document.getElementsByClassName) { oElement = document.getElementsByClassName("qb")[0]; // works in Opera, FF if (oElement !== undefined) { Debug ("-- LocationCoordinates oElement: " + oElement + (oElement !== undefined) + (typeof oElement !== undefined)); oQuickBarHeads = oElement.getElementsByTagName("th"); // works in Opera, FF } } else { oQuickBarHeads = document.getElementsByTagName("table")[0].getElementsByTagName("th"); //getElementsByClassName don't understand every browser } Debug ("-- oQuickBarHeads oElement: " + oQuickBarHeads); if (oQuickBarHeads !== undefined) { for (i=0; i<oQuickBarHeads.length; i++) { if (GetInnerText (oQuickBarHeads[i]) == "Einwohner") { sPopulation = GetInnerText (oQuickBarHeads[i].parentNode.getElementsByTagName("td")[0]); xsPopulation = sPopulation.split(" "); // may be population + date comment iPopulation = (xsPopulation[0].replace(".", "")) * 1; // and converted to number Debug ("xsPopulation: " + xsPopulation + ", iPopulation: " + iPopulation); //Debug ("REVISIONSIZE: " + {{REVISIONSIZE}} ); if (iPopulation < 4000) {iMapZoom = 15;} // perhaps to adapt else if (iPopulation > 500000) {iMapZoom = 12;} else if (iPopulation > 150000) {iMapZoom = 13;} } } } if (!(oLocation.zoom >= 0 && oLocation.zoom < 20)) oLocation.zoom = 14; return oLocation; } //---- zoom level by scale ---- // http://wiki.openstreetmap.org/wiki/Zoom_levels function ZoomByScale (iScale) { var iZoom = 14; if (iScale <= 1000) iZoom = 19; else if (iScale <= 2000) iZoom = 18; else if (iScale <= 4000) iZoom = 17; else if (iScale <= 8000) iZoom = 16; else if (iScale <= 15000) iZoom = 15; else if (iScale <= 35000) iZoom = 14; else if (iScale <= 70000) iZoom = 13; else if (iScale <= 150000) iZoom = 12; else if (iScale <= 250000) iZoom = 11; else if (iScale <= 500000) iZoom = 10; else if (iScale <= 1000000) iZoom = 9; else if (iScale <= 2000000) iZoom = 8; else if (iScale <= 4000000) iZoom = 7; else if (iScale <= 10000000) iZoom = 6; else if (iScale <= 15000000) iZoom = 5; else if (iScale <= 35000000) iZoom = 4; else if (iScale <= 70000000) iZoom = 3; else if (iScale <= 150000000) iZoom = 2; else if (iScale <= 250000000) iZoom = 1; else if (iScale <= 500000000) iZoom = 0; Debug ("-- ZoomByScale iZoom: " + iZoom); return iZoom; } //---- separate popup window ---- function MapframeWindow(sLink, sLocname) { var sLeft = PreferenceDefault("mapframe_window_left", "0"); var sTop = PreferenceDefault("mapframe_window_top", "0"); var sWidth = PreferenceDefault ("mapframe_window_width", gsMapWidth); var sHeight = PreferenceDefault ("mapframe_window_height", gsMapHeight); // screenLeft, screenTop for Opera goWindow = window.open("", "mapframe-window", "width=" + sWidth + ",height=" + sHeight + ",left=" + sLeft + ",top=" + sTop + ",screenX=" + sLeft + ",screenY=" + sTop + ",screenLeft=" + sLeft + ",screenTop=" + sTop + ",status=yes,resizable,scrollbars=no,dependent=yes"); if (goWindow !== null) { var sCollapseUseChecked = PreferenceDefault("collapse_enable"); goWindow.document.open(); goWindow.document.write(' \ <html><head><title>Stadtplan ' + sLocname + '</title> \ </head> \ \ <frameset onbeforeunload="document.cookie="mapframe_window_left=test;expires=1 Dec 2020 12:00 UTC";"> \ <frame src="' + sLink + '"> \ </frameset></html>'); goWindow.document.close(); // store the last position and size of the popup window // onbeforeunload don't work in opera if (IsEventSupported("onbeforeunload")) oWindow.onbeforeunload=function() {StoreWindowPosition(goWindow, "mapframe_window"); }; else oWindow.onunload=function() {StoreWindowPosition(goWindow, "mapframe_window"); }; // setInterval(MapframeWindowOnTop, 1000); // setInterval(function() {goWindow.focus();}, 2000); } } // ---- Popup window on top ---- function MapframeWindowOnTop () { // goWindow.focus(); window.mapframe-window.focus(); }