مدیاویکی:Watchlist.js
نکته: پس از انتشار ممکن است برای دیدن تغییرات نیاز باشد که حافظهٔ نهانی مرورگر خود را پاک کنید.
- فایرفاکس / سافاری: کلید Shift را نگه دارید و روی دکمهٔ Reload کلیک کنید، یا کلیدهای Ctrl-F5 یا Ctrl-R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای ⌘-R)
- گوگل کروم: کلیدهای Ctrl+Shift+R را با هم فشار دهید (در رایانههای اپل مکینتاش کلیدهای ⌘-Shift-R)
- اینترنت اکسپلورر/ Edge: کلید Ctrl را نگهدارید و روی دکمهٔ Refresh کلیک کنید، یا کلیدهای Ctrl-F5 را با هم فشار دهید
- اپرا: Ctrl-F5 را بفشارید.
// from https://en.wikipedia.org/wiki/MediaWiki:Common.js/watchlist.js
/** Add dismiss buttons to watchlist-message
* Allows multiple dismiss buttons on [[MediaWiki:Watchlist-summary]] with bumpable cookie IDs.
* Note: HTML is backwards compatible with old version, new version ignores old syntax, except for dismissed IDs.
* @author: [[:en:User:Ruud Koot]]
* @author: [[:en:User:MZMcBride]]
*/
/*jslint white: true, regexp: true */
/*global jQuery, mediaWiki */
( function ( mw, $ ) {
'use strict';
function dismissWatchlistMessage( event ) {
var $message = $( this ).closest( '.watchlist-message' );
var cid = $( this ).data( 'watchlistMessage' ).cid;
$message.hide();
var e = new Date();
e.setTime( e.getTime() + (4*7*24*60*60*1000) );
document.cookie = 'hidewatchlistmessage-' + cid + '=yes; expires=' + e.toGMTString() + '; path=/';
event.preventDefault();
}
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( 'نهفتن' );
ButtonLink.className = 'dismissButton';
ButtonLink.setAttribute( 'href', '#' );
ButtonLink.setAttribute( 'title', 'پنهانکردن این پیام' );
ButtonLink.appendChild( ButtonText );
$( ButtonLink ).data( 'watchlistMessage', {
index: i,
cid: watchlistCookieID
} );
$( ButtonLink ).click( dismissWatchlistMessage );
Button.appendChild( document.createTextNode(' [' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
watchItems[i].appendChild( Button );
}
$( '#watchlist-message' ).show();
}
$( addDismissButton );
}( mediaWiki, jQuery ) );