VOOZH about

URL: https://minecraft.wiki/w/MediaWiki:Gadget-protectionLocks.js

⇱ MediaWiki:Gadget-protectionLocks.js – Minecraft Wiki


MediaWiki:Gadget-protectionLocks.js

From Minecraft Wiki
Jump to navigation Jump to search
In other languages

Note: After saving, you have to bypass your browser's cache to see the changes.

Google Chrome, Firefox, Microsoft Edge, and Safari: Hold down the key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.

// Page protection indicators
;(function($,mw){
'use strict';
consti18n={
protectionLevelDescriptions:{
'autoconfirmed':'This page is semi-protected so that only autoconfirmed users can edit it.',
'directoreditprotected':'This page is directors-only protected so that only directors can edit it.',
'sysop':'This page is fully protected so that only administrators can edit it.',
'interface':'This page is fully protected because it provides interface text on this wiki.'
},
moveProtectionLevelDescriptions:{
'directoreditprotected':'This page is directors-only protected so that only directors can move it.',
'sysop':'This page is move-protected so that only administrators can move it.'
},
uploadProtectionLevelDescriptions:{
'directoreditprotected':'This page is fully protected so that only directors can reupload it.',
'sysop':'This page is move-protected so that only administrators can reupload it.'
},
protectionLevelLinks:{
'autoconfirmed':'Minecraft Wiki:Autoconfirmed users',
'directoreditprotected':'Minecraft Wiki:Directors',
'sysop':'Minecraft Wiki:Administrators',
'interface':'Minecraft Wiki:Administrators'
}
};
constconfig=mw.config.get([
'wgRestrictionEdit',
'wgRestrictionMove',
'wgRestrictionCreate',
'wgNamespaceNumber',
'wgIsMainPage',
'wgAction'
]);
consteditProtectionLevelData=config.wgRestrictionEdit;
constmoveProtectionLevelData=config.wgRestrictionMove;
constcreateProtectionLevelData=config.wgRestrictionCreate;
if(
// Null on nonexistent or special pages. Avoids a crash there.
(!editProtectionLevelData&&!createProtectionLevelData)||config.wgIsMainPage||
// No need to display the indicator when viewing history or editing the page
config.wgAction!=='view'){
return;
}
functiongetImageThumbnailURL(name,size){
constencodedName=mw.util.wikiUrlencode(name);
return'/images/'+
encodedName;
}
functionmimicIndicator(id,link,imgName,title){
constencodedLink=mw.util.getUrl(link);
return$('<div class="mw-indicator">').attr({
'id':'mw-indicator-'+id
}).append($('<div class="mw-parser-output">')
.append($('<span typeof="mw:File">')
.append($('<a>')
.attr({
'href':encodedLink,
'title':title
}).append($('<img>')
.attr({
'alt':title,
'src':getImageThumbnailURL(imgName,25),
'srcset':getImageThumbnailURL(imgName,38)+
' 1.5x, '+
getImageThumbnailURL(imgName,50)+
' 2x',
'width':'25',
'height':'25'
})
))));
}
// remove native MW protection locks
$('[id^="mw-indicator-protection-"]').remove();
consteditProtectionLevel=editProtectionLevelData?editProtectionLevelData[0]:null;
constmoveProtectionLevel=moveProtectionLevelData?moveProtectionLevelData[0]:null;
constcreateProtectionLevel=createProtectionLevelData?createProtectionLevelData[0]:null;
if(config.wgNamespaceNumber===6&&(editProtectionLevel==='directoreditprotected'||createProtectionLevel==='directoreditprotected')){// [[File:Upload-protected page lock.svg]]
mimicIndicator(
'protection-director-upload',
i18n.protectionLevelLinks.directoreditprotected,
'Upload-protected page lock.svg',
i18n.uploadProtectionLevelDescriptions.directoreditprotected
).appendTo($('.mw-indicators'));
}elseif(config.wgNamespaceNumber===6&&(editProtectionLevel==='sysop'||createProtectionLevel==='sysop')){
mimicIndicator(
'protection-full-upload',
i18n.protectionLevelLinks.sysop,
'Upload-protected page lock.svg',
i18n.uploadProtectionLevelDescriptions.sysop
).appendTo($('.mw-indicators'));
}elseif(editProtectionLevel==='autoconfirmed'||createProtectionLevel==='autoconfirmed'){// [[File:Semi-protected page lock.svg]]
mimicIndicator(
'protection-semi',
i18n.protectionLevelLinks.autoconfirmed,
'Semi-protected page lock.svg',
i18n.protectionLevelDescriptions.autoconfirmed
).appendTo($('.mw-indicators'));
}elseif(editProtectionLevel==='directoreditprotected'||createProtectionLevel==='directoreditprotected'){// [[File:Director-protected page lock.svg]]
mimicIndicator(
'protection-director',
i18n.protectionLevelLinks.directoreditprotected,
'Director-protected page lock.svg',
i18n.protectionLevelDescriptions.directoreditprotected
).appendTo($('.mw-indicators'));
}elseif(editProtectionLevel==='sysop'||createProtectionLevel==='sysop'){// [[File:Fully-protected page lock.svg]]
mimicIndicator(
'protection-full',
i18n.protectionLevelLinks.sysop,
'Fully-protected page lock.svg',
i18n.protectionLevelDescriptions.sysop
).appendTo($('.mw-indicators'));
}elseif(moveProtectionLevel){// [[File:Move-protected page lock.svg]]
mimicIndicator(
'protection-move',
i18n.protectionLevelLinks[moveProtectionLevel],
'Move-protected page lock.svg',
i18n.moveProtectionLevelDescriptions[moveProtectionLevel]
).appendTo($('.mw-indicators'));
}elseif(config.wgNamespaceNumber===8){// [[File:Interface-protected page lock.svg]]
mimicIndicator(
'protection-interface',
i18n.protectionLevelLinks.interface,
'Interface-protected page lock.svg',
i18n.protectionLevelDescriptions.interface
).appendTo($('.mw-indicators'));
}
})(window.jQuery,window.mediaWiki);
Retrieved from "https://minecraft.wiki/w/MediaWiki:Gadget-protectionLocks.js?oldid=3423308"

Navigation menu