17,097
edits
(Add Purge link to page tools) |
(Amend purge link such that it only appears for current revisions of articles which the user can edit) |
||
Line 767: | Line 767: | ||
function isUserLoggedIn() { | function isUserLoggedIn() { | ||
if (mw.config.get('wgUserName') === null) { | |||
return false; | |||
} else { | |||
return true; | |||
} | |||
} | } | ||
function addToPageTools() { | function addToPageTools() { | ||
if (isUserLoggedIn()) { | if (isUserLoggedIn()) { | ||
$.when(mw.loader.using(['mediawiki.util']), $.ready).then( function() { | var canEdit = mw.config.get('wgIsProbablyEditable') ?? false; | ||
var isArticle = mw.config.get('wgIsArticle') ?? false; | |||
var isCurRevision = (mw.config.get('wgRevisionId') ?? 0) >= (mw.config.get('wgCurRevisionId') ?? 0); | |||
if (canEdit && isArticle && isCurRevision) { | |||
$.when(mw.loader.using(['mediawiki.util']), $.ready).then( function() { | |||
mw.util.addPortletLink( | |||
'p-cactions', | |||
mw.util.getUrl() + '?action=purge', | |||
'Purge', | |||
); | 't-purgecache', | ||
} | 'Purge the cache for this page', | ||
null, | |||
null | |||
); | |||
}); | |||
} | |||
} | } | ||
} | } | ||
Line 800: | Line 805: | ||
function showAndroidAppDownloadLink() { | function showAndroidAppDownloadLink() { | ||
var shouldShowDownload = /Android/i.test(window.navigator.userAgent) && window.navigator.userAgent.indexOf('gonative melvorwiki') === -1; | |||
if (shouldShowDownload) { | |||
$('.android-app-download').removeClass('d-none'); | |||
} else { | |||
$('.android-app-download').addClass('d-none'); | |||
} | |||
} | } | ||