Note: After saving, you have to
bypass your browser's cache to see the changes.
Internet Explorer: press
Ctrl-F5 ,
Mozilla: hold down
Shift while clicking
Reload (or press
Ctrl-Shift-R ),
Opera/Konqueror: press
F5 ,
Safari: hold down
Shift + Alt while clicking
Reload ,
Chrome: hold down
Shift while clicking
Reload .
var coordupdate =
{
config : {
coordurls : new Array (
'http://tools.wikimedia.de/~magnus/geo/geohack.php?' ,
'http://www8.brinkster.com/erikbaas/wiki/maps.asp?' ,
'http://www.nsesoftware.nl/wiki/maps.asp?'
)
},
// Check against coordinate urls
isMaplink : function ( url )
{
if ( typeof ( url ) != 'string' ) return false ;
with ( coordupdate )
{
for ( var key in config . coordurls ) {
if ( url . substr ( 0 , config . coordurls [ key ]. length ) == config . coordurls [ key ] )
return true ;
}
}
return false ;
},
transmit : function ( title , data )
{
var myIframe = document . createElement ( 'iframe' );
myIframe . style . visibility = 'hidden' ;
document . getElementById ( 'content' ). appendChild ( myIframe );
myIframe . src =
'http://tools.wikimedia.de/~dschwen/wikiminiatlas/receive_update.php?title=' +
escape ( title ) + '&data=' + escape ( data ) + '&user=' + escape ( mw . config . get ( 'wgUserName' ));
},
install : function ()
{
var edittag_name = 'cue_' + mw . config . get ( 'wgPageName' );
var expiry ;
if ( document . getElementById ( 'editform' ) != null )
{
//
// Tag article as being edited
//
expiry = new Date ();
expiry . setTime ( expiry . getTime () + ( 5 * 60 * 1000 ) ); // +5min
document . cookie = edittag_name + '=1; path=/; expires=' + expiry . toGMTString ();
}
if ( ( mw . config . get ( 'wgCanonicalNamespace' ) == '' || mw . config . get ( 'wgNamespaceNumber' ) == 6 )
&& mw . config . get ( 'wgIsArticle' ) )
{
var coord_index ;
var cookie_data = '' ;
var cookie_name = 'cu_' + mw . config . get ( 'wgPageName' );
var wasEdited = false ;
//
// Gather current coordinate Data
//
var links = document . getElementsByTagName ( 'A' );
for ( key in links ) {
if ( coordupdate . isMaplink ( links [ key ]. href ) )
{
coord_index = links [ key ]. href . indexOf ( 'params=' );
if ( coord_index >- 1 ) {
cookie_data += links [ key ]. href . substr ( coord_index + 7 ) + '|' ;
}
}
}
//
// Recover matching Cookie
//
var cookies = document . cookie . split ( "; " );
var cookie_read = '' ;
for ( key in cookies )
{
if ( cookies [ key ]. substr ( 0 , edittag_name . length + 2 ) ==
( edittag_name + '=1' ) ) wasEdited = true ;
if ( cookies [ key ]. substr ( 0 , cookie_name . length + 1 ) ==
( cookie_name + '=' ) )
{
cookie_read = cookies [ key ]. substr ( cookie_name . length + 1 );
break ;
}
}
/*
if( ( cookie_read != cookie_data && cookie_read != '' ) ||
( cookie_read != cookie_data && cookie_read == '' && wasEdited ) )
coordupdate.transmit( mw.config.get('wgTitle'), cookie_data );
*/
if ( cookie_read != cookie_data &&
( cookie_read != '' || ( cookie_read == '' && wasEdited ) ) )
coordupdate . transmit ( mw . config . get ( 'wgTitle' ), cookie_data );
//
// Expire Edit Tag and possibly unset coordinate cookie
//
expiry = new Date ();
expiry . setTime ( expiry . getTime () - 1 ); // unset cookie
document . cookie = edittag_name + '=0; path=/; expires=' + expiry . toGMTString ();
if ( cookie_data == '' )
document . cookie = cookie_name + '=""; expires=' + expiry . toGMTString ();
//
// Set current Data as Cookie
//
expiry = new Date ();
expiry . setTime ( expiry . getTime () + ( 5 * 60 * 1000 ) ); // +5min
if ( cookie_data != '' )
document . cookie = cookie_name + '=' + cookie_data +
'; expires=' + expiry . toGMTString ();
}
}
}
//
// Hook up installation function
//
$ ( coordupdate . install );