require "recordings"

function onRequest(env)
	print [[<html>
			<head>
				<title>Neuros OSD - Scheduled Recordings</title>
				<link rel="stylesheet" type="text/css" href="style.css" />
			</head>]];
	print("<body>\n ");
	
	list = recordings.loadRecordings("/media/USB/.Neuros/samplerecordings");
	print("<center");
	print("<h1>Scheduled Recordings</h1>");
	print("<table>\n");
	print("<thead><td>File</td><td>Start</td><td>Duration</td></tr></thead>\n");
	for name, recording in pairs(list) do
		print("<tr>");
		print("<td>", recording:getPath(), "</td>");
		print("<td>", os.date("%c", recording:getStartTime()), "</td>");
		print("<td>", string.format("%dh %dm", recording:getDuration()), "</td>");
		print("<td><center><a href='editrecording.lua?id=", name, "'>Edit</a></center></td>");
		print("</tr>\n");
	end
	print("<tr><td colspan='4'><center><a href='editrecording?new=true'>Schedule a new recording</a></center></td></tr>\n");
	print("</table>\n");
	print("</center>\n");	
	print("</html>");
end
