Add eject, more context icons, fix some HTML issues, update jquery

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@2090 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2014-12-29 22:28:51 +00:00
parent fcb036801e
commit 5d0939d8de
28 changed files with 326 additions and 103 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 1.0.18-3
Version: 1.0.18-4
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.14),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(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.0.14),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),tcpping(>=1.1),mongoose

View File

@ -49,6 +49,11 @@ fi
/mod/webif/lib/bin/diskattrs
#/mod/webif/lib/bin/resetnew
# Remove hook script placed by the legacy rt3070 package which does not work
# with CFW >= 3.00
hook=/mod/boot/xinit.d/rt3070
[ -f $hook ] && rm -f $hook
[ -f $tmpf ] && rm -f $tmpf
exit 0

29
webif/cgi-bin/usbeject.jim Executable file
View File

@ -0,0 +1,29 @@
#!/mod/bin/jimsh
package require cgi
source /mod/webif/lib/setup
require system.class
httpheader "application/json"
set label [cgi_get label -]
foreach usb [system usbmounts 1] {
if {$usb(LABEL) eq $label} {
puts "{"
if {[catch {exec /bin/umount $usb(MP)} msg]} {
if {[string match {*resource busy*} $msg]} {
set msg "Failed to eject $label - in use"
}
puts "\"status\": 0,"
puts "\"result\": \"$msg\""
} else {
puts "\"status\": 1,"
puts "\"result\": \"Successfully ejected $label\""
file delete -force $usb(MP)
}
puts "}"
exit
}
}

25
webif/cgi-bin/usbinfo.jim Executable file
View File

@ -0,0 +1,25 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class
httpheader "application/json"
puts "\["
set flag 0
foreach usb [system usbmounts 1] {
if {$flag} { puts "," } else { set flag 1 }
puts " {"
set sf 0
foreach k [array names usb] {
if {$sf} { puts "," } else { set sf 1 }
puts -nonewline " \"$k\": \"$usb($k)\""
}
puts ""
puts -nonewline " }"
}
puts ""
puts "]"

View File

