implement delete action + menu item greying out and correct lock/unlock labels. Also add SMTP server settings
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif@180 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
5dccb7cbbf
commit
700306b3a8
@ -6,20 +6,20 @@ source /mod/var/mongoose/lib/ts.class
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
set ignore {nts thm hmt hmi}
|
||||
set standard {avi mpg wmv mkv}
|
||||
set ignore {.nts .thm .hmt .hmi}
|
||||
set standard {.avi .mpg .wmv .mkv}
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
#set _cgi(tsfile) "/media/My Video/Family Guy/2.19._Excellence_in_Broadcasting.ts"
|
||||
#set _cgi(action) "lock"
|
||||
#set _cgi(action) "delete"
|
||||
#set env(REQUEST_URI) ''
|
||||
|
||||
proc tsfile {file bfile} {{i 0}} {
|
||||
proc tsfile {file bfile {ajax 0}} {{i 0}} {
|
||||
set ts [ts fetch $file]
|
||||
if {$ajax == 0} { puts "<div class=\"va tsfile\" id=[incr i]>" }
|
||||
puts "
|
||||
<div class=\"va tsfile\" id=[incr i]>
|
||||
<a class=ts file=\"$file\" href=#>
|
||||
<img class=va border=0 width=45
|
||||
src=/images/741_1_10_Video_Title.png>
|
||||
@ -31,20 +31,21 @@ proc tsfile {file bfile} {{i 0}} {
|
||||
} else {
|
||||
puts "<img class=va src=/images/172_1_26_SD.png height=21>"
|
||||
}
|
||||
set locked 0
|
||||
if {[$ts flag "Locked"] > 0} {
|
||||
set locked 1
|
||||
puts "<img class=va src=/images/178_1_00_Icon_Lock.png
|
||||
height=21>"
|
||||
|
||||
}
|
||||
|
||||
puts "
|
||||
<a class=tsopt file=\"$file\" href=#>
|
||||
<img class=\"opt va\" border=0 width=45 did=$i
|
||||
<img class=\"opt va\" border=0 width=45 did=$i locked=$locked
|
||||
src=/images/181_1_00_Help5_OPT_Plus.png>
|
||||
</a>
|
||||
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>
|
||||
</div>
|
||||
"
|
||||
if {$ajax == 0} { puts "</div>" }
|
||||
}
|
||||
|
||||
proc genfile {file bfile} {
|
||||
@ -66,7 +67,7 @@ proc directory {file bfile} {
|
||||
puts "$bfile</a></div>"
|
||||
}
|
||||
|
||||
proc entry {file} {
|
||||
proc entry {file {ajax 0}} {
|
||||
set bfile [lindex [split $file /] end]
|
||||
if {[string index $bfile 0] == "\025"} {
|
||||
set bfile [string range $bfile 1 end]
|
||||
@ -75,9 +76,9 @@ proc entry {file} {
|
||||
directory $file $bfile
|
||||
continue
|
||||
}
|
||||
regexp -- {\.([^.]+)$} "$file" allmatch ext
|
||||
if {$ext eq "ts"} {
|
||||
tsfile $file $bfile
|
||||
set ext [file extension $file]
|
||||
if {$ext eq ".ts"} {
|
||||
tsfile $file $bfile $ajax
|
||||
continue
|
||||
}
|
||||
if {$ext in $::ignore} { continue }
|
||||
@ -94,7 +95,7 @@ if {[dict exists $_cgi tsfile]} {
|
||||
if {[dict exists $_cgi action]} {
|
||||
switch [dict get $_cgi action] {
|
||||
entry {
|
||||
entry $file
|
||||
entry $file 1
|
||||
}
|
||||
delete {
|
||||
if {[$ts delete]} {
|
||||
@ -190,6 +191,48 @@ puts {
|
||||
<div id=confirm title="Confirmation Required"></div>
|
||||
|
||||
<script type=text/javascript>
|
||||
function bindmenu(selector)
|
||||
{
|
||||
$(selector).contextMenu(
|
||||
{
|
||||
menu: 'optmenu',
|
||||
leftButton: true,
|
||||
beforeShow:
|
||||
function(el, menu)
|
||||
{
|
||||
if (el.attr('locked') == 1)
|
||||
{
|
||||
$(menu).changeContextMenuItem('#lock', 'Unlock');
|
||||
$('#optmenu').disableContextMenuItems('#delete');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(menu).changeContextMenuItem('#lock', 'Lock');
|
||||
$('#optmenu').enableContextMenuItems('#delete');
|
||||
}
|
||||
}
|
||||
},
|
||||
function (action, el, pos)
|
||||
{
|
||||
var ts = $(el).parent().prevAll('a.ts').last().attr('file');
|
||||
var did = $(el).attr('did');
|
||||
switch (action)
|
||||
{
|
||||
case 'delete':
|
||||
confirm_action('delete', delete_callback, ts, did);
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
confirm_action('change the lock on', lock_callback, ts, did);
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Unhandled action: ' + action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var $confirm = $('#confirm').dialog({
|
||||
modal: true, autoOpen: false,
|
||||
@ -234,7 +277,9 @@ puts {
|
||||
$(results).load(url + 'lock', function() {
|
||||
$(results).delay(3000).slideUp(150,
|
||||
function() {
|
||||
$(el).load(url + 'entry');
|
||||
$(el).load(url + 'entry', function() {
|
||||
bindmenu(el + ' img.opt');
|
||||
});;
|
||||
}
|
||||
);
|
||||
});
|
||||
@ -255,6 +300,9 @@ puts {
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#optmenu').disableContextMenuItems('#rename,#title');
|
||||
bindmenu('img.opt');
|
||||
|
||||
$('a.ts').click(function(e) {
|
||||
e.preventDefault();
|
||||
var file = $(this).attr('file');
|
||||
@ -264,31 +312,6 @@ puts {
|
||||
$dialog.dialog('open');
|
||||
});
|
||||
|
||||
$('img.opt').contextMenu(
|
||||
{
|
||||
menu: 'optmenu',
|
||||
leftButton: true,
|
||||
},
|
||||
function (action, el, pos)
|
||||
{
|
||||
var ts = $(el).parent().prevAll('a.ts').last().attr('file');
|
||||
var did = $(el).attr('did');
|
||||
switch (action)
|
||||
{
|
||||
case 'delete':
|
||||
confirm_action('delete', delete_callback, ts, did);
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
confirm_action('change the lock on', lock_callback, ts, did);
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Unhandled action: ' + action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
@ -12,10 +12,14 @@ cgi_input
|
||||
set settings [settings new]
|
||||
|
||||
set hostname [$settings hostname]
|
||||
set smtp_server [$settings smtp_server]
|
||||
set channel_group [$settings channel_group]
|
||||
|
||||
# Handle updates
|
||||
|
||||
#set _cgi(smtp_server) "fred.bob"
|
||||
#set env(REQUEST_URI) ''
|
||||
|
||||
proc _handle_update {class var old text} {
|
||||
global _cgi
|
||||
global settings
|
||||
@ -43,6 +47,7 @@ proc handle_str_update {var old {text "Value"}} {
|
||||
}
|
||||
|
||||
handle_str_update hostname $hostname Hostname
|
||||
_handle_update ascii smtp_server $smtp_server "SMTP Server"
|
||||
handle_int_update channel_group $channel_group "Channel Group"
|
||||
|
||||
source /mod/var/mongoose/html/lib/header.jim
|
||||
@ -51,7 +56,8 @@ puts {<script type="text/javascript" src="/js/jquery.form.js"></script>}
|
||||
puts {
|
||||
<script type=text/javascript>
|
||||
$(document).ready(function () {
|
||||
$(":submit").button();
|
||||
//$(":submit").button();
|
||||
//$(":submit").height(20);
|
||||
$('form').each(function(i, el) {
|
||||
var id = $(this).attr('id');
|
||||
var output = '#' + id + '_output'
|
||||
@ -83,6 +89,19 @@ puts "
|
||||
</tr>
|
||||
"
|
||||
|
||||
puts "
|
||||
<tr>
|
||||
<form id=smtp_server method=get action=$env(REQUEST_URI)>
|
||||
<th>SMTP Server for outbound email</th>
|
||||
<td><input name=smtp_server value=\"$smtp_server\"
|
||||
length=20 maxlength=50>
|
||||
<input id=smtp_server_submit value=\"change\" type=submit>
|
||||
<div id=smtp_server_output></div>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
"
|
||||
|
||||
puts "
|
||||
<tr>
|
||||
<form id=channel_group method=get action=$env(REQUEST_URI)>
|
||||
|
@ -13,8 +13,9 @@
|
||||
// (C)2008 by Cory S.N. LaViska.
|
||||
//
|
||||
// For details, visit http://creativecommons.org/licenses/by/3.0/us/
|
||||
//
|
||||
// Modified 11NOV08 By Bill Beckelman to include option to use left mouse button instead.
|
||||
|
||||
// Modified by Andy Fiddaman to support left click and
|
||||
// support modification of menu items.
|
||||
|
||||
if (jQuery) (function() {
|
||||
$.extend($.fn, {
|
||||
@ -25,6 +26,7 @@ if (jQuery) (function() {
|
||||
if (o.inSpeed == undefined) o.inSpeed = 150;
|
||||
if (o.outSpeed == undefined) o.outSpeed = 75;
|
||||
if (o.leftButton == undefined) o.leftButton = false;
|
||||
if (o.beforeShow == undefined) o.beforeShow = false;
|
||||
// 0 needs to be -1 for expected results (no fade)
|
||||
if (o.inSpeed == 0) o.inSpeed = -1;
|
||||
if (o.outSpeed == 0) o.outSpeed = -1;
|
||||
@ -34,8 +36,8 @@ if (jQuery) (function() {
|
||||
var offset = $(el).offset();
|
||||
// Add contextMenu class
|
||||
$('#' + o.menu).addClass('contextMenu');
|
||||
if (o.leftButton) $(this).bind('click', false);
|
||||
// Simulate a true right click
|
||||
$(this).bind('click', false);
|
||||
$(this).mousedown(function(e) {
|
||||
var evt = e;
|
||||
$(this).mouseup(function(e) {
|
||||
@ -49,6 +51,8 @@ if (jQuery) (function() {
|
||||
|
||||
if ($(el).hasClass('disabled')) return false;
|
||||
|
||||
if (o.beforeShow) o.beforeShow(el, menu);
|
||||
|
||||
// Detect mouse position
|
||||
var d = {}, x, y;
|
||||
if (self.innerHeight) {
|
||||
@ -185,6 +189,15 @@ if (jQuery) (function() {
|
||||
return ($(this));
|
||||
},
|
||||
|
||||
// Change context menu text on the fly
|
||||
changeContextMenuItem: function(d, t) {
|
||||
if (d == undefined) return;
|
||||
$(this).each(function() {
|
||||
$(this).find('A[href="' + d + '"]').text(t);
|
||||
});
|
||||
return ($(this));
|
||||
},
|
||||
|
||||
// Disable context menu(s)
|
||||
disableContextMenu: function() {
|
||||
$(this).each(function() {
|
||||
|
@ -7,6 +7,7 @@ set settingsdb [sqlite3.open /mod/etc/webif.db]
|
||||
class settings {
|
||||
hostname ""
|
||||
channel_group 0
|
||||
smtp_server ""
|
||||
}
|
||||
|
||||
settings method hostname {{name ""}} {
|
||||
@ -30,6 +31,34 @@ settings method hostname {{name ""}} {
|
||||
}
|
||||
}
|
||||
|
||||
settings method smtp_server {{server ""}} {
|
||||
if {$server == ""} {
|
||||
# Get
|
||||
if {[catch {set fd [open "/mod/etc/ssmtp/ssmtp.conf" r]}]} {
|
||||
set server "mail"
|
||||
} else {
|
||||
foreach line [split [read $fd] "\n"] {
|
||||
set a [string first "mailhub=" $line]
|
||||
if {$a == 0} {
|
||||
set server [string range $line 8 end]
|
||||
set server [string trim $server]
|
||||
}
|
||||
}
|
||||
close $fd
|
||||
}
|
||||
return $server
|
||||
} else {
|
||||
# Set
|
||||
if {[string is ascii -strict $server]} {
|
||||
set fd [open "/mod/etc/ssmtp/ssmtp.conf" w]
|
||||
puts $fd "mailhub=$server"
|
||||
puts $fd "rewriteDomain=hummypkg.org.uk"
|
||||
puts $fd "hostname=[$self hostname].hummypkg.org.uk"
|
||||
close $fd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
settings method _nval_setting {name {val -1}} {
|
||||
global settingsdb;
|
||||
|
||||
|
@ -3,6 +3,7 @@ if {[expr ! [exists -proc class ]]} { package require oo }
|
||||
|
||||
class ts {
|
||||
file ""
|
||||
base ""
|
||||
title ""
|
||||
synopsis ""
|
||||
definition ""
|
||||
@ -82,6 +83,11 @@ proc {ts fetch} {file} {
|
||||
}
|
||||
|
||||
ts method delete {} {
|
||||
# Extract file basename
|
||||
foreach f [glob -nocomplain "[file rootname $file].*"] {
|
||||
puts "Removed $f<br>"
|
||||
file delete $f
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user