<% local form, viewlibrary, page_info, session = ... 
require("htmlviewfunctions")
html = require("acf.html")
%>

<script type="text/javascript" src="<%= html.html_escape(page_info.wwwprefix) %>/js/jquery-latest.js"></script>
<script type="text/javascript">
	$(function(){
		$("input[name='value']").focus();
		$('input').keydown(function(e){
			if (e.keyCode == 13) {
				$(this).parents('form').find('input.submit').click();
				return false;
			}
		});
	});
</script>

<% htmlviewfunctions.displaycommandresults({"deletedevice", "editdevice", "editdeviceparams", "overridedeviceparams"}, session) %>

<%
if session.searchdevicesresult then
	local data = session.searchdevicesresult
	session.searchdevicesresult = nil

	if data.value and data.value.result then
		local func = haserl.loadfile(page_info.viewfile:gsub("searchbymac", "listdevices"))
		func(data.value.result, viewlibrary, page_info, session)
	end
end
%>

<H1>Search by MAC Address</H1>
<DL>
<form action="/cgi-bin/acf/provisioning/provisioning/searchdevices" method="POST">
<input type="hidden" name="id" value="device.mac">
<input type="hidden" name="comparison" value="~">
<DT>MAC Address</DT>
<DD><input class="text" type="text"  name="value"  value="" ></DD>
<DT></DT><DD><input class="submit" type="submit" name="submit" value="Search"></DD>
</FORM></DL>