@ -9,8 +9,8 @@ puts {
<li class=cut><a href=#cut>Cut to clipboard</a></li>
<li class=pwcopy><a href=#copy>Copy to clipboard</a></li>
<li class=separator><a href=#rename>Rename</a></li>
<li><a href=#download>Download</a></li>
<li class="separator rename"><a href=#rename>Rename</a></li>
<li class=download><a href=#download>Download</a></li>
}
if {$model eq "HDR"} {
@ -27,7 +27,7 @@ if {[system pkginst ffmpeg]} {
}
}
puts { <li><a href=#vthm>View Thumbnail</a></li> }
puts { <li class=thm><a href=#vthm>View Thumbnail</a></li> }
puts { <li class=bookmark><a href=#bmarks>Bookmarks</a></li> }
@ -38,8 +38,8 @@ if $nicesplice {
}
}
puts {
<li class=separator><a href=#lock>Toggle Lock</a></li>
<li><a href=#new>Toggle New</a></li>
<li class="separator lock"><a href=#lock>Toggle Lock</a></li>
<li class=new><a href=#new>Toggle New</a></li>
}
if {[llength $plugins(menu)]} {
@ -57,8 +57,8 @@ puts {
<li class=cut><a href=#cut>Cut to clipboard</a></li>
<li class=pwcopy><a href=#copy>Copy to clipboard</a></li>
<li class=separator><a href=#rename>Rename</a></li>
<li><a href=#download>Download</a></li>
<li class="separator rename"><a href=#rename>Rename</a></li>
<li class="download"><a href=#download>Download</a></li>
}
if {[llength $plugins(omenu)]} {
foreach plugin $plugins(omenu) {
@ -83,10 +83,10 @@ puts {
<li class=cut><a href=#cut>Cut to clipboard</a></li>
<li class=pwcopy><a href=#copy>Copy to clipboard</a></li>
<li class=pwpaste><a href=#paste>Paste to folder</a></li>
<li class=separator><a href=#rename>Rename</a></li>
<li class="separator rename"><a href=#rename>Rename</a></li>
<li class=separator><a href=#resetnew>Reset new flag</a></li>
<li class="separator compress"><a href=#shrink>Auto-Shrink</a></li>
<li class="compressr"><a href=#shrinkr>Recursive Auto-Shrink</a></li>
<li class=compressr><a href=#shrinkr>Recursive Auto-Shrink</a></li>
<li class=dedup><a href=#dedup>Auto-Dedup</a></li>
}
if {$model eq "HDR"} {

View File

@ -68,6 +68,13 @@ div.container .middle
height: 116px;
}
div.container .usb
{
position: absolute;
left: -5px;
top: 8px;
}
div.footer
{
clear: both;
@ -373,6 +380,7 @@ div.cut
div.toolbarouter
{
position: relative;
z-index: 29;
}
div.toolbar
@ -522,3 +530,17 @@ span.foldernum
top: -10px !important;
}
#usbejectinfo
{
position: relative;
border: 1px solid #899caa;
box-shadow: 2px 2px 11px #666;
-moz-box-shadow: 2px 2px 11px #666;
-webkit-box-shadow: 2px 2px 11px #666;
border-radius: 5px;
-moz-border-radius: 5px;
background: #d2e0ea;
padding: 6px;
z-index: 40;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

BIN
webif/html/img/eject.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

BIN
webif/html/img/usb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

File diff suppressed because one or more lines are too long

4
webif/html/js/jquery-1.11.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
jquery-1.11.0.min.js
jquery-1.11.2.min.js

31
webif/html/js/toolbar.js Normal file
View File

@ -0,0 +1,31 @@
var tb_lastupd = 0;
if (window.location.pathname != '/' &&
window.location.pathname != '/index.jim')
{
var down = function() {
$('#toolbar').stop(true, true).delay(200).slideDown(400,
function() {
if (+new Date() - tb_lastupd > 5000)
{
tb_lastupd = +new Date();
$('#tbstatus')
.empty()
.html('<img src=/img/loading.gif> ' +
'Updating...')
.load('/cgi-bin/status.jim');
}
});
};
var up = function() {
$('#toolbar').stop(true, true).delay(200).slideUp();
};
$('#topbar, #toolbar').hover(down, up);
$('span.toolbarcell').hover(
function() {
$(this).addClass('tbhover');
}, function() {
$(this).removeClass('tbhover');
});
}

10
webif/html/js/topbar.js Normal file
View File

@ -0,0 +1,10 @@
$('#topbar').hover(
function() { $(this).css('cursor', 'pointer'); },
function() { $(this).css('cursor', 'auto'); }
);
$('#topbar a').on('click', function(e) {
e.stopPropagation();
});

83
webif/html/js/usbeject.js Normal file
View File

@ -0,0 +1,83 @@
String.prototype.capitalise = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
var usbeject_lastupd = 0;
var usbeject_visible = 0;
$('#usbeject').on('click', function(e) {
e.stopPropagation();
if (usbeject_visible)
{
$('#usbejectinfo').slideUp();
usbeject_visible = 0;
return;
}
if (+new Date() - usbeject_lastupd <= 5000)
{
$('#usbejectinfo').slideDown();
usbeject_visible = 1;
return;
}
usbeject_lastupd = +new Date();
$('#usbejecttab tbody').empty();
$('#usbejectout').html('<img src=/img/loading.gif> ' +
'<span class=blood>Scanning media...</span>');
usbeject_visible = 1;
$('#usbejectinfo').slideDown();
$.getJSON('/cgi-bin/usbinfo.jim', function(data) {
var num = 0;
$.each(data, function(k,v) {
num++;
var size = (v.SIZE / 1000000000).toFixed(1);
var type = v.TYPE;
var drive = v.MP.split(/[/]/).pop().capitalise();
switch (type)
{
case 'vfat':
type = 'FAT';
case 'Unknown':
break;
default:
type = type.toUpperCase();
}
$('#usbejecttab').append(
'<tr><td><img class=va height=20 ' +
'src=/img/usb.png></td>' +
'<td class=usblabel>' + v.LABEL + '</td>' +
'<td class=blood>(' + drive + '&nbsp;-&nbsp;' +
type + '&nbsp;' + '&nbsp;-&nbsp;' +
size + 'GB)</td>' +
'<td><img class="va eject" border=0 height=20' +
' drive=' + v.MP +
' label="' + v.LABEL + '"' +
' src=/img/media-eject.png></td>' +
'</tr>');
});
$('#usbejectout').empty();
if (!num)
$('#usbejectout').html('No removable drives found.');
});
}).on('click', 'img.eject', function(e) {
e.stopPropagation();
var btn = $(this);
var drive = btn.attr('drive');
var label = btn.attr('label');
if (!confirm('Eject ' + label + '?'))
return;
$('#usbejectout').html('<img src=/img/loading.gif> ' +
'<span class=blood>Ejecting ' + label + '</span>');
$.getJSON('/cgi-bin/usbeject.jim', {
label: label,
drive: drive
}, function(data) {
$('#usbejectout').html(data.result);
if (data.status)
// Success
btn.closest('tr').slideUp('slow', function() {
$(this).remove();
});
});
});

View File

@ -1,5 +1,8 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class
puts {
<!doctype html>
<html>

View File

@ -19,4 +19,8 @@
.context-menu-item.icon-clock { background-image: url(/img/context/clock.png); }
.context-menu-item.icon-thm { background-image: url(/img/context/thumb.png); }
.context-menu-item.icon-bookmark { background-image: url(/img/context/bookmark.png); }
.context-menu-item.icon-lock { background-image: url(/img/context/lock.png); }
.context-menu-item.icon-download { background-image: url(/img/context/download.png); }
.context-menu-item.icon-rename { background-image: url(/img/context/rename.png); }
.context-menu-item.icon-new { background-image: url(/img/context/new.png); }

View File

@ -74,5 +74,9 @@
.contextMenu LI.clock A { background-image: url(/img/context/clock.png); }
.contextMenu LI.thm A { background-image: url(/img/context/thumb.png); }
.contextMenu LI.bookmark A { background-image: url(/img/context/bookmark.png); }
.contextMenu LI.lock A { background-image: url(/img/context/lock.png); }
.contextMenu LI.rename A { background-image: url(/img/context/rename.png); }
.contextMenu LI.download A { background-image: url(/img/context/download.png); }
.contextMenu LI.new A { background-image: url(/img/context/new.png); }

View File

@ -8,7 +8,6 @@ puts {
<div class=middle>
<!-- Start include diskspace - above other items to work around IE feature.. -->
}
#source /mod/webif/include/diskspace.jim
source /mod/webif/html/diskspace/diskspace.jim
puts {
<!-- End include diskspace -->
@ -22,19 +21,16 @@ puts {
</span>
</div>
<div class=right><img src=/images/154_1_00_WIN_MD116_3R.png></div>
}
if {[system model] eq "HDR" && [system usbmounts] > 0} {
source /mod/webif/include/usbeject.jim
}
puts {
</div>
}
source /mod/webif/include/toolbar.jim
puts {
<script type=text/javascript>
$('#topbar').hover(
function() { $(this).css('cursor', 'pointer'); },
function() { $(this).css('cursor', 'auto'); }
);
$('#topbar a').on('click', function(e) {
e.stopPropagation();
});
</script>
<script type=text/javascript src=/js/topbar.js></script>
<!-- end of topbar -->
}

View File

@ -239,6 +239,7 @@ puts {
<button onclick="window.location='/backup/index.jim';">
Backup/Restore Scheduled Recordings/Events
</button>
</small>
}
if {$ended} {

View File

@ -1,7 +1,3 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class
puts "Humax [system model] Fox T2 ([system hostname])"

View File

@ -1,6 +1,5 @@
#!/mod/bin/jimsh
source /mod/webif/lib/setup
require settings.class
if {[[settings] notoolbar] eq "0"} {
@ -52,39 +51,7 @@ puts {
</div>
</div>
<script type=text/javascript>
var lastupd = 0;
if (window.location.pathname != '/' &&
window.location.pathname != '/index.jim')
{
var down = function() {
$('#toolbar').stop(true, true).delay(200).slideDown(400,
function() {
if (+new Date() - lastupd > 5000)
{
lastupd = +new Date();
$('#tbstatus')
.empty()
.html('<img src=/img/loading.gif> ' +
'Updating...')
.load('/cgi-bin/status.jim');
}
});
};
var up = function() {
$('#toolbar').stop(true, true).delay(200).slideUp();
};
$('#topbar, #toolbar').hover(down, up);
}
$('span.toolbarcell').hover(
function() {
$(this).addClass('tbhover');
}, function() {
$(this).removeClass('tbhover');
});
</script>
<script type=text/javascript src=/js/toolbar.js> </script>
<!-- end of toolbar -->

15
webif/include/usbeject.jim Executable file
View File

@ -0,0 +1,15 @@
#!/mod/bin/jimsh
puts {
<div id=usbeject class=usb>
<img height=25 src=/img/eject.png>
<div id=usbejectinfo class=hidden>
<table id=usbejecttab></table>
<div id=usbejectout>
...
</div>
</div>
</div>
<script type=text/javascript src=/js/usbeject.js></script>
}

View File

@ -5,7 +5,8 @@ if {![exists -proc binary]} { package require binary }
class system {}
proc {system model} {} {
proc {system model} {} {{model ""}} {
if {$model ne ""} { return $model }
if {[catch {set fp [open /etc/model r]}]} {
set model {HD[R]}
} else {
@ -32,29 +33,32 @@ proc {system ip} {} {
return $ip
}
proc {system modversion} {{short 0}} {
if {[catch {set fp [open /etc/modversion r]}]} {
set modver "102"
} else {
set modver [string trim [read $fp]]
close $fp
proc {system modversion} {{short 0}} {{modver ""}} {
if {$modver eq ""} {
if {[catch {set fp [open /etc/modversion r]}]} {
set modver "102"
} else {
set modver [string trim [read $fp]]
close $fp
}
}
if {$short} { return $modver }
lassign [split $modver ""] a b c
return [format "%d.%d%d" $a $b $c]
}
proc {system modbuild} {} {
proc {system modbuild} {} {{modbuild ""}} {
if {$modbuild ne ""} { return $modbuild }
if {[catch {set fp [open /etc/modbuild r]}]} {
return 0
set modbuild 0
} else {
set modbuild [string trim [read $fp]]
close $fp
}
return $modbuild
}
proc {system fhtcpversion} {} {
proc {system fhtcpversion} {} {{ver ""}} {
if {$ver ne ""} { return $ver }
set file "/etc/fhtcpversion"
if {![file exists $file]} { set file "/root/fhtcpversion" }
if {[catch {set fp [open $file r]}]} {
@ -68,20 +72,23 @@ proc {system fhtcpversion} {} {
# 822272+6 - MAC address
# 833536 - Serial number
proc {system serialno} {} {
proc {system serialno} {} {{serial ""}} {
if {$serial ne ""} { return $serial }
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] [
set serial "[string range $bytes 0 1] [string range $bytes 2 8] [
string range $bytes 9 end]"
return $serial
}
proc {system kernelver} {} {
proc {system kernelver} {} {{ver ""}} {
if {$ver ne ""} { return $ver }
#1 SMP Sun Mar 25 18:30:38 KST 2012
set ver [string range [exec uname -v] 11 end]
return [switch $ver {
set rver [string range [exec uname -v] 11 end]
set ver [switch $rver {
# HDR
"Sep 16 20:17:56 KST 2010" { format "HDR_1.01.05" }
"Oct 11 21:11:05 KST 2010" { format "HDR_1.01.09" }
@ -108,6 +115,7 @@ proc {system kernelver} {} {
default { format "Unknown - $ver" }
}]
return $ver
}
proc {system pkgver} {{pkg webif}} {
@ -118,30 +126,6 @@ proc {system pkginst} {pkg} {
return [file exists "/mod/var/opkg/info/$pkg.control"]
}
#proc {system pkginst} {pkg} {{cache {}} {ncache {}}} {
# if {$pkg in $cache} { return 1 }
# if {$pkg in $ncache} { return 0 }
#
# # It may not be possible to get an opkg lock immediately so
# # try several times and throw an error if not.
# set status unknown
# loop i 0 5 {
# if {[catch {set status [exec opkg list-installed $pkg]}]} {
# sleep 1
# } else break
# }
# if {$status eq "unknown"} {
# error "Could not get opkg lock after 5 seconds."
# }
#
# if {$status ne ""} {
# lappend cache $pkg
# return 1
# }
# lappend ncache $pkg
# return 0
#}
proc {system mediaroot} {} {
switch [system model] {
HDR { return "/media/My Video" }
@ -408,3 +392,51 @@ proc {system strip} {str} {
return $str
}
proc {system usbmounts} {{full 0}} {
if {!$full} {
set num 0
catch {
set num [
exec grep -cE {/media/(usb-)?drive} /proc/mounts]
}
return $num
}
set ret {}
if {[catch {
set lines [exec grep -E {media/(usb-)?drive} /proc/mounts]
}]} { return $ret }
foreach line [split $lines "\n"] {
lassign $line dev mp
set rec "DEV $dev MP $mp LABEL {NO NAME} TYPE Unknown"
lassign [exec stat -f -c {%b %S} $mp] blockc blocks
set rec(SIZE) $($blockc * $blocks)
# /dev/sda1: LABEL="SAN" UUID="DBC1-1CF8" TYPE="vfat"
catch {
foreach field [
split [exec /mod/sbin/blkid -c /dev/null $dev] "\n"] {
while {[regexp { *([A-Z]+)="?([^"]+)"?(.*)} \
$field x k v field]} {
set rec($k) $v
}
}
}
# Test for EXFAT
if {$rec(TYPE) eq "Unknown" && [
file exists /mod/sbin/exfatlabel]} {
catch {
set label [exec /mod/sbin/exfatlabel $dev 2>/dev/null]
if {$label ne ""} {
set rec(TYPE) "EXFAT"
set rec(LABEL) $label
}
}
}
lappend ret $rec
}
return $ret
}