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() {
var c = $( '#coordinates-title' );
if ( !c.length ) {
return;
}
var a = c.find( 'a' );
var geohack = false;
for (var i = 0; i < a.length; i++) {
var h = a[i].href;
if (!h.match(/geohack/)) continue;
if (h.match(/skyhack/)) continue;
if (h.match(/_globe:/)) continue; // no OSM for moon, mars, etc
geohack = true;
break;
}
if ( !geohack ) {
return;
}
var separator = $( '<span>' );
separator.text( ' | ' );
separator.attr( 'class', 'noprint coordinates-separator' );
c.append( separator );
var img = $( '<img>' );
img.attr( {
'src': '/media/wikipedia/commons/thumb/c/c9/OpenStreetMapLogo.png/17px-OpenStreetMapLogo.png',
'width': '17px',
'height': '17px'
} );
var a = $( '<a>' );
a.attr( {
'href': '#',
'title': 'Afficher / Masquer la carte',
'class': 'noprint osm-icon-coordinates'
} );
a.click( function () {
var c = $( '#coordinates-title' );
if ( !c.length) {
return false;
}
var cs = $( '#contentSub' );
var osm = $( '#openstreetmap' );
if ( cs.length && osm.length ) {
if ( osm.css( 'display' ) === 'none' ) {
osm.css( 'display', 'block' );
} else {
osm.css( 'display', 'none' );
}
return false;
}
var found_link = false;
var a = c.find( 'a' );
var h;
for (var i = 0; i < a.length; i++) {
h = a[i].href;
if (!h.match(/geohack/)) continue;
found_link = true;
break;
}
if ( !found_link ) {
return false; // No geohack link found
}
h = h.split('params=')[1];
var url = '//tools.wmflabs.org/wiwosm/osm-on-ol/kml-on-ol.php?lang=de&uselang='
+ mw.util.rawurlencode( mw.config.get( 'wgUserLanguage' ) )
+ '¶ms=' + h
+ '&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgTitle' ) );
var iframe = $( '<iframe>' );
iframe.attr( 'id', 'openstreetmap' );
iframe.css({
'width': '100%',
'height': '350px',
'clear': 'both'
} );
iframe.attr( 'src', url );
var screenWidth = MoveResizeAbsolute_GetScreenWidth();
var screenHeight = MoveResizeAbsolute_GetScreenHeight();
var OSMDiv = document.createElement('div');
OSMDiv.id = 'OpenStreetMap';
OSMDiv.style.position = "absolute";
OSMDiv.style.zIndex = 5000;
OSMDiv.style.top = (screenHeight*10/100) + "px";
OSMDiv.style.left = (screenWidth*15/100) + "px";
OSMDiv.style.width = "70%";
OSMDiv.style.height = (screenHeight*80/100) + "px";
OSMDiv.style.border = "2px solid black";
OSMDiv.style.backgroundColor = "white";
OSMDiv.style.overflow = "hidden";
var MoveArea = document.createElement('div');
MoveArea.style.position = "relative";
MoveArea.style.top = "0";
MoveArea.style.width = "100%";
MoveArea.style.height = "50px";
MoveArea.title = "Cliquer et glisser pour déplacer la carte";
var CloseLink = document.createElement('a');
CloseLink.setAttribute("style", "float:right;margin:10px;");
CloseLink.innerHTML = "Masquer";
CloseLink.title = "Cliquer pour masquer la carte";
CloseLink.href = "javascript:openStreetMap_Toggle();";
MoveArea.appendChild(CloseLink);
var ResizeArea = document.createElement('div');
ResizeArea.style.position = "relative";
ResizeArea.style.top = "0";
ResizeArea.style.width = "100%";
ResizeArea.style.height = "50px";
ResizeArea.title = "Cliquer et glisser pour redimensionner la carte";
OSMDiv.appendChild(MoveArea);
OSMDiv.appendChild(iframe);
OSMDiv.appendChild(ResizeArea);
MoveResizeAbsolute_AddMoveArea( MoveArea, [ OSMDiv ] );
MoveResizeAbsolute_AddResizeArea( ResizeArea, [ OSMDiv, iframe ], [ 150, 150 ], [ 200, 100 ] );
cs.append( OSMDiv );
return false;
} );
a.append( img );
a.append( ' carte' );
c.append( a );
} );