MediaWiki:Gadget-CommentWatch.js
Shënim: Pas botimit, mund t’ju duhet të anashkaloni fshehtinën e shfletuesit tuaj, që të shihni ndryshimet.
- Firefox / Safari: Mbani të shtypur tastin Shift teksa klikoni mbi Ringarkoje, ose shtypni një nga kombinimet Ctrl-F5 ose Ctrl-R (⌘-R në Mac)
- Google Chrome: Shtypni Ctrl-Shift-R (⌘-Shift-R në Mac)
- Internet Explorer / Edge: Mbani të shtypur Ctrl teksa klikoni mbi Refresh, ose shtypni Ctrl-F5
- Opera: Shtypni Ctrl-F5.
//This is a very quick script that is not very good. Will make nicer later. YMMV with this.
/*extern wgNamespaceNumber, wgPageName, sajax_init_object addOnloadHook */
if (mw.config.get('wgNamespaceNumber') === 0 || mw.config.get('wgNamespaceNumber') === 1 || mw.config.get('wgNamespaceNumber') === 102) {
var cWatch = {}; //init obj
cWatch.init = function () {
var Page = "Komentet:" + wgPageName; // default
if (mw.config.get('wgNamespaceNumber') === 1) {
Page = "Komentet:" + wgPageName.split(":", 2)[1];
}
else if (mw.config.get('wgNamespaceNumber') === 102) {
Page = wgPageName.split(":", 2)[1];
}
cWatch.watchComments = function () {
var x;
x = sajax_init_object();
// do nothing if we can't check
if (!x) {
return;
}
x.open("GET", "//en.wikinews.org/w/index.php?action=watch&title=" + Page, true);
x.setRequestHeader("Pragma", "cache=yes");
x.setRequestHeader("Cache-Control", "no-transform");
x.onreadystatechange = function () {
if (x.readyState === 4) {
/* Start success*/
if (x.status === 200) {
document.getElementById("siteNotice").innerHTML += ('Comment Page now watched' );
}
else {
document.getElementById("siteNotice").innerHTML += ('Auto comment page watch <b>failed</b>. <a href="//en.wikinews.org/w/index.php?action=watch&title=' + Page + '">Watch manually?</a>.' );
}
if (document.getElementById("ca-watch").addEventListener) {
document.getElementById("ca-watch").firstChild.removeEventListener("click", cWatch.watchComments, true);
}
else if (document.getElementById("ca-watch").firstChild.attachEvent) {
document.getElementById("ca-watch").firstChild.detachEvent("onclick", cWatch.watchComments);
}
x = undefined;
}
}
x.send(null);
}
if (document.getElementById("ca-watch")) { //In case we're already watching
var watchTab = document.getElementById("ca-watch").firstChild;
if (watchTab.addEventListener) {
watchTab.addEventListener("click", cWatch.watchComments, true);
}
else if (watchTab.attachEvent) {
watchTab.attachEvent("onclick", cWatch.watchComments);
}
else {
document.getElementById("siteNotice").innerHTML += ('Auto comment page watch <b>failed</b>. <a href="//en.wikinews.org/w/index.php?action=watch&title=' + Page + '">Watch manually?</a>.' );
}
}
} //End cWatch.init
if (document.getElementById("globalWrapper")) { //We're a load event
cWatch.init();
}
else {
$(document).ready(cWatch.init);
}
}