diff --git a/.gitattributes b/.gitattributes index ebf4564..7635ed6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ -ifm.php -diff -build/* -diff +ifm.php -diff +ifm.min.php -diff +build/* -diff diff --git a/build/ifmlib.php b/build/libifm.php similarity index 99% rename from build/ifmlib.php rename to build/libifm.php index 7b5f8e9..e3b5ae7 100644 --- a/build/ifmlib.php +++ b/build/libifm.php @@ -333,7 +333,8 @@ function IFM( params ) { * @param string content - content of the modal * @param object options - options for the modal */ - this.showModal = function( content, options = {} ) { + this.showModal = function( content, options ) { + options = options || {}; var modal = $( document.createElement( 'div' ) ) .addClass( "modal fade" ) .attr( 'id', 'ifmmodal' ) @@ -522,7 +523,8 @@ function IFM( params ) { * @param string newdir - target directory * @param object options - options for changing the directory */ - this.changeDirectory = function( newdir, options={} ) { + this.changeDirectory = function( newdir, options ) { + options = options || {}; config = { absolute: false, pushState: true }; jQuery.extend( config, options ); if( ! config.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); @@ -1405,6 +1407,7 @@ function IFM( params ) { break; case 'h': case 'ArrowLeft': + case 'Backspace': e.preventDefault(); self.changeDirectory( '..' ); break; @@ -1559,7 +1562,7 @@ function IFM( params ) { */ private function handleRequest() { - if($_REQUEST["api"] == "getRealpath") { + if( $_REQUEST["api"] == "getRealpath" ) { if( isset( $_REQUEST["dir"] ) && $_REQUEST["dir"] != "" ) echo json_encode( array( "realpath" => $this->getValidDir( $_REQUEST["dir"] ) ) ); else @@ -1599,7 +1602,7 @@ function IFM( params ) { break; } } else { - print json_encode(array("status"=>"ERROR", "message"=>"No valid working directory")); + print json_encode( array( "status" => "ERROR", "message" => "No valid working directory" ) ); } } exit( 0 ); @@ -1613,7 +1616,7 @@ function IFM( params ) { else chdir( realpath( $this->config['root_dir'] ) ); $this->mode = $mode; - if ( isset( $_REQUEST['api'] ) || $mode == "api" ) { + if( isset( $_REQUEST['api'] ) || $mode == "api" ) { $this->handleRequest(); } elseif( $mode == "standalone" ) { $this->getApplication(); @@ -1642,7 +1645,7 @@ function IFM( params ) { else { $item = array(); $item["name"] = $result; - if( is_dir($result) ) { + if( is_dir( $result ) ) { $item["type"] = "dir"; if( $result == ".." ) $item["icon"] = "icon icon-up-open"; @@ -2542,45 +2545,6 @@ f00bar; {{/items}} -f00bar; - $templates['file'] = <<<'f00bar' -
- - -
- -f00bar; - $templates['createdir'] = <<<'f00bar' -
- - -
- f00bar; $templates['ajaxrequest'] = <<<'f00bar'
diff --git a/compiler.php b/compiler.php index 8192409..5fab978 100755 --- a/compiler.php +++ b/compiler.php @@ -13,7 +13,8 @@ $IFM_SRC_PHPFILES = array( "src/ifmzip.php" ); $IFM_SRC_JS = "src/ifm.js"; $IFM_BUILD_STANDALONE = "ifm.php"; -$IFM_BUILD_LIB_PHP = "build/ifmlib.php"; +$IFM_BUILD_STANDALONE_COMPRESSED = "ifm.min.php"; +$IFM_BUILD_LIB_PHP = "build/libifm.php"; /** * Prepare main script @@ -40,14 +41,18 @@ foreach( $IFM_SRC_PHPFILES as $file ) { */ file_put_contents( $IFM_BUILD_STANDALONE, $main ); file_put_contents( $IFM_BUILD_STANDALONE, $phpincludes, FILE_APPEND ); -file_put_contents( $IFM_BUILD_STANDALONE, array( - '', - '/**', - ' * start IFM', - ' */', - '$ifm = new IFM();', - '$ifm->run();' -), FILE_APPEND ); +file_put_contents( $IFM_BUILD_STANDALONE, ' +/** + * start IFM + */ +$ifm = new IFM(); +$ifm->run(); +', FILE_APPEND ); + +/** + * Build compressed standalone script + */ +file_put_contents( $IFM_BUILD_STANDALONE_COMPRESSED, '' . gzencode( file_get_contents( "ifm.php", false, null, 5 ) ) ); /** * Build library diff --git a/ifm.php b/ifm.php index 639e5dc..515f0ca 100644 --- a/ifm.php +++ b/ifm.php @@ -333,7 +333,8 @@ function IFM( params ) { * @param string content - content of the modal * @param object options - options for the modal */ - this.showModal = function( content, options = {} ) { + this.showModal = function( content, options ) { + options = options || {}; var modal = $( document.createElement( 'div' ) ) .addClass( "modal fade" ) .attr( 'id', 'ifmmodal' ) @@ -522,7 +523,8 @@ function IFM( params ) { * @param string newdir - target directory * @param object options - options for changing the directory */ - this.changeDirectory = function( newdir, options={} ) { + this.changeDirectory = function( newdir, options ) { + options = options || {}; config = { absolute: false, pushState: true }; jQuery.extend( config, options ); if( ! config.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); @@ -1405,6 +1407,7 @@ function IFM( params ) { break; case 'h': case 'ArrowLeft': + case 'Backspace': e.preventDefault(); self.changeDirectory( '..' ); break; @@ -1559,7 +1562,7 @@ function IFM( params ) { */ private function handleRequest() { - if($_REQUEST["api"] == "getRealpath") { + if( $_REQUEST["api"] == "getRealpath" ) { if( isset( $_REQUEST["dir"] ) && $_REQUEST["dir"] != "" ) echo json_encode( array( "realpath" => $this->getValidDir( $_REQUEST["dir"] ) ) ); else @@ -1599,7 +1602,7 @@ function IFM( params ) { break; } } else { - print json_encode(array("status"=>"ERROR", "message"=>"No valid working directory")); + print json_encode( array( "status" => "ERROR", "message" => "No valid working directory" ) ); } } exit( 0 ); @@ -1613,7 +1616,7 @@ function IFM( params ) { else chdir( realpath( $this->config['root_dir'] ) ); $this->mode = $mode; - if ( isset( $_REQUEST['api'] ) || $mode == "api" ) { + if( isset( $_REQUEST['api'] ) || $mode == "api" ) { $this->handleRequest(); } elseif( $mode == "standalone" ) { $this->getApplication(); @@ -1642,7 +1645,7 @@ function IFM( params ) { else { $item = array(); $item["name"] = $result; - if( is_dir($result) ) { + if( is_dir( $result ) ) { $item["type"] = "dir"; if( $result == ".." ) $item["icon"] = "icon icon-up-open"; @@ -2542,45 +2545,6 @@ f00bar; {{/items}} -f00bar; - $templates['file'] = <<<'f00bar' - - - -
- -f00bar; - $templates['createdir'] = <<<'f00bar' -
- - -
- f00bar; $templates['ajaxrequest'] = <<<'f00bar'
@@ -2834,4 +2798,9 @@ class IFMZip { } } } -/** * start IFM */$ifm = new IFM();$ifm->run(); \ No newline at end of file + +/** + * start IFM + */ +$ifm = new IFM(); +$ifm->run(); diff --git a/src/ifm.js b/src/ifm.js index bc7b632..aecc854 100644 --- a/src/ifm.js +++ b/src/ifm.js @@ -21,7 +21,8 @@ function IFM( params ) { * @param string content - content of the modal * @param object options - options for the modal */ - this.showModal = function( content, options = {} ) { + this.showModal = function( content, options ) { + options = options || {}; var modal = $( document.createElement( 'div' ) ) .addClass( "modal fade" ) .attr( 'id', 'ifmmodal' ) @@ -210,7 +211,8 @@ function IFM( params ) { * @param string newdir - target directory * @param object options - options for changing the directory */ - this.changeDirectory = function( newdir, options={} ) { + this.changeDirectory = function( newdir, options ) { + options = options || {}; config = { absolute: false, pushState: true }; jQuery.extend( config, options ); if( ! config.absolute ) newdir = self.pathCombine( self.currentDir, newdir ); @@ -1093,6 +1095,7 @@ function IFM( params ) { break; case 'h': case 'ArrowLeft': + case 'Backspace': e.preventDefault(); self.changeDirectory( '..' ); break; diff --git a/src/main.php b/src/main.php index a22d12d..98a67bc 100644 --- a/src/main.php +++ b/src/main.php @@ -115,7 +115,7 @@ class IFM { */ private function handleRequest() { - if($_REQUEST["api"] == "getRealpath") { + if( $_REQUEST["api"] == "getRealpath" ) { if( isset( $_REQUEST["dir"] ) && $_REQUEST["dir"] != "" ) echo json_encode( array( "realpath" => $this->getValidDir( $_REQUEST["dir"] ) ) ); else @@ -155,7 +155,7 @@ class IFM { break; } } else { - print json_encode(array("status"=>"ERROR", "message"=>"No valid working directory")); + print json_encode( array( "status" => "ERROR", "message" => "No valid working directory" ) ); } } exit( 0 ); @@ -169,7 +169,7 @@ class IFM { else chdir( realpath( $this->config['root_dir'] ) ); $this->mode = $mode; - if ( isset( $_REQUEST['api'] ) || $mode == "api" ) { + if( isset( $_REQUEST['api'] ) || $mode == "api" ) { $this->handleRequest(); } elseif( $mode == "standalone" ) { $this->getApplication(); @@ -198,7 +198,7 @@ class IFM { else { $item = array(); $item["name"] = $result; - if( is_dir($result) ) { + if( is_dir( $result ) ) { $item["type"] = "dir"; if( $result == ".." ) $item["icon"] = "icon icon-up-open"; @@ -964,12 +964,6 @@ class IFM { f00bar; $templates['filetable'] = <<<'f00bar' @@@src/templates/filetable.html@@@ -f00bar; - $templates['file'] = <<<'f00bar' -@@@src/templates/modal.file.html@@@ -f00bar; - $templates['createdir'] = <<<'f00bar' -@@@src/templates/modal.createdir.html@@@ f00bar; $templates['ajaxrequest'] = <<<'f00bar' @@@src/templates/modal.ajaxrequest.html@@@