User:Dschwen/wikiminiatlas3.js

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<pre>  // Script to embed interactive maps into pages that have coordinate templates  // also check my commons page [[:commons:User:Dschwen]] for more tools    //  // defaults  //  var wikiminiatlas_coordinate_region = '';  var wikiminiatlas_width = 500;  var wikiminiatlas_height = 300;  var wikiminiatlas_iframeurl = 'http://up2p77.gwdg.de/~daniel/MiniWikiAtlas/iframe.html';  var wikiminiatlas_imgbase = 'http://up2p77.gwdg.de/~daniel/MiniWikiAtlas/tiles/';    //  // globals  //  var wikiminiatlas_iframe = null;    //  // Insert the IFrame into the page.  //  function wikiminiatlasLoader()  {   var wikiminiatlas_marker_lon;   var wikiminiatlas_marker_lat;   var coordinates = document.getElementById('coordinates');     if (coordinates != null && wikiminiatlas_iframe == null)    {    var coord_index = (coordinates.innerHTML).indexOf('params=');    if(coord_index>-1)    {     var coord_params = (coordinates.innerHTML).substr(coord_index+7);       // en.wp coordinates     var coord_filter = /([\d+-.]+)_([NS])_([\d+-.]+)_([EW])_/;     if(coord_filter.test(coord_params))     {      coord_filter.exec(coord_params);      wikiminiatlas_marker_lat=RegExp.$1;      if(RegExp.$2=='S') wikiminiatlas_marker_lat*=-1;      wikiminiatlas_marker_lon=RegExp.$3;      if(RegExp.$4=='W') wikiminiatlas_marker_lon*=-1;     }       // de.wp coordinates     coord_filter = /([\d+-.]+)_([\d+-.]+)_([\d+-.]*)_([NS])_([\d+-.]+)_([\d+-.]+)_([\d+-.]*)_([EW])_/;     if(coord_filter.test(coord_params))     {      coord_filter.exec(coord_params);      wikiminiatlas_marker_lat=(1.0*RegExp.$1) + (RegExp.$2/60.0) + (RegExp.$3/3600.0);      if(RegExp.$4=='S') wikiminiatlas_marker_lat*=-1;      wikiminiatlas_marker_lon=(1.0*RegExp.$5) + (RegExp.$6/60.0) + (RegExp.$6/3600.0);      if(RegExp.$8=='W') wikiminiatlas_marker_lon*=-1;     }        // de.wp coordinates     coord_filter = /([\d+-.]+)_([\d+-.]+)_([NS])_([\d+-.]+)_([\d+-.]+)_([EW])_/;     if(coord_filter.test(coord_params))     {      coord_filter.exec(coord_params);      wikiminiatlas_marker_lat=(1.0*RegExp.$1) + (RegExp.$2/60.0);      if(RegExp.$3=='S') wikiminiatlas_marker_lat*=-1;      wikiminiatlas_marker_lon=(1.0*RegExp.$4) + (RegExp.$5/60.0);      if(RegExp.$6=='W') wikiminiatlas_marker_lon*=-1;     }    }    var region_index = (coordinates.innerHTML).indexOf('region:');    if(region_index>-1)    {     wikiminiatlas_coordinate_region = (coordinates.innerHTML).substr(region_index+7);     wikiminiatlas_coordinate_region = wikiminiatlas_coordinate_region.substr(0,wikiminiatlas_coordinate_region.indexOf('"'));    }      WikiMiniAtlasHTML =  '&nbsp;<a href="#" onclick="return toggleWikiMiniAtlasIFrame();"><img src="http://upload.wikimedia.org/wikipedia/commons/6/65/Atlasbutton_mini.png" border="0"</a>';    WikiMiniAtlasHTML += '<div id="wikiminiatlas_iframe" style="position:absolute; right:2em; top: 1em; width:'+(wikiminiatlas_width+12)+'px; height:'+(wikiminiatlas_height+12)+'px; background-color: white; padding: 0px; margin: 0px; visibility: hidden; border: 1px solid gray">';    WikiMiniAtlasHTML += '<img src="'+wikiminiatlas_imgbase+'button_hide.png" style="z-index:10; position:absolute; right:11px; top: 11px; width:18px; cursor:pointer" onclick="toggleWikiMiniAtlasIFrame()">'    WikiMiniAtlasHTML += '<iframe style="position:absolute; right:1px; top: 1px; width:'+(wikiminiatlas_width+10)+'px; height:'+(wikiminiatlas_height+10)+'px; background-color: white; padding: 0px; margin: 0px;" src="'+wikiminiatlas_iframeurl+'?'+wikiminiatlas_marker_lat+'_'+wikiminiatlas_marker_lon+'_'+wikiminiatlas_width+'_'+wikiminiatlas_height+'_'+window.location.host.substr(0,2)+'" scrolling="no" border="0"></div>';      coordinates.innerHTML = coordinates.innerHTML + WikiMiniAtlasHTML ;      wikiminiatlas_iframe = document.getElementById('wikiminiatlas_iframe');   }  }    //  // Hook up instalation function  //  addOnloadHook(wikiminiatlasLoader);        function toggleWikiMiniAtlasIFrame()  {   if(wikiminiatlas_iframe.style.visibility != "visible")   {     wikiminiatlas_iframe.style.visibility="visible";   }   else   {     wikiminiatlas_iframe.style.visibility="hidden";   }     return false;  }    //</pre>