<%#
 Copyright (C) 2017-2018 Jian Chang <aa65535@live.com>
 Licensed to the public under the GNU General Public License v3.
-%>

<% include("cbi/map") %>

<script type="text/javascript">//<![CDATA[
	(function($) {
		var password = $("password");
		var key = $("key");
		var form = key.form;
		var checkCryptoConfig = function() {
			password.className = password.className.replace(/ cbi-input-invalid/g, "");
			key.className = key.className.replace(/ cbi-input-invalid/g, "");
			if (password.value.length == 0 && key.value.length == 0) {
				password.className += " cbi-input-invalid";
				key.className += " cbi-input-invalid";
				return false;
			}
			return true;
		};
		password.onkeyup = checkCryptoConfig;
		key.onkeyup = checkCryptoConfig;
		if (form) {
			if (!form.cbi_validators) {
				form.cbi_validators = [];
			}
			form.cbi_validators.push(checkCryptoConfig);
		}
		checkCryptoConfig();
	}(function(id) {
		return document.getElementById("cbid.<%=self.config%>.<%=self.sid%>." + id);
	}));
//]]></script>
