<%+cbi/valueheader%>
<%
	local stream_id_name = string.gsub(self.value, "%W", "")
%>
<script type="text/javascript">//<![CDATA[

function act_manual_unlock_test_<%=stream_id_name%>(btn, type)
{
	var manual_<%=stream_id_name%>_type_legend = document.getElementById('manual-<%=stream_id_name%>-test-state');
	var manual_<%=stream_id_name%>_type_output = document.getElementById('manual-<%=stream_id_name%>-test-output');
	var r = confirm("<%:Network instability may occur during testing, Are you sure want to start test?%>")
	if (r == true) {
		if (manual_<%=stream_id_name%>_type_legend && manual_<%=stream_id_name%>_type_output)
		{
			manual_<%=stream_id_name%>_type_output.innerHTML =
				'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
				'<%:Waiting for command to complete...%>';

			manual_<%=stream_id_name%>_type_legend.parentNode.style.display = 'block';
			manual_<%=stream_id_name%>_type_legend.style.display = 'inline';
		};
				
		XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "manual_stream_unlock_test")%>', {type: type}, function(x, status) {
			if (x && x.status == 200 && x.responseText != "")
			{
				manual_<%=stream_id_name%>_type_legend.style.display = 'none';
				manual_<%=stream_id_name%>_type_output.innerHTML = '<textarea id="manual_<%=stream_id_name%>_type_output" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="10" cols="50" readonly="readonly" >'+x.responseText+'</textarea>';
				other_log_area(document.getElementById("manual_<%=stream_id_name%>_type_output"), 'true', manual_<%=stream_id_name%>_type_output.offsetWidth, '250px');
			}
			else
			{
				manual_<%=stream_id_name%>_type_legend.style.display = 'none';
				manual_<%=stream_id_name%>_type_output.innerHTML = '<span class="error"><%:Something Wrong While Testing...%></span>';
			}
		}
		);
	};
};

function act_all_proxies_test_<%=stream_id_name%>(btn, type)
{
	var all_<%=stream_id_name%>_legend = document.getElementById('all-<%=stream_id_name%>-test-state');
	var all_<%=stream_id_name%>_output = document.getElementById('all-<%=stream_id_name%>-test-output');
	var r = confirm("<%:Network instability may occur during testing, Are you sure want to start test?%>")
	if (r == true) {
		if (all_<%=stream_id_name%>_legend && all_<%=stream_id_name%>_output)
		{
			all_<%=stream_id_name%>_output.innerHTML =
				'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
				'<%:Waiting for command to complete...%>';

			all_<%=stream_id_name%>_legend.parentNode.style.display = 'block';
			all_<%=stream_id_name%>_legend.style.display = 'inline';
		};
				
		XHR.get('<%=luci.dispatcher.build_url("admin", "services", "openclash", "all_proxies_stream_test")%>', {type: type}, function(x, status) {
			if (x && x.status == 200 && x.responseText != "")
			{
				all_<%=stream_id_name%>_legend.style.display = 'none';
				all_<%=stream_id_name%>_output.innerHTML = '<textarea id="all_<%=stream_id_name%>_output" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="10" cols="50" readonly="readonly" >'+x.responseText+'</textarea>';
				other_log_area(document.getElementById("all_<%=stream_id_name%>_output"), 'true', all_<%=stream_id_name%>_output.offsetWidth, '250px');
			}
			else
			{
				all_<%=stream_id_name%>_legend.style.display = 'none';
				all_<%=stream_id_name%>_output.innerHTML = '<span class="error"><%:Something Wrong While Testing...%></span>';
			}
		}
		);
	};
};
	
//]]></script>


<input type="button" class="btn cbi-button cbi-input-reload" value="<%:Unlock Test(Select)%>" onclick="return act_manual_unlock_test_<%=stream_id_name%>(this, '<%=self.value%>')" />
<input type="button" class="btn cbi-button cbi-input-reload" value="<%:All Proxies Test%>" onclick="return act_all_proxies_test_<%=stream_id_name%>(this, '<%=self.value%>')" />
<fieldset style="display: none;margin: 0 auto;">
	<legend id="manual-<%=stream_id_name%>-test-state"><%:Collecting data...%></legend>
	<br />
	<span id="manual-<%=stream_id_name%>-test-output"></span>
</fieldset>
<fieldset style="display: none;margin: 0 auto;">
	<legend id="all-<%=stream_id_name%>-test-state"><%:Collecting data...%></legend>
	<br />
	<span id="all-<%=stream_id_name%>-test-output"></span>
</fieldset>
<%+cbi/valuefooter%>
