MediaWiki:Common.js: Difference between revisions

Amend for ECMASCript 5 compatibility
(Amend purge link such that it only appears for current revisions of articles which the user can edit)
(Amend for ECMASCript 5 compatibility)
 
Line 776: Line 776:
function addToPageTools() {
function addToPageTools() {
if (isUserLoggedIn()) {
if (isUserLoggedIn()) {
var canEdit = mw.config.get('wgIsProbablyEditable') ?? false;
var canEdit = mw.config.get('wgIsProbablyEditable');
var isArticle = mw.config.get('wgIsArticle') ?? false;
var isArticle = mw.config.get('wgIsArticle');
var isCurRevision = (mw.config.get('wgRevisionId') ?? 0) >= (mw.config.get('wgCurRevisionId') ?? 0);
var isCurRevision = mw.config.get('wgRevisionId') >= mw.config.get('wgCurRevisionId');
if (canEdit && isArticle && isCurRevision) {
if (canEdit && isArticle && isCurRevision) {
$.when(mw.loader.using(['mediawiki.util']), $.ready).then( function() {
$.when(mw.loader.using(['mediawiki.util']), $.ready).then( function() {