<%
local api = require "luci.passwall.api"
-%>

<style>
/*!
Pure v1.0.1
Copyright 2013 Yahoo!
Licensed under the BSD License.
https://github.com/pure-css/pure/blob/master/LICENSE.md
*/
.pure-g{letter-spacing:-.31em;text-rendering:optimizespeed;font-family:FreeSans,Arimo,"Droid Sans",Helvetica,Arial,sans-serif;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-flex-flow:row wrap;-ms-flex-flow:row wrap;flex-flow:row wrap;-webkit-align-content:flex-start;-ms-flex-line-pack:start;align-content:flex-start}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active) {table .pure-g{display:block}}.opera-only :-o-prefocus,.pure-g{word-spacing:-.43em}.pure-u{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-g [class*=pure-u]{font-family:-apple-system,BlinkMacSystemFont,sans-serif}.pure-u-1,.pure-u-1-1,.pure-u-1-12,.pure-u-1-2,.pure-u-1-24,.pure-u-1-3,.pure-u-1-4,.pure-u-1-5,.pure-u-1-6,.pure-u-1-8,.pure-u-10-24,.pure-u-11-12,.pure-u-11-24,.pure-u-12-24,.pure-u-13-24,.pure-u-14-24,.pure-u-15-24,.pure-u-16-24,.pure-u-17-24,.pure-u-18-24,.pure-u-19-24,.pure-u-2-24,.pure-u-2-3,.pure-u-2-5,.pure-u-20-24,.pure-u-21-24,.pure-u-22-24,.pure-u-23-24,.pure-u-24-24,.pure-u-3-24,.pure-u-3-4,.pure-u-3-5,.pure-u-3-8,.pure-u-4-24,.pure-u-4-5,.pure-u-5-12,.pure-u-5-24,.pure-u-5-5,.pure-u-5-6,.pure-u-5-8,.pure-u-6-24,.pure-u-7-12,.pure-u-7-24,.pure-u-7-8,.pure-u-8-24,.pure-u-9-24{display:inline-block;zoom:1;letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto}.pure-u-1-24{width:4.1667%}.pure-u-1-12,.pure-u-2-24{width:8.3333%}.pure-u-1-8,.pure-u-3-24{width:12.5%}.pure-u-1-6,.pure-u-4-24{width:16.6667%}.pure-u-1-5{width:20%}.pure-u-5-24{width:20.8333%}.pure-u-1-4,.pure-u-6-24{width:25%}.pure-u-7-24{width:29.1667%}.pure-u-1-3,.pure-u-8-24{width:33.3333%}.pure-u-3-8,.pure-u-9-24{width:37.5%}.pure-u-2-5{width:40%}.pure-u-10-24,.pure-u-5-12{width:41.6667%}.pure-u-11-24{width:45.8333%}.pure-u-1-2,.pure-u-12-24{width:50%}.pure-u-13-24{width:54.1667%}.pure-u-14-24,.pure-u-7-12{width:58.3333%}.pure-u-3-5{width:60%}.pure-u-15-24,.pure-u-5-8{width:62.5%}.pure-u-16-24,.pure-u-2-3{width:66.6667%}.pure-u-17-24{width:70.8333%}.pure-u-18-24,.pure-u-3-4{width:75%}.pure-u-19-24{width:79.1667%}.pure-u-4-5{width:80%}.pure-u-20-24,.pure-u-5-6{width:83.3333%}.pure-u-21-24,.pure-u-7-8{width:87.5%}.pure-u-11-12,.pure-u-22-24{width:91.6667%}.pure-u-23-24{width:95.8333%}.pure-u-1,.pure-u-1-1,.pure-u-24-24,.pure-u-5-5{width:100%}
	.block {
		margin: 0.5rem;
		padding: 0;
		font-weight: normal;
		font-style: normal;
		line-height: 1;
		font-family: inherit;
		min-width: inherit;
		overflow-x: auto;
		overflow-y: hidden;
		border: 1px solid rgba(0,0,0,.05);
		border-radius: .375rem;
		box-shadow: 0 0 2rem 0 rgba(136,152,170,.15);
	}
	.img-con {
		margin: 1rem;

	}
	.green {
		font-size:.9rem;
		color: #2dce89;
	}
	.red {
		font-size:.9rem;
		color: #fb6340;
	}
	.yellow {
		font-size:.9rem;
		color: #fb9a05;
	}
	.block img {
		width: 48px;
		height: auto;
		/* float:right; */
	}
	.block h4 {
		font-size: .8125rem;
		font-weight: 600;
		margin: 1rem 0rem 1rem 1rem;
		color:#8898aa!important;
		line-height: 1.8em;
		min-height: 48px;
		border-radius: 12.375px;
	}

	.check {
		cursor: pointer;
	}

	@media screen and (max-width: 720px) {
		.block {
			margin: 0.2rem;
		}
		.pure-u-1-4 {
			width: 50%;
		}
		.pure-u-1-2 {
			width: 100%;
		}
		.block h4 {
			margin: 1rem 0rem 1rem 0.5rem;
		}
	}

	@media screen and (max-width: 480px) {
		.img-con {
			margin: 1.5rem 0.5rem;
		}
		.block img {
			width: 36px;
		}
	}

</style>

<fieldset id="_passwall_status_fieldset" class="cbi-section">
	<legend>
		<%:Running Status%>
	</legend>
	<div class="pure-g status">
		<div class="pure-u-1-4">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/png;base64,[encoded data, 12828 characters]" />
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_tcp_node">TCP<br /><span class="red"><%:NOT RUNNING%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjEsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0i5Zu+5bGCXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTAwIDEwMDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHN0eWxlIHR5cGU9InRleHQvY3NzIj4NCgkuc3Qwe2Zpb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ure-u-2-3">
					<h4 id="status_udp_node">UDP<br /><span class="red"><%:NOT RUNNING%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/png;base64,[encoded data, 27140 characters]" />
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_dns">DNS<br /><span class="red"><%:NOT RUNNING%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/png;base64,[encoded data, 9652 characters]" />
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_haproxy"><%:Load Balancing%><br /><span class="red"><%:NOT RUNNING%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4 check" onclick="check_connect('aliyun', 'https://www.aliyun.com')" title="<%:TLS handshake test, latency for reference only%>">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/svg+xml;base64,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBoZWlnaHQ9IjQwMCIgd2lkdGg9IjQwMCIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMTY1MyAxNjUzIiBjbGFzcz0iaWNvbiIgcHJlc2VydmVBc3BlY3RSYXRpbz0ieE1pZFlNaWQgbWVldCI+Cgk8cmVjdCB3aWR0aD0iMTY1MyIgaGVpZ2h0PSIxNjUzIiBmaWxsPSJ0cmFuc3BhcmVudCIvPgoJPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwgMzE0LjUpIj4KCQk8cGF0aCBmaWxsPSIjRjc2RTA1IiBkPSJNMjk1LjYzMzQ4OCA3ODMuNjMyODE3YTc0Ljg5ODIxNiA3NC44OTgyMTYgMCAwIDEtNTkuNzIwNjA0LTcyLjU4ODU4di0zOTkuMjM3MTg4YTc3LjUzNzgwMSA3Ny41Mzc4MDEgMCAwIDEgNTkuNzIwNjA0LTcyLjU4ODU4bDM3MC42OTY2NzktODAuMzQyMzYgMzguOTMzODc0LTE1OC44NzAwMDVIMjc0Ljg0Njc1OUEyNzIuODY3MDcgMjcyLjg2NzA3IDAgMCAwIDAuMTY0OTc0IDI3Mi44NzMxNzR2NDcxLjgyNTc2OGEyNzYuNjYxNDczIDI3Ni42NjE0NzMgMCAwIDAgMjc0LjY4MTc4NSAyNzQuODQ2NzU5aDQzMC40MTcyODJsLTM4LjkzMzg3NC0xNTguMjEwMTA5ek0xMzc0LjIzMzc5MyAwLjAwNjEwNEg5NDAuNTE3MDI5bDM5LjU5Mzc3MSAxNTguODcwMDA1IDM3MC42OTY2NzkgODAuMzQyMzZhNzUuMDYzMTkgNzUuMDYzMTkgMCAwIDEgNTkuNzIwNjA0IDcyLjU4ODU4djM5OS4yMzcxODhhNzcuODY3NzQ5IDc3Ljg2Nzc0OSAwIDAgMS01OS43MjA2MDQgNzIuNTg4NThsLTM3MC42OTY2NzkgODAuMzQyMzYtMzkuNTkzNzcxIDE1OC44NzAwMDVIMTM3NC4yMzM3OTNhMjc1LjAxMTczMyAyNzUuMDExNzMzIDAgMCAwIDI3NS42NzE2MjktMjc1LjUwNjY1NVYyNzIuODczMTc0QTI3Ni4xNjY1NTEgMjc2LjE2NjU1MSAwIDAgMCAxMzc0LjIzMzc5MyAwLjAwNjEwNHoiLz4KCQk8cGF0aCBmaWxsPSIjRjc2RTA1IiBkPSJNNjY2LjMzMDE2NyA0OTAuNjM4OTEzaDMxNi4yNTUyNDR2MzguOTMzODc1SDY2Ni4zMzAxNjd6Ii8+Cgk8L2c+Cjwvc3ZnPg==" />
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_aliyun"><%:AliCloud Conn.%><br /><span id="_aliyun_status" class="red"><%:Touch Check%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4 check" onclick="check_connect('google', 'https://www.google.com/generate_204')" title="<%:TLS handshake test, latency for reference only%>">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/png;base64,[encoded data, 27520 characters]" alt=""/>
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_google"><%:Google Conn.%><br /><span id="_google_status" class="red"><%:Touch Check%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4 check" onclick="check_connect('github', 'https://github.com')" title="<%:TLS handshake test, latency for reference only%>">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/png;base64,[encoded data, 19784 characters]" />
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_github"><%:GitHub Conn.%><br /><span id="_github_status" class="red"><%:Touch Check%></span></h4>
				</div>
			</div>
		</div>
		<div class="pure-u-1-4 check" onclick="check_connect('youtube', 'https://www.youtube.com')" title="<%:TLS handshake test, latency for reference only%>">
			<div class="block pure-g">
				<div class="pure-u-1-3">
					<div class="img-con">
						<img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIKICAgd2lkdGg9IjMwMCIKICAgaGVpZ2h0PSIzMDAiCiAgIHZlcnNpb249IjEuMSIKICAgaWQ9InN2ZzYiCiAgIHNvZGlwb2RpOmRvY25hbWU9IllvdVR1YmVfc29jaWFsX3JlZF9jaXJjbGVfKDIwMjQpLnN2ZyIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMS4yLjIgKGIwYTg0ODY1NDEsIDIwMjItMTItMDEpIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3Vy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i41OTk2MTA4NCAzMC4yMzQzODA0OHYtNjAuNTkzNzYwOTd6IgogICBpZD0icGF0aDQiCiAgIHN0eWxlPSJmaWxsOiNmZmZmZmY7ZmlsbC1vcGFjaXR5OjEiIC8+Cjwvc3ZnPg==" />
					</div>
				</div>
				<div class="pure-u-2-3">
					<h4 id="status_youtube"><%:YouTube Conn.%><br /><span id="_youtube_status" class="red"><%:Touch Check%></span></h4>
				</div>
			</div>
		</div>
	  </div>
	<script>
		//<![CDATA[
		var imgs = document.getElementsByTagName('img');
		for (var i = 0 ; i < imgs.length; i++) {
			document.getElementsByTagName('img')[i].setAttribute("oncontextmenu","return false;");
			document.getElementsByTagName('img')[i].setAttribute("ondragstart","return false;");
		}
		XHR.poll(5, '<%=api.url("index_status")%>', null,
			function (x, data) {
				var status_dns = document.getElementById('status_dns');
				var status_haproxy = document.getElementById('status_haproxy');
				if (data) {
					if (true) {
						var status_tcp_node = document.getElementById('status_tcp_node');
						if (status_tcp_node) {
							var text = 'TCP<br />';
							if (data["tcp_node_status"])
								text += '<span class="green"><%:RUNNING%></span>';
							else
								text += '<span class="red"><%:NOT RUNNING%></span>';
							status_tcp_node.innerHTML = text;
						}
					}

					if (true) {
						var status_udp_node = document.getElementById('status_udp_node');
						if (status_udp_node) {
							var text = 'UDP<br />';
							if (data["udp_node_status"])
								text += '<span class="green"><%:RUNNING%></span>';
							else
								text += '<span class="red"><%:NOT RUNNING%></span>';
							status_udp_node.innerHTML = text;
						}
					}

					if (data.dns_mode_status) {
						status_dns.innerHTML = 'DNS<br /><span class="green"><%:RUNNING%></span>';
					} else {
						status_dns.innerHTML = 'DNS<br /><span class="red"><%:NOT RUNNING%></span>';
					}
					if (status_haproxy) {
						if (data.haproxy_status) {
							status_haproxy.innerHTML = '<%:Load Balancing%><br /><span class="green"><%:RUNNING%></span>'
						} else {
							status_haproxy.innerHTML = '<%:Load Balancing%><br /><span class="red"><%:NOT RUNNING%></span>'
						}
					}
				}
			});

		function check_connect(type, url) {
			var s = document.getElementById('_' + type + '_status');
			if (s) {
				var div = s.parentNode.parentNode.parentNode.parentNode;
				div.removeAttribute('onclick');
				s.innerHTML = '<%:Check...%>';
				var sendDate = (new Date()).getTime();
				XHR.get('<%=api.url("connect_status")%>', {
						type: type,
						url : url
					},
					function(x, rv) {
						if (rv.ping_type && rv.ping_type == "curl") {
							var use_time = rv.use_time;
							if (use_time < 1000) {
								s.className="green";
							} else if (use_time < 2000) {
								s.className="yellow";
							} else {
								s.className="red";
							}
							s.innerHTML = use_time + " ms";
						} else if (rv.status) {
							s.className="green";
							s.innerHTML = "<%:Working...%>";
						}
						else {
							s.className="red";
							s.innerHTML = '<%:Problem detected!%>';
						}
						div.setAttribute('onclick','check_connect("' + type + '","' + url + '")');
					}
				);
			}
			return false;
		}
//]]>
	</script>
</fieldset>
