<%#
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 check_vpn_status_label() {
  var run_xhr = new XHR();
  run_xhr.get('<%=luci.dispatcher.build_url("opennet", "opennet_1")%>/vpn_tunnel/on_vpn_status_label', null,
  function(x) {
  if (x.responseText)
    document.getElementById("vpn_status_label").innerHTML = x.responseText;
  }
  );
}

function check_vpn_status_form() {
  var run_xhr = new XHR();
  run_xhr.get('<%=luci.dispatcher.build_url("opennet", "opennet_1")%>/vpn_tunnel/on_vpn_status_form', null,
  function(x) {
  if (x.responseText)
    document.getElementById("vpn_status_form").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);} 
// 
//   window .onload = function test() {init();}
function init() {
  check_vpn_status_label();
  check_vpn_status_form();
  setInterval('check_vpn_status_label()', 5000 )
  setInterval('check_vpn_status_form()', 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">
          </form> 
      </td></tr></table>
    </fieldset>
	</fieldset>
</div>
<% end %>
