User:Para/geonotice.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Para/geonotice. |
var notices = {
WN_SFMLN:
{ begin: '1 February 2008 00:00 UTC',
corners: [ [39.6,-128.3], [35.7,-115.8] ],
text: 'Bay area Wikipedians may be interested in the <a href="http://lists.wikimedia.org/pipermail/wikimedia-sf/">wikimedia-sf mailing list</a>.'
},
TEST:
{ begin: '15 March 2009 00:00 UTC',
corners: [ [36,35], [34,32] ],
text: 'Party at Cyprus? Join us!'
},
NYC:
{ begin: '15 March 2009 00:00 UTC',
corners: [ [42,-76], [40,-72] ],
text: 'Wikipedia Takes the Bronx Zoo!'
}
/*******************************************
* End of list.
* Edit only above!
*
* Format is:
*
* ID:
* { begin: 'date',
* corners: [ [lat,lon], [lat,lon] ],
* text: 'message'
* }
*
* Don't forget the comma between notices!
*
*******************************************/
}
if (typeof(geoip) != 'undefined') {
var now = new Date();
for (var id in notices) {
if (!document.cookie.match('hidegeonotice'+id+'=1')) {
var notice = notices[id];
var minlat = Math.min(notice.corners[0][0], notice.corners[1][0]);
var maxlat = Math.max(notice.corners[0][0], notice.corners[1][0]);
var minlon = Math.min(notice.corners[0][1], notice.corners[1][1]);
var maxlon = Math.max(notice.corners[0][1], notice.corners[1][1]);
if ( now.getTime() > Date.parse(notice.begin)
&& minlat<geoip.latitude && geoip.latitude<maxlat
&& minlon<geoip.longitude && geoip.longitude<maxlat
) {
insertsub = document.getElementById('contentSub');
insertsub.innerHTML += '<div class="plainlinks" id="geonotice'+id+'" style="width:98%; margin:5px auto 0; background:transparent; text-align:right"><font size="+1" color="#000">'+notice.text+'</font><br/><i>[<a href="#" onClick="var date = new Date(); date.setTime(date.getTime()+8640000000);document.cookie = \'hidegeonotice'+id+'=1; expires=\' + date.toGMTString() + \'; path=/\';document.getElementById(\'geonotice'+id+'\').style.visibility = \'hidden\';return false">hide</a>]</i></div>';
}
}
}
}