1,963
edits
mNo edit summary |
mNo edit summary |
||
Line 177: | Line 177: | ||
// Begin Purge link | // Begin Purge link | ||
var purgeLink = { | |||
if (mw.config.get("wgIsArticle")) { | init: function () { | ||
if (mw.config.get("wgIsArticle")) { | |||
var purgeBtn = mw.util.addPortletLink("p-cactions", | |||
mw.util.wikiScript() + "?" + $.param({ title: mw.config.get("wgPageName"), action: "purge" }), | |||
"Purge", | |||
"ca-purge", | |||
"Purge the server cache of this page" | |||
" | ); | ||
} | // Quick Purge | ||
var qpurgeBtn = mw.util.addPortletLink("p-views", | |||
"#", | |||
"Quick Purge", | |||
"ca-purge", | |||
"Quickly purge the server cache of this page (skips confirmation)" | |||
); | |||
qpurgeBtn.classList.add("collapsible"); | |||
qpurgeBtn.addEventListener("click", purgeLink.handleQpurge.bind(this)); | |||
} | |||
}, | |||
handleQpurge: function (event) { | |||
event.preventDefault(); | |||
new mw.Api().post({ action: "purge", titles: mw.config.get("wgPageName") }).then(function (data) { | |||
mw.notify("Quick Purge: Success!", { type: "success" }); | |||
}).catch(function (error, data) { | |||
mw.notify("Quick Purge: " + (data.error ? data.error.info : error), { type: "error" }); | |||
}); | |||
}, | |||
}; | |||
$(purgeLink.init); | |||
// End Purge link | // End Purge link | ||