မီႇတီႇယႃႇဝီႇၶီႇ:Geonotice.js
မၢႆတွင်း: ဝၢႆးသေသိမ်းပၼ်ယဝ်ႉ၊ တွၼ်ႈတႃႇ ၸဝ်ႈၵဝ်ႇ တေႁၼ်လႆႈ လွင်ႈလႅၵ်ႈလၢႆႈၼၼ်ႉ ၸဝ်ႈၵဝ်ႇတေၸၢင်ႈလႆႈလတ်းၶၢမ်ႈ ၶႅတ်ႉၶျ် တူဝ်ပိုတ်ႇဝႅပ်ႉၸဝ်ႈၵဝ်ႇယဝ်ႉ။
- ၽွင်းမိူဝ်ႈတိုၵ်ႉၼဵၵ်း Reload တီႈ Firefox / Safari: ၼၼ်ႉ ၼဵၵ်းဝႆႉပႃး Shift ၊ဢမ်ႇၼၼ် ၼဵၵ်းပၼ် Ctrl-F5 ဢမ်ႇၼၼ် Ctrl-R (တီႈၼႂ်း Mac ၼႆ ၼဵၵ်းပၼ်⌘-R)
- တီႈၼႂ်း Google Chrome: ၼဵၵ်းပၼ် Ctrl-Shift-R (တီႈၼႂ်း Mac ၼႆႉ ၼဵၵ်းပၼ်⌘-Shift-R )
- ၽွင်းမိူဝ်ႈ တိုၵ်ႉၼဵၵ်း Refreshတီႈ Internet Explorer/ Edge: ၼဵၵ်းဝႆႉပၼ် Ctrl ဢမ်ႇၼၼ် ၼဵၵ်းပၼ် Ctrl-F5
- တီႈၼႂ်း Opera: ၵႂႃႇၸူးတီႈ Menu → Settings (ပေႃးပဵၼ်တီႈၼႂ်း Mac ၸိုင် Opera → Preferences ) သေ သိုပ်ႇၵႂႃႇ Privacy & security → Clear browsing data → Cached images and files ၼၼ်ႉလႄႈ။
(function() {
var notices = {
Test2:
{ begin: '9 October 2013 00:00 UTC',
end: '17 October 2013 00:00 UTC',
corners: [ [34, 74.5], [24.5, 62.1] ],
text : "Test"
},
/*******************************************
* End of list.
* Edit only above!
*
* Format is:
*
* ID:
* { begin: 'date',
* end: 'date',
* corners: [ [lat,lon], [lat,lon] ],
* text: 'message'
* }
*
* There also is an option to use country instead of corners. For example:
* ID:
* { begin: 'date',
* end: 'date',
* country: 'US',
* text: 'message'
* }
*
* See http://dev.maxmind.com/geoip/legacy/codes/iso3166 for full list of country codes
*
* * There should be commas between the notices, but not after the last one. BE SURE TO ESCAPE YOUR APOSTROPHES (put a backslash in front of it, like this: \')!
* Use [[meta:w:en:link|link]] format for internal links, so that they work properly on the other projects where the geonotice is displayed.
*
*******************************************/
};
function geoWikiLinker (str, page, text) {
text = text || page;
return mw.html.element(
'a', {
href: mw.util.getUrl( page ),
title: page
}, text
);
}
function addGeonoticeCss() {
mw.util.addCSS( [
'#watchlist-message .geonotice {',
'width:98%;',
'background:transparent;',
'text-align:left;',
'line-height:1.8em;',
'}',
'#watchlist-message .geonotice span {',
'font-size:144.5%;',
'}',
'#watchlist-message .geonotice small {',
'font-style:italic;',
'margin-left:.5em;',
'}',
'#watchlist-message .geonotice small a::before {',
'content: "[";',
'}',
'#watchlist-message .geonotice small a::after {',
'content: "]";',
'}'
].join( ' ' ) );
}
function hideGeonotice(e) {
e.preventDefault();
var parentId = $(this).closest('li').attr('id');
var date = new Date();
date.setTime(date.getTime()+8640000000);
var expireDate = date.toGMTString();
document.cookie = 'hide' + parentId + '=1; expires=' + expireDate + ';path=/';
$( '#' + parentId ).hide();
$( '#geonotice-hr' ).hide();
return false;
}
var firstnotice = true;
var regexForInternalLinks = /\[\[([^{|}\[\]\n]+)(?:\|(.*?))?\]\]/g;
function displayGeonotice(notice) {
var geonoticeText = notice.text.replace( regexForInternalLinks, geoWikiLinker );
if (firstnotice) {
firstnotice = false;
$('#watchlist-message').prepend(
$( '<hr>' ).attr({ 'id' : 'geonotice-hr' })
);
addGeonoticeCss();
}
$('#watchlist-message').prepend(
$('<li>')
.attr({
'class' : 'geonotice plainlinks',
'id' : 'geonotice' + notice.id
})
.append(
$( '<span>' )
.html( geonoticeText )
)
.append( $( '<small>' )
.append(
$('<a>')
.text( 'hide' )
.click( hideGeonotice )
.attr({ 'href' : '#' })
)
)
);
}
if ( Geo !== undefined && notices ) {
var now = new Date(),
id, notice, minlat, maxlat, minlon, maxlon,
startNotice, endNotice;
for (id in notices) {
if (!document.cookie.match('hidegeonotice'+id+'=1')) {
notice = notices[id];
notice.id = id;
if (!notice || !notice.begin || !notice.end) {
continue;
}
startNotice = Date.parse(notice.begin);
endNotice = Date.parse(notice.end);
if ( now.getTime() > startNotice &&
now.getTime() < endNotice ) {
if (notice.country && Geo.country === notice.country) {
displayGeonotice(notice);
} else {
if (notice.corners) {
minlat = Math.min(notice.corners[0][0], notice.corners[1][0]);
maxlat = Math.max(notice.corners[0][0], notice.corners[1][0]);
minlon = Math.min(notice.corners[0][1], notice.corners[1][1]);
maxlon = Math.max(notice.corners[0][1], notice.corners[1][1]);
// Geo coordinates can be empty string if unknown. parseFloat makes
// these NaN, so that you do not get to see a notice in that case.
if ( minlat < parseFloat( Geo.lat ) && parseFloat( Geo.lat ) < maxlat &&
minlon < parseFloat( Geo.lon ) && parseFloat( Geo.lon ) < maxlon ) {
displayGeonotice(notice);
}
}
}
}
}
}
}
})();