<fieldset class="cbi-section">
	<legend><%:Running Status%></legend>
	<fieldset class="cbi-section">
		<div class="cbi-value">
			<label class="cbi-value-title">Nginx <%:Status%></label>
			<div class="cbi-value-field" id="_nginx_status"><%:Collecting data...%></div>
		</div>
		<div class="cbi-value">
			<label class="cbi-value-title">PHP <%:Status%></label>
			<div class="cbi-value-field" id="_php_status"><%:Collecting data...%></div>
		</div>
		<div class="cbi-value">
			<label class="cbi-value-title"></label>
			<div class="cbi-value-field">
				<font color="red" id="tips"></font>
			</div>
		</div>
	</fieldset>
</fieldset>

<script type="text/javascript">//<![CDATA[
	var nginx_status = document.getElementById('_nginx_status');
	var php_status = document.getElementById('_php_status');
	XHR.poll(3, '<%=url([[admin]], [[nas]], [[kodexplorer]], [[status]])%>', null,
		function(x, json) {
			if (x && x.status == 200) {
				if (nginx_status) {
					var str = "";
					if (json.nginx_status) {
						document.getElementById("tips").innerHTML = '<%:If you need external network access, please open the port by yourself.%>';
						str = '<font color="green"><%:RUNNING%> ✓</font><input type="button" class="cbi-button cbi-input-apply" value="<%:Enter interface%>" onclick="open_web()" />'
					} else {
						str = '<font color="red"><%:NOT RUNNING%> X</font>';
					}
					nginx_status.innerHTML = str;
				}
				if (php_status) {
					php_status.innerHTML = json.php_status ? '<font color="green"><%:RUNNING%> ✓</font>' : '<font color="red"><%:NOT RUNNING%> X</font>';
				}
			}
		}
	);
	function open_web(){
		var port = '<%=luci.sys.exec("uci -q get kodexplorer.@global[0].port"):gsub("^%s*(.-)%s*$", "%1")%>';
		var ishttps = '<%=luci.sys.exec("uci -q get kodexplorer.@global[0].https"):gsub("^%s*(.-)%s*$", "%1")%>';
		var protocol = (ishttps == "1") ? "https://" : "http://";
		var hostname = location.hostname;
		
		var url = protocol + hostname + ":" + port;
		window.open(url, 'target', '');
	}
//]]></script>