
<%
local fs = require "nixio.fs"

%>

<script type="text/javascript" src="<%=resource%>/cbi.js?v=1.1"></script>
<script type="text/javascript">//<![CDATA[
	var stxhr = new XHR();

	function update_status(field, proto)
	{
		var tool = field.name;
		var addr = field.value;
		var protocol = proto ;
        
		var legend = document.getElementById('test-rc-legend');
		var output = document.getElementById('test-rc-output');
		if (legend && output)
		{
			output.innerHTML =
				'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
				'<%:Waiting for command to complete...%>'
			;

			legend.parentNode.style.display = 'block';
			legend.style.display = 'inline';

			stxhr.post('<%=url('admin/network')%>/test_' + tool + protocol + '/' + addr, { token: '<%=token%>' },
				function(x)
				{
					if (x.responseText)
					{
						legend.style.display = 'none';
						output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
                                                
	 
					}
					else
					{
						legend.style.display = 'none';
						output.innerHTML ='</p><%:Operation execution complete%></p>';

					}

				}
			);
		}
}
//]]></script>

<form method="post" action="<%=url('admin/network/netspeedtest')%>">
    <div style="width:100%; float:left">
      <table>

        <tr><td  class="cbi-value-title"  ><input style="margin: 5px 0"  type="hidden" value="" name="iperf" />
            <select name="iperf_to" style="width:auto">
              <option value="0" selected="selected"><%:iperfstart%></option>
              <option value="1"><%:iperfstop%></option>
            </select></td>
        <td class="cbi-value-field" style="width:100%;" >
            <input type="button" value="<%:Perform operation%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.iperf,this.form.iperf_to.selectedIndex)" /></td>
        </tr>
        <tr><td  class="cbi-value-title" ><%:iperf3 instructions%></td>
          <td class="cbi-value-field"  ><%:The speed measurement terminal must be in the same LAN as the router that starts the speed measurement%><br /><%:Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service%></td>
        </tr>
        <tr>
          <td class="cbi-value-title"><%:Iperf3 speed measurement software download%></td>
          <td class="cbi-value-field"  >
            <input type="button" class="cbi-button cbi-input-reload" value="<%:Domestic download password:%>cpd6" onclick="javascript:window.open('https://sipdboy.lanzoui.com/b01c3esih','target');" />
            <input type="button" class="cbi-button cbi-input-reload" value="<%:Download from foreign official websites%>" onclick="javascript:window.open('https://iperf.fr/iperf-download.php','target');" /></td>
        </tr>

      </table>


  <fieldset class="cbi-section" style="display:none">
    <legend id="test-rc-legend">
    <%:Collecting data...%>
    </legend>
    <span id="test-rc-output"></span>
  </fieldset>
</div>
</form>
