ميدياويكي:Common.js/watchlist.js

من موسوعة المزرعة
< ميدياويكي:Common.js
مراجعة 02:20، 5 أبريل 2021 بواسطة Abdul Aziz Alwafaay (نقاش | مساهمات) (أنشأ الصفحة ب'/** Add dismiss buttons to watchlist-message ************************************* * * Description: Allows multiple dismiss buttons on MediaWiki:Watchlist-details...')
(فرق) → مراجعة أقدم | المراجعة الحالية (فرق) | مراجعة أحدث ← (فرق)
اذهب إلى التنقل اذهب إلى البحث

ملاحظة: بعد الحفظ، أنت قد تحتاج إلى إفراغ الكاش الخاص بمتصفحك لرؤية التغييرات.

  • فايرفوكس / سافاري: أمسك Shift أثناء ضغط Reload، أو اضغط على إما Ctrl-F5 أو Ctrl-R (⌘-R على ماك)
  • جوجل كروم: اضغط Ctrl-Shift-R (⌘-Shift-R على ماك)
  • إنترنت إكسبلورر: أمسك Ctrl أثناء ضغط Refresh، أو اضغط Ctrl-F5
  • أوبرا: اذهب إلى Menu → Settings (Opera → Preferences على ماك) ثم إلى Privacy & security → Clear browsing data → Cached images and files.
/** Add dismiss buttons to watchlist-message *************************************
 *
 *  Description: Allows multiple dismiss buttons on [[MediaWiki:Watchlist-details]] with bump-able cookie IDs.
 *  Note: HTML is backwards compatible with old version, new version ignores old syntax, except for dismissed IDs.
 */

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','javascript:dismissWatchlistMessage(' + i + ',' + watchlistCookieID + ')');
    ButtonLink.setAttribute('title','أخف الرسالة (إلى حين إفراغ الكوكيز، أو انتهاء مهلة الرسالة)');
    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() {
  addDismissButton();
  if ( $( 'table.mw-enhanced-rc' ).length > 0 ) {
    mw.util.addCSS( '#mw-wlheader-showupdated, #mw-watchlist-resetbutton { display: none; } ' );
  }
});