/**
* All icons used in this script (linked here for attribution and for WhatLinksHere):
* [[File:Move-protection-shackle.svg]]
* [[File:Upload-protection-shackle.svg]]
* [[File:Semi-protection-unlocked.svg]]
* [[File:Full-protection-unlocked.svg]]
* [[File:Extended-protection-unlocked.svg]]
* [[File:Template-protection-unlocked.svg]]
* [[File:Semi-protection-shackle.svg]]
* [[File:Full-protection-shackle.svg]]
* [[File:Extended-protection-shackle.svg]]
* [[File:Template-protection-shackle.svg]]
* [[File:Generic-protected-shackle.svg]]
* [[File:Create-protection-unlocked.svg]]
* [[File:Create-protection-shackle.svg]]
* <nowiki>
**/
$(document).ready(function() {
var userGroups = mw.config.get("wgUserGroups");
var protImage = "";
var altProtImage1 = "";
var altProtImage2 = "";
var subsection = "";
// can move
try {
var moveProtectionLevels = mw.config.get("wgRestrictionMove");
var canMove = false;
if (moveProtectionLevels.length === 0) {
canMove = true;
} else {
for (var i = 0; i < userGroups.length; i++) {
if (userGroups[i] === moveProtectionLevels[0]) {
canMove = true;
}
}
}
if (canMove) {
//show the locks in their unlocked state
} else {
subsection = "move";
protImage = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Move-protection-shackle.svg/20px-Move-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Move-protection-shackle.svg/30px-Move-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Move-protection-shackle.svg/40px-Move-protection-shackle.svg.png";
}
} catch (Error) {
console.error(Error);
}
// can upload
try {
var uploadProtectionLevels = mw.config.get("wgRestrictionUpload");
var canUpload = false;
if (uploadProtectionLevels.length === 0) {
canUpload = true;
} else {
for (i = 0; i < userGroups.length; i++) {
if (userGroups[i] === uploadProtectionLevels[0]) {
canUpload = true;
}
}
}
if (canUpload) {
//show the locks in their unlocked state
} else {
protImage = "//up.wiki.x.io/wikipedia/en/thumb/d/d7/Upload-protection-shackle.svg/20px-Upload-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/d/d7/Upload-protection-shackle.svg/30px-Upload-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/d/d7/Upload-protection-shackle.svg/40px-Upload-protection-shackle.svg.png";
subsection = "upload";
}
} catch (Error) {
console.error(Error);
}
// can edit
try {
var editProtectionLevels = mw.config.get("wgRestrictionEdit");
var canEdit = false;
if (editProtectionLevels.length === 0) {
canEdit = true;
} else {
for (i = 0; i < userGroups.length; i++) {
if (userGroups[i] === editProtectionLevels[0]) {
canEdit = true;
}
}
}
if (canEdit) {
//show the locks in their unlocked state
switch (editProtectionLevels[0]) {
case "autoconfirmed": protImage = "//up.wiki.x.io/wikipedia/commons/thumb/e/e0/Semi-protection-unlocked.svg/20px-Semi-protection-unlocked.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/commons/thumb/e/e0/Semi-protection-unlocked.svg/30px-Semi-protection-unlocked.svg.png";
altProtImage2 = "https://up.wiki.x.io/wikipedia/commons/thumb/e/e0/Semi-protection-unlocked.svg/40px-Semi-protection-unlocked.svg.png";
subsection = "semi";
break;
case "sysop": protImage = "//up.wiki.x.io/wikipedia/commons/thumb/4/40/Full-protection-unlocked.svg/20px-Full-protection-unlocked.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/commons/thumb/4/40/Full-protection-unlocked.svg/30px-Full-protection-unlocked.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/commons/thumb/4/40/Full-protection-unlocked.svg/40px-Full-protection-unlocked.svg.png";
subsection = "full";
break;
case "extendedconfirmed": protImage = "//up.wiki.x.io/wikipedia/commons/thumb/d/db/Extended-protection-unlocked.svg/20px-Extended-protection-unlocked.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/commons/thumb/d/db/Extended-protection-unlocked.svg/30px-Extended-protection-unlocked.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/commons/thumb/d/db/Extended-protection-unlocked.svg/40px-Extended-protection-unlocked.svg.png";
subsection = "extended";
break;
case "templateeditor": protImage = "//up.wiki.x.io/wikipedia/en/thumb/5/5a/Template-protection-unlocked.svg/20px-Template-protection-unlocked.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/5/5a/Template-protection-unlocked.svg/30px-Template-protection-unlocked.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/5/5a/Template-protection-unlocked.svg/40px-Template-protection-unlocked.svg.png";
subsection = "template";
break;
}
} else {
switch (editProtectionLevels[0]) {
case "autoconfirmed": protImage = "//up.wiki.x.io/wikipedia/en/thumb/1/1b/Semi-protection-shackle.svg/20px-Semi-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/1/1b/Semi-protection-shackle.svg/30px-Semi-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/1/1b/Semi-protection-shackle.svg/40px-Semi-protection-shackle.svg.png";
subsection = "semi";
break;
case "sysop": protImage = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Full-protection-shackle.svg/20px-Full-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Full-protection-shackle.svg/30px-Full-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Full-protection-shackle.svg/40px-Full-protection-shackle.svg.png";
subsection = "full";
break;
case "extendedconfirmed": protImage = "//up.wiki.x.io/wikipedia/en/thumb/8/8c/Extended-protection-shackle.svg/20px-Extended-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/8/8c/Extended-protection-shackle.svg/30px-Extended-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/4/44/Full-protection-shackle.svg/40px-Full-protection-shackle.svg.png";
subsection = "extended";
break;
case "templateeditor": protImage = "//up.wiki.x.io/wikipedia/en/thumb/5/53/Template-protection-shackle.svg/20px-Template-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/5/53/Template-protection-shackle.svg/30px-Template-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/5/53/Template-protection-shackle.svg/40px-Template-protection-shackle.svg.png";
subsection = "template";
break;
default: protImage = "//up.wiki.x.io/wikipedia/en/thumb/9/99/Generic-protected-shackle.svg/20px-Generic-protected-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/9/99/Generic-protected-shackle.svg/30px-Generic-protected-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/9/99/Generic-protected-shackle.svg/40px-Generic-protected-shackle.svg.png";
break;
}
}
} catch (Error) {
console.error(Error);
}
// can create
try {
var createProtectionLevels = mw.config.get("wgRestrictionCreate");
var canCreate = false;
if (createProtectionLevels.length === 0) {
canCreate = true;
} else {
for (i = 0; i < userGroups.length; i++) {
if (userGroups[i] === createProtectionLevels[0]) {
canCreate = true;
}
}
}
if (canCreate) {
//show the locks unlocked
if (createProtectionLevels.length > 0) {
subsection = "create";
protImage = "//up.wiki.x.io/wikipedia/commons/thumb/8/86/Create-protection-unlocked.svg/20px-Create-protection-unlocked.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/commons/thumb/8/86/Create-protection-unlocked.svg/30px-Create-protection-unlocked.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/commons/thumb/8/86/Create-protection-unlocked.svg/40px-Create-protection-unlocked.svg.png";
}
} else {
subsection = "create";
protImage = "//up.wiki.x.io/wikipedia/en/thumb/0/02/Create-protection-shackle.svg/20px-Create-protection-shackle.svg.png";
altProtImage1 = "//up.wiki.x.io/wikipedia/en/thumb/0/02/Create-protection-shackle.svg/30px-Create-protection-shackle.svg.png";
altProtImage2 = "//up.wiki.x.io/wikipedia/en/thumb/0/02/Create-protection-shackle.svg/40px-Create-protection-shackle.svg.png";
}
} catch (Error) {
console.error(Error);
}
if (protImage.length > 0) {
if ($("#mw-indicator-pp-default").length > 0) $("#mw-indicator-pp-default").html("<span><a title=\"This page is protected.\" href=\"/wiki/Wikipedia:Protection_policy#" + subsection + "\"><img height=\"20\" src=\"" + protImage + "\" srcset=\"" + altProtImage1 + " 1.5x, " + altProtImage2 + " 2x\" alt=\"Protected page lock\"></a></span>");
else $(".mw-indicators").append("<div class=\"mw-indicator\" id=\"mw-indicator-pp-default\"><span><a title=\"This page is protected.\" href=\"/wiki/Wikipedia:Protection_policy#" + subsection + "\"><img height=\"20\" src=\"" + protImage + "\" srcset=\"" + altProtImage1 + " 1.5x, " + altProtImage2 + " 2x\" alt=\"Protected page lock\"></a></span></div>");
}
});
//</nowiki>