<%inherit file="base.html" />

<%def name="body()">

	<div id="paddingheader">
		<h1>Search Results<h1>
	</div>
	<table class="display" id="searchresults_table">
		<thead>
			<tr>
			%if type == 'album':
				<th id="albumname">Album Name</th>
			%endif
				<th id="artistname">Artist Name</th>
				<th id="score">Score</th>
				<th id="add"></th>
			</tr>
		</thead>
		<tbody>
			%if searchresults:
				%for result in searchresults:
				<%
					if result['score'] == 100:
						grade = 'A'
					else:
						grade = 'Z'
				%>
				<tr class="grade${grade}">
				%if type == 'album':
					<td id="albumname"><a href="${result['albumurl']}">${result['title']}</a></td>
				%endif
					<td id="artistname"><a href="${result['url']}">${result['uniquename']}</a></td>
					<td id="score">${result['score']}</td>
				%if type == 'album':	
					<td id="add"><a href="addReleaseById?rid=${result['albumid']}">Add this album</a></td>
				%else:
					<td id="add"><a href="addArtist?artistid=${result['id']}">Add this artist</a></td>
				%endif
				</tr>
				%endfor
			%endif
		</tbody>
	</table>
</%def>

<%def name="headIncludes()">
	<link rel="stylesheet" href="css/data_table.css">
</%def>

<%def name="javascriptIncludes()">
	<script src="js/libs/jquery.dataTables.min.js"></script>
	<script>
	$(document).ready(function()
	{
		$('#searchresults_table').dataTable(
			{
				"oLanguage": {
					"sLengthMenu":"Show _MENU_ results per page",
					"sEmptyTable": "No results",
					"sInfo":"Showing _START_ to _END_ of _TOTAL_ results",
					"sInfoEmpty":"Showing 0 to 0 of 0 results",
					"sInfoFiltered":"(filtered from _MAX_ total results)"},
				"iDisplayLength": 25,
				"sPaginationType": "full_numbers",
				"aaSorting": []

			});
	});
	</script>
</%def>