MediaWiki:Wikiminiatlas.js: Difference between revisions

add zoomsize patch by dispenser
No edit summary
(add zoomsize patch by dispenser)
Line 3: Line 3:
// also check my user page [[User:Dschwen]] for more tools<pre>
// also check my user page [[User:Dschwen]] for more tools<pre>
//
//
// Revision 16.2
// Revision 16.3


jQuery(function ($) {
jQuery(function ($) {
Line 172: Line 172:


  bodyc,
  bodyc,
  coord_filter = /^([\d+-.]+)_([\d+-.]*)_?([\d+-.]*)_?([NSZ])_([\d+-.]+)_([\d+-.]*)_?([\d+-.]*)_?([EOW])/,
  coord_filter = /&params=([\d.+-]+)_([\d.+-]*)_?([\d.+-]*)_?([NSZ])_([\d.+-]+)_([\d.+-]*)_?([\d.+-]*)_?([EOW])([^&=<>|]{0,250})/,
  coord_list = [],
  coord_list = [],
  coord_highlight = -1,
  coord_highlight = -1,
Line 344: Line 344:
   }
   }


  function capitalize(s) { return s.substr(0,1).toUpperCase()+s.substr(1).toLowerCase(); }
   if(!coord_filter.exec(link.href)){
   if( /_globe:([^_&]+)/.exec(link.href) ) { globe = capitalize(RegExp.$1); }
  if( globe!="Earth" && globe!="Moon" && globe!="Mars" && globe!="Venus" && globe!="Mercury" && globe!="Io" ) { return; }
 
  coordinates = link.href.replace( /−/g, '-' );
  coord_params = coordinates.match(/&params=([^&=<>|]{7,255})/);
 
  if(!coord_params) { return true; }
  coord_params = coord_params[1];
 
  if(!coord_filter.test(coord_params)) {
   return true;
   return true;
   }
   }
  coord_filter.exec(coord_params);
   marker.lat=(1.0*RegExp.$1) + ((RegExp.$2||0)/60.0) + ((RegExp.$3||0)/3600.0);
   marker.lat=(1.0*RegExp.$1) + ((RegExp.$2||0)/60.0) + ((RegExp.$3||0)/3600.0);
   if( RegExp.$4 !== 'N' ) { marker.lat*=-1; }
   if( RegExp.$4 !== 'N' ) { marker.lat*=-1; }
   marker.lon=(1.0*RegExp.$5) + ((RegExp.$6||0)/60.0) + ((RegExp.$7||0)/3600.0);
   marker.lon=(1.0*RegExp.$5) + ((RegExp.$6||0)/60.0) + ((RegExp.$7||0)/3600.0);
   if( RegExp.$8 === 'W' ) { marker.lon*=-1; }
   if( RegExp.$8 === 'W' ) { marker.lon*=-1; }
  coord_params = RegExp.$9;
  // Zoom based on coordinate N/S precision
  var coord_digits = RegExp.$3 ? 4 : RegExp.$2 ? 2 : RegExp.$1.length - (RegExp.$1+".").indexOf('.') - 1;
  zoomlevel = coord_digits * Math.log(10)/Math.log(2);
console.log(coord_digits,link.href);


   // Find a sensible Zoom-level based on type
   // Find a sensible Zoom-level based on type
  zoomlevel = 1;
   if( /_type:(airport|edu|pass|landmark|railwaystation)/.test(coord_params) ) {
   if( /_type:(airport|edu|pass|landmark|railwaystation)/.test(coord_params) ) {
   zoomlevel = 8;
   zoomlevel = 8;
Line 383: Line 377:
   if( wc.zoom !== -1 ) { zoomlevel = wc.zoom; }
   if( wc.zoom !== -1 ) { zoomlevel = wc.zoom; }
   if( zoomlevel > 12 ) { zoomlevel = 12; }
   if( zoomlevel > 12 ) { zoomlevel = 12; }
  function capitalize(s) { return s.substr(0,1).toUpperCase()+s.substr(1).toLowerCase(); }
  if( /_globe:([^_&]+)/.test(coord_params) ) { globe = capitalize(RegExp.$1); }
  if( globe!="Earth" && globe!="Moon" && globe!="Mars" && globe!="Venus" && globe!="Mercury" && globe!="Io" ) { return; }


   // Test the unicode Symbol
   // Test the unicode Symbol
Line 422: Line 420:


   // store coordinates
   // store coordinates
   params = parseParams(coordinates);
  coordinates = link.href;
   params = parseParams(link.href);
   coord_list.push( { lat: marker.lat, lon: marker.lon, obj: link, mb: mapbutton, title: params.title || params.pagename || '' } );
   coord_list.push( { lat: marker.lat, lon: marker.lon, obj: link, mb: mapbutton, title: params.title || params.pagename || '' } );


Anonymous user