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

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

<script type="text/javascript">//<![CDATA[
	(function() {
		var _status_rules = document.getElementById("_status_rules");
		var _status_ss_redir = document.getElementById("_status_ss_redir");
		var _status_ssr_redir = document.getElementById("_status_ssr_redir");
		var _status_v2ray = document.getElementById("_status_v2ray");
		var _status_redsocks = document.getElementById("_status_redsocks");

		XHR.poll(5, "<%=luci.dispatcher.build_url("admin", "services", "transparent-proxy", "status")%>", null, function(x, status) {
			if (_status_rules) {
				_status_rules.textContent = status.rules ? "<%:EXIST%>" : "<%:NOT EXIST%>";
				_status_rules.style = status.rules ? "color:green; font-weight: bold;" : "color:red; font-weight: normal;";
			}
			if (_status_ss_redir) {
				_status_ss_redir.textContent = status.ss_redir ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
				_status_ss_redir.style = status.ss_redir ? "color:green; font-weight: bold;" : "color:red; font-weight: normal;";
			}
			if (_status_ssr_redir) {
				_status_ssr_redir.textContent = status.ssr_redir ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
				_status_ssr_redir.style = status.ssr_redir ? "color:green; font-weight: bold;" : "color:red; font-weight: normal;";
			}
			if (_status_v2ray) {
				_status_v2ray.textContent = status.v2ray ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
				_status_v2ray.style = status.v2ray ? "color:green; font-weight: bold;" : "color:red; font-weight: normal;";
			}
			if (_status_redsocks) {
				_status_redsocks.textContent = status.redsocks ? "<%:RUNNING%>" : "<%:NOT RUNNING%>";
				_status_redsocks.style = status.redsocks ? "color:green; font-weight: bold;" : "color:red; font-weight: normal;";
			}
		});
	}());
//]]></script>
