MediaWiki:Common.js/watchlist.js
Đây là JavaScript ảnh hưởng đến danh sách theo dõi. Nó được tải trong MediaWiki:Common.js. Các thay đổi lớn ở đây nên được đề xuất trước hết trong trang thảo luận hoặc Phòng thảo luận.
Xin lưu ý rằng những thay đổi ở đây sẽ có hiệu lực sau vài phút. Những lỗi vô tình ở đây có thể phá hỏng toàn bộ bách khoa toàn thư, vì vậy hãy đảm bảo rằng bạn biết chắc mình đang làm gì. Có thể thử nghiệm trước trong trang common.js hay một trang skin JS tùy chọn khác của cá nhân bạn. |
/** Ẩn các thông điệp trong watchlist-message *************************************
*
* Mô tả: Cho phép ẩn thông điệp trong [[MediaWiki:Watchlist-details]].
* Bảo trì: [[:en:User:Ruud Koot|Ruud Koot]], [[:en:User:MZMcBride|MZMcBride]]
*/
function addDismissButton() {
var watchItems = $("div.watchlist-message");
if (watchItems.length == 0) watchItems = $("li.watchlist-message")
if (watchItems.length == 0) return
for (var i = 0; i < watchItems.length; i++) {
var watchlistCookieID = parseInt(watchItems[i].className.replace(/.*cookie\-ID\_(\d*).*/ig,'$1'));
if (isNaN(watchlistCookieID)) continue
if (document.cookie.indexOf('hidewatchlistmessage-' + watchlistCookieID + '=yes') != -1) {
watchItems[i].style.display = 'none';
continue;
}
var Button = document.createElement('span');
var ButtonLink = document.createElement('a');
var ButtonText = document.createTextNode('ẩn thông điệp này');
ButtonLink.className = 'dismissButton';
ButtonLink.setAttribute('href','javascript:dismissWatchlistMessage(' + i + ',' + watchlistCookieID + ')');
ButtonLink.setAttribute('title','Ẩn thông điệp này');
ButtonLink.appendChild(ButtonText);
Button.appendChild(document.createTextNode(' ['));
Button.appendChild(ButtonLink);
Button.appendChild(document.createTextNode(']'));
watchItems[i].appendChild(Button);
}
}
function dismissWatchlistMessage(num,cid) {
var watchItems = $("div.watchlist-message");
if(watchItems.length == 0) watchItems = $("li.watchlist-message")
watchItems[num].style.display = 'none';
var e = new Date();
e.setTime( e.getTime() + (4*7*24*60*60*1000) );
document.cookie = 'hidewatchlistmessage-' + cid + '=yes; expires=' + e.toGMTString() + '; path=/';
}
/**
* Hide the "green bullets" message for those using enhanced recent changes.
*/
$( document ).ready( function() {
if ( $( 'table.mw-enhanced-rc' ).length > 0 ) {
mw.util.addCSS( '#mw-wlheader-showupdated, #mw-watchlist-resetbutton { display: none; } ' );
}
addDismissButton();
/* Load the geonotices. See [[Wikipedia:Geonotice]]. */
// mw.loader.load( mw.config.get( 'wgScript' ) + '?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600&ver=2');
});