MediaWiki:Gadget-purge.js

From Old School Near-Reality Wiki
Jump to navigation Jump to 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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
 1 $(function () {
 2 	function purgePage(e) {
 3 		mw.notify("The page is now purging and will refresh when it is ready.", { title: 'Purging', tag: 'purge', autoHide: false });
 4 		(new mw.Api()).post({
 5 			action: 'purge',
 6 			titles: mw.config.get('wgPageName')
 7 		}).then(function(){
 8 			window.location.reload();
 9 		}, function(){
10 			var uri = new mw.Uri();
11 			uri.query.action = 'purge';
12 			mw.notify($.parseHTML('Purging the page failed. Please try again or <a href="'+uri.toString()+'">do so manually</a>.'), { title: 'Purging failed', tag: 'purge', type: 'error', autoHide:false });
13 		});
14 		e.preventDefault();
15 	}
16 	function init() {
17 		$('.jsPurgeLink').click(purgePage);
18 		$('.jsPurgeLink > a').attr({'href': '#', target: ''});
19 	}
20 	
21 	init();
22 })