From 1c00e63f4806e1d16427c2f4020a10a4a8e27186 Mon Sep 17 00:00:00 2001
From: hummypkg <af123@hpkg.tv>
Date: Sun, 6 Jul 2014 20:11:59 +0000
Subject: [PATCH] fix bookmarks, add serial number

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@2012 2a923420-c742-0410-a762-8d5b09965624
---
 CONTROL/control                       |  4 ++--
 webif/html/browse/bookmarks/index.jim |  5 +++--
 webif/html/settings/settings.jim      |  8 +++++++-
 webif/html/settings/settings.js       | 22 +++++++++++++++-------
 webif/include/modversion.jim          |  9 ++-------
 webif/lib/hexdump                     |  2 +-
 webif/lib/system.class                | 12 ++++++++++++
 7 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/CONTROL/control b/CONTROL/control
index 7f03793..ad68364 100644
--- a/CONTROL/control
+++ b/CONTROL/control
@@ -1,10 +1,10 @@
 Package: webif
 Priority: optional
 Section: web
-Version: 1.0.15-5
+Version: 1.0.15-6
 Architecture: mipsel
 Maintainer: af123@hummypkg.org.uk
-Depends: webif-channelicons(>=1.1.11),lighttpd(>=1.4.35-2),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.0.13),hmt(>=1.1.21),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),mongoose
+Depends: webif-channelicons(>=1.1.12-1),lighttpd(>=1.4.35-2),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.0.13),hmt(>=1.1.21),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),mongoose
 Suggests:
 Description: An evolving web interface for the Humax.
 Tags: http://hummy.tv/forum/threads/5031/
diff --git a/webif/html/browse/bookmarks/index.jim b/webif/html/browse/bookmarks/index.jim
index 32f7b0b..b12c937 100755
--- a/webif/html/browse/bookmarks/index.jim
+++ b/webif/html/browse/bookmarks/index.jim
@@ -10,7 +10,8 @@ header
 
 set rfile [cgi_get file]
 set ts [ts fetch $rfile]
-set dir [file dirname $rfile]
+set dir [string map {' \\'} [file dirname $rfile]]
+set erfile [string map {' \\'} $rfile]
 
 set len [$ts duration 1]
 
@@ -18,7 +19,7 @@ puts "
 <script type=text/javascript>
 var initbookmarks = '[$ts bookmarks]';
 var len = [$ts duration 1];
-var file = '$rfile';
+var file = '$erfile';
 var dir = '$dir';
 </script>
 <fieldset class=cleft>
diff --git a/webif/html/settings/settings.jim b/webif/html/settings/settings.jim
index d721166..1030b1a 100755
--- a/webif/html/settings/settings.jim
+++ b/webif/html/settings/settings.jim
@@ -2,7 +2,7 @@
 
 package require cgi
 source /mod/webif/lib/setup
-require settings.class plugin system.class
+require settings.class plugin system.class spinner.class
 
 httpheader
 
@@ -130,6 +130,12 @@ jqplugin form iphone-style-checkboxes touchpunch
 jscss settings.js
 header
 
+[spinner new {
+        text "Loading Settings..."
+        size "1.2em"
+        style "margin: 1em;"
+        }] start
+
 puts {
 <div id=accordion>
 }
diff --git a/webif/html/settings/settings.js b/webif/html/settings/settings.js
index e25f6b6..94489ce 100644
--- a/webif/html/settings/settings.js
+++ b/webif/html/settings/settings.js
@@ -21,11 +21,6 @@
 
 $(document).ready(function () {
 	$(":submit").button();
-	//$('[type="checkbox"] :not(.yesno)').iphoneStyle();
-	$('[type="checkbox"]').iphoneStyle({
-		checkedLabel: 'YES',
-		uncheckedLabel: 'NO'
-	});
 	$('form.auto').each(function(i, el) {
 		var id = $(this).attr('id');
 		var output = '#' + id + '_output';
@@ -74,11 +69,24 @@ $(document).ready(function () {
 		    });
 	});
 
+	// Use window.name to remember the active accordion index
+	if (window.name == "")
+		window.name = "0";
+	accordionindex = ~~window.name;
+
 	$('#accordion').accordion({
+	    active: accordionindex,
 	    header: 'h4',
 	    collapsible: true,
-	    active: 0,
-	    heightStyle: 'content'
+	    heightStyle: 'content',
+	    activate: function(event, ui) {
+		window.name = $('#accordion').accordion('option', 'active');
+	    }
+	}).show();
+
+	$('[type="checkbox"]').iphoneStyle({
+		checkedLabel: 'YES',
+		uncheckedLabel: 'NO'
 	});
 
 	// For now - until plugins are updated.
diff --git a/webif/include/modversion.jim b/webif/include/modversion.jim
index 09ed522..1e37033 100755
--- a/webif/include/modversion.jim
+++ b/webif/include/modversion.jim
@@ -9,18 +9,13 @@ if {$modbuild > 0} {
 	append modver " (build $modbuild)"
 }
 
-if {[dict exists $env SERVER_SOFTWARE]} {
-	set wstype "Lighttpd"
-} else {
-	set wstype "Mongoose"
-}
-
 puts "<span class=blood style=\"font-size: 0.9em; float: right; clear: right\">
-	Web interface version: [system pkgver webif] ($wstype)<br>
+	Web interface version: [system pkgver webif]<br>
 	Custom firmware version: $modver
 "
 catch {set fhtcpversion [system fhtcpversion]}
 catch {set kernelver [system kernelver]}
 puts "<br>Humax Version: $fhtcpversion (kernel $kernelver)"
+puts "<br>Serial Number: [system serialno]"
 puts "</span>"
 
diff --git a/webif/lib/hexdump b/webif/lib/hexdump
index 5824e27..9c1122e 100644
--- a/webif/lib/hexdump
+++ b/webif/lib/hexdump
@@ -7,7 +7,7 @@ proc hexdump data {
 		set bytes [string byterange $data $n $($n+15)]
 		binary scan $bytes H* hex
 		set hex [regexp -all -inline .. $hex]
-		regsub -all -- {[^a-z]} $bytes . ascii
+		regsub -all -- {[^a-z0-9]} $bytes . ascii
 		append dump [format "%04X: %-48s %-16s\n" $n $hex $ascii]
 		incr n 16
 	}
diff --git a/webif/lib/system.class b/webif/lib/system.class
index 711d6a5..d530f43 100644
--- a/webif/lib/system.class
+++ b/webif/lib/system.class
@@ -66,6 +66,18 @@ proc {system fhtcpversion} {} {
 	return $ver
 }
 
+# 822272+6 - MAC address
+# 833536 - Serial number
+proc {system serialno} {} {
+	set fd [open /dev/mtd3 r]
+	
+	$fd seek 833536
+	set bytes [$fd read 14]
+	$fd close
+	return "[string range $bytes 0 1] [string range $bytes 2 8] [
+	    string range $bytes 9 end]"
+}
+
 proc {system kernelver} {} {
 	#1 SMP Sun Mar 25 18:30:38 KST 2012
 	set ver [string range [exec uname -v] 11 end]