Pengguna:Otourly/vector.js
Catatan: Setelah menyimpan, Anda harus memintas tembolok (cache) peramban Anda untuk melihat perubahannya. Google Chrome, Firefox, Microsoft Edge dan Safari: Tahan tombol ⇧ Shift dan klik Muat ulang (Reload) di tombol bilah alat. Untuk detail dan instruksi tentang peramban lain, lihat halaman menghapus singgahan (Inggris).
/**
* Move the coordinates which are at the top of the page
* From fr:mediawiki:common.js
*/
function moveCoord() {
var h1 = document.getElementById('firstHeading');
if(!h1) h1 = document.getElementsByTagName('h1')[0]; // Nostalgia, Standard
var coord = document.getElementById('coordinates');
if ( !coord || !h1 ) return;
coord.id = "coordinates-title";
h1.parentNode.insertBefore(coord, h1); /* déplacement de l'élément */
}
addOnloadHook(moveCoord);
// Verwendung von OpenStreetMap in Wikipedia.
// (c) 2008 by Magnus Manske
// Released under GPL
// Modified version in order to makes it work with moveCoord() above
// From fr:mediawiki:common.js
// modified to makes it work for IT : Otourly
if(typeof(MoveResizeAbsolute_AddMoveArea)!="function") importScriptURI('http://it.wiki-indonesia.club/w/index.php?title=MediaWiki:Gadget-MoveResizeAbsolute.js&action=raw&ctype=text/javascript');
function openStreetMap_Init () {
var c = document.getElementById ( 'coordinates-title' ) ;
if ( !c ) return ;
var a = c.getElementsByTagName ( 'a' ) ;
var geohack = false;
for ( var i = 0 ; i < a.length ; i++ ) {
var h = a[i].href ;
if ( !h.match(/geohack/) ) continue ;
geohack = true ;
break ;
}
if ( !geohack ) return ;
var na = document.createElement ( 'a' ) ;
na.href = 'javascript:openStreetMap_Toggle();' ;
na.title = 'Mostrare / nascondere la mappa' ;
na.appendChild ( document.createTextNode ( 'Mappa' ) ) ;
c.appendChild ( document.createTextNode ( ' (' ) ) ;
c.appendChild ( na ) ;
c.appendChild ( document.createTextNode ( ') ' ) ) ;
}
function openStreetMap_Toggle () {
var c = document.getElementById ( 'coordinates-title' ) ;
if ( !c) return ;
var osm = document.getElementById ( 'OpenStreetMap' ) ;
if (osm) {
if ( osm.style.display == 'none' ) {
osm.style.display = 'block' ;
} else {
osm.style.display = 'none' ;
}
return;
}
var found_link = false ;
var a = c.getElementsByTagName ( '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 ; // No geohack link found
h = h.split('params=')[1] ;
var LarghezzaSchermo = MoveResizeAbsolute_GetScreenWidth();
var AlterigiaSchermo = MoveResizeAbsolute_GetScreenHeight();
var OSMDiv = document.createElement('div');
OSMDiv.id = 'OpenStreetMap' ;
OSMDiv.style.position = "absolute";
OSMDiv.style.zIndex = 5000;
OSMDiv.style.top = (AlterigiaSchermo*10/100) + "px";
OSMDiv.style.left = (LarghezzaSchermo*15/100) + "px";
OSMDiv.style.width = "70%";
OSMDiv.style.height = (AlterigiaSchermo*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 = "Clicca e trascina per ridimensionare la mappa";
var CloseLink = document.createElement('a');
CloseLink.setAttribute("style", "float:right;margin:10px;");
CloseLink.innerHTML = "Nascondere";
CloseLink.title = "Clicca per nascondere";
CloseLink.href = "javascript:openStreetMap_Toggle();";
MoveArea.appendChild(CloseLink);
var iFrame = document.createElement ( 'iframe' ) ;
var url = 'http://toolserver.org/~kolossos/openlayers/kml-on-ol.php?lang=' + mw.config.get('wgUserLanguage') + '¶ms=' + h ;
iFrame.style.width = '100%' ;
iFrame.style.height = ((AlterigiaSchermo*80/100)-100) + 'px' ;
iFrame.style.clear = 'both' ;
iFrame.src = url ;
var ResizeArea = document.createElement('div');
ResizeArea.style.position = "relative";
ResizeArea.style.top = "0";
ResizeArea.style.width = "100%";
ResizeArea.style.height = "50px";
ResizeArea.title = "Clicca e trascina per ridimensionare la mappa";
OSMDiv.appendChild(MoveArea);
OSMDiv.appendChild(iFrame);
OSMDiv.appendChild(ResizeArea);
document.body.appendChild ( OSMDiv ) ;
var ElementsToMove = new Array(OSMDiv);
var ElementsToResize = new Array(OSMDiv, iFrame);
var ElementsMinWidth = new Array(150, 150);
var ElementsMinHeights = new Array(200, 100);
MoveResizeAbsolute_AddMoveArea(MoveArea, ElementsToMove);
MoveResizeAbsolute_AddResizeArea(ResizeArea, ElementsToResize, ElementsMinWidth, ElementsMinHeights);
}
addOnloadHook(openStreetMap_Init);