1 // [[image:Erioll_world.svg|18px]] '''WikiMiniAtlas''' <br>
2 // Script to embed interactive maps into pages that have coordinate templates <br>
3 // also check my user page [[User:Dschwen]] for more tools<pre>
16 iframeurl
: 'http://tools.wikimedia.de/~dschwen/wikiminiatlas/iframe.html',
17 imgbase
: 'http://tools.wikimedia.de/~dschwen/wikiminiatlas/tiles/',
18 coordurls
: new Array (
19 'http://tools.wikimedia.de/~magnus/geo/geohack.php?',
20 'http://www8.brinkster.com/erikbaas/wiki/maps.asp?',
21 'http://www.nsesoftware.nl/wiki/maps.asp?'
24 'http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Erioll_world.svg/18px-Erioll_world.svg.png'
30 bg
:'покажи местоположението на интерактивната карта',
31 ca
:'mostra la localització en un mapa interactiu',
32 da
:'vis beligenhed på interaktivt kort',
33 de
:'Ort auf interaktiver Karte anzeigen',
34 el
:'εμφάνιση τοποθεσίας σε διαδραστικό χάρτη',
35 en
:'show location on an interactive map',
36 eo
:'Montru lokigon sur interaktiva karto',
37 eu
:'erakutsi kokalekua mapa interaktibo batean',
38 es
:'mostrar el lugar en un mapa interactivo',
39 fr
:'Montrer la localisation sur une carte interactive',
40 fy
:'it plak op in oanpasbere kaart oanjaan',
41 gl
:'Amosar o lugar nun mapa interactivo',
42 he
:'הראה מיקום במפה האינטראקטיבית',
43 hu
:'Mutasd a helyet egy interaktív térképen!',
44 it
:'mostra la località su una carta interattiva',
45 is
:'sýna staðsetningu á gagnvirku korti',
46 id
:'Tunjukkan letak di peta interaktif',
47 ja
:'インタラクティブ地図上に位置を表示',
48 lt
:'Rodyti vietą interaktyviame žemėlapyje',
49 mk
:'Prikazi go mestoto na interaktivnata mapa',
50 nl
:'toon de locatie op een interactieve kaart',
51 no
:'vis beliggenhet på interaktivt kart',
52 pl
:'Pokaż lokalizację na mapie interaktywnej',
53 pt
:'mostrar a localidade num mapa interactivo',
54 ru
:'показать положение на интерактивной карте',
55 sk
:'zobraz miesto na interaktívnej mape',
56 sl
:'prikaži lokacijo na interaktivnem zemljevidu',
57 sq
:'trego vendndodhjen në hartë',
58 fi
:'näytä paikka interaktiivisella kartalla',
59 sv
:'visa platsen på en interaktiv karta',
60 vi
:'mở lên vị trí này trên bản đồ tương tác',
61 vo
:'Jonön topi su kaed itjäfidik',
63 'zh-cn':'显示该地在地图上的位置',
64 'zh-sg':'显示该地在地图上的位置',
65 'zh-tw':'顯示該地在地圖上的位置',
66 'zh-hk':'顯示該地在地圖上的位置',
67 ar
:'شاهد الموقع على الخريطة التفاعلية'
117 iframe
: { div
: null, iframe
: null, closebutton
: null},
119 marker
: { lat
:0, lon
:0 },
127 coordinate_region
: '',
129 WikiMiniAtlasHTML
: '',
131 // cross-browser event attachment (John Resig)
132 // http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
133 addEvent
: function ( obj
, type
, fn
)
135 if (obj
.addEventListener
)
136 obj
.addEventListener( type
, fn
, false );
137 else if (obj
.attachEvent
)
139 obj
["e"+type+fn
] = fn
;
140 obj
[type+fn
] = function() { obj
["e"+type+fn
]( window
.event
); }
141 obj
.attachEvent( "on"+type
, obj
[type+fn
] );
145 // vertikale position auf der Seite bestimmen
146 totalOffset
: function( obj
, offset
)
148 if( obj
.offsetParent
== null ||
149 obj
.offsetParent
.id
== 'content' )
150 return offset + obj
.offsetTop
;
152 return wikiminiatlas
.totalOffset(obj
.offsetParent
, offset + obj
.offsetTop
);
155 // move iframe around and toggle visibility
156 toggleIFrame
: function( e
)
160 var newurl
= config
.iframeurl +
'?' + this
.mapparam
;
162 if(iframe
.div
.style
.visibility
!= "visible" ||
163 ( ( iframe
.iframe
.src
!= newurl
) && ( this
.mapparam
!= '' ) ) )
165 if( iframe
.iframe
.src
!= newurl
)
167 iframe
.iframe
.src
= newurl
;
169 iframe
.div
.style
.top
= (totalOffset( this
, 0 ) +
20 ) +
'px';
170 iframe
.div
.style
.visibility
="visible";
173 iframe
.div
.style
.visibility
="hidden";
178 // Check against coordinate urls
179 isMaplink
: function( url_orig
)
181 if( typeof(url_orig
) != 'string' ) return false;
183 // needed for the russian WP
185 try { url
= decodeURI( url_orig
) } catch( err
) { url
= url_orig
}
189 // for( var key = 0; key < config.coordurls.length; key++ ) {
190 for( var key in config
.coordurls
) {
191 if( url
.substr(0,config
.coordurls
[key
].length
) == config
.coordurls
[key
] )
199 // Insert the IFrame into the page.
203 if( typeof(wma_settings
) == 'object' )
204 for (var key in wma_settings
)
206 if( typeof(wma_settings
[key
]) == typeof(wikiminiatlas
.config
[key
]) )
207 wikiminiatlas
.config
[key
] = wma_settings
[key
];
210 if( wikiminiatlas
.config
.enabled
== false ) return;
214 site
= window
.location
.host
.substr(0,window
.location
.host
.indexOf('.'));
215 language
= wgUserLanguage
;
217 var len
; // cache array length for iterations
219 // remove stupid icons from title coordinates
220 var coord_title
= document
.getElementById('coordinates');
222 var icons
= coord_title
.getElementsByTagName('a');
224 for( var key
= 0; key
< len
; key++
) {
225 if( typeof(icons
[key
]) == 'object' && icons
[key
].className
== 'image' )
226 icons
[key
].parentNode
.removeChild(icons
[key
]);
231 if( config
.onlytitle
)
233 bodyc
= document
.getElementById('coordinates');
234 if( bodyc
== null ) return;
237 bodyc
= document
.getElementById('bodyContent') || document
;
239 links
= bodyc
.getElementsByTagName('a');
241 for( var key
= 0; key
< len
; key++
)
244 if( link
.className
== 'external text' && isMaplink(link
.href
) )
246 coordinates
= link
.href
;
247 coord_index
= coordinates
.indexOf('params=');
250 coord_params
= coordinates
.substr(coord_index+
7);
253 coord_filter
= /([\d+
-.]+
)_([NS
])_([\d+
-.]+
)_([EOW
])_
/;
254 if(coord_filter
.test(coord_params
))
256 coord_filter
.exec(coord_params
);
257 marker
.lat
=RegExp
.$1;
258 if(RegExp
.$2=='S') marker
.lat
*=-1;
259 marker
.lon
=RegExp
.$3;
260 if(RegExp
.$4=='W') marker
.lon
*=-1;
264 coord_filter
= /([\d+
-.]+
)_([\d+
-.]+
)_([NS
])_([\d+
-.]+
)_([\d+
-.]+
)_([EOW
])_
/;
265 if(coord_filter
.test(coord_params
))
267 coord_filter
.exec(coord_params
);
268 marker
.lat
=(1.0*RegExp
.$1) +
(RegExp
.$2/60.0);
269 if(RegExp
.$3=='S') marker
.lat
*=-1;
270 marker
.lon
=(1.0*RegExp
.$4) +
(RegExp
.$5/60.0);
271 if(RegExp
.$6=='W') marker
.lon
*=-1;
274 // degrees, minutes, seconds (+ fix for weird russian coords)
275 coord_filter
= /([\d+
-.]+
)_([\d+
-.]*)_([\d+
-.]*)_([NS
])_([\d+
-.]+
)_([\d+
-.]*)_([\d+
-.]*)_([EOW
])_
/;
276 if(coord_filter
.test(coord_params
))
278 coord_filter
.exec(coord_params
);
279 marker
.lat
=(1.0*RegExp
.$1) +
(RegExp
.$2/60.0) +
(RegExp
.$3/3600.0);
280 if(RegExp
.$4=='S') marker
.lat
*=-1;
281 marker
.lon
=(1.0*RegExp
.$5) +
(RegExp
.$6/60.0) +
(RegExp
.$7/3600.0);
282 if(RegExp
.$8=='W') marker
.lon
*=-1;
286 region_index = coordinates.indexOf('region:');
289 coordinate_region = coordinates.substr(region_index+7);
290 coordinate_region = coordinate_region.substr(0,coordinate_region.indexOf('"'));
294 // Find a sensible Zoom-level
295 var zoomlevel
= config
.zoom
;
299 if( coord_params
.indexOf('type:landmark') >= 0 ) zoomlevel
= 8;
300 if( coord_params
.indexOf('type:city') >= 0 ) zoomlevel
= 4;
303 mapbutton
= document
.createElement('img');
304 mapbutton
.title
= strings
.buttonTooltip
[language
] || strings
.buttonTooltip
.en
;
305 mapbutton
.style
.padding
= '0px 3px 0px 0px';
306 mapbutton
.style
.cursor
= 'pointer';
307 mapbutton
.src
= config
.buttonImage
;
309 marker
.lat +
'_' + marker
.lon +
'_' +
310 config
.width +
'_' + config
.height +
'_' +
311 site +
'_' + zoomlevel +
'_' + language
;
312 addEvent( mapbutton
, 'click', toggleIFrame
);
314 // link.parentNode.insertBefore(mapbutton, link.nextSibling);
315 link
.parentNode
.insertBefore(mapbutton
,link
);
318 /* var def_zoom = '';
319 if( typeof(wikiminiatlas_defaultzoom) == 'number' )
320 def_zoom = '_' + wikiminiatlas_defaultzoom; */
327 // iframe vorbereiten
328 if ( coordinates
!= null ) {
329 iframe
.div
= document
.createElement('div');
330 iframe
.div
.style
.visibility
= 'hidden';
331 iframe
.div
.style
.width
= (config
.width+
2)+
'px';
332 iframe
.div
.style
.height
= (config
.height+
2)+
'px';
333 iframe
.div
.style
.margin
= '0px';
334 iframe
.div
.style
.padding
= '0px';
335 iframe
.div
.style
.backgroundColor
= 'white';
336 iframe
.div
.style
.position
= 'absolute';
337 iframe
.div
.style
.right
= '2em';
338 iframe
.div
.style
.top
= '1em';
339 iframe
.div
.style
.border
= '1px solid gray';
340 iframe
.div
.style
.zIndex
= 13;
342 iframe
.closebutton
= document
.createElement('img');
343 iframe
.closebutton
.title
= strings
.close
[language
] || strings
.close
.en
;
344 // was: config.imgbase + 'button_hide.png'
345 iframe
.closebutton
.src
= 'http://upload.wikimedia.org/wikipedia/commons/d/d4/Button_hide.png'
346 iframe
.closebutton
.style
.zIndex
= 15;
347 iframe
.closebutton
.style
.position
= 'absolute';
348 iframe
.closebutton
.style
.right
= '11px';
349 iframe
.closebutton
.style
.top
= '9px';
350 iframe
.closebutton
.style
.width
= '18px';
351 iframe
.closebutton
.style
.cursor
= 'pointer';
352 iframe
.closebutton
.mapparam
= '';
353 addEvent( iframe
.closebutton
, 'click', toggleIFrame
);
355 iframe
.iframe
= document
.createElement('iframe');
356 iframe
.iframe
.scrolling
= 'no';
357 iframe
.iframe
.frameBorder
= '0';
358 iframe
.iframe
.style
.zIndex
= 14;
359 iframe
.iframe
.style
.position
= 'absolute';
360 iframe
.iframe
.style
.right
= '1px';
361 iframe
.iframe
.style
.top
= '1px';
362 iframe
.iframe
.style
.width
= (config
.width
)+
'px';
363 iframe
.iframe
.style
.height
= (config
.height
)+
'px';
364 iframe
.iframe
.style
.margin
= '0px';
365 iframe
.iframe
.style
.padding
= '0px';
367 iframe
.div
.appendChild(iframe
.iframe
);
368 iframe
.div
.appendChild(iframe
.closebutton
);
370 var content
= document
.getElementById('content');
371 content
.insertBefore(iframe
.div
,content
.childNodes
[0]);
379 // Hook up installation function
381 addOnloadHook(wikiminiatlas
.loader
);