မီႇတီႇယႃႇဝီႇၶီႇ:Gadget-watchlist-notice-core.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 ၼၼ်ႉလႄႈ။
/**
* Add dismiss buttons to watchlist-message, then unhide it
* Allows multiple dismiss buttons on [[MediaWiki:Watchlist-messages]] with bumpable cookie IDs (now used for LS).
* 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';
var storageKey = 'hidewatchlistmessages';
function getDismissedNotices () {
var hiddenNotices = mw.storage.get( storageKey )
|| mw.storage.session.get( storageKey );
try {
return JSON.parse( hiddenNotices ) || [];
} catch (e) {
return [];
}
}
function saveDismissedNotices ( notices ) {
notices = JSON.stringify( notices );
mw.storage.set( storageKey, notices )
|| mw.storage.session.set( storageKey, notices );
}
// Remove ids which are no longer defined
function expungeOldNotices ( currentList ) {
var dismissedNotices = getDismissedNotices(),
originalLength = dismissedNotices.length;
for ( var i = dismissedNotices.length - 1; i >= 0; i--) {
if( currentList.indexOf( dismissedNotices[i] ) === -1 ) {
dismissedNotices.splice( i, 1 );
}
}
if( originalLength !== dismissedNotices.length ) {
saveDismissedNotices( dismissedNotices );
}
}
function dismissWatchlistMessage( event ) {
var $message = $( this ).closest( '.watchlist-message' );
var cid = $( this ).data( 'watchlistMessage' ).cid;
var notices = getDismissedNotices();
$message.hide();
notices.push( cid );
saveDismissedNotices( notices );
event.preventDefault();
}
function addDismissButton() {
var watchItems = $( 'div.watchlist-message' );
var watchItemIds = [];
var dismissedNotices = getDismissedNotices();
var dismissedNoticesLength = dismissedNotices.length;
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;
}
watchItemIds.push( watchlistCookieID );
if ( dismissedNotices.indexOf( watchlistCookieID ) !== -1 ) {
watchItems[i].style.display = 'none';
continue;
}
var Button = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( 'dismiss' );
ButtonLink.className = 'dismissButton';
ButtonLink.setAttribute( 'href', '#' );
ButtonLink.setAttribute( 'title', 'Hide this message' );
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 );
}
expungeOldNotices( watchItemIds );
$( '#watchlist-message' ).show();
}
$( addDismissButton );
}( mediaWiki, jQuery ) );