From 3416d4e9e2b12c0dec3bfe5c58f6abd21aba4c6f Mon Sep 17 00:00:00 2001
From: hummypkg <af123@hpkg.tv>
Date: Sun, 23 Feb 2014 22:22:07 +0000
Subject: [PATCH] fixes

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1804 2a923420-c742-0410-a762-8d5b09965624
---
 CONTROL/control                               |  2 +-
 var/mongoose/cgi-bin/epg/search.jim           |  1 +
 var/mongoose/html/epg/service.jim             |  8 ++++++--
 var/mongoose/html/epg/service.js              |  5 +++++
 var/mongoose/html/lib/header.jim              |  4 ++--
 .../scrollto/jquery.scrollTo.min.js           |  7 +++++++
 var/mongoose/include/backup.jim               |  1 +
 var/mongoose/include/epg.jim                  | 19 +++++++++++++++----
 var/mongoose/lib/setup                        |  6 ++++++
 9 files changed, 44 insertions(+), 9 deletions(-)
 create mode 100644 var/mongoose/html/lib/jquery.plugin/scrollto/jquery.scrollTo.min.js

diff --git a/CONTROL/control b/CONTROL/control
index 73530e8..c25aabe 100644
--- a/CONTROL/control
+++ b/CONTROL/control
@@ -1,7 +1,7 @@
 Package: webif
 Priority: optional
 Section: web
-Version: 1.0.9
+Version: 1.0.9-3
 Architecture: mipsel
 Maintainer: af123@hummypkg.org.uk
 Depends: webif-channelicons(>=1.1.9),mongoose(>=3.0.11),jim(>=0.74-4),jim-oo,jim-sqlite3(>=0.74-1),jim-cgi(>=0.7),jim-binary,service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6)
diff --git a/var/mongoose/cgi-bin/epg/search.jim b/var/mongoose/cgi-bin/epg/search.jim
index 2322784..4418174 100755
--- a/var/mongoose/cgi-bin/epg/search.jim
+++ b/var/mongoose/cgi-bin/epg/search.jim
@@ -55,6 +55,7 @@ if {$ct > 0 } {
 }
 
 set favlist [epg favlist]
+set s [settings]
 if {[$s service_style] eq "standard"} {
 	set surl xservice
 } else {
diff --git a/var/mongoose/html/epg/service.jim b/var/mongoose/html/epg/service.jim
index 546168a..d976b15 100755
--- a/var/mongoose/html/epg/service.jim
+++ b/var/mongoose/html/epg/service.jim
@@ -4,7 +4,7 @@ package require cgi
 source /mod/webif/lib/setup
 require epg.class spinner.class altrow
 
-jqplugin iphone-style-checkboxes freezeheader
+jqplugin iphone-style-checkboxes freezeheader scrollto
 jscss service.js service.css
 header
 
@@ -30,6 +30,8 @@ if {[llength $records] == 0} {
 	exit
 }
 
+set nowhour [clock format [clock seconds] -format "%H"]
+
 # Load the channel information from the first entry
 set tr [lindex $records 0]
 $tr get_channel_info
@@ -42,6 +44,8 @@ puts "
 	[$tr channel_icon 40 {vertical-align:middle}]
 	</td><td>
 		$channel_num - $channel_name
+	</td><td style=\"width: 50px\">&nbsp;</td><td>
+		<button id=jumptonow hour=$nowhour>Jump to Now</button>
 	</td><td style=\"width: 50px\">&nbsp;</td><td>
 		Show synopsis?
 	</td><td>
@@ -219,7 +223,7 @@ foreach e $records {
 			puts -nonewline "</td></tr>"
 		}
 		puts "
-			<tr class=hour>
+			<tr class=hour id=hour_$hour>
 			<th class=hour>$hour:00</th>
 			<td class=dayhour>
 		"
diff --git a/var/mongoose/html/epg/service.js b/var/mongoose/html/epg/service.js
index 5fa7541..6c6c6ae 100644
--- a/var/mongoose/html/epg/service.js
+++ b/var/mongoose/html/epg/service.js
@@ -20,5 +20,10 @@ $('#listview').bind('click', function() {
 
 $('table.weekview').freezeHeader();
 
+$('#jumptonow').bind('click', function() {
+	var hour = $(this).attr('hour');
+	$('body').scrollTo('#hour_' + hour);
+});
+
 });
 
diff --git a/var/mongoose/html/lib/header.jim b/var/mongoose/html/lib/header.jim
index 56563e7..41d6631 100755
--- a/var/mongoose/html/lib/header.jim
+++ b/var/mongoose/html/lib/header.jim
@@ -26,10 +26,10 @@ puts {
 <script type="text/javascript" src="/lib/jquery.ui/js/jquery-ui.js"></script>
 }
 if {[info exists _mws_js]} {
-	foreach js $_mws_js {
+	foreach js $::_mws_js {
 		puts "<script type=text/javascript src=\"$js\"></script>"
 	}
-	foreach css $_mws_css {
+	foreach css $::_mws_css {
 		puts "<link href=\"$css\" rel=stylesheet type=text/css />"
 	}
 }
diff --git a/var/mongoose/html/lib/jquery.plugin/scrollto/jquery.scrollTo.min.js b/var/mongoose/html/lib/jquery.plugin/scrollto/jquery.scrollTo.min.js
new file mode 100644
index 0000000..32cd786
--- /dev/null
+++ b/var/mongoose/html/lib/jquery.plugin/scrollto/jquery.scrollTo.min.js
@@ -0,0 +1,7 @@
+/**
+ * Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
+ * Licensed under MIT
+ * @author Ariel Flesler
+ * @version 1.4.11
+ */
+;(function(a){if(typeof define==='function'&&define.amd){define(['jquery'],a)}else{a(jQuery)}}(function($){var j=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};j.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};j.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(f,g,h){if(typeof g=='object'){h=g;g=0}if(typeof h=='function')h={onAfter:h};if(f=='max')f=9e9;h=$.extend({},j.defaults,h);g=g||h.duration;h.queue=h.queue&&h.axis.length>1;if(h.queue)g/=2;h.offset=both(h.offset);h.over=both(h.over);return this._scrollable().each(function(){if(f==null)return;var d=this,$elem=$(d),targ=f,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}var e=$.isFunction(h.offset)&&h.offset(d,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=j.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=e[pos]||0;if(h.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*h.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&h.queue){if(old!=attr[key])animate(h.onAfterFirst);delete attr[key]}});animate(h.onAfter);function animate(a){$elem.animate(attr,g,h.easing,a&&function(){a.call(this,targ,h)})}}).end()};j.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||typeof a=='object'?a:{top:a,left:a}};return j}));
diff --git a/var/mongoose/include/backup.jim b/var/mongoose/include/backup.jim
index 6a1288e..79db2d4 100755
--- a/var/mongoose/include/backup.jim
+++ b/var/mongoose/include/backup.jim
@@ -3,6 +3,7 @@
 source /mod/webif/lib/setup
 require altrow rsv.class
 
