<%#
Opennet Firmware

Copyright 2010 Rene Ejury <opennet@absorb.it>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

-%>

<script type="text/javascript">//<![CDATA[

function update_vpn_status_item(item) {
	var element = document.getElementById(item);
	if (element) {
		var run_xhr = new XHR();
		run_xhr.get('<%=luci.dispatcher.build_url("opennet", "opennet_1")%>/vpn_tunnel/on_' + item, null,
			function(x) { if (x.responseText) element.innerHTML = x.responseText; });
	}
}


if (window.attachEvent) {
	window.attachEvent('onload', init);
} else if (window.addEventListener) {
	window.addEventListener('load', init, false);
} else {
	document.addEventListener('load', init, false);
}
function init() {
	["vpn_status_label", "vpn_status_form"].map(function(item) {
		if (document.getElementById(item)) {
			update_vpn_status_item(item);
			setInterval('update_vpn_status_item("' + item + '")', 5000);
		}
	});
}
//]]></script>


<% if certstatus.on_keycrt_ok then %>
<h3><%:Status%></h3>
<div class="cbi-map">
	<fieldset class="cbi-section" id="on_vpn_status_fieldset">
		<fieldset class="cbi-section-node">
			<table width="100%">
				<tr>
					<td><table class="usergw-status" id="vpn_status_label">
						<tr><td>
							<img class='loading_img_small' id="vpn_status_spinner" src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" />
						</td></tr>
					</table></td>
					<td>
						<form method="post" action="<%=REQUEST_URI%>?restartvpn=true" id="vpn_status_form" />
					</td>
				</tr>
			</table>
		</fieldset>
	</fieldset>
</div>
<% end %>
