MediaWiki:Geonotice.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- The following documentation is located at MediaWiki:Geonotice.js/documentation. [edit]
- Useful links: subpage list • links • redirects
// {{documentation}}
var notices = {
/*******************************************
* End of list.
* Edit only above!
*
* Format is:
*
* ID:
* { begin: '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];
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 < maxlon
) {
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>';
}
}
}
}