<%
local dsp = require "luci.dispatcher"
-%>

<fieldset class="cbi-section">
	<legend><%:Running Status%></legend>
	<fieldset class="cbi-section">
		<div class="cbi-value">
			<label class="cbi-value-title"><%:Status%></label>
			<div class="cbi-value-field" id="_status"><%:Collecting data...%></div>
		</div>
	</fieldset>
</fieldset>

<script type="text/javascript">//<![CDATA[
	var _status = document.getElementById('_status');
	XHR.poll(3,'<%=dsp.build_url("admin/nas/filebrowser/status")%>', null,
		function(x, json) {
			if (x && x.status == 200) {
				if (_status)
					_status.innerHTML = json.status ? '<font color="green"><%:RUNNING%> ✓</font><p><input type="button" class="cbi-button cbi-input-apply" value="<%:Enter interface%>" onclick="openwebui()" /></p>' : '<font color="red"><%:NOT RUNNING%> X</font>';
			}
		});
		
	function openwebui(){
		var url = window.location.host+":<%=luci.sys.exec("uci get filebrowser.@global[0].port"):gsub("^%s*(.-)%s*$", "%1")%>";
		window.open('http://'+url,'target','');
	}
//]]></script>