Webadmin - toggle Formularparameter

Add a toggle to expand/collapse the form-parameters of a afs-webadmin

اعتبارا من 10-11-2014. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        Webadmin - toggle Formularparameter
// @namespace   com.aforms2web.ds.ujs
// @description Add a toggle to expand/collapse the form-parameters of a afs-webadmin
// @author      [email protected]
// @include     *webadmin*
// @version     1.0
// @grant       none
// ==/UserScript==

var parameterList = document.getElementById("parameterList");

if(parameterList != null){

	// ### Insert CSS (because Stylish is not able to use Wildcards)
	var css = new Array();

	function writeStyle(css) {
	    var style = document.createElement('style');
	    style.type = 'text/css';
	    if (document.getElementsByTagName) {
		document.getElementsByTagName('head')[0].appendChild(style);
		if (style.sheet && style.sheet.insertRule) {
		    for (var i = 0; i < css.length; i++) {
		        style.sheet.insertRule(css[i], 0);
		    }
		}
	    }
	}

	function addStyle(style) {
	    css[css.length] = style;
	}

	// Define your CSS here

	addStyle("#parameterListToggle{"
	 + "  padding-left: 20px!important;"
	 + "  color: navy;"
	 + "  font-weight: normal!important;"
	 + "  cursor: pointer;"
	 + "}");
	addStyle("#parameterListToggle:hover{"
	 + "  color: green;"
	 + "}");
	addStyle("#parameterListToggle:before{"
	 + "  content:  \"[ \";"
	 + "  color: black;"
	 + "}");
	addStyle("#parameterListToggle:after{"
	 + "  content:  \" ] \";"
	 + "  color: black;"
	 + "}");
	
	// Writes CSS to the document
	writeStyle(css);



	// ### Gnerate Toggle Link

	var parameterList = document.getElementById("parameterList");
	var parameterListHeaderTd = parameterList.previousSibling.previousSibling.childNodes[1].childNodes[2].childNodes[1];

	var newSpan = document.createElement("span");
	var idNode = document.createAttribute("id");
	idNode.nodeValue = "parameterListToggle";
	newSpan.setAttributeNode(idNode);
	var onclickNode = document.createAttribute("onclick");
	onclickNode.nodeValue = "toggle_parameterList();";
	newSpan.setAttributeNode(onclickNode);
	newSpan.appendChild(document.createTextNode("toggle"));
	parameterListHeaderTd.appendChild(newSpan)

	var newScript = document.createElement("script");
	var typeNode = document.createAttribute("type");
	typeNode.nodeValue = "text/javascript";
	newScript.setAttributeNode(typeNode);
	newScript.appendChild(document.createTextNode(
	"function toggle_parameterList() {\n"
	 + "  var elem = document.getElementById('parameterList');\n"
	 + "  var tggl = document.getElementById('parameterListToggle').childNodes[0];\n"
	 + "  if(elem.style.display == '')  {\n"
	 + "    elem.style.display = 'none';\n"
	 + "    tggl.nodeValue = '▼ expand';\n"
	 + "  } else {\n"
	 + "    elem.style.display = '';\n"
	 + "    tggl.nodeValue = '△ collapse';\n"
	 + "  }\n"
	 + "} "));
	parameterListHeaderTd.appendChild(newScript)

	toggle_parameterList();

}