Bahaipedia
Bahaipedia
Menu
About Bahaipedia
Ask a question
General help
Random page
Recent changes
In other projects
Tools
What links here
Related changes
Upload file
Special pages
Printable version
Permanent link
Page information
Message
Discussion
View source
View history
Talk
Contributions
Create account
Log in
Navigation
About Bahaipedia
Ask a question
General help
Random page
Recent changes
In other projects
Learn more
Core topics
Bahá’í Faith
Central Figures
Teachings
Practices
Tools
What links here
Related changes
Upload file
Special pages
Printable version
Permanent link
Page information
Translations

MediaWiki:Common.js/watchlist.js

From Bahaipedia
< MediaWiki:Common.js
Jump to:navigation, search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
//<source lang="JavaScript">

/** 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.
 *  Maintainers: [[User:Ruud Koot|Ruud Koot]], [[User:MZMcBride|MZMcBride]]
 */

function addDismissButton() {
  var docobj = document.getElementById('bodyContent') || document.getElementById('content') || document
  var watchItems = getElementsByClassName(docobj, 'div', '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('dismiss');

    ButtonLink.setAttribute('id','dismissButton');
    ButtonLink.setAttribute('href','javascript:dismissWatchlistMessage(' + i + ',' + watchlistCookieID + ')');
    ButtonLink.setAttribute('title','Hide this message for one week');
    ButtonLink.appendChild(ButtonText);

    Button.appendChild(document.createTextNode('['));
    Button.appendChild(ButtonLink);
    Button.appendChild(document.createTextNode(']'));
    watchItems[i].appendChild(Button);
  }
}

function dismissWatchlistMessage(num,cid) {
  var docobj = document.getElementById('bodyContent') || document.getElementById('content') || document
  var watchItems = getElementsByClassName(docobj, 'div', 'watchlist-message');
  watchItems[num].style.display = 'none';

  var e = new Date();
  e.setTime( e.getTime() + (7*24*60*60*1000) );
  document.cookie = 'hidewatchlistmessage-' + cid + '=yes; expires=' + e.toGMTString() + '; path=/';
}
addOnloadHook(addDismissButton);

/** Geo-targeted watchlist notice *******************************************************
  *
  *  Description: Allows for geographic targeting of watchlist notices. See [[Wikipedia:Geonotice]] for more information.
  *  Created by: [[User:Gmaxwell]]
  */

if (wgPageName == "Special:Watchlist") {
  addOnloadHook(function() { importScriptURI('http://tools.wikimedia.de/~gmaxwell/cgi-bin/geonotice.py') });
}

//</source>
Retrieved from "https://bahaipedia.org/index.php?title=MediaWiki:Common.js/watchlist.js&oldid=22390"
Category:
  • Pages using deprecated source tags
This page was last edited on 19 July 2008, at 08:51.
Text is available under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.
Privacy policy
About Bahaipedia
Disclaimers
Powered by MediaWiki