MediaWiki:Common.js/watchlist.js: diferenças entre revisões
Conteúdo apagado Conteúdo adicionado
Fazendo atualizações no script. |
|||
Linha 1: | Linha 1: | ||
/* Load the geonotices. */ |
/* Load the geonotices. */ |
||
$(function () { |
$(function () { |
||
mw.loader.load(mw.config.get('wgScript') + '?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600&ver=2'); |
mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600&ver=2'); |
||
}); |
}); |
||
Revisão das 21h53min de 18 de julho de 2012
/* Load the geonotices. */
$(function () {
mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=MediaWiki:Geonotice.js&action=raw&ctype=text/javascript&maxage=3600&ver=2');
});
/** Add dismiss buttons to watchlist-message *************************************
*
* Description: Allows multiple dismiss buttons on div.watchlist-message
* Maintainers: [[User:Ruud Koot|Ruud Koot]], [[User:MZMcBride|MZMcBride]], [[User:Merlissimo|Merlissimo]]
*/
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'), 10);
if (isNaN(watchlistCookieID)) {
continue;
}
if (document.cookie.indexOf('ptwiki-hidewatchlistmessage-' + watchlistCookieID + '=yes') != -1) {
watchItems[i].style.display = 'none';
continue;
} else {
watchItems[i].style.display = 'block';
}
var Button = document.createElement('span');
var ButtonLink = document.createElement('a');
var ButtonText = document.createTextNode('esconder');
ButtonLink.setAttribute('id', 'dismissButton');
ButtonLink.setAttribute('href', 'javascript:dismissWatchlistMessage(' + i + ',' + watchlistCookieID + ')');
ButtonLink.setAttribute('title', 'Esconda esta mensagem');
ButtonLink.appendChild(ButtonText);
Button.setAttribute('style', 'font-size:0.6em;float:right;position:relative;padding-right:4px');
Button.appendChild(document.createTextNode('['));
Button.appendChild(ButtonLink);
Button.appendChild(document.createTextNode(']'));
watchItems[i].insertBefore(Button, watchItems[i].firstChild);
}
}
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() + (3 * 7 * 24 * 60 * 60 * 1000));
document.cookie = 'ptwiki-hidewatchlistmessage-' + cid + '=yes; expires=' + e.toGMTString() + '; path=/';
}
$(addDismissButton);