only show transmission/mediatomb icons if running, fix pkgdev toggle

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@681 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2012-01-21 01:27:06 +00:00
parent 8ec03f2636
commit 572e31efcc
6 changed files with 56 additions and 22 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.8.13
Version: 0.8.13-1
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-7),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.5),jim-oo,jim-pack,service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.4),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2

View File

@ -64,9 +64,6 @@ handle_str_update hostname $hostname Hostname
_handle_update ascii smtp_server $smtp_server "SMTP Server"
handle_int_update channel_group $channel_group "Channel Group"
handle_str_update epg_style $epg_style "EPG Type"
if {[dict exists $_cgi pkgdevoff] && ![dict exists $_cgi pkgdev]} {
set _cgi(pkgdev) 0
}
handle_int_update pkgdev $pkgdev "Development Package Display"
set acluser [cgi_get acluser "-"]
@ -318,34 +315,21 @@ $('button.pwchange').click(function(el) {
</script>
}
puts "
puts -nonewline "
<br><br>
<fieldset style=\"display: inline\">
<legend> Advanced Settings </legend>
<table>
"
puts "
<tr>
<form class=auto id=pkgdev method=get action=$env(REQUEST_URI)>
<th class=key>Show development and advanced packages?</th>
<td><input name=pkgdevoff value=0 type=hidden>
<input name=pkgdev id=pkgdev value=1 type=checkbox
<td><input name=pkgdev id=pkgdev value=1 type=checkbox
"
if {$pkgdev} { puts " checked" }
puts {
>
<small>
<input id=pkgdev_submit value="save" type=submit>
</small>
<div id=pkgdev_output></div>
if {$pkgdev} { puts -nonewline " checked" }
puts ">
</td>
</form>
</tr>
}
puts "
</table>
<div id=pkgdev_output></div>
</fieldset>
"

View File

@ -35,6 +35,25 @@ $(document).ready(function () {
});
});
$('#pkgdev').change(function() {
var arg = '0';
if ($(this).attr('checked'))
arg = '1';
$(this).disable();
$('#pkgdev_output')
.empty()
.show('slow')
.load('/cgi-bin/settings.jim?pkgdev=' + arg,
function() {
$('#pkgdev').enable();
$('#pkgdev_output')
.css('font-style', 'italic')
.delay(2000).fadeOut('slow');
});
});
$('#https_toggle').change(function() {
var arg = 'off';
if ($(this).attr('checked'))

View File

@ -1,5 +1,8 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require system.class
if { [catch {set fd [open "/mod/mediatomb/config/mediatomb.html" r]} fid] } {
exit 0
}
@ -8,6 +11,10 @@ close $fd
regexp {URL=([^"]*)} $data match
set url [string range $match 4 [string length $match]]
set port [string range [lindex [split $url ":"] 2] 0 end-1]
if {![system is_listening $port]} { exit 0 }
puts "
<div style=\"float: left; padding-top: 5em\">
<center>

View File

@ -1,6 +1,10 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require system.class
if {![file exists /mod/sbin/transmission-daemon]} { exit 0 }
if {![system is_listening 9091]} { exit 0 }
set url "/cgi-bin/transmission.jim"

View File

@ -130,3 +130,23 @@ proc {system mkdir_p} {dir} {
exec /mod/bin/busybox/mkdir -p $dir
}
proc {system listening} {{mport 0}} {
set ret {}
foreach line [split [exec /mod/bin/busybox/netstat -lntpw] "\n"] {
# Remove repeated spaces
regsub -all -- {[[:space:]]+} $line " " line
# tcp 0 0 0.0.0.0:9955 0.0.0.0:* LISTEN 169/humaxtv
lassign [split $line " "] x x x port x type app
if {$type ne "LISTEN"} { continue }
lassign [split $port ":"] x port
if {$mport && $mport != $port} { continue }
lappend ret [list $port [split $app "/"]]
}
return $ret
}
proc {system is_listening} {mport} {
return [llength [system listening $mport]]
}