#filter WebSafe
#from urllib import quote
#from time import localtime, strftime
#from Plugins.Extensions.OpenWebif.local import tstrings
<div id="content_main" class="ui-widget-content" style="min-height: 500px;">
	<div id="tvcontentmain">
		<div id="toolbar-header" class="ui-widget-header">
			<span id="toolbar">
				<span id="timerbuttons">
					<button id="timerbutton0" onclick="addTimer(); return false">$tstrings['add_timer']</button>
					<button id="timerbutton1" onclick="cleanupTimer(); return false">$tstrings['cleanup_timer']</button>
					<button id="timerbutton2" onclick="lastcontenturl='';load_maincontent('ajax/timers'); return false;">$tstrings['refresh_timer']</button>
				</span>
			</span>
		</div>

		<div id="timers">
		#for $timer in $timers
			<div class="tm_row ui-widget-content ui-state-default" id="$timer.begin-$timer.end">
				<div class="t_buttons tm_buttons">
						<div>
						#set $sref=quote($timer.serviceref, safe=' ~@#$&()*!+=:;,.?/\'')
						#set $tname=quote($timer.name)
						<a href='#' onClick="editTimer('$sref', '$timer.begin', '$timer.end');" title="$tstrings['edit_timer']"><div><i class="fa fa-edit"></i></div></a>
						<a href='#' onClick="deleteTimer('$sref', '$timer.begin', '$timer.end', '$tname');" title="$tstrings['delete_timer']"><div><i class="fa fa-trash-o"></i></div></a>
						<a href='#' onClick="toggleTimerStatus('$sref', '$timer.begin', '$timer.end');" 
						#if $timer.disabled
						title="$tstrings['enable_timer']"><div id='img-$timer.begin-$timer.end'><i data-ref="$sref" class="fa fa-square-o">
						#else
						title="$tstrings['disable_timer']"><div id='img-$timer.begin-$timer.end'><i data-ref="$sref" class="fa fa-check-square-o">
						#end if
						</i></div></a>
						</div>
					</div>
				<div class="tm_text">
					<div>
						<div class="tm_title">
							$timer.name
						</div>
						$tstrings[("day_" + (time.strftime("%w", time.localtime($timer.begin))))]
						$timer.realbegin - $timer.realend
						#if $timer.repeated != 0
							<div>
								$tstrings['every_timer']
							#set $flags=$timer.repeated
							#set $timerDays=[]
							#for $day in [$tstrings['monday'],$tstrings['tuesday'],$tstrings['wednesday'],$tstrings['thursday'],$tstrings['friday'],$tstrings['saturday'],$tstrings['sunday']]
								#if $flags&1
									$timerDays.append($day)
								#end if
								#set $flags = $flags >> 1
							#end for
							#echo ', '.join($timerDays)
							</div>
						#end if
						<div style="font-weight: bold;">
							$timer.servicename
						</div>
					</div>
					<div>
						$timer.description
					</div>
					<div>
						<span class="tm_desc" style="font-weight: bold;">
							#if $timer.disabled
								$tstrings['disabled']
							#elif $timer.state == 0
								$tstrings['waiting']
							#elif $timer.state == 2
								$tstrings['running']
							#elif $timer.state == 3
								$tstrings['finished']
							#end if
						</span>
					</div>
				</div>
				<div style="clear: both;"></div>
			</div>
		#end for
		</div>
	</div>
</div>
<script type="text/javascript">
#raw
var reloadTimers = true;
$(function() {
	setTMHover();
	$('#timerbuttons').buttonset();
	if(!timeredit_initialized)
		$('#editTimerForm').load('ajax/edittimer');
	$('#timers').scroll(function() {
		SetLSValue('TimerListOffset',$('#timers').scrollTop());
	});
	$('#timers').scrollTop(GetLSValue('TimerListOffset',0));
});
#end raw
</script>
#end filter
