2011-06-09 21:16:30 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
source /mod/var/mongoose/lib/settings.class
|
2011-06-09 21:16:30 +00:00
|
|
|
package require cgi
|
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
set settings [settings new]
|
2011-06-09 21:16:30 +00:00
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
set hostname [$settings hostname]
|
2011-06-16 23:49:48 +00:00
|
|
|
set smtp_server [$settings smtp_server]
|
2011-06-14 11:48:55 +00:00
|
|
|
set channel_group [$settings channel_group]
|
2011-06-09 21:16:30 +00:00
|
|
|
|
|
|
|
# Handle updates
|
|
|
|
|
2011-06-16 23:49:48 +00:00
|
|
|
#set _cgi(smtp_server) "fred.bob"
|
|
|
|
#set env(REQUEST_URI) ''
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
proc _handle_update {class var old text} {
|
|
|
|
global _cgi
|
|
|
|
global settings
|
|
|
|
|
|
|
|
if {[dict exists $_cgi $var]} {
|
|
|
|
set new [string trim [dict get $_cgi $var]]
|
|
|
|
if {$new == $old} {
|
|
|
|
puts "$text unchanged."
|
|
|
|
} elseif [string is $class -strict $new] {
|
|
|
|
$settings $var $new
|
|
|
|
puts "$text updated."
|
|
|
|
} else {
|
|
|
|
puts "Invalid value for $var."
|
|
|
|
}
|
|
|
|
exit
|
2011-06-09 21:16:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
proc handle_int_update {var old {text "Value"}} {
|
|
|
|
_handle_update digit $var $old $text
|
|
|
|
}
|
|
|
|
|
|
|
|
proc handle_str_update {var old {text "Value"}} {
|
|
|
|
_handle_update alnum $var $old $text
|
|
|
|
}
|
|
|
|
|
|
|
|
handle_str_update hostname $hostname Hostname
|
2011-06-16 23:49:48 +00:00
|
|
|
_handle_update ascii smtp_server $smtp_server "SMTP Server"
|
2011-06-14 11:48:55 +00:00
|
|
|
handle_int_update channel_group $channel_group "Channel Group"
|
|
|
|
|
2011-06-09 21:16:30 +00:00
|
|
|
source /mod/var/mongoose/html/lib/header.jim
|
|
|
|
puts {<script type="text/javascript" src="/js/jquery.form.js"></script>}
|
|
|
|
|
|
|
|
puts {
|
|
|
|
<script type=text/javascript>
|
|
|
|
$(document).ready(function () {
|
2011-06-16 23:49:48 +00:00
|
|
|
//$(":submit").button();
|
|
|
|
//$(":submit").height(20);
|
2011-06-09 21:16:30 +00:00
|
|
|
$('form').each(function(i, el) {
|
|
|
|
var id = $(this).attr('id');
|
|
|
|
var output = '#' + id + '_output'
|
|
|
|
$(this).ajaxForm({
|
|
|
|
target: output,
|
|
|
|
success: function() {
|
|
|
|
$(output).css('font-style', 'italic');
|
|
|
|
$(output).show('slow');
|
|
|
|
$(output).delay(2000).fadeOut('slow');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
}
|
|
|
|
|
|
|
|
puts "
|
|
|
|
<h1>Settings</h1>
|
|
|
|
<table class=keyval>
|
|
|
|
<tr>
|
2011-06-14 11:48:55 +00:00
|
|
|
<form id=hostname method=get action=$env(REQUEST_URI)>
|
2011-06-09 21:16:30 +00:00
|
|
|
<th>Hostname</th>
|
|
|
|
<td><input name=hostname value=\"$hostname\"
|
|
|
|
length=20 maxlength=50>
|
|
|
|
<input id=hostname_submit value=\"change\" type=submit>
|
|
|
|
<div id=hostname_output></div>
|
|
|
|
</td>
|
2011-06-14 11:48:55 +00:00
|
|
|
</form>
|
|
|
|
</tr>
|
|
|
|
"
|
|
|
|
|
2011-06-16 23:49:48 +00:00
|
|
|
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>
|
|
|
|
"
|
|
|
|
|
2011-06-14 11:48:55 +00:00
|
|
|
puts "
|
|
|
|
<tr>
|
|
|
|
<form id=channel_group method=get action=$env(REQUEST_URI)>
|
|
|
|
<th>Channel Group for EPG</th>
|
|
|
|
<td><select id=channel_group name=channel_group
|
|
|
|
value=[$settings channel_group]>
|
|
|
|
"
|
|
|
|
|
|
|
|
set i 0
|
|
|
|
puts "<option value=0>-- None --"
|
|
|
|
foreach grp [$settings channel_groups] {
|
|
|
|
incr i
|
|
|
|
puts -nonewline "<option value=$i"
|
|
|
|
if {$channel_group == $i} {
|
|
|
|
puts -nonewline " selected"
|
|
|
|
}
|
|
|
|
puts ">$grp"
|
|
|
|
}
|
|
|
|
|
|
|
|
puts "
|
|
|
|
</select>
|
|
|
|
<input name=channel_group value=\"change\" type=submit>
|
|
|
|
<div id=channel_group_output></div>
|
|
|
|
</td>
|
|
|
|
</form>
|
2011-06-09 21:16:30 +00:00
|
|
|
</tr>
|
2011-06-14 11:48:55 +00:00
|
|
|
"
|
|
|
|
|
|
|
|
puts "
|
2011-06-09 21:16:30 +00:00
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<br>
|
|
|
|
More coming soon...
|
|
|
|
<br>
|
|
|
|
<br>
|
|
|
|
"
|
|
|
|
source /mod/var/mongoose/html/lib/footer.jim
|
|
|
|
|