From b8fba3ac8e1707a8401c9b2f68085a7f66a8da54 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 4 Jul 2011 02:18:27 +0200 Subject: [PATCH] Added basic options support. Refactored js. --- README.md | 9 +- build.properties | 2 +- src/h5ai/footer.html | 3 +- src/h5ai/js/inc/file.js | 99 ++++++ src/h5ai/js/inc/h5ai.js | 629 ++++++++++++++++++------------------ src/h5ai/js/inc/h5aitree.js | 312 ------------------ src/h5ai/js/inc/tree.js | 183 +++++++++++ src/h5ai/js/inc/utils.js | 15 + src/h5ai/js/main.js | 40 ++- src/h5ai/options.js | 8 + target/dot.htaccess | 4 +- target/h5ai/footer.html | 5 +- target/h5ai/header.html | 2 +- target/h5ai/js/main.js | 2 +- target/h5ai/options.js | 8 + 15 files changed, 682 insertions(+), 639 deletions(-) create mode 100644 src/h5ai/js/inc/file.js delete mode 100644 src/h5ai/js/inc/h5aitree.js create mode 100644 src/h5ai/js/inc/tree.js create mode 100644 src/h5ai/js/inc/utils.js create mode 100644 src/h5ai/options.js create mode 100644 target/h5ai/options.js diff --git a/README.md b/README.md index 104ae1d8..be6c59e7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# h5ai v0.5.2   ·   a beautified Apache index +# h5ai v0.5.3   ·   a beautified Apache index ## Screenshots @@ -47,6 +47,13 @@ please respect their rights. ## Changelog +### v0.5.3 +*2011-07-04* + +* refactored js +* added basic options support + + ### v0.5.2 *2011-07-02* diff --git a/build.properties b/build.properties index 4643659e..5c8790e2 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ custom = true # project project.name = h5ai -project.version = 0.5.2 +project.version = 0.5.3 # src diff --git a/src/h5ai/footer.html b/src/h5ai/footer.html index f864ab22..5f5025b7 100644 --- a/src/h5ai/footer.html +++ b/src/h5ai/footer.html @@ -15,8 +15,9 @@ using Faenza icons - + + \ No newline at end of file diff --git a/src/h5ai/js/inc/file.js b/src/h5ai/js/inc/file.js new file mode 100644 index 00000000..58d6ab33 --- /dev/null +++ b/src/h5ai/js/inc/file.js @@ -0,0 +1,99 @@ + +var File = function ( utils, folder, tableRow ) { + + if ( ! /\/$/.test( folder ) ) { + folder += "/"; + }; + + if ( tableRow !== undefined ) { + var $tds = $( tableRow ).find( "td" ); + var $img = $( $tds.get( 0 ) ).find( "img" ); + var $a= $( $tds.get( 1 ) ).find( "a" ); + + this.parentFolder = folder; + this.icon16 = $img.attr( "src" ); + this.alt = $img.attr( "alt" ); + this.label = $a.text(); + this.href = $a.attr("href"); + this.date = $( $tds.get(2) ).text(); + this.size = $( $tds.get(3) ).text(); + } else { + var splits = utils.splitPathname( folder ); + + this.parentFolder = splits[0]; + this.label = splits[1]; + this.icon16 = "/h5ai/icons/16x16/folder.png"; + this.alt = "[DIR]"; + this.href = this.label; + this.date = ""; + this.size = ""; + if ( this.label === "/" ) { + this.label = document.domain + "/"; + }; + }; + + this.icon48 = this.icon16.replace( "16x16", "48x48" ); + this.isFolder = ( this.alt === "[DIR]" ); + this.isParentFolder = ( this.isFolder && this.label === "Parent Directory" ); + this.absHref = this.isParentFolder ? this.href : this.parentFolder + this.href; + this.content = undefined; + + + this.isComplete = function () { + + if ( this.isFolder ) { + if ( this.content === undefined ) { + return false; + } else if ( this.content instanceof Array ) { + for ( idx in this.content ) { + if ( !this.content[idx].isComplete() ) { + return false; + }; + }; + }; + }; + return true; + }; + + + this.toHtml = function () { + + var $entry = $( "
" ); + + try { + var $a = $( "" ) + .appendTo( $entry ) + .append( $( "" ) ) + .append( $( "" + this.label + "" ) ); + + if ( this.isFolder ) { + $entry.addClass( "folder" ); + if ( this.absHref === document.location.pathname ) { + $a.find( ".icon img" ).attr( "src", "/h5ai/images/folder-open.png" ); + $entry.addClass( "current" ); + }; + if ( this.content instanceof Array ) { + var $ul = $( "