diff --git a/ifm.php b/ifm.php index 57844b0..a94c08b 100644 --- a/ifm.php +++ b/ifm.php @@ -490,11 +490,13 @@ function IFM() { this.rebuildFileTable = function( data ) { var newTBody = $(document.createElement('tbody')); - for( var i=0; i < data.length; i++ ) { - var newRow = ''; - - 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(); newRow += '
'; @@ -514,30 +515,24 @@ function IFM() { } else { 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 += ''; @@ -1136,6 +1131,20 @@ function IFM() { self.deleteFileDialog( item.data( 'filename' ) ); } break; + case 'e': + var item = $('.highlightedItem'); + if( item.length && ! item.hasClass( 'isDir' ) ) { + e.preventDefault(); + var action = item.data( 'eaction' ); + switch( action ) { + case 'extract': + self.extractFileDialog( item.data( 'filename' ) ); + break; + case 'edit': + self.editFile( item.data( 'filename' ) ); + } + } + break; case 'g': e.preventDefault(); $('#currentDir').focus(); @@ -1164,20 +1173,24 @@ function IFM() { e.preventDefault(); self.createDirForm(); break; + case 'h': case 'ArrowLeft': e.preventDefault(); self.changeDirectory( '..' ); break; + case 'l': case 'ArrowRight': e.preventDefault(); var item = $('.highlightedItem'); if( item.hasClass('isDir') ) self.changeDirectory( item.data( 'filename' ) ); break; + case 'j': case 'ArrowDown': e.preventDefault(); self.highlightItem('next'); break; + case 'k': case 'ArrowUp': e.preventDefault(); self.highlightItem('prev'); @@ -1200,7 +1213,8 @@ function IFM() { console.log( "key: "+e.key ); } - // static button bindings and filetable initial filling + + // initialization this.init = function() { // bind static buttons $("#refresh").click(function(){ @@ -1221,13 +1235,10 @@ function IFM() { self.changeDirectory( $(this).val(), { absolute: true } ); } }); - // handle keystrokes $(document).on( 'keydown', self.handleKeystrokes ); - // handle history manipulation window.onpopstate = self.historyPopstateHandler; - // load initial file table if( window.location.hash ) { self.changeDirectory( window.location.hash.substring( 1 ) ); diff --git a/src/ifm.js b/src/ifm.js index bac7e52..e0a6868 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -56,8 +56,12 @@ function IFM() { this.rebuildFileTable = function( data ) { var newTBody = $(document.createElement('tbody')); for( var i=0; i < data.length; i++ ) { - var newRow = ''; - newRow += '