#from urllib import quote
#from json import dumps
#from Plugins.Extensions.OpenWebif.local import tstrings
<body> 
	#import datetime
	<div data-role="page">
		<div id="header">
			<div class="button" onClick="history.back()">$tstrings['back']</div>
			<!-- <div class="button-bold">+</div> -->
			<h1><a style="color:#FFF;text-decoration:none;" href='/mobile'>OpenWebif</a></h1>
		</div>
		<div id="contentContainer">
			<div data-role="collapsibleset">
				<div data-role="collapsible" data-disabled="true" data-collapsed-icon="false" data-theme="b">
					<h2>$tstrings['timer_list']</h2>
				</div>
				#set $oldstartdate = ""
				#for $timer in $timers
				#set $duration = $timer.duration/60
				#set $starttime = datetime.datetime.fromtimestamp($timer.begin).strftime("%H:%M")
				#set $startdate = datetime.datetime.fromtimestamp($timer.begin).strftime("%d.%m.%Y")
				#set $endtime = datetime.datetime.fromtimestamp($timer.end).strftime("%H:%M")
				#if $startdate <> $oldstartdate
				#if $oldstartdate <> ""
					</ul>
				</div>
				<div data-role="collapsible">
				#else
				<div data-role="collapsible" data-collapsed="false">
				#end if
					<h2>$startdate</h2>
					#set $oldstartdate = $startdate
					<ul data-role="listview" data-inset="false" data-theme="a">
				#end if
					<li>
						#set $sref=quote($timer.serviceref, safe=' ~@#$&()*!+=:;,.?/\'')
						#set $name=quote($timer.name, safe=' ~@#$&()*!+=:;,.?/\'').replace("'","\\'")
						<a href="#">
							<h2>$timer.name</h2>
							<p><strong>$timer.servicename - $starttime - $endtime ($duration min)</strong></p>
							<p>$timer.description</p>
						</a>
						<a href="#" onClick="deleteTimer('$sref', '$timer.begin', '$timer.end', '$name');" aria-expanded="false" class="ui-btn ui-btn-icon-notext ui-icon-delete ui-btn-a" title="delete"></a>
					</li>
				#end for
				</ul>
			</div>
			<button onClick="document.location.reload(true)">$tstrings['refresh']</button>
		</div>
		<div id="footer">
			<p>OpenWebif Mobile</p>
			<a onclick="document.location.href='/index?mode=fullpage';return false;" href="#">$tstrings['show_full_openwebif']</a>
		</div>
	<script>
	function deleteTimer(sRef, begin, end, title) {
		var t = decodeURIComponent(title);
		if (confirm("$tstrings['delete_timer_question']" + ": " + t) === true) {
			\$.ajax({ url: "/api/timerdelete?sRef=" + sRef + "&begin=" + begin + "&end=" + end, cache: false, async: false}).done(function() { 
				location.reload(true);
			});
		}
	}
	</script>
</div>
</body>
</html>
