User:Aude/geonotice.js
Appearance
(Redirected from User:Aude/Geonotice.js)
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:Aude/geonotice. |
//<source lang="JavaScript">
var notices = {
AmbassadorsDC:
{
begin : '14 November 2010 00:00 UTC',
end: '28 November 2010 00:00 UTC',
corners: [ [40,-76], [37.5,-78] ],
text: 'ZOMG!!!! there is a meetup coming up soon! You must be there!'
},
DubaiMeetup:
{
begin : '23 November 2010 22:00 UTC',
end : '4 December 2010 14:00 UTC',
corners: [ [27, 57], [22, 50] ],
text: 'Join other Wikipedians and Wikimedia Foundation Executive Director <a href="http://wikimediafoundation.org/wiki/User:Sue_Gardner">Sue Gardner</a> for a meetup in <a href="http://wiki.riteme.site/wiki/Wikipedia:Meetup/Dubai_1">Dubai</a> on 4 December!'
}
/*******************************************
* End of list.
* Edit only above!
*
* Format is:
*
* ID:
* { begin: 'date',
* end: 'date',
* corners: [ [lat,lon], [lat,lon] ],
* text: 'message'
* }
*
* There should be a commas between the notices, but not after the last one.
*
*******************************************/
}
if (typeof(geoip) != 'undefined') {
var now = new Date();
for (var id in notices) {
if (!document.cookie.match('hidegeonotice'+id+'=1')) {
var notice = notices[id];
if (!notice || !notice.corners) continue;
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)
&& now.getTime() < Date.parse(notice.end)
&& minlat<geoip.latitude && geoip.latitude<maxlat
&& minlon<geoip.longitude && geoip.longitude<maxlon
) {
insertsub = document.getElementById('contentSub');
insertsub.innerHTML += '<div class="plainlinks" id="geonotice'+id+'" style="width:98%; margin:5px auto 0; background:transparent; text-align:left; line-height: 1.8em;"><font size="+1">'+notice.text+'</font> <small><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></small></div>';
}
}
}
}
//</source>