Webadmin - toggle Formularparameter

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

Stan na 10-11-2014. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

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

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();

}