Difference between revisions of "MediaWiki:Common.js"

From BGBM Collection Workflows
Jump to: navigation, search
(added easy account approval for admins)
 
(adjustment of account approval script)
 
Line 15: Line 15:
 
linkMenu.insertBefore(editRightsLink, linkMenu.lastChild);
 
linkMenu.insertBefore(editRightsLink, linkMenu.lastChild);
 
}
 
}
}else if(mw.config.get("wgPageName").indexOf("Special:UserRights/")===0){
+
}else if(mw.config.get("wgNamespaceNumber")==2||mw.config.get("wgNamespaceNumber")==3){
var gfbioUserCheckbox = document.getElementById("wpGroup-gfbioUser");
+
var deleteLink = document.getElementById("ca-delete")
if(!gfbioUserCheckbox.checked){
+
var username = mw.config.get("wgTitle");
gfbioUserCheckbox.checked = true;
+
if(username.indexOf("/")!=-1){
var inputReason = document.getElementById("wpReason");
+
username = username.substring(0,username.indexOf("/"));
inputReason.value = "is part of the GFBio Team";
 
 
var label = gfbioUserCheckbox.nextElementSibling;
 
label.innerHTML = label.innerHTML + " <i>(auto selected by script)</i>";
 
label.setAttribute("style","background:#8f8;")
 
 
}
 
}
 +
mw.util.addPortletLink("p-cactions","https://wiki.bgbm.org/collectionworkflows/index.php/Special:UserRights/"+username,"Rights", "ca-user-rights","User Rights","g",deleteLink);
 
}
 
}
 
}
 
}

Latest revision as of 09:41, 10 July 2018

/* Any JavaScript here will be loaded for all users on every page load. */


//easy account approval for admins
if(mw.config.get("wgUserGroups").includes("sysop")){
	if(mw.config.get("wgPageName")=="Special:ListUsers" || mw.config.get("wgPageName")=="Special:ActiveUsers"){
		var linkMenues = document.getElementById("mw-content-text").getElementsByClassName("mw-usertoollinks")
		for(i=0;i<linkMenues.length;i++){
			var linkMenu = linkMenues[i];
			var editRightsLink = linkMenu.lastElementChild.cloneNode(true);
			editRightsLink.href = editRightsLink.href.replace("Special:Block","Special:UserRights");
			editRightsLink.title = editRightsLink.title.replace("Special:Block","Special:UserRights");
			editRightsLink.innerHTML = "edit rights";
			linkMenu.insertBefore(document.createTextNode(" | "), linkMenu.lastChild);
			linkMenu.insertBefore(editRightsLink, linkMenu.lastChild);
		}
	}else if(mw.config.get("wgNamespaceNumber")==2||mw.config.get("wgNamespaceNumber")==3){
		var deleteLink = document.getElementById("ca-delete")
		var username = mw.config.get("wgTitle");
		if(username.indexOf("/")!=-1){
			username = username.substring(0,username.indexOf("/"));
		}
		mw.util.addPortletLink("p-cactions","https://wiki.bgbm.org/collectionworkflows/index.php/Special:UserRights/"+username,"Rights", "ca-user-rights","User Rights","g",deleteLink);
	}
}