From 423093862f8c61ff079d83b78179326e38e00d1f Mon Sep 17 00:00:00 2001 From: Marco Dickert Date: Tue, 21 Feb 2017 16:45:38 +0100 Subject: [PATCH] added more keystrokes, cleaned some code --- ifm.php | 204 ++++++++++++++++++++++++++----------------------- src/config.php | 2 +- src/ifm.js | 173 +++++++++++++++++++++-------------------- src/main.php | 13 ++-- src/style.css | 7 +- 5 files changed, 205 insertions(+), 194 deletions(-) diff --git a/ifm.php b/ifm.php index 839f0d0..57844b0 100644 --- a/ifm.php +++ b/ifm.php @@ -35,7 +35,7 @@ class IFMConfig { const showowner = 1; // show file owner? const showgroup = 1; // show file group? const showpath = 0; // show real path of directory (not only root)? - const showrights = 2; // show permissions 0 -> not; 1 -> octal, 2 -> human readable + const showpermissions = 2; // show permissions 0 -> not; 1 -> octal, 2 -> human readable const showhtdocs = 1; // show .htaccess and .htpasswd const showhiddenfiles = 1; // show files beginning with a dot (e.g. ".bashrc") @@ -129,6 +129,9 @@ class IFMZip { * main */ +error_reporting( E_ALL ); +ini_set( 'display_errors', ON ); + class IFM { const VERSION = '2.3.1'; @@ -290,11 +293,10 @@ div#content { width: 100%; height: 350px; } input[name=newperms] { width: 7em; } #filetable tr th.buttons { min-width: 95px; } -#filetable tr.clickable-row.active td { background-color: lightblue; } -#filetable tbody tr.highlightedItem td { border-top: 1px solid #555 !important; border-bottom: 1px solid #555 !important; } -#filetable tbody tr.highlightedItem td:first-child { border-left: 1px solid #555; } -#filetable tbody tr.highlightedItem td:last-child { border-right: 1px solid #555; } +#filetable tbody tr.highlightedItem { box-shadow: 0px 0px 10px 2px #337ab7; } #filetable tbody tr.highlightedItem td:first-child a { outline: none; } +#filetable tbody tr.selectedItem { background-color: #337ab7; color: #FFF; } +#filetable tbody tr.selectedItem * a { color: #FFF; } #navbar { max-width: 100%; } @@ -389,7 +391,7 @@ div.footer div.panel-body { padding: 5px !important; } if( IFMConfig::download == 1 ) print ''; if( IFMConfig::showlastmodified == 1 ) print 'last modified'; if( IFMConfig::showfilesize == 1 ) print 'size'; - if( IFMConfig::showrights > 0 ) print 'permissions'; + if( IFMConfig::showpermissions > 0 ) print 'permissions'; if( IFMConfig::showowner == 1 && function_exists( "posix_getpwuid" ) ) print 'owner'; if( IFMConfig::showgroup == 1 && function_exists( "posix_getgrgid" ) ) print 'group'; if( in_array( 1, array( IFMConfig::edit, IFMConfig::rename, IFMConfig::delete, IFMConfig::zipnload, IFMConfig::extract ) ) ) print ''; @@ -473,12 +475,12 @@ function IFM() { }; this.refreshFileTable = function () { - var id=ifm.generateGuid(); - ifm.task_add("Refresh", id); + var id=self.generateGuid(); + self.task_add("Refresh", id); $.ajax({ - url: ifm.IFM_SCFN, + url: self.IFM_SCFN, type: "POST", - data: "api=getFiles&dir="+ifm.currentDir, + data: "api=getFiles&dir=" + self.currentDir, dataType: "json", success: self.rebuildFileTable, error: function(response) { ifm.showMessage("General error occured: No or broken response", "e"); }, @@ -487,81 +489,83 @@ function IFM() { }; this.rebuildFileTable = function( data ) { - var newRows = $(document.createElement('tbody')); - for(i=0;i'; + var newTBody = $(document.createElement('tbody')); + + for( var i=0; i < data.length; i++ ) { + var newRow = ''; + + newRow += '"'; - newrow += '> '+data[i].name+''; + newRow += ' href="'+self.pathCombine(ifm.currentDir,data[i].name)+'"'; + if( data[i].icon.indexOf( 'file-image' ) !== -1 ) + newRow += ' data-toggle="tooltip" title=""'; } else { - newrow += ' '; - if( data[i].name == ".." ) newrow += "[ up ]"; - else newrow += data[i].name; - newrow += ''; + newRow += ' onclick="ifm.changeDirectory(\''+data[i].name+'\')"'; } - if( data[i].type != "dir" && self.config.download == 1) { - newrow += '\ - \ - \ - '; - } - else if( data[i].type == "dir" && self.config.zipnload == 1 ) { + newRow += '> ' + ( data[i].name == '..' ? '[ up ]' : data[i].name ) + ''; + + if( ( data[i].type != "dir" && self.config.download == 1 ) || ( data[i].type == "dir" && self.config.zipnload == 1 ) ) { var guid = self.generateGuid(); - if( data[i].name == ".." ) data[i].name = "."; - newrow += '
\ -
\ - \ - \ - '; - newrow += '\ - \ - \ -
\ -
'; + newRow += '
'; + newRow += ''; + newRow += ''; + newRow += ''; + newRow += '
'; + } else { + newRow += ''; } - else - newrow += ''; // empty cell for download link - if(data[i].lastmodified) newrow += ''+data[i].lastmodified+''; - if(data[i].filesize) newrow += ''+data[i].filesize+''; - if(data[i].fileperms) { - newrow += ''; - if(data[i].group) newrow += ''+data[i].group+''; - if(ifm.inArray(1,[self.config.edit, self.config.rename, self.config.delete, self.config.extract])) { - newrow += ''; + + // last-modified + if( self.config.showlastmodified > 0 ) + newRow += '' + data[i].lastmodified + ''; + + // size + if( self.config.showfilesize > 0 ) + newRow += '' + data[i].filesize + ''; + + // permissions + if( self.config.showpermissions > 0 ) + newRow += ''; + + // owner + if( self.config.showowner > 0 ) + newRow += ''+data[i].owner+''; + + // group + if( self.config.showgroup > 0 ) + newRow += '' + data[i].group + ''; + + // actions + if( self.inArray( 1, [self.config.edit, self.config.rename, self.config.delete, self.config.extract] ) ) { + newRow += ''; if( data[i].name.toLowerCase().substr(-4) == ".zip" && self.config.extract == 1 ) { - newrow += ''; + newRow += ''; } else if( self.config.edit == 1 && data[i].type != "dir" ) { - newrow += ''; + newRow += ''; } if( data[i].name != ".." && data[i].name != "." ) { - if(self.config.rename == 1) newrow += ''; - if(self.config.delete == 1) newrow += ''; + if( self.config.rename == 1 ) + newRow += ''; + if( self.config.delete == 1 ) + newRow += ''; } - newrow += ''; + newRow += ''; + } else { + newRow += ''; } - newRows.append(newrow); + newTBody.append( newRow ); } $("#filetable tbody").remove(); - $("#filetable").append(newRows); + $("#filetable").append( newTBody ); if( self.config.multiselect == 1 ) { $('.clickable-row').click(function(event) { if( event.ctrlKey ) { - $(this).toggleClass('active'); + $(this).toggleClass( 'selectedItem' ); + } else { + self.highlightItem( $(this) ); } }); } @@ -989,7 +993,7 @@ function IFM() { $("#savequestion").remove(); }; this.handleMultiselect = function() { - var amount = $("#filetable tr.active").length; + var amount = $("#filetable tr.selectedItem").length; if(amount > 0) { if(document.getElementById("multiseloptions")===null) { $(document.body).prepend('
\ @@ -1009,13 +1013,13 @@ function IFM() { } }; this.multiDeleteDialog = function() { - var form = '