+noheader
 jscss /cgi-bin/backup/backup.js
 puts {
 <h2>Backup/Restore</h2>
diff --git a/var/mongoose/include/epg.jim b/var/mongoose/include/epg.jim
index b429bb6..679c1da 100755
--- a/var/mongoose/include/epg.jim
+++ b/var/mongoose/include/epg.jim
@@ -2,7 +2,11 @@
 
 package require cgi
 source /mod/webif/lib/setup
-require epg.class spinner.class altrow epg_search totop system.class
+require epg.class spinner.class altrow epg_search system.class
+
+noheader
+
+require totop
 
 set irinst [system pkginst ir]
 
@@ -17,7 +21,8 @@ require epg_popup
 set start [clock milliseconds]
 set now [clock seconds]
 set then $($now + 14400)
-set favgroup [[settings] channel_group]
+set s [settings]
+set favgroup [$s channel_group]
 if {$::qepg} {
 	if {$favgroup} {
 		set records [epg dbfetch dump \
@@ -31,13 +36,19 @@ if {$::qepg} {
 }
 set got [clock milliseconds]
 
-if {[[settings] chanchangenc]} {
+if {[$s chanchangenc]} {
 	jscss /js/chanchangeenc.js
 } else {
 	jqplugin confirmAction
 	jscss /js/chanchange.js
 }
 
+if {[$s service_style] eq "standard"} {
+	set surl xservice
+} else {
+	set surl service
+}
+
 puts {
 	<small><button id=switch>Switch to grid-style Now/Next</button></small>
 	<script type=text/javascript>
@@ -71,7 +82,7 @@ foreach record $records {
 		if {$irinst} { puts "</a>" }
 		puts "</td>
 		    <td>
-	    <a href=\"/epg/service.jim?service=[\
+	    <a href=\"/epg/$surl.jim?service=[\
 		$record get service_id]\">
 		    [$record get channel_name]
 		    </a></td>"
diff --git a/var/mongoose/lib/setup b/var/mongoose/lib/setup
index 76eebd1..9e50521 100644
--- a/var/mongoose/lib/setup
+++ b/var/mongoose/lib/setup
@@ -35,6 +35,7 @@ if {![exists -proc require]} {
 	}
 
 	proc noheader {} {
+		emit_jscss
 		incr ::_mws_headerdone
 	}
 
@@ -66,6 +67,11 @@ if {![exists -proc require]} {
 		}
 	}
 
+	proc emit_jscss {} {
+		foreach js $::_mws_js { _js $js }
+		foreach css $::_mws_css { _css $css }
+	}
+
 	proc jqplugin {args} {{done {}}}  {
 	    foreach name $args {
 		if {$name in $done} continue