improve diagnostics and file editor

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@755 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2012-02-22 19:09:46 +00:00
parent aadac18796
commit 973a7cdacf
47 changed files with 595 additions and 214 deletions

View File

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

View File

@ -40,6 +40,14 @@ if {$url eq ""} {
exit
}
if {![system is_listening 9000]} {
puts "The Humax media server is not running, cannot decrypt."
puts "Have you enabled <i>Content Sharing</i> in the Humax menus?"
puts "It can sometimes turn itself off so it's worth double checking."
puts "If it is on then try turning sharing off and on again."
exit
}
puts "
<span class=hidden id=params

View File

@ -1,43 +0,0 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
puts "Content-Type: text/html"
puts ""
header
cgi_input
#cgi_dump
set file [cgi_get file "/tmp/hosts"]
puts "
<script type=text/javascript src=/js/enadis.js></script>
<script type=text/javascript src=/js/tabsupport.js></script>
<script type=text/javascript src=script.js></script>
<link rel=stylesheet href=style.css type=text/css />
<fieldset class=cleft>
<legend>File Editor</legend>
<div class=blood style=\"padding-bottom: 0.7em\">
Editing: <span id=filename>$file</span>
</div>
<textarea cols=80 rows=15 id=editor class=loading>
Loading file...
</textarea>
<br>
<button class=afterload id=revert>Revert</button>
<button class=afterload id=save>Save</button>
<div id=result class=\"blood hidden\"></div>
</fieldset>
<div class=cleft>
<button id=back>Back to diagnostics</button>
</div>
"
footer

View File

@ -1,24 +0,0 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require chunked
cgi_input
#cgi_dump
set file [cgi_get file "/tmp/hosts"]
if {$file eq "-"} { exit }
start_chunked
if {![file exists $file]} {
chunk ">>> File $file does not exist.\r\n"
} else {
set fp [open $file r]
chunk [read $fp]
close $fp
}
end_chunked

View File

@ -1,51 +0,0 @@
$(function() {
var file = $('#filename').text();
function loadfile()
{
$('button.afterload').disable();
$('#editor')
.addClass('loading')
.val('Loading file...');
$.get('get.jim?file=' + encodeURIComponent(file), function(data) {
$('#editor')
.removeClass('loading')
.val(data);
$('button.afterload').enable();
});
}
$('#save')
.button()
.click(function() {
$.post('put.jim', {
'file': file,
'data': $('#editor').val()
}, function(data) {
$('#result')
.html(data)
.slideDown('slow')
.delay(5000)
.slideUp('slow');
});
});
$('#revert')
.button()
.click(function() {
loadfile();
});
$('#back')
.button()
.click(function() {
window.location = '/diag.shtml';
});
$('#editor').tabsupport();
loadfile();
});

View File

@ -335,24 +335,5 @@ puts ">
eval_plugins settings
#puts {
#<br><br>
#<fieldset style="display: inline">
#<legend> Reset Custom Firmware </legend>
#<button id=cfwreset>
#Click to remove all packages and settings installed by the custom firmware.
#</button>
#</fieldset>
#<script type=text/javascript>
#$('#cfwreset').jConfirmAction({
# yesAnswer: "Delete"
#}, function(el) {
# $('html').html('Restart the Humax using the remote control.');
# $.get('/cgi-bin/cfwreset');
#});
#</script>
#
#}
footer

View File

@ -0,0 +1,91 @@
UL.jqueryFileTree {
font-family: Verdana, sans-serif;
font-size: 11px;
line-height: 18px;
padding: 0px;
margin: 0px;
}
UL.jqueryFileTree LI {
list-style: none;
padding: 0px;
padding-left: 20px;
margin: 0px;
white-space: nowrap;
}
UL.jqueryFileTree A {
color: #333;
text-decoration: none;
display: block;
padding: 0px 2px;
}
UL.jqueryFileTree A:hover {
background: #BDF;
}
/* Core Styles */
.jqueryFileTree LI.directory { background: url(/img/filetree/directory.png) left top no-repeat; }
.jqueryFileTree LI.expanded { background: url(/img/filetree/folder_open.png) left top no-repeat; }
.jqueryFileTree LI.file { background: url(/img/filetree/file.png) left top no-repeat; }
.jqueryFileTree LI.wait { background: url(/img/filetree/spinner.gif) left top no-repeat; }
/* File Extensions*/
.jqueryFileTree LI.ext_3gp { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_afp { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_afpa { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_asp { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_aspx { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_avi { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_bat { background: url(/img/filetree/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_bmp { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_c { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_cfm { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_cgi { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_com { background: url(/img/filetree/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_cpp { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_css { background: url(/img/filetree/css.png) left top no-repeat; }
.jqueryFileTree LI.ext_doc { background: url(/img/filetree/doc.png) left top no-repeat; }
.jqueryFileTree LI.ext_exe { background: url(/img/filetree/application.png) left top no-repeat; }
.jqueryFileTree LI.ext_gif { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_fla { background: url(/img/filetree/flash.png) left top no-repeat; }
.jqueryFileTree LI.ext_h { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_htm { background: url(/img/filetree/html.png) left top no-repeat; }
.jqueryFileTree LI.ext_html { background: url(/img/filetree/html.png) left top no-repeat; }
.jqueryFileTree LI.ext_jar { background: url(/img/filetree/java.png) left top no-repeat; }
.jqueryFileTree LI.ext_jpg { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_jpeg { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_js { background: url(/img/filetree/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_lasso { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_log { background: url(/img/filetree/txt.png) left top no-repeat; }
.jqueryFileTree LI.ext_m4p { background: url(/img/filetree/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_mov { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mp3 { background: url(/img/filetree/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_mp4 { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mpg { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_mpeg { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_ogg { background: url(/img/filetree/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_pcx { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_pdf { background: url(/img/filetree/pdf.png) left top no-repeat; }
.jqueryFileTree LI.ext_php { background: url(/img/filetree/php.png) left top no-repeat; }
.jqueryFileTree LI.ext_png { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_ppt { background: url(/img/filetree/ppt.png) left top no-repeat; }
.jqueryFileTree LI.ext_psd { background: url(/img/filetree/psd.png) left top no-repeat; }
.jqueryFileTree LI.ext_pl { background: url(/img/filetree/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_py { background: url(/img/filetree/script.png) left top no-repeat; }
.jqueryFileTree LI.ext_rb { background: url(/img/filetree/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rbx { background: url(/img/filetree/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rhtml { background: url(/img/filetree/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_rpm { background: url(/img/filetree/linux.png) left top no-repeat; }
.jqueryFileTree LI.ext_ruby { background: url(/img/filetree/ruby.png) left top no-repeat; }
.jqueryFileTree LI.ext_sql { background: url(/img/filetree/db.png) left top no-repeat; }
.jqueryFileTree LI.ext_swf { background: url(/img/filetree/flash.png) left top no-repeat; }
.jqueryFileTree LI.ext_tif { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_tiff { background: url(/img/filetree/picture.png) left top no-repeat; }
.jqueryFileTree LI.ext_txt { background: url(/img/filetree/txt.png) left top no-repeat; }
.jqueryFileTree LI.ext_vb { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_wav { background: url(/img/filetree/music.png) left top no-repeat; }
.jqueryFileTree LI.ext_wmv { background: url(/img/filetree/film.png) left top no-repeat; }
.jqueryFileTree LI.ext_xls { background: url(/img/filetree/xls.png) left top no-repeat; }
.jqueryFileTree LI.ext_xml { background: url(/img/filetree/code.png) left top no-repeat; }
.jqueryFileTree LI.ext_zip { background: url(/img/filetree/zip.png) left top no-repeat; }

View File

@ -1,61 +0,0 @@
<!--#include virtual="/lib/header.shtml" -->
<script type=text/javascript src=/js/enadis.js></script>
<fieldset class=cleft>
<legend>Diagnostics</legend>
Diagnostic:
<input name=seq id=seq autocorrect=off autocapitalize=off
value=general size=30 maxlength=50
class="text ui-widget-content ui-corner-all">
<button id=rundiag>Run Diagnostic</button>
</fieldset>
<fieldset class=cleft>
<legend>File Editor</legend>
File:
<input name=editfile id=editfile autocorrect=off autocapitalize=off
value='' size=30 maxlength=50
class="text ui-widget-content ui-corner-all">
<button id=runedit>Edit File</button>
</fieldset>
<fieldset class=cleft>
<legend>Log Files</legend>
<!--#exec cmd="/mod/var/mongoose/include/logfiles.jim" -->
</fieldset>
<div style="margin-top: 2em; display: none; float: left; clear: left"
id=results></div>
<script type=text/javascript>
$('#rundiag').button().click(function() {
$('#results')
.slideDown()
.text('\n\nRunning diagnostic, please wait...\n\n')
.load('/cgi-bin/diag.jim?diag=' +
encodeURIComponent($('#seq').val()), function() {
$('#results').wrapInner('<pre>');
});
});
$('#runedit').button().click(function() {
if ($('#editfile').val().length)
window.location = '/cgi-bin/edit/edit.jim?file=' +
encodeURIComponent($('#editfile').val());
});
$('a.log').click(function() {
$('#results')
.slideDown()
.text('\n\nLoading log, please wait...\n\n')
.load('/cgi-bin/cat.jim?file=' +
encodeURIComponent($(this).attr('file')), function() {
$('#results').wrapInner('<pre>');
});
});
</script>
<!--#include virtual="/lib/footer.shtml" -->

80
var/mongoose/html/diag/diag.jim Executable file
View File

@ -0,0 +1,80 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require pretty_size
puts "Content-Type: text/html"
puts ""
header
puts {
<script type=text/javascript src=/js/enadis.js></script>
<script type=text/javascript src=script.js></script>
<fieldset class=cleft>
<legend>Utilities</legend>
<table>
<tr>
<td>Run Diagnostic:</td>
<td><input name=seq id=seq autocorrect=off autocapitalize=off
value=general size=30 maxlength=50
class="text ui-widget-content ui-corner-all">
<button id=rundiag>Run Diagnostic</button>
</td>
</tr>
<tr>
<td>Package:</td>
<td><input name=fopkg id=fopkg autocorrect=off autocapitalize=off
value='' size=30 maxlength=50
class="text ui-widget-content ui-corner-all">
<button id=runfopkg>Force re-install</button>
</td>
</tr>
<tr>
<td colspan=2>
<button id=runedit style="width: 100%">File Editor</button>
</td>
</tr>
<tr>
<td colspan=2>
<button id=runreset style="width: 100%">
Remove all custom firmware packages and settings
</button>
<div class=footnote style="text-align: center">
(This option will return with firmware 1.18)
</div>
</td>
</tr>
</table>
</fieldset>
<fieldset class=left>
<legend>View Log Files</legend>
}
foreach file [lsort [concat \
[glob -nocomplain /var/log/*.log] \
[glob -nocomplain /mod/tmp/*.log] \
]] {
puts "<a href=# class=log file=\"$file\">
<img border=0 height=14 src=/images/421_1_00_CH_Title_2R_Arrow.png>
[file tail $file]</a> ([pretty_size [file size $file]]) <br>"
}
puts {
</fieldset>
<div style="margin-top: 2em; display: none; float: left; clear: left"
id=results></div>
}
footer

View File

@ -0,0 +1,45 @@
$(function() {
$('button').button();
$('#rundiag').click(function() {
$('#results')
.slideDown()
.text('\n\nRunning diagnostic, please wait...\n\n')
.load('rundiag.jim?diag=' +
encodeURIComponent($('#seq').val()), function() {
$('#results').wrapInner('<pre>');
});
});
$('#runfopkg').click(function() {
$('#results')
.slideDown()
.text('\n\nForcibly re-installing package, please wait...\n\n')
.load('/cgi-bin/opkg.jim?cmd=install+--force-reinstall+' +
encodeURIComponent($('#fopkg').val()), function() {
$('#results').wrapInner('<pre>');
$('#fopkg').val('');
});
});
$('a.log').click(function() {
$('#results')
.slideDown()
.text('\n\nLoading log, please wait...\n\n')
.load('/cgi-bin/cat.jim?file=' +
encodeURIComponent($(this).attr('file')), function() {
$('#results').wrapInner('<pre>');
});
});
$('#runedit').click(function(e) {
e.preventDefault();
window.location = '/edit/edit.jim';
});
$('#runreset').disable();
});

53
var/mongoose/html/edit/edit.jim Executable file
View File

@ -0,0 +1,53 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
puts "Content-Type: text/html"
puts ""
header
cgi_input
#cgi_dump
set file [cgi_get file "/tmp/hosts"]
puts {
<script type=text/javascript src=/js/enadis.js></script>
<script type=text/javascript src=/js/tabsupport.js></script>
<script type=text/javascript src=/js/jqueryFileTree.js></script>
<link rel=stylesheet type=text/css href=/css/jqueryFileTree.css />
<script type=text/javascript src=script.js></script>
<link rel=stylesheet href=style.css type=text/css />
<fieldset class=cleft>
<legend>File Editor</legend>
<div id=msg class=blood style="padding-bottom: 0.7em">
Use the <i>Open</i> button below to begin.
</div>
<textarea cols=80 rows=20 id=editor></textarea>
<br>
<button class=xeditactive id=open>Open</button>
<button class=editactive id=save>Save</button>
<button class=editactive id=revert>Revert</button>
<div id=result class="blood hidden" />
</fieldset>
<div class=cleft>
<button id=back>Back to diagnostics</button>
</div>
<div id=chooserd>
<i>Humax Filesystem</i>
<div id=chooser></div>
</div>
}
footer

View File

@ -0,0 +1,43 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
cgi_input
#cgi_dump
puts "Content-Type: text/html"
puts ""
set root [cgi_get dir]
set files [lsort [readdir -nocomplain $root]]
puts "<ul class=jqueryFileTree class=hidden>"
foreach dir $files {
set path "$root/$dir"
regsub -all -- {\/+} $path "/" path
if {![file isdirectory $path]} continue
puts -nonewline "<li class=\"directory collapsed\"><a href=# rel=\""
puts -nonewline [cgi_quote_url $path]
puts "\">[cgi_quote_html $dir]</a></li>"
}
foreach file $files {
set path "$root/$file"
regsub -all -- {\/+} $path "/" path
if {[file isdirectory $path]} continue
set ext [file extension $file]
puts -nonewline "<li class=\"file"
if {[string length $ext]} {
puts -nonewline " ext_[string range $ext 1 end]"
}
puts -nonewline "\">"
puts -nonewline "<a href=# rel=\"[cgi_quote_url $path]\">"
puts -nonewline [cgi_quote_html $file]
puts "</a></li>"
}
puts "</ul>"

32
var/mongoose/html/edit/get.jim Executable file
View File

@ -0,0 +1,32 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require chunked pretty_size
cgi_input
#cgi_dump
set file [cgi_get file "/tmp/hosts"]
if {$file eq "-"} { exit }
start_chunked
if {![file exists $file]} {
chunk ">>> File $file does not exist.\r\n"
} else {
set type [exec /mod/bin/file --brief --mime-type --dereference $file]
if {![string match {text/*} $type]} {
chunk ">>> File $file is not a plain file ($type)"
} elseif {[file size $file] > 102400} {
chunk ">>> File $file is too large."
chunk ">>> [pretty_size [file size $file]]"
} else {
set fp [open $file r]
chunk [read $fp]
close $fp
}
}
end_chunked

View File

@ -0,0 +1,107 @@
$(function() {
var file = null;
var changed = false;
$('button').button();
$('button.editactive').disable();
$('#editor').tabsupport().disable();
function loadfile(f)
{
if (!f)
f = file;
$('button.editactive').disable();
$('#editor').disable().val('');
$('#msg').text('Loading ' + f);
$.get('get.jim?file=' + encodeURIComponent(f), function(data) {
if (data.match('^>>>'))
{
$('#msg').text(data);
file = null;
changed = false;
}
else
{
$('#editor').val(data).enable();
$('button.editactive').enable();
$('#msg').html('Editing <i>' + f + '</i>');
file = f;
changed = false;
}
});
}
function result(msg)
{
$('#result')
.html(msg)
.slideDown('slow')
.delay(5000)
.slideUp('slow');
}
$('#chooser').fileTree({
root: '/',
script: 'files.jim',
multiFolder: false
}, function(file) {
$('#chooserd').dialog('close');
loadfile(file);
});
$('#chooserd').dialog({
title: "Choose File to Edit",
modal: true, autoOpen: false,
height: '500', width: '600',
draggable: true, resizable: true,
closeOnEscape: true,
buttons: {
"Cancel" : function() {$(this).dialog('close');}
}
});
$('#open').click(function() {
$('#chooserd').dialog('open');
});
$('#editor').change(function() {
changed = true;
});
$('#save').click(function() {
if (!changed)
{
result('No changes to save.');
return;
}
if (!confirm('Save file?'))
return;
$.post('put.jim', {
'file': file,
'data': $('#editor').val()
}, function(data) {
result(data);
});
});
$('#revert').click(function() {
if (!changed)
{
result('No changes to revert.');
return;
}
if (!confirm('Discard changes and re-load file?'))
return;
loadfile();
});
$('#back').click(function() {
window.location = '/diag/diag.jim';
});
});

View File

@ -16,3 +16,9 @@ textarea
background: white;
}
#chooser
{
border: solid 1px #bbb;
padding: 5px;
}

33
var/mongoose/html/edit/test.jim Executable file
View File

@ -0,0 +1,33 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
puts "Content-Type: text/html"
puts ""
header
puts {
<script type=text/javascript src=/js/jqueryFileTree.js></script>
<link rel=stylesheet type=text/css href=/css/jqueryFileTree.css />
<div id=chooser />
<script type=text/javascript>
$(function() {
$('#chooser').fileTree({
root: '/',
script: 'files.jim',
multiFolder: false
}, function(file) {
console.log(file);
});
});
</script>
}
footer

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 583 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

View File

@ -117,7 +117,7 @@ Release Notes:
Firmware</a> |
<a target=_blank href="http://wiki.hummy.tv/wiki/Webif_release_notes">Webif</a>
</li><li>
<a href=/diag.shtml>Diagnostics</a>
<a href=/diag/diag.jim>Diagnostics & Utilities</a>
</li><li>
<a href=/cgi-bin/channel.jim>Channel Information</a>
</li><li>

View File

@ -5,6 +5,7 @@
return this.each(function() {
$(this)
.removeClass('ui-state-disabled')
.removeClass('ui-button-disabled')
.removeProp('disabled');
});
};

94
var/mongoose/html/js/jqueryFileTree.js vendored Normal file
View File

@ -0,0 +1,94 @@
// jQuery File Tree Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 24 March 2008
//
// Visit http://abeautifulsite.net/notebook.php?article=58 for more information
//
// Usage: $('.fileTreeDemo').fileTree( options, callback )
//
// Options: root - root folder to display; default = /
// script - location of the serverside AJAX file to use; default = jqueryFileTree.php
// folderEvent - event to trigger expand/collapse; default = click
// expandSpeed - default = 500 (ms); use -1 for no animation
// collapseSpeed - default = 500 (ms); use -1 for no animation
// expandEasing - easing function to use on expand (optional)
// collapseEasing - easing function to use on collapse (optional)
// multiFolder - whether or not to limit the browser to one subfolder at a time
// loadMessage - Message to display while initial tree loads (can be HTML)
//
// History:
//
// 1.01 - updated to work with foreign characters in directory/file names (12 April 2008)
// 1.00 - released (24 March 2008)
//
// TERMS OF USE
//
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC.
//
if(jQuery) (function($){
$.extend($.fn, {
fileTree: function(o, h) {
// Defaults
if( !o ) var o = {};
if( o.root == undefined ) o.root = '/';
if( o.script == undefined ) o.script = 'jqueryFileTree.php';
if( o.folderEvent == undefined ) o.folderEvent = 'click';
if( o.expandSpeed == undefined ) o.expandSpeed= 750;
if( o.collapseSpeed == undefined ) o.collapseSpeed= 750;
if( o.expandEasing == undefined ) o.expandEasing = null;
if( o.collapseEasing == undefined ) o.collapseEasing = null;
if( o.multiFolder == undefined ) o.multiFolder = true;
if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
$(this).each( function() {
function showTree(c, t) {
$(c).addClass('wait');
$(".jqueryFileTree.start").remove();
$.post(o.script, { dir: t }, function(data) {
$(c).find('.start').html('');
$(c).removeClass('wait').append(data);
if( o.root == t ) $(c).find('UL:hidden').show(); else $(c).find('UL:hidden').slideDown({ duration: o.expandSpeed, easing: o.expandEasing });
bindTree(c);
});
}
function bindTree(t) {
$(t).find('LI A').bind(o.folderEvent, function() {
if( $(this).parent().hasClass('directory') ) {
if( $(this).parent().hasClass('collapsed') ) {
// Expand
if( !o.multiFolder ) {
$(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
$(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');
}
$(this).parent().find('UL').remove(); // cleanup
showTree( $(this).parent(), $(this).attr('rel') );
$(this).parent().removeClass('collapsed').addClass('expanded');
} else {
// Collapse
$(this).parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
$(this).parent().removeClass('expanded').addClass('collapsed');
}
} else {
h($(this).attr('rel'));
}
return false;
});
// Prevent A from triggering the # on non-click events
if( o.folderEvent.toLowerCase != 'click' ) $(t).find('LI A').bind('click', function() { return false; }); }
// Loading message
$(this).html('<ul class="jqueryFileTree start"><li class="wait">' + o.loadMessage + '<li></ul>');
// Get the initial file list
showTree( $(this), o.root);
});
}
});
})(jQuery);

View File

@ -1,14 +0,0 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require pretty_size
foreach file [concat \
[glob -nocomplain /var/log/*.log] \
[glob -nocomplain /mod/tmp/*.log] \
] {
puts "<a href=# class=log file=\"$file\">
<img border=0 height=14 src=/images/421_1_00_CH_Title_2R_Arrow.png>
[file tail $file]</a> ([pretty_size [file size $file]]) <br>"
}