MediaWiki:Gadget-osm.js
Apparence
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.// Verwendung von OpenStreetMap in Wikipedia.
// (c) 2008 by Magnus Manske
// Released under GPL
function openStreetMapInit () {
c = document.getElementById ( 'coordinates' ) ;
if ( !c ) return ;
a = c.getElementsByTagName ( 'a' ) ;
geohack = 0 ;
for ( i = 0 ; i < a.length ; i++ ) {
h = a[i].href ;
if ( !h.match(/geohack/) ) continue ;
geohack = 1 ;
break ;
}
if ( geohack == 0 ) return ;
na = document.createElement ( 'a' ) ;
na.href = '#' ;
na.onclick = openStreetMapToggle ;
na.appendChild ( document.createTextNode ( 'OSM' ) ) ;
// c.appendChild ( document.createElement ( 'br' ) )
c.appendChild ( document.createTextNode ( ' (' ) ) ;
c.appendChild ( na ) ;
c.appendChild ( document.createTextNode ( ') ' ) ) ;
}
function openStreetMapToggle () {
c = document.getElementById ( 'coordinates' ) ;
if ( !c ) return ;
cs = document.getElementById ( 'contentSub' ) ;
osm = document.getElementById ( 'openstreetmap' ) ;
if ( cs && osm ) {
if ( osm.style.display == 'none' ) {
osm.style.display = 'block' ;
} else {
osm.style.display = 'none' ;
// cs.removeChild ( osm ) ;
}
return false ;
}
var found_link = 0 ;
a = c.getElementsByTagName ( 'a' ) ;
for ( i = 0 ; i < a.length ; i++ ) {
h = a[i].href ;
if ( !h.match(/geohack/) ) continue ;
found_link = 1 ;
break ;
}
if ( found_link == 0 ) return ; // No geohack link found
h = h.split('params=')[1] ;
i = document.createElement ( 'iframe' ) ;
url = 'http://tools.wikimedia.de/~magnus/ol/wp_poi.php?title=' + wgTitle ;
url += '&language=' + wgUserLanguage ;
url += '¶ms=' + h ;
i.id = 'openstreetmap' ;
i.style.width = '100%' ;
i.style.height = '300px' ;
i.style.clear = 'both' ;
i.src = url ;
cs.appendChild ( i ) ;
return false ;
}
addOnloadHook(openStreetMapInit);