From 7c038a17761ebe60baa0d3409cbed2e6ac817a98 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Wed, 28 Dec 2011 21:36:35 +0000 Subject: [PATCH] checkpoint git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@588 2a923420-c742-0410-a762-8d5b09965624 --- var/mongoose/cgi-bin/browse.jim | 123 +------------------- var/mongoose/cgi-bin/browse/assets.jim | 131 ++++++++++++++++++++++ var/mongoose/cgi-bin/browse/browse.js | 45 +++++++- var/mongoose/cgi-bin/browse/clipboard.jim | 48 +++++++- var/mongoose/cgi-bin/browse/style.css | 5 + var/mongoose/html/css/jquery.bar.css | 48 ++++++++ var/mongoose/html/js/jquery.bar.js | 53 +++++++++ var/mongoose/lib/clipboard.class | 41 ++++++- 8 files changed, 366 insertions(+), 128 deletions(-) create mode 100755 var/mongoose/cgi-bin/browse/assets.jim create mode 100644 var/mongoose/html/css/jquery.bar.css create mode 100644 var/mongoose/html/js/jquery.bar.js diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim index c9b79dd..745f3a7 100755 --- a/var/mongoose/cgi-bin/browse.jim +++ b/var/mongoose/cgi-bin/browse.jim @@ -196,131 +196,16 @@ header puts { - - - - - - - - - - - -
-
- + + } -puts "$dir" +source /mod/var/mongoose/cgi-bin/browse/assets.jim puts " + $dir
" diff --git a/var/mongoose/cgi-bin/browse/assets.jim b/var/mongoose/cgi-bin/browse/assets.jim new file mode 100755 index 0000000..2cae11f --- /dev/null +++ b/var/mongoose/cgi-bin/browse/assets.jim @@ -0,0 +1,131 @@ +#!/mod/bin/jimsh + +puts { + +
+ + + + + + + + + + + +
+
+ +} + diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index 6c85a26..7507e75 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -24,6 +24,33 @@ function disableall() $('button,a,input').disable(); } +function reloadclipboard() +{ + $('#clipboard') + .empty() + .html(' Loading...') + .load('/cgi-bin/browse/clipboard.jim', function() { + +// Start Clipboard post-load actions + +$('#clipclear').button().click(function() { + $.get('/cgi-bin/browse/clipboard.jim?act=clear', function() { + reloadclipboard(); + }); +}); + +$('a.clipdel').click(function() { + $.get('/cgi-bin/browse/clipboard.jim?act=remove&path=' + + $(this).attr('path'), function() { + reloadclipboard(); + }); +}); + +// End Clipboard post-load actions + + }); +} + function epginfo_callback(data, status, xhr) { var width = 85; @@ -245,6 +272,14 @@ var menuclick = function(action, el, pos) type, id); break; + case 'cut': + case 'copy': + $.get('/cgi-bin/browse/clipboard.jim?act=add&mode=' + action + + '&path=' + file, function() { + reloadclipboard(); + }); + break; + case 'lock': confirm_action('change the lock on', lock_callback, file, type, id); @@ -334,6 +369,14 @@ var dmenuclick = function(action, el, pos) } break; + case 'cut': + case 'copy': + $.get('/cgi-bin/browse/clipboard.jim?act=add&mode=' + action + + '&path=' + file, function() { + reloadclipboard(); + }); + break; + case 'rename': $('#drename').val(decodeURIComponent(bfile)); $('#drenameorig').val(decodeURIComponent(file)); @@ -458,7 +501,7 @@ var dmenuclick = function(action, el, pos) new_folder_callback); // Load clipboard - $('#clipboard').load('/cgi-bin/browse/clipboard.jim'); + reloadclipboard(); // Uncheck everything $('input.fs:checked').attr('checked', false); diff --git a/var/mongoose/cgi-bin/browse/clipboard.jim b/var/mongoose/cgi-bin/browse/clipboard.jim index 799dab2..ea41f86 100755 --- a/var/mongoose/cgi-bin/browse/clipboard.jim +++ b/var/mongoose/cgi-bin/browse/clipboard.jim @@ -2,12 +2,13 @@ package require cgi source /mod/var/mongoose/lib/setup +require classdump require clipboard.class puts "Content-Type: text/html" puts "" -cgi_input +cgi_input 1 #cgi_dump set cb [[clipboard new {path "/tmp/webif-browse.cb"}] load] @@ -20,12 +21,55 @@ switch $action { puts "Clipboard is empty" exit } + puts "
" + foreach file [$cb get items] { + set img "page_white_copy" + if {[$file get action] eq "cut"} { + set img "cut" + } + set path [$file get path] + set xpath [cgi_quote_html $path] + puts "" + puts "" + set dfile [file tail $path] + if {[string length $dfile] > 25} { + set dfile "[string range $dfile 0 22]..." + } + if {[file isdirectory $path]} { + puts "" + } + puts [cgi_quote_html $dfile] + puts " + " + puts "" + } + puts "
" + puts "" } add { + if {[set path [cgi_get path]] eq "0"} { + puts "No path." + exit + } + set mode [cgi_get mode copy] + foreach p [split $path ","] { + set p [cgi_unquote_input $p] + if {![$cb present $p]} { + $cb add $mode $p + puts "Added $p for $mode
" + } + } + $cb save } - del { + remove { + $cb remove [cgi_unquote_input [cgi_get path]] + $cb save } clear { + $cb clear + $cb save } } diff --git a/var/mongoose/cgi-bin/browse/style.css b/var/mongoose/cgi-bin/browse/style.css index 1df1101..7a9888a 100644 --- a/var/mongoose/cgi-bin/browse/style.css +++ b/var/mongoose/cgi-bin/browse/style.css @@ -5,3 +5,8 @@ div.brow clear: left; } +div.cliplist span +{ + display: block; +} + diff --git a/var/mongoose/html/css/jquery.bar.css b/var/mongoose/html/css/jquery.bar.css new file mode 100644 index 0000000..43cf430 --- /dev/null +++ b/var/mongoose/html/css/jquery.bar.css @@ -0,0 +1,48 @@ +.jbar{ + height:50px; + width:100%; + background-color: #ffffcc; + color: #ff4000; + position:fixed; + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=95); + opacity: 0.95; + -moz-opacity: 0.95; + text-align:center; + left:0px; + z-index:9999999; + margin:0px; + padding:0px; +} +.jbar-top{ + top:0px; + border-top:2px solid #fff; + border-bottom: 1px solid #ebebeb; +} +.jbar-bottom{ + bottom:0px; + border-bottom:2px solid #fff; + border-top: 1px solid #ebebeb; + color:#777; +} +.jbar-content{ + line-height:46px; + font-size: 18px; + font-family:'Lucida Grande',sans-serif; +} +a.jbar-cross{ + position:absolute; + width:31px; + height:31px; + background:transparent url(/images/cross.png) no-repeat top left; + cursor:pointer; + right:10px; +} +a.jbar-cross:hover{ + background-image: url(/images/cross_hover.png) +} +.jbar-top a.jbar-cross{ + top:8px; +} +.jbar-bottom a.jbar-cross{ + bottom:8px; +} diff --git a/var/mongoose/html/js/jquery.bar.js b/var/mongoose/html/js/jquery.bar.js new file mode 100644 index 0000000..971e316 --- /dev/null +++ b/var/mongoose/html/js/jquery.bar.js @@ -0,0 +1,53 @@ +(function($) { + + $.fn.bar = function(options) { + var opts = $.extend({}, $.fn.bar.defaults, options); + return this.each(function() { + $this = $(this); + var o = $.meta ? $.extend({}, opts, $this.data()) : opts; + +// $this.click(function(e){ + if(!$('.jbar').length){ + timeout = setTimeout('$.fn.bar.removebar()',o.time); + var _message_span = $(document.createElement('span')).addClass('jbar-content').html(o.message); + _message_span.css({"color" : o.color}); + var _wrap_bar; + (o.position == 'bottom') ? + _wrap_bar = $(document.createElement('div')).addClass('jbar jbar-bottom'): + _wrap_bar = $(document.createElement('div')).addClass('jbar jbar-top') ; + + _wrap_bar.css({"background-color" : o.background_color}); + if(o.removebutton){ + var _remove_cross = $(document.createElement('a')).addClass('jbar-cross'); + _remove_cross.click(function(e){$.fn.bar.removebar();}) + } + else{ + _wrap_bar.css({"cursor" : "pointer"}); + _wrap_bar.click(function(e){$.fn.bar.removebar();}) + } + _wrap_bar.append(_message_span).append(_remove_cross).hide().insertBefore($('.content')).fadeIn('fast'); + } +// }) + + + }); + }; + var timeout; + $.fn.bar.removebar = function(txt) { + if($('.jbar').length){ + clearTimeout(timeout); + $('.jbar').fadeOut('fast',function(){ + $(this).remove(); + }); + } + }; + $.fn.bar.defaults = { + background_color : '#FFFFFF', + color : '#000', + position : 'top', + removebutton : true, + time : 5000 + }; + +})(jQuery); + diff --git a/var/mongoose/lib/clipboard.class b/var/mongoose/lib/clipboard.class index 21a6d67..25c4eae 100644 --- a/var/mongoose/lib/clipboard.class +++ b/var/mongoose/lib/clipboard.class @@ -8,12 +8,11 @@ class clipboard { class clipboarditem { action "" - type "" path "" } clipboarditem method _parse {line} { - lassign [split $line "|"] action type path + lassign [split $line "|"] action path } proc {clipboarditem load} {line} { @@ -25,7 +24,7 @@ proc {clipboarditem load} {line} { clipboard method save {} { set fd [open $path w] foreach item $items { - puts $fd "[$item get action]|[$item get type]|[$item get path]" + puts $fd "[$item get action]|[$item get path]" } $fd close } @@ -38,7 +37,7 @@ clipboard method load {} { foreach line [split [$fd read] "\n"] { set ci [clipboarditem load $line] if {[file exists [$ci get path]]} { - lappend $items $ci + lappend items $ci } else { set changed 1 } @@ -48,11 +47,41 @@ clipboard method load {} { return $self } +clipboard method present {xfile} { + foreach item $items { + if {[$item get path] eq $xfile} { + return 1 + } + } + return 0 +} + +clipboard method index {xfile} { + set index -1 + foreach item $items { + incr index + if {[$item get path] eq $xfile} { + return $index + } + } + return -1 +} + +clipboard method clear {} { + set items {} +} + clipboard method size {} { return [llength $items] } -clipboard method add {action type path} { - lappend $items [clipboarditem load "$action|$type|$path"] +clipboard method add {xaction xpath} { + lappend items [clipboarditem load "$xaction|$xpath"] +} + +clipboard method remove {xpath} { + set index [$self index $xpath] + if {$index < 0} { return } + set items [lreplace $items $index $index] }