#import sickgear
##
#set global $title = 'Cache'
#set global $header = 'Cache'
#set global $sbPath = '..'
#set global $topmenu = 'cache'
##
#import os.path
#from sickgear import providers
#from sickgear.common import Quality
#from sickgear.helpers import try_int
#from sickgear.sgdatetime import SGDatetime
#include $os.path.join($sickgear.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl')

<script type="text/javascript">
<!--
\$(document).ready(function()
{
	\$('#cacheTable:has(tbody tr)').tablesorter({
		widgets: ['zebra', 'filter'],
		sortList: [[1,0]],
	});

	#raw
	$('.addQTip').each(function () {
		$(this).css({'cursor':'help', 'text-shadow':'0px 0px 0.5px #666'});
		$(this).qtip({
			show: {solo:true},
			position: {viewport:$(window), my:'right center', adjust:{ y: -10, x: -15 }},
			style: {classes:'qtip-rounded qtip-shadow'}
		});
	});
	#end raw
});
//-->
</script>

#if $varExists('header')
	<h1 class="header">$header</h1>
#else
	<h1 class="title">$title</h1>
#end if

	<table id="cacheTable" class="sickbeardTable tablesorter" cellspacing="1" border="0" cellpadding="0">
		<thead>
			<tr>
				<th class="col-cache">Prov</th>
				<th class="col-name-cache">Rls Name</th>
				<th class="col-cache">Sn</th>
				<th class="col-cache col-episodes">En</th>
				<th class="col-cache">Show Id</th>
				<th class="col-cache">Url</th>
				<th class="col-cache">TimeStamp</th>
				<th class="col-cache">Quality</th>
				<th class="col-cache">Rls Group</th>
				<th class="col-cache">Ver</th>
			</tr>
		</thead>

		<tfoot>
			<tr>
				<th class="nowrap" colspan="10" style="text-align:left">$len($cacheResults) releases</th>
			</tr>
		</tfoot>

		<tbody>
#for $hItem in $cacheResults:
    #set $provider = $providers.getProviderClass($hItem['provider'])
    #set $tip = '%s @ %s' % ($hItem['provider'], $SGDatetime.sbfdatetime($SGDatetime.fromtimestamp($hItem['time'])))
    #set $ver = $hItem['version']
    #set $ver = ($ver, '')[-1 == $ver]
    #set $quality = try_int($hItem['quality'])
			<tr>
    #if $provider
                <td class="col-cache"><img src="$sbRoot/images/providers/$provider.image_name()" class="addQTip" alt="$tip" title="$tip" width="16" height="16" style="vertical-align:middle"></td>
    #else
                <td class="col-cache"><span class="addQTip" alt="$tip" title="$tip" width="16" height="16" style="vertical-align:middle">$hItem['provider']</span></td>
    #end if
				<td class="col-name-cache">$hItem['name']</td>
				<td class="col-cache">$hItem['season']</td>
				<td class="col-episodes" style="white-space:nowrap">$hItem['episodes'].strip('|').replace('|', ',')</td>
				<td class="col-cache">$hItem['indexerid']</td>
				<td class="col-cache"><span title="$hItem['url']" class="addQTip"><img src="$sbRoot/images/info32.png" width="16" height="16" /></span></td>
				<td class="col-cache">$hItem['time']</td>
				<td class="col-cache"><span class="quality $Quality.get_quality_css($quality)">$Quality.get_quality_ui($quality)</span></td>
				<td class="col-cache">$hItem['release_group']</td>
				<td class="col-cache">$ver</td>
			</tr>
#end for
		</tbody>
	</table>

#include $os.path.join($sickgear.PROG_DIR,'gui/slick/interfaces/default/inc_bottom.tmpl')