From 47b626018621567752ec000f5883fef3dc974ae3 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sun, 12 Feb 2012 02:40:14 +0100 Subject: [PATCH 01/36] Prepares for 0.18. --- .gitignore | 32 ++------------------- LICENSE.txt | 2 +- README.md | 74 ++++++++++++++++++++++++++---------------------- build.properties | 2 +- build.xml | 3 -- 5 files changed, 44 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index 206365b2..498f0cf8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,8 @@ build build.local.* release - -# Eclipse -.classpath -.ant-targets-* +# Sublime +*.sublime-* # Numerous always-ignore extensions *.diff @@ -20,29 +18,3 @@ release *.vi *~ *.sass-cache - -# OS or Editor folders -.DS_Store -.cache -.project -.settings -.tmproj -nbproject -Thumbs.db - -# Dreamweaver added files -_notes -dwsync.xml - -# Komodo -*.komodoproject -.komodotools - -# Folders to ignore -.hg -.svn -.CVS -intermediate -publish -.idea - diff --git a/LICENSE.txt b/LICENSE.txt index f16e3a99..bab9d95b 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2011 Lars Jung, http://larsjung.de +Copyright (c) 2012 Lars Jung, http://larsjung.de Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 644e8af5..05b54482 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,13 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h ## Changelog -### v0.17 · *2011-11-28* + +### v0.18 - *2012-02-??* + +* updates year in `LICENSE.TXT` + + +### v0.17 - *2011-11-28* * h5ai is now located in `_h5ai` to reduce collisions * switches from HTML5 Boilerplate reset to normalization @@ -43,7 +49,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * adds support for use with userdir (requires some manual changes) -### v0.16 · *2011-11-02* +### v0.16 - *2011-11-02* * sorts translations in `options.js` * improves HTML head sections @@ -57,25 +63,25 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * image thumbs and zipped download is disabled by default now, but works fine if PHP is configured -### v0.15.2 · *2011-09-18* +### v0.15.2 - *2011-09-18* * added it translation by [Salvo Gentile](http://github.com/SalvoGentile) and [Marco Patriarca](http://github.com/Fexys) * switched build process from scripp to wepp -### v0.15.1 · *2011-09-06* +### v0.15.1 - *2011-09-06* * fixed security issues with the zipped download feature * made zipped download optional (but enabled by default) -### v0.15 · *2011-09-04* +### v0.15 - *2011-09-04* * added zipped download for selected files * cleaned and refactored -### v0.14.1 · *2011-09-01* +### v0.14.1 - *2011-09-01* * display meta information in bottom bar (icon view) * added zh-cn translation by [Dongsheng Cai](http://github.com/dongsheng) @@ -83,18 +89,18 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * added ru translation by Богдан Илюхин -### v0.14 · *2011-08-16* +### v0.14 - *2011-08-16* * added image thumbnails for PHP version * new option `slideTree` to turn off auto slide in -### v0.13.2 · *2011-08-12* +### v0.13.2 - *2011-08-12* * changes in `/h5ai/.htaccess` ... PHP configuration ... -### v0.13.1 · *2011-08-12* +### v0.13.1 - *2011-08-12* * ~~hopefully fixed that PHP doesn't get interpreted~~ :/ * fixed initial tree display @@ -103,7 +109,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * added lv translation by Sandis Veinbergs -### v0.13 · *2011-08-06* +### v0.13 - *2011-08-06* * added PHP implementation! (should work with PHP 5.2+) * added new options @@ -117,42 +123,42 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * added bg translation by George Andonov -### v0.12.3 · *2011-07-30* +### v0.12.3 - *2011-07-30* * added tr translation by [Batuhan Icoz](http://github.com/batuhanicoz) -### v0.12.2 · *2011-07-30* +### v0.12.2 - *2011-07-30* * added es translation by Jose David Calderon Serrano -### v0.12.1 · *2011-07-29* +### v0.12.1 - *2011-07-29* * fixed unchecked use of console.log -### v0.12 · *2011-07-28* +### v0.12 - *2011-07-28* * improved performance -### v0.11 · *2011-07-27* +### v0.11 - *2011-07-27* * changed license to MIT license, see `LICENSE.txt` -### v0.10.2 · *2011-07-26* +### v0.10.2 - *2011-07-26* * improved tree scrollbar -### v0.10.1 · *2011-07-24* +### v0.10.1 - *2011-07-24* * fixed problems with ' in links -### v0.10 · *2011-07-24* +### v0.10 - *2011-07-24* * fixed problems with XAMPP on Windows (see `dot.htaccess` comments for instructions) * fixed tree fade-in-fade-out effect for small displays ([issue #6](http://github.com/lrsjng/h5ai/issues/6)) @@ -161,7 +167,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * added "empty" to localization (hope Google Translate did a good job here) -### v0.9 · *2011-07-18* +### v0.9 - *2011-07-18* * linked hover states between crumb, extended view and tree * fixed size of tree view (now there's a ugly scrollbar, hopefully will be fixed) @@ -172,7 +178,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * added sv translation by Oscar Carlsson -### v0.8 · *2011-07-08* +### v0.8 - *2011-07-08* * removed slashes from folder labels * optionally rename parent folder entries to real folder names, see `options.js` @@ -181,19 +187,19 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * refactored js a lot (again...) -### v0.7 · *2011-07-07* +### v0.7 - *2011-07-07* * removed shadows * smarter tree side bar -### v0.6 · *2011-07-05* +### v0.6 - *2011-07-05* * refactored js * added localization, see `options.js` -### v0.5.3 · *2011-07-04* +### v0.5.3 - *2011-07-04* * refactored js * added basic options support via `options.js` @@ -201,24 +207,24 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * optional tree sidebar -### v0.5.2 · *2011-07-02* +### v0.5.2 - *2011-07-02* * details view adjusts to window width * linked icon for *.gz and *.bz2 -### v0.5.1 · *2011-07-01* +### v0.5.1 - *2011-07-01* * disabled tree sidebar for now, since it had unwanted side effects -### v0.5 · *2011-07-01* +### v0.5 - *2011-07-01* * added tree sidebar * some refactorings -### v0.4 · *2011-06-27* +### v0.4 - *2011-06-27* * added better fallback, in case JavaScript is disabled * rewrote js, fixed middle-button click etc. problems @@ -227,20 +233,20 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * updated dot.access -### v0.3.2 · *2011-06-24* +### v0.3.2 - *2011-06-24* * removed lib versions from file names * added 'empty' indicator for icons view -### v0.3.1 · *2011-06-24* +### v0.3.1 - *2011-06-24* * refactored js * added `folderClick` and `fileClick` callback hooks * fixed .emtpy style -### v0.3 · *2011-06-23* +### v0.3 - *2011-06-23* * included build stuff, files previously found in the base directory are now located in folder `target` * styles and scripts are now minified @@ -248,20 +254,20 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * updated jQuery to version 1.6.1 -### v0.2.3 · *2011-06-17* +### v0.2.3 - *2011-06-17* * more refactoring in main.js * ~~added custom js support, and global includes~~ *removed, only custom top and bottom sections supported* -### v0.2.2 · *2011-06-16* +### v0.2.2 - *2011-06-16* * refactored a lot, added some comments * included fixes from [NumEricR](http://github.com/NumEricR) * added top/bottom message support, only basicly styled -### v0.2.1 · *2011-06-16* +### v0.2.1 - *2011-06-16* * fixed croped filenames * fixed missing .png extension in header @@ -269,7 +275,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * added changelog -### v0.2 · *2011-06-15* +### v0.2 - *2011-06-15* * added icon view diff --git a/build.properties b/build.properties index 93189df2..7df81595 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ custom = true # project project.name = h5ai -project.version = 0.17 +project.version = 0.18 # src diff --git a/build.xml b/build.xml index 864063e9..00c3ef52 100644 --- a/build.xml +++ b/build.xml @@ -49,9 +49,6 @@ - - - From 231ba3013ba6cedce64a703233ca1a29e13e196c Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sun, 12 Feb 2012 21:59:17 +0100 Subject: [PATCH 02/36] Updates es translation. --- src/_h5ai/config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index 0a004027..daf52f25 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -249,9 +249,9 @@ var H5AI_CONFIG = { "size": "Tamaño", "parentDirectory": "Directorio superior", "empty": "vacío", - "folders": "folders", - "files": "files", - "download": "download" + "folders": "Directorios", + "files": "Archivos", + "download": "Descargar" }, "fr": { From 20858a1f4371fa1deb7985044ba2c8b8f78216c3 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sun, 12 Feb 2012 22:35:38 +0100 Subject: [PATCH 03/36] Switches indentation to tabs. --- README.md | 1 + build.xml | 118 ++-- src/_h5ai/.htaccess | 24 +- src/_h5ai/config.js | 734 ++++++++++----------- src/_h5ai/css/inc/extended.less | 506 +++++++------- src/_h5ai/css/inc/main.less | 378 +++++------ src/_h5ai/css/inc/mixins.less | 36 +- src/_h5ai/css/inc/responsive.less | 42 +- src/_h5ai/css/inc/table.less | 122 ++-- src/_h5ai/css/inc/tree.less | 244 +++---- src/_h5ai/css/main-js.less | 1 - src/_h5ai/css/main-php.less | 10 +- src/_h5ai/footer.html | 64 +- src/_h5ai/footer.php | 4 +- src/_h5ai/header.html | 46 +- src/_h5ai/header.php | 102 +-- src/_h5ai/js/inc/Connector.js | 178 ++--- src/_h5ai/js/inc/Core.js | 678 +++++++++---------- src/_h5ai/js/inc/Extended.js | 202 +++--- src/_h5ai/js/inc/Html.js | 428 ++++++------ src/_h5ai/js/inc/Path.js | 152 ++--- src/_h5ai/js/inc/Sort.js | 260 ++++---- src/_h5ai/js/inc/Util.js | 192 +++--- src/_h5ai/js/inc/ZippedDownload.js | 176 ++--- src/_h5ai/js/inc/lib/jquery.mousewheel.js | 113 ++-- src/_h5ai/js/inc/lib/jquery.scrollpanel.js | 248 +++---- src/_h5ai/js/main-js.js | 32 +- src/_h5ai/js/main-php.js | 26 +- src/_h5ai/php/api.php | 130 ++-- src/_h5ai/php/inc/Cache.php | 118 ++-- src/_h5ai/php/inc/Crumb.php | 76 +-- src/_h5ai/php/inc/Customize.php | 32 +- src/_h5ai/php/inc/Extended.php | 220 +++--- src/_h5ai/php/inc/H5ai.php | 478 +++++++------- src/_h5ai/php/inc/Image.php | 258 ++++---- src/_h5ai/php/inc/Thumbnail.php | 74 +-- src/_h5ai/php/inc/Tree.php | 214 +++--- src/_h5ai/php/inc/ZipIt.php | 92 +-- tools/wepp.ant.xml | 68 +- 39 files changed, 3437 insertions(+), 3440 deletions(-) diff --git a/README.md b/README.md index 05b54482..f1e8fe96 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h ### v0.18 - *2012-02-??* * updates year in `LICENSE.TXT` +* updates es translation ### v0.17 - *2011-11-28* diff --git a/build.xml b/build.xml index 00c3ef52..7b6b1313 100644 --- a/build.xml +++ b/build.xml @@ -1,75 +1,75 @@ - + - - - - - - - Build: ${build.label} - + + + + + + + Build: ${build.label} + - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + - - JSLint "${tool.jsxint.file}" - - - - + + JSLint "${tool.jsxint.file}" + + + + - - JSHint "${tool.jsxint.file}" - - - - + + JSHint "${tool.jsxint.file}" + + + + - - + + diff --git a/src/_h5ai/.htaccess b/src/_h5ai/.htaccess index 467dfb32..ec4f2924 100644 --- a/src/_h5ai/.htaccess +++ b/src/_h5ai/.htaccess @@ -19,17 +19,17 @@ AddType text/html .php # cache images, css and js for 52 weeks - - Header set Cache-Control "max-age=31449600, public" - - - Header set Cache-Control "max-age=31449600, public" - - - Header set Cache-Control "max-age=31449600, public" - - - Header set Cache-Control "max-age=31449600, public" - + + Header set Cache-Control "max-age=31449600, public" + + + Header set Cache-Control "max-age=31449600, public" + + + Header set Cache-Control "max-age=31449600, public" + + + Header set Cache-Control "max-age=31449600, public" + diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index daf52f25..b95f9d8f 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -7,405 +7,405 @@ var H5AI_CONFIG = { - "options": { + "options": { - /* - * The absolute links to webroot and h5ai. - * Do not change this unless you know what you are doing. - */ - "rootAbsHref": "/", - "h5aiAbsHref": "/_h5ai/", + /* + * The absolute links to webroot and h5ai. + * Do not change this unless you know what you are doing. + */ + "rootAbsHref": "/", + "h5aiAbsHref": "/_h5ai/", - /* - * Filenames of customized header and footer files to look for - * in each folder. - */ - "customHeader": "_h5ai.header.html", - "customFooter": "_h5ai.footer.html", + /* + * Filenames of customized header and footer files to look for + * in each folder. + */ + "customHeader": "_h5ai.header.html", + "customFooter": "_h5ai.footer.html", - /* - * An array of view modes the user may choose from. Currently there - * are two possible values: "details" and "icons". The first value - * indicates the default view mode. If only one value is given the - * view mode is fixed and the selector buttons are hidden. - * The user selected view mode is also stored local in modern browsers - * so that it will be persistent. - */ - "viewmodes": ["details", "icons"], + /* + * An array of view modes the user may choose from. Currently there + * are two possible values: "details" and "icons". The first value + * indicates the default view mode. If only one value is given the + * view mode is fixed and the selector buttons are hidden. + * The user selected view mode is also stored local in modern browsers + * so that it will be persistent. + */ + "viewmodes": ["details", "icons"], - /* - * Default sort order is a two letter code. The first letter specifies - * the column: "n" for "Name", "d" for "Date" or "s" for "Size". The - * second letter specifies the sort order: "a" for "ascending" or "d" - * for "descending". - */ - "sortorder": "na", + /* + * Default sort order is a two letter code. The first letter specifies + * the column: "n" for "Name", "d" for "Date" or "s" for "Size". The + * second letter specifies the sort order: "a" for "ascending" or "d" + * for "descending". + */ + "sortorder": "na", - /* - * Show a folder tree, boolean. - * Note that this tree might have side effects as it sends HEAD requests - * to the folders, and therefore will invoke index.php scripts. Use - * folderStatus below to avoid such requests. - * It might also affect performance significantly. - */ - "showTree": true, + /* + * Show a folder tree, boolean. + * Note that this tree might have side effects as it sends HEAD requests + * to the folders, and therefore will invoke index.php scripts. Use + * folderStatus below to avoid such requests. + * It might also affect performance significantly. + */ + "showTree": true, - /* - * Slide tree bar into viewport if there is enough space, boolean. - */ - "slideTree": true, + /* + * Slide tree bar into viewport if there is enough space, boolean. + */ + "slideTree": true, - /* - * Associative array of folders and their HTTP status codes to - * avoid HEAD requests to that folders. The key (folder) must start - * and end with a slash (/). - * For example: - * "/some/folder/": 200 - * will always return HTTP status 200 (OK), which will be interpreted - * as a non auto indexed folder, that means a folder containing an - * appropriate default index file. - */ - "folderStatus": {}, + /* + * Associative array of folders and their HTTP status codes to + * avoid HEAD requests to that folders. The key (folder) must start + * and end with a slash (/). + * For example: + * "/some/folder/": 200 + * will always return HTTP status 200 (OK), which will be interpreted + * as a non auto indexed folder, that means a folder containing an + * appropriate default index file. + */ + "folderStatus": {}, - /* - * Localization, for example "en", "de" etc. - see h5aiLangs below for - * possible values. Adjust it to your needs. If lang is not found in - * h5aiLangs it defaults to "en". - */ - "lang": "en", + /* + * Localization, for example "en", "de" etc. - see h5aiLangs below for + * possible values. Adjust it to your needs. If lang is not found in + * h5aiLangs it defaults to "en". + */ + "lang": "en", - /* - * Try to use browser language, falls back to previous specified lang. - */ - "useBrowserLang": true, + /* + * Try to use browser language, falls back to previous specified lang. + */ + "useBrowserLang": true, - /* - * Set parent folder labels to real folder names. - */ - "setParentFolderLabels": true, + /* + * Set parent folder labels to real folder names. + */ + "setParentFolderLabels": true, - /* - * Link the hover effects between crumb, extended view and tree. - */ - "linkHoverStates": true, + /* + * Link the hover effects between crumb, extended view and tree. + */ + "linkHoverStates": true, - /* - * Date format in detailed view, for example: "yyyy-MM-dd HH:mm:ss" - * Syntax as specified by date.js - * http://code.google.com/p/datejs/wiki/FormatSpecifiers - */ - "dateFormat": "yyyy-MM-dd HH:mm", + /* + * Date format in detailed view, for example: "yyyy-MM-dd HH:mm:ss" + * Syntax as specified by date.js + * http://code.google.com/p/datejs/wiki/FormatSpecifiers + */ + "dateFormat": "yyyy-MM-dd HH:mm", - /* - * Requires PHP on the server. - * Show thumbnails for image files. - */ - "showThumbs": false, + /* + * Requires PHP on the server. + * Show thumbnails for image files. + */ + "showThumbs": false, - /* - * Requires PHP on the server. - * Enable zipped download of selected entries. - */ - "zippedDownload": false - }, + /* + * Requires PHP on the server. + * Enable zipped download of selected entries. + */ + "zippedDownload": false + }, - /* - * File types mapped to file extensions. - */ - "types": { - "archive": [".tar.bz2", ".tar.gz", ".tgz"], - "audio": [".aif", ".m4a", ".mid", ".mp3", ".mpa", ".ra", ".ogg", ".wav", ".wma"], - "authors": ["authors"], - "bin": [".class", ".o", ".so"], - "blank": [], - "bmp": [".bmp"], - "c": [".c"], - "calc": [".ods", ".ots", ".xlr", ".xls", ".xlsx"], - "cd": [".cue", ".iso"], - "copying": ["copying", "license"], - "cpp": [".cpp"], - "css": [".css", ".less"], - "deb": [".deb"], - "default": [], - "doc": [".doc", ".docx", ".odm", ".odt", ".ott"], - "draw": [".drw"], - "eps": [".eps"], - "exe": [".exe"], - "folder": [], - "folder-home": [], - "folder-open": [], - "folder-page": [], - "folder-parent": [], - "gif": [".gif"], - "gzip": [".gz"], - "h": [".h"], - "hpp": [".hpp"], - "html": [".htm", ".html", ".shtml"], - "ico": [".ico"], - "image": [".xpm"], - "install": ["install"], - "java": [".java"], - "jpg": [".jpg", ".jpeg"], - "js": [".js", ".json"], - "log": [".log", "changelog"], - "makefile": [".pom", "build.xml", "pom.xml"], - "package": [], - "pdf": [".pdf"], - "php": [".php"], - "playlist": [".m3u"], - "png": [".png"], - "pres": [".odp", ".otp", ".pps", ".ppt", ".pptx"], - "psd": [".psd"], - "py": [".py"], - "rar": [".rar"], - "rb": [".rb"], - "readme": ["readme"], - "rpm": [".rpm"], - "rss": [".rss"], - "rtf": [".rtf"], - "script": [".conf", ".csh", ".ini", ".ksh", ".sh", ".shar", ".tcl"], - "source": [], - "sql": [], - "tar": [".tar"], - "tex": [".tex"], - "text": [".markdown", ".md", ".text", ".txt"], - "tiff": [".tiff"], - "unknown": [], - "vcal": [".vcal"], - "video": [".avi", ".flv", ".mov", ".mp4", ".mpg", ".rm", ".swf", ".vob", ".wmv"], - "xml": [".xml"], - "zip": [".bz2", ".jar", ".war", ".z", ".Z", ".zip"] - }, + /* + * File types mapped to file extensions. + */ + "types": { + "archive": [".tar.bz2", ".tar.gz", ".tgz"], + "audio": [".aif", ".m4a", ".mid", ".mp3", ".mpa", ".ra", ".ogg", ".wav", ".wma"], + "authors": ["authors"], + "bin": [".class", ".o", ".so"], + "blank": [], + "bmp": [".bmp"], + "c": [".c"], + "calc": [".ods", ".ots", ".xlr", ".xls", ".xlsx"], + "cd": [".cue", ".iso"], + "copying": ["copying", "license"], + "cpp": [".cpp"], + "css": [".css", ".less"], + "deb": [".deb"], + "default": [], + "doc": [".doc", ".docx", ".odm", ".odt", ".ott"], + "draw": [".drw"], + "eps": [".eps"], + "exe": [".exe"], + "folder": [], + "folder-home": [], + "folder-open": [], + "folder-page": [], + "folder-parent": [], + "gif": [".gif"], + "gzip": [".gz"], + "h": [".h"], + "hpp": [".hpp"], + "html": [".htm", ".html", ".shtml"], + "ico": [".ico"], + "image": [".xpm"], + "install": ["install"], + "java": [".java"], + "jpg": [".jpg", ".jpeg"], + "js": [".js", ".json"], + "log": [".log", "changelog"], + "makefile": [".pom", "build.xml", "pom.xml"], + "package": [], + "pdf": [".pdf"], + "php": [".php"], + "playlist": [".m3u"], + "png": [".png"], + "pres": [".odp", ".otp", ".pps", ".ppt", ".pptx"], + "psd": [".psd"], + "py": [".py"], + "rar": [".rar"], + "rb": [".rb"], + "readme": ["readme"], + "rpm": [".rpm"], + "rss": [".rss"], + "rtf": [".rtf"], + "script": [".conf", ".csh", ".ini", ".ksh", ".sh", ".shar", ".tcl"], + "source": [], + "sql": [], + "tar": [".tar"], + "tex": [".tex"], + "text": [".markdown", ".md", ".text", ".txt"], + "tiff": [".tiff"], + "unknown": [], + "vcal": [".vcal"], + "video": [".avi", ".flv", ".mov", ".mp4", ".mpg", ".rm", ".swf", ".vob", ".wmv"], + "xml": [".xml"], + "zip": [".bz2", ".jar", ".war", ".z", ".Z", ".zip"] + }, - /* - * Available translations. - */ - "langs": { + /* + * Available translations. + */ + "langs": { - "en": { - "lang": "english", - "details": "details", - "icons": "icons", - "name": "Name", - "lastModified": "Last modified", - "size": "Size", - "parentDirectory": "Parent Directory", - "empty": "empty", - "folders": "folders", - "files": "files", - "download": "download" - }, + "en": { + "lang": "english", + "details": "details", + "icons": "icons", + "name": "Name", + "lastModified": "Last modified", + "size": "Size", + "parentDirectory": "Parent Directory", + "empty": "empty", + "folders": "folders", + "files": "files", + "download": "download" + }, - "bg": { - "lang": "български", - "details": "детайли", - "icons": "икони", - "name": "Име", - "lastModified": "Последна промяна", - "size": "Размер", - "parentDirectory": "Предходна директория", - "empty": "празно", - "folders": "папки", - "files": "файлове", - "download": "download" - }, + "bg": { + "lang": "български", + "details": "детайли", + "icons": "икони", + "name": "Име", + "lastModified": "Последна промяна", + "size": "Размер", + "parentDirectory": "Предходна директория", + "empty": "празно", + "folders": "папки", + "files": "файлове", + "download": "download" + }, - "cs": { - "lang": "čeština", - "details": "podrobnosti", - "icons": "ikony", - "name": "Název", - "lastModified": "Upraveno", - "size": "Velikost", - "parentDirectory": "Nadřazený adresář", - "empty": "prázdný", - "folders": "složek", - "files": "souborů", - "download": "download" - }, + "cs": { + "lang": "čeština", + "details": "podrobnosti", + "icons": "ikony", + "name": "Název", + "lastModified": "Upraveno", + "size": "Velikost", + "parentDirectory": "Nadřazený adresář", + "empty": "prázdný", + "folders": "složek", + "files": "souborů", + "download": "download" + }, - "de": { - "lang": "deutsch", - "details": "Details", - "icons": "Icons", - "name": "Name", - "lastModified": "Geändert", - "size": "Größe", - "parentDirectory": "Übergeordnetes Verzeichnis", - "empty": "leer", - "folders": "Ordner", - "files": "Dateien", - "download": "Download" - }, + "de": { + "lang": "deutsch", + "details": "Details", + "icons": "Icons", + "name": "Name", + "lastModified": "Geändert", + "size": "Größe", + "parentDirectory": "Übergeordnetes Verzeichnis", + "empty": "leer", + "folders": "Ordner", + "files": "Dateien", + "download": "Download" + }, - "es": { - "lang": "español", - "details": "Detalles", - "icons": "Íconos", - "name": "Nombre", - "lastModified": "Última modificación", - "size": "Tamaño", - "parentDirectory": "Directorio superior", - "empty": "vacío", - "folders": "Directorios", - "files": "Archivos", - "download": "Descargar" - }, + "es": { + "lang": "español", + "details": "Detalles", + "icons": "Íconos", + "name": "Nombre", + "lastModified": "Última modificación", + "size": "Tamaño", + "parentDirectory": "Directorio superior", + "empty": "vacío", + "folders": "Directorios", + "files": "Archivos", + "download": "Descargar" + }, - "fr": { - "lang": "français", - "details": "détails", - "icons": "icônes", - "name": "Nom", - "lastModified": "Dernière modification", - "size": "Taille", - "parentDirectory": "Dossier parent", - "empty": "vide", - "folders": "Répertoires", - "files": "Fichiers", - "download": "télécharger" - }, + "fr": { + "lang": "français", + "details": "détails", + "icons": "icônes", + "name": "Nom", + "lastModified": "Dernière modification", + "size": "Taille", + "parentDirectory": "Dossier parent", + "empty": "vide", + "folders": "Répertoires", + "files": "Fichiers", + "download": "télécharger" + }, - "it": { - "lang": "italiano", - "details": "dettagli", - "icons": "icone", - "name": "Nome", - "lastModified": "Ultima modifica", - "size": "Dimensione", - "parentDirectory": "Cartella Superiore", - "empty": "vuota", - "folders": "cartelle", - "files": "file", - "download": "download" - }, + "it": { + "lang": "italiano", + "details": "dettagli", + "icons": "icone", + "name": "Nome", + "lastModified": "Ultima modifica", + "size": "Dimensione", + "parentDirectory": "Cartella Superiore", + "empty": "vuota", + "folders": "cartelle", + "files": "file", + "download": "download" + }, - "lv": { - "lang": "latviešu", - "details": "detaļas", - "icons": "ikonas", - "name": "Nosaukums", - "lastModified": "Pēdējoreiz modificēts", - "size": "Izmērs", - "parentDirectory": "Vecākdirektorijs", - "empty": "tukšs", - "folders": "mapes", - "files": "faili", - "download": "lejupielādēt" - }, + "lv": { + "lang": "latviešu", + "details": "detaļas", + "icons": "ikonas", + "name": "Nosaukums", + "lastModified": "Pēdējoreiz modificēts", + "size": "Izmērs", + "parentDirectory": "Vecākdirektorijs", + "empty": "tukšs", + "folders": "mapes", + "files": "faili", + "download": "lejupielādēt" + }, - "nl": { - "lang": "nederlands", - "details": "details", - "icons": "iconen", - "name": "Naam", - "lastModified": "Laatste wijziging", - "size": "Grootte", - "parentDirectory": "Bovenliggende map", - "empty": "lege", - "folders": "folders", - "files": "files", - "download": "download" - }, + "nl": { + "lang": "nederlands", + "details": "details", + "icons": "iconen", + "name": "Naam", + "lastModified": "Laatste wijziging", + "size": "Grootte", + "parentDirectory": "Bovenliggende map", + "empty": "lege", + "folders": "folders", + "files": "files", + "download": "download" + }, - "pl": { - "lang": "polski", - "details": "szczegóły", - "icons": "ikony", - "name": "Nazwa", - "lastModified": "Ostatnia modyfikacja", - "size": "Rozmiar", - "parentDirectory": "Katalog nadrzędny", - "empty": "pusty", - "folders": "foldery", - "files": "pliki", - "download": "download" - }, + "pl": { + "lang": "polski", + "details": "szczegóły", + "icons": "ikony", + "name": "Nazwa", + "lastModified": "Ostatnia modyfikacja", + "size": "Rozmiar", + "parentDirectory": "Katalog nadrzędny", + "empty": "pusty", + "folders": "foldery", + "files": "pliki", + "download": "download" + }, - "pt": { - "lang": "português", - "details": "detalhes", - "icons": "ícones", - "name": "Nome", - "lastModified": "Última modificação", - "size": "Tamanho", - "parentDirectory": "Diretório superior", - "empty": "vazio", - "folders": "pastas", - "files": "arquivos", - "download": "download" - }, + "pt": { + "lang": "português", + "details": "detalhes", + "icons": "ícones", + "name": "Nome", + "lastModified": "Última modificação", + "size": "Tamanho", + "parentDirectory": "Diretório superior", + "empty": "vazio", + "folders": "pastas", + "files": "arquivos", + "download": "download" + }, - "ru": { - "lang": "русский", - "details": "детали", - "icons": "иконки", - "name": "Имя", - "lastModified": "Последние изменения", - "size": "Размер", - "parentDirectory": "Главная директория", - "empty": "пусто", - "folders": "папки", - "files": "файлы", - "download": "download" - }, + "ru": { + "lang": "русский", + "details": "детали", + "icons": "иконки", + "name": "Имя", + "lastModified": "Последние изменения", + "size": "Размер", + "parentDirectory": "Главная директория", + "empty": "пусто", + "folders": "папки", + "files": "файлы", + "download": "download" + }, - "sk": { - "lang": "slovenčina", - "details": "podrobnosti", - "icons": "ikony", - "name": "Názov", - "lastModified": "Upravené", - "size": "Velkosť", - "parentDirectory": "Nadriadený priečinok", - "empty": "prázdny", - "folders": "priečinkov", - "files": "súborov", - "download": "download" - }, + "sk": { + "lang": "slovenčina", + "details": "podrobnosti", + "icons": "ikony", + "name": "Názov", + "lastModified": "Upravené", + "size": "Velkosť", + "parentDirectory": "Nadriadený priečinok", + "empty": "prázdny", + "folders": "priečinkov", + "files": "súborov", + "download": "download" + }, - "sv": { - "lang": "svenska", - "details": "detaljerad", - "icons": "ikoner", - "name": "Filnamn", - "lastModified": "Senast ändrad", - "size": "Filstorlek", - "parentDirectory": "Till överordnad mapp", - "empty": "tom", - "folders": "folders", - "files": "files", - "download": "download" - }, + "sv": { + "lang": "svenska", + "details": "detaljerad", + "icons": "ikoner", + "name": "Filnamn", + "lastModified": "Senast ändrad", + "size": "Filstorlek", + "parentDirectory": "Till överordnad mapp", + "empty": "tom", + "folders": "folders", + "files": "files", + "download": "download" + }, - "tr": { - "lang": "türkçe", - "details": "detaylar", - "icons": "ikonlar", - "name": "İsim", - "lastModified": "Son Düzenleme", - "size": "Boyut", - "parentDirectory": "Üst Dizin", - "empty": "boş", - "folders": "klasörler", - "files": "dosyalar", - "download": "indir" - }, + "tr": { + "lang": "türkçe", + "details": "detaylar", + "icons": "ikonlar", + "name": "İsim", + "lastModified": "Son Düzenleme", + "size": "Boyut", + "parentDirectory": "Üst Dizin", + "empty": "boş", + "folders": "klasörler", + "files": "dosyalar", + "download": "indir" + }, - "zh-cn": { - "lang": "简体中文", - "details": "详情", - "icons": "图标", - "name": "文件名", - "lastModified": "上次修改", - "size": "大小", - "parentDirectory": "上层文件夹", - "empty": "空文件夹", - "folders": "文件夹", - "files": "文件", - "download": "download" - } - } + "zh-cn": { + "lang": "简体中文", + "details": "详情", + "icons": "图标", + "name": "文件名", + "lastModified": "上次修改", + "size": "大小", + "parentDirectory": "上层文件夹", + "empty": "空文件夹", + "folders": "文件夹", + "files": "文件", + "download": "download" + } + } }; diff --git a/src/_h5ai/css/inc/extended.less b/src/_h5ai/css/inc/extended.less index 7eaa140d..733360a6 100644 --- a/src/_h5ai/css/inc/extended.less +++ b/src/_h5ai/css/inc/extended.less @@ -1,280 +1,280 @@ #extended.details-view { - display: none; + display: none; - ul { - margin: 0; - padding: 0; - list-style: none; + ul { + margin: 0; + padding: 0; + list-style: none; - li { - position: relative; - white-space: nowrap; - clear: both; + li { + position: relative; + white-space: nowrap; + clear: both; - &.header { - a, a:active, a:visited { - padding-bottom: 18px; - color: #555; - text-decoration: none; - opacity: 0.4; - cursor: pointer; - .transition(all 0.2s ease-in-out); + &.header { + a, a:active, a:visited { + padding-bottom: 18px; + color: #555; + text-decoration: none; + opacity: 0.4; + cursor: pointer; + .transition(all 0.2s ease-in-out); - img.ascending, img.descending { - position: relative; - top: -2px; - display: none; - width: 12px; - height: 12px; - padding: 0 8px; - } - &:hover { - color: #555; - opacity: 0.9; - } - &.ascending img.ascending { - display: inline; - } - &.descending img.descending { - display: inline; - } - } - } - &.entry { + img.ascending, img.descending { + position: relative; + top: -2px; + display: none; + width: 12px; + height: 12px; + padding: 0 8px; + } + &:hover { + color: #555; + opacity: 0.9; + } + &.ascending img.ascending { + display: inline; + } + &.descending img.descending { + display: inline; + } + } + } + &.entry { - a, a:active, a:visited { - display: block; - color: #555; - text-decoration: none; - cursor: pointer; - border-bottom: 1px solid #ddd; + a, a:active, a:visited { + display: block; + color: #555; + text-decoration: none; + cursor: pointer; + border-bottom: 1px solid #ddd; - &:hover, &.hover { - background-color: #f6f6f6; - color: #e80; - } - &.selected:not(.selecting), &.selecting:not(.selected) { - border-color: rgba(240,100,0,0.2); - background-color: rgba(240,100,0,0.2); - } - } - &.error { - a, a:active, a:visited { - color: #aaa; + &:hover, &.hover { + background-color: #f6f6f6; + color: #e80; + } + &.selected:not(.selecting), &.selecting:not(.selected) { + border-color: rgba(240,100,0,0.2); + background-color: rgba(240,100,0,0.2); + } + } + &.error { + a, a:active, a:visited { + color: #aaa; - .label { - .hint { - margin-left: 12px; - font-size: 0.9em; - color: #c55; - } - } - &:hover, &.hover { - opacity: 1; - background-color: #f6f6f6; - color: #e80; - } - } - } - &.folder-parent { - .date, .size { - display: none; - } - } - &.folder { - .size { - display: none; - } - } - } - .icon, .label, .date, .size { - padding: 6px; - } - .icon { - display: inline-block; - position: absolute; - left: 0; - top: -2px; - width: 16px; + .label { + .hint { + margin-left: 12px; + font-size: 0.9em; + color: #c55; + } + } + &:hover, &.hover { + opacity: 1; + background-color: #f6f6f6; + color: #e80; + } + } + } + &.folder-parent { + .date, .size { + display: none; + } + } + &.folder { + .size { + display: none; + } + } + } + .icon, .label, .date, .size { + padding: 6px; + } + .icon { + display: inline-block; + position: absolute; + left: 0; + top: -2px; + width: 16px; - img { - width: 16px; - height: 16px; - &.thumb { - border: 1px solid #eee; - } - } - } - .icon.big { - display: none; - } - .label { - display: block; - margin: 0 270px 0 24px; - overflow: hidden; - white-space: nowrap; - text-align: left; - } - .date { - position: absolute; - right: 100px; - top: 0; - text-align: right; - width: 160px; - white-space: nowrap; - } - .size { - position: absolute; - right: 0; - top: 0; - text-align: right; - width: 80px; - white-space: nowrap; - } - &.entry.thumb .icon.small { - overflow: hidden; - padding: 5px; + img { + width: 16px; + height: 16px; + &.thumb { + border: 1px solid #eee; + } + } + } + .icon.big { + display: none; + } + .label { + display: block; + margin: 0 270px 0 24px; + overflow: hidden; + white-space: nowrap; + text-align: left; + } + .date { + position: absolute; + right: 100px; + top: 0; + text-align: right; + width: 160px; + white-space: nowrap; + } + .size { + position: absolute; + right: 0; + top: 0; + text-align: right; + width: 80px; + white-space: nowrap; + } + &.entry.thumb .icon.small { + overflow: hidden; + padding: 5px; - img { - background-color: #eee; - width: 16px; - height: 16px; - border: 1px solid #ddd; - overflow: hidden; - } - } - } - } - .empty { - text-align: center; - margin: 50px 0; - color: #ddd; - font-size: 5em; - font-weight: bold; - } + img { + background-color: #eee; + width: 16px; + height: 16px; + border: 1px solid #ddd; + overflow: hidden; + } + } + } + } + .empty { + text-align: center; + margin: 50px 0; + color: #ddd; + font-size: 5em; + font-weight: bold; + } } #selection-rect { - display: none; - position: absolute; - left: 0; - top: 0; - z-index: 2; - border: 1px dashed rgba(240,100,0,0.5); - background-color: rgba(240,100,0,0.2); + display: none; + position: absolute; + left: 0; + top: 0; + z-index: 2; + border: 1px dashed rgba(240,100,0,0.5); + background-color: rgba(240,100,0,0.2); } #extended.icons-view { - display: none; - padding: 3px; - border: 1px solid #eee; - border-radius: 15px; + display: none; + padding: 3px; + border: 1px solid #eee; + border-radius: 15px; - ul { - margin: 0; - padding: 0; - list-style: none; + ul { + margin: 0; + padding: 0; + list-style: none; - li { - &.header { - display: none; - } - &.entry { - float: left; + li { + &.header { + display: none; + } + &.entry { + float: left; - a, a:active, a:visited { - display: block; - margin: 8px; - padding: 8px; - width: 100px; - height: 120px; - float: left; - text-align: center; - text-decoration: none; - overflow: hidden; - border-radius: 5px; - color: #555; - cursor: pointer; - border: 2px solid rgba(0,0,0,0); + a, a:active, a:visited { + display: block; + margin: 8px; + padding: 8px; + width: 100px; + height: 120px; + float: left; + text-align: center; + text-decoration: none; + overflow: hidden; + border-radius: 5px; + color: #555; + cursor: pointer; + border: 2px solid rgba(0,0,0,0); - &:hover, &.hover { - color: #e80; - border-color: #eee; - background-color: #f6f6f6; - } - &.selected:not(.selecting), &.selecting:not(.selected) { - border-color: rgba(240,100,0,0.2); - background-color: rgba(240,100,0,0.2); - } - .icon { - display: block; + &:hover, &.hover { + color: #e80; + border-color: #eee; + background-color: #f6f6f6; + } + &.selected:not(.selecting), &.selecting:not(.selected) { + border-color: rgba(240,100,0,0.2); + background-color: rgba(240,100,0,0.2); + } + .icon { + display: block; - img { - min-width: 48px; - min-height: 48px; - margin-bottom: 8px; - &.thumb { - border: 1px solid #eee; - } - } - } - .icon.small { - display: none; - } - .label { - display: block; - word-wrap: break-word; - } - .date, .size { - display: none; - } - } - &.error { - a, a:active, a:visited { - color: #aaa; - text-decoration: none; + img { + min-width: 48px; + min-height: 48px; + margin-bottom: 8px; + &.thumb { + border: 1px solid #eee; + } + } + } + .icon.small { + display: none; + } + .label { + display: block; + word-wrap: break-word; + } + .date, .size { + display: none; + } + } + &.error { + a, a:active, a:visited { + color: #aaa; + text-decoration: none; - .label { - .hint { - padding: 0 6px; - font-size: 0.9em; - color: #c55; - } - } - &:hover, &.hover { - color: #e80; - border-color: #eee; - background-color: #f6f6f6; - } - } - } - } - &.entry.thumb .icon.big { - width: 100px; - height: 58px; - overflow: hidden; + .label { + .hint { + padding: 0 6px; + font-size: 0.9em; + color: #c55; + } + } + &:hover, &.hover { + color: #e80; + border-color: #eee; + background-color: #f6f6f6; + } + } + } + } + &.entry.thumb .icon.big { + width: 100px; + height: 58px; + overflow: hidden; - img { - background-color: #eee; - min-width: 46px; - min-height: 46px; - min-width: 12px; - min-height: 12px; - border: 1px solid #ddd; - overflow: hidden; - } - } - } - } - .empty { - padding: 16px; - height: 120px; - text-align: center; - color: #ddd; - font-size: 5em; - font-weight: bold; - } + img { + background-color: #eee; + min-width: 46px; + min-height: 46px; + min-width: 12px; + min-height: 12px; + border: 1px solid #ddd; + overflow: hidden; + } + } + } + } + .empty { + padding: 16px; + height: 120px; + text-align: center; + color: #ddd; + font-size: 5em; + font-weight: bold; + } } diff --git a/src/_h5ai/css/inc/main.less b/src/_h5ai/css/inc/main.less index d1228985..b1df578f 100644 --- a/src/_h5ai/css/inc/main.less +++ b/src/_h5ai/css/inc/main.less @@ -4,116 +4,116 @@ html.js { - .hideOnJs { - display: none; - } + .hideOnJs { + display: none; + } } html.no-js { - .hideOnNoJs { - display: none; - } + .hideOnNoJs { + display: none; + } } body { - font-family: Ubuntu, sans-serif; - font-size: 16px; - color: #555; - background-color: #fff; - margin: 80px 30px; + font-family: Ubuntu, sans-serif; + font-size: 16px; + color: #555; + background-color: #fff; + margin: 80px 30px; } body > nav { - position: fixed; - z-index: 1; - width: 100%; - left: 0; - top: 0; - font-size: 0.85em; - background-color: rgb(241,241,241); - border-bottom: 2px solid rgb(210,210,210); + position: fixed; + z-index: 1; + width: 100%; + left: 0; + top: 0; + font-size: 0.85em; + background-color: rgb(241,241,241); + border-bottom: 2px solid rgb(210,210,210); - span.jsDisabledFallback { - display: block; - height: 30px; - line-height: 30px; - padding: 0 10px; - color: #999; - } - a, a:active, a:visited { - color: #555; - cursor: pointer; - text-decoration: none; - opacity: 0.7; - .transition(all 0.2s ease-in-out); + span.jsDisabledFallback { + display: block; + height: 30px; + line-height: 30px; + padding: 0 10px; + color: #999; + } + a, a:active, a:visited { + color: #555; + cursor: pointer; + text-decoration: none; + opacity: 0.7; + .transition(all 0.2s ease-in-out); - display: block; - height: 30px; - line-height: 30px; - padding: 0 10px; + display: block; + height: 30px; + line-height: 30px; + padding: 0 10px; - &:hover, &.hover { - color: #e80; - background-color: rgba(255,255,255,0.5); - opacity: 1.0; - } - } - .current a { - background-color: rgba(255,255,255,0.5); - opacity: 1.0; - } - img { - position: relative; - top: -2px; - width: 16px; - height: 16px; - } - img + span { - margin-left: 6px; - } - .crumb { - float: left; - border-right: 1px solid rgb(231,231,231); - .hint { - margin-left: 8px; - font-style: italic; - color: #999; - } - img.hint { - width: 10px; - height: 10px; - } - } - .view { - float: right; - border-left: 1px solid rgb(231,231,231); - } - #download { - display: none; - float: right; - border-left: 1px solid rgb(231,231,231); - } + &:hover, &.hover { + color: #e80; + background-color: rgba(255,255,255,0.5); + opacity: 1.0; + } + } + .current a { + background-color: rgba(255,255,255,0.5); + opacity: 1.0; + } + img { + position: relative; + top: -2px; + width: 16px; + height: 16px; + } + img + span { + margin-left: 6px; + } + .crumb { + float: left; + border-right: 1px solid rgb(231,231,231); + .hint { + margin-left: 8px; + font-style: italic; + color: #999; + } + img.hint { + width: 10px; + height: 10px; + } + } + .view { + float: right; + border-left: 1px solid rgb(231,231,231); + } + #download { + display: none; + float: right; + border-left: 1px solid rgb(231,231,231); + } } #content { - max-width: 960px; - margin: 0 auto; + max-width: 960px; + margin: 0 auto; - > header { - display: none; - padding-bottom: 10px; - margin-bottom: 80px; - border-bottom: 2px dashed #ddd; - } - > footer { - display: none; - padding-top: 10px; - margin-top: 80px; - border-top: 2px dashed #ddd; - } + > header { + display: none; + padding-bottom: 10px; + margin-bottom: 80px; + border-bottom: 2px dashed #ddd; + } + > footer { + display: none; + padding-top: 10px; + margin-top: 80px; + border-top: 2px dashed #ddd; + } } @@ -123,114 +123,114 @@ body > nav { body > footer { - position: fixed; - z-index: 1; - width: 100%; - left: 0; - bottom: 0; - padding: 6px 0 8px 0; - background-color: rgb(241,241,241); - border-top: 2px solid rgb(210,210,210); + position: fixed; + z-index: 1; + width: 100%; + left: 0; + bottom: 0; + padding: 6px 0 8px 0; + background-color: rgb(241,241,241); + border-top: 2px solid rgb(210,210,210); - color: #999; - font-size: 0.85em; - text-align: center; + color: #999; + font-size: 0.85em; + text-align: center; - a, a:active, a:visited { - color: #555; - text-decoration: none; - .transition(all 0.2s ease-in-out); - opacity: 0.7; + a, a:active, a:visited { + color: #555; + text-decoration: none; + .transition(all 0.2s ease-in-out); + opacity: 0.7; - &:hover { - color: #e80; - opacity: 1; - } - } - .left { - display: block; - padding: 0 8px; - float: left - } - .center { - display: block; - margin: 0 100px; - } - .right { - display: block; - padding: 0 8px; - float: right - } - .noJsMsg { - color: #c33; - margin-left: 16px; - } - .status { - .sep { - display: inline-block; - padding: 0 6px; - } - &.default { - } - &.dynamic { - display: none; - } - } - #langSelector { - position: relative; - cursor: pointer; + &:hover { + color: #e80; + opacity: 1; + } + } + .left { + display: block; + padding: 0 8px; + float: left + } + .center { + display: block; + margin: 0 100px; + } + .right { + display: block; + padding: 0 8px; + float: right + } + .noJsMsg { + color: #c33; + margin-left: 16px; + } + .status { + .sep { + display: inline-block; + padding: 0 6px; + } + &.default { + } + &.dynamic { + display: none; + } + } + #langSelector { + position: relative; + cursor: pointer; - .langOptions { - position: absolute; - z-index: 2; - overflow: auto; - display: none; - right: 0; - top: 0; - max-height: 200px; - background-color: rgb(241,241,241); - border: 1px solid rgb(210,210,210); + .langOptions { + position: absolute; + z-index: 2; + overflow: auto; + display: none; + right: 0; + top: 0; + max-height: 200px; + background-color: rgb(241,241,241); + border: 1px solid rgb(210,210,210); - > .scrollbar { - margin: 0; - width: 6px; - background-color: rgb(210,210,210); + > .scrollbar { + margin: 0; + width: 6px; + background-color: rgb(210,210,210); - .drag { - background-color: rgb(180,180,180); - } - &.dragOn .drag { - background-color: rgb(150,150,150); - } - } + .drag { + background-color: rgb(180,180,180); + } + &.dragOn .drag { + background-color: rgb(150,150,150); + } + } - ul { - margin: 0; - padding: 0; - list-style: none; - text-align: left; + ul { + margin: 0; + padding: 0; + list-style: none; + text-align: left; - li { - padding: 8px 24px 10px 24px; - white-space: nowrap; - border-top: 1px solid rgb(231,231,231); - .transition(all 0.2s ease-in-out); + li { + padding: 8px 24px 10px 24px; + white-space: nowrap; + border-top: 1px solid rgb(231,231,231); + .transition(all 0.2s ease-in-out); - &.current { - color: #333; - background-color: rgba(255,255,255,0.8); - } - &:hover { - color: #e80; - background-color: rgba(255,255,255,0.8); - } - } - li:nth-child(3n+1) { + &.current { + color: #333; + background-color: rgba(255,255,255,0.8); + } + &:hover { + color: #e80; + background-color: rgba(255,255,255,0.8); + } + } + li:nth-child(3n+1) { - } - } - } - } + } + } + } + } } @import "responsive"; diff --git a/src/_h5ai/css/inc/mixins.less b/src/_h5ai/css/inc/mixins.less index 7bc06916..4e2f8847 100644 --- a/src/_h5ai/css/inc/mixins.less +++ b/src/_h5ai/css/inc/mixins.less @@ -1,38 +1,38 @@ .border-radius (@radius) { - -moz-border-radius: @radius; - -webkit-border-radius: @radius; - border-radius: @radius; + -moz-border-radius: @radius; + -webkit-border-radius: @radius; + border-radius: @radius; } .box-shadow (@shadow) { - -moz-box-shadow: @shadow; - -webkit-box-shadow: @shadow; - box-shadow: @shadow; + -moz-box-shadow: @shadow; + -webkit-box-shadow: @shadow; + box-shadow: @shadow; } .transition (@transition) { - -moz-transition: @transition; - -ms-transition: @transition; - -o-transition: @transition; - -webkit-transition: @transition; - transition: @transition; + -moz-transition: @transition; + -ms-transition: @transition; + -o-transition: @transition; + -webkit-transition: @transition; + transition: @transition; } .transform (@transform) { - -moz-transform: @transform; - -o-transform: @transform; - -webkit-transform: @transform; - transform: @transform; + -moz-transform: @transform; + -o-transform: @transform; + -webkit-transform: @transform; + transform: @transform; } .background-size (@size) { - -moz-background-size: @size; - -webkit-background-size: @size; - background-size: @size; + -moz-background-size: @size; + -webkit-background-size: @size; + background-size: @size; } diff --git a/src/_h5ai/css/inc/responsive.less b/src/_h5ai/css/inc/responsive.less index 7b38e320..ffe47861 100644 --- a/src/_h5ai/css/inc/responsive.less +++ b/src/_h5ai/css/inc/responsive.less @@ -1,36 +1,36 @@ @media only screen and (max-width: 500px) { body > nav { - .view span { - display: none; - } + .view span { + display: none; + } } #extended.icons-view { - padding: 0; - border: none; - margin: 0 -14px; + padding: 0; + border: none; + margin: 0 -14px; } } @media only screen and (max-width: 350px) { body > nav { - .crumb { - display: none; - } - .current { - display: block; - } + .crumb { + display: none; + } + .current { + display: block; + } } #extended.details-view { - .header .label, .entry .label { - margin-right: 110px; - } - .header .date, .entry .date { - display: none; - } + .header .label, .entry .label { + margin-right: 110px; + } + .header .date, .entry .date { + display: none; + } } body > footer { - .center { - display: none; - } + .center { + display: none; + } } } diff --git a/src/_h5ai/css/inc/table.less b/src/_h5ai/css/inc/table.less index 22881893..cfd5241b 100644 --- a/src/_h5ai/css/inc/table.less +++ b/src/_h5ai/css/inc/table.less @@ -1,68 +1,68 @@ #table { - table { - display: block; - width: 100%; - border-collapse: collapse; + table { + display: block; + width: 100%; + border-collapse: collapse; - th, td { - padding: 3px 6px; - text-align: left; - border: none; - } - th { - padding-bottom: 18px; - opacity: 0.4; - .transition(all 0.2s ease-in-out); + th, td { + padding: 3px 6px; + text-align: left; + border: none; + } + th { + padding-bottom: 18px; + opacity: 0.4; + .transition(all 0.2s ease-in-out); - &:hover, &:hover a { - color: #555; - cursor: pointer; - opacity: 0.9; - } - a, a:visited { - color: #555; - font-weight: normal; + &:hover, &:hover a { + color: #555; + cursor: pointer; + opacity: 0.9; + } + a, a:visited { + color: #555; + font-weight: normal; - img { - width: 12px; - height: 12px; - padding: 0 8px; - } - } - } - td { - border: 1px solid #ddd; - border-left: none; - border-right: none; - } - td:nth-child(1), th:nth-child(1) { - text-align: center; - width: 16px; + img { + width: 12px; + height: 12px; + padding: 0 8px; + } + } + } + td { + border: 1px solid #ddd; + border-left: none; + border-right: none; + } + td:nth-child(1), th:nth-child(1) { + text-align: center; + width: 16px; - img { - width: 16px; - height: 16px; - padding-top: 2px; - } - } - td:nth-child(2), th:nth-child(2) { - width: 682px; - max-width: 682px; - overflow: hidden; - white-space: nowrap; - } - td:nth-child(3), th:nth-child(3) { - text-align: right; - width: 160px; - min-width: 160px; - white-space: nowrap; - } - td:nth-child(4), th:nth-child(4) { - text-align: right; - width: 70px; - min-width: 70px; - white-space: nowrap; - } - } + img { + width: 16px; + height: 16px; + padding-top: 2px; + } + } + td:nth-child(2), th:nth-child(2) { + width: 682px; + max-width: 682px; + overflow: hidden; + white-space: nowrap; + } + td:nth-child(3), th:nth-child(3) { + text-align: right; + width: 160px; + min-width: 160px; + white-space: nowrap; + } + td:nth-child(4), th:nth-child(4) { + text-align: right; + width: 70px; + min-width: 70px; + white-space: nowrap; + } + } } diff --git a/src/_h5ai/css/inc/tree.less b/src/_h5ai/css/inc/tree.less index b35b488f..0862cef0 100644 --- a/src/_h5ai/css/inc/tree.less +++ b/src/_h5ai/css/inc/tree.less @@ -1,130 +1,130 @@ #tree { - display: none; - position: fixed; - left: 0; - top: 82px; - z-index: 1; - overflow: auto; - font-size: 0.85em; - padding: 8px; - background-color: rgb(241,241,241); - border: 1px solid rgb(210,210,210); - border-left: none; - .border-radius(0 10px 10px 0); + display: none; + position: fixed; + left: 0; + top: 82px; + z-index: 1; + overflow: auto; + font-size: 0.85em; + padding: 8px; + background-color: rgb(241,241,241); + border: 1px solid rgb(210,210,210); + border-left: none; + .border-radius(0 10px 10px 0); - > .scrollbar { - margin: 8px 8px 8px 0; - width: 6px; - background-color: rgb(210,210,210); - .border-radius(3px); + > .scrollbar { + margin: 8px 8px 8px 0; + width: 6px; + background-color: rgb(210,210,210); + .border-radius(3px); - .drag { - background-color: rgb(180,180,180); - .border-radius(3px); - } - &.dragOn .drag { - background-color: rgb(150,150,150); - } - } + .drag { + background-color: rgb(180,180,180); + .border-radius(3px); + } + &.dragOn .drag { + background-color: rgb(150,150,150); + } + } - .entry { - .blank, .indicator { - display: inline-block; - width: 16px; - height: 25px; - float: left; - } - .indicator { - opacity: 0.7; - .transition(all 0.2s ease-in-out); - cursor: pointer; + .entry { + .blank, .indicator { + display: inline-block; + width: 16px; + height: 25px; + float: left; + } + .indicator { + opacity: 0.7; + .transition(all 0.2s ease-in-out); + cursor: pointer; - &:hover { - opacity: 1; - } - img { - position: relative; - left: 0; - top: 3px; - width: 12px; - height: 12px; - vertical-align: bottom; - .transition(all 0.2s ease-in-out); - } - &.open { - img { - .transform(rotate(90deg)); - } - } - &.unknown { - opacity: 0.3; - } - } - > a, > a:active, > a.visited { - margin-left: 16px; - padding: 4px 6px; - border: 1px solid rgba(0,0,0,0); - .border-radius(5px); - display: block; - color: #555; - text-decoration: none; - opacity: 0.7; + &:hover { + opacity: 1; + } + img { + position: relative; + left: 0; + top: 3px; + width: 12px; + height: 12px; + vertical-align: bottom; + .transition(all 0.2s ease-in-out); + } + &.open { + img { + .transform(rotate(90deg)); + } + } + &.unknown { + opacity: 0.3; + } + } + > a, > a:active, > a.visited { + margin-left: 16px; + padding: 4px 6px; + border: 1px solid rgba(0,0,0,0); + .border-radius(5px); + display: block; + color: #555; + text-decoration: none; + opacity: 0.7; - &:hover, &.hover { - color: #e80; - background-color: rgba(255,255,255,0.5); - opacity: 1; - } - .label { - display: inline-block; - } - .icon { - display: inline-block; - width: 20px; - img { - width: 16px; - height: 16px; - vertical-align: bottom; - } - } - .hint { - display: inline-block; - margin-left: 12px; - font-size: 0.9em; - color: #ccc; - img { - width: 10px; - height: 10px; - vertical-align: baseline; - } - } - } - &.file { - display: none; - } - &.current { - > a, > a:active, > a:visited { - border: 1px solid rgb(221,221,221); - background-color: rgba(255,255,255,0.5); - opacity: 1; - } - } - &.error { - > a, > a:active, > a:visited { - color: #999; - &:hover, &.hover { - color: #e80; - } - } - .hint { - color: #c55; - } - } - .content, ul.content { - list-style: none; - margin: 0; - padding: 0 0 0 24px; - } - } + &:hover, &.hover { + color: #e80; + background-color: rgba(255,255,255,0.5); + opacity: 1; + } + .label { + display: inline-block; + } + .icon { + display: inline-block; + width: 20px; + img { + width: 16px; + height: 16px; + vertical-align: bottom; + } + } + .hint { + display: inline-block; + margin-left: 12px; + font-size: 0.9em; + color: #ccc; + img { + width: 10px; + height: 10px; + vertical-align: baseline; + } + } + } + &.file { + display: none; + } + &.current { + > a, > a:active, > a:visited { + border: 1px solid rgb(221,221,221); + background-color: rgba(255,255,255,0.5); + opacity: 1; + } + } + &.error { + > a, > a:active, > a:visited { + color: #999; + &:hover, &.hover { + color: #e80; + } + } + .hint { + color: #c55; + } + } + .content, ul.content { + list-style: none; + margin: 0; + padding: 0 0 0 24px; + } + } } diff --git a/src/_h5ai/css/main-js.less b/src/_h5ai/css/main-js.less index fee495b4..f72967ff 100644 --- a/src/_h5ai/css/main-js.less +++ b/src/_h5ai/css/main-js.less @@ -1,3 +1,2 @@ @import "inc/main"; - diff --git a/src/_h5ai/css/main-php.less b/src/_h5ai/css/main-php.less index c6f9e34e..5efa7731 100644 --- a/src/_h5ai/css/main-php.less +++ b/src/_h5ai/css/main-php.less @@ -3,15 +3,15 @@ #table { - display: none; + display: none; } #tree, #content > header, #content > footer { - display: block; + display: block; } html.no-js { - #extended.details-view, #extended.icons-view { - display: block; - } + #extended.details-view, #extended.icons-view { + display: block; + } } diff --git a/src/_h5ai/footer.html b/src/_h5ai/footer.html index 2a2a0e40..3f67a409 100644 --- a/src/_h5ai/footer.html +++ b/src/_h5ai/footer.html @@ -1,34 +1,34 @@ - - -
-
- -
-
- - h5ai %BUILD_VERSION% (js) - ⚡ JavaScript is disabled! ⚡ - - - - en - english - - - - - - - folders - · - files - - - - - -
- - - + + +
+
+ +
+
+ + h5ai %BUILD_VERSION% (js) + ⚡ JavaScript is disabled! ⚡ + + + + en - english + + + + + + + folders + · + files + + + + + +
+ + + \ No newline at end of file diff --git a/src/_h5ai/footer.php b/src/_h5ai/footer.php index f1ee8cc3..ee6c2b75 100644 --- a/src/_h5ai/footer.php +++ b/src/_h5ai/footer.php @@ -1,4 +1,4 @@ - - + + diff --git a/src/_h5ai/header.html b/src/_h5ai/header.html index 70aa9621..ab84245f 100644 --- a/src/_h5ai/header.html +++ b/src/_h5ai/header.html @@ -4,28 +4,28 @@ - - - Directory index · styled with h5ai - - - - - - - - + + + Directory index · styled with h5ai + + + + + + + + -
- -
-
-
- +
+ +
+
+
+ diff --git a/src/_h5ai/header.php b/src/_h5ai/header.php index 03ad2cc7..c3c2ef59 100644 --- a/src/_h5ai/header.php +++ b/src/_h5ai/header.php @@ -5,56 +5,56 @@ - - - <?php echo $h5ai->getTitle(); ?> - - - - - - - - + + + <?php echo $h5ai->getTitle(); ?> + + + + + + + + -
- - toHtml(); ?> -
- getHeader(); ?> - toHtml(); ?> - getFooter(); ?> -
-
- - h5ai %BUILD_VERSION% (php) - ⚡ JavaScript is disabled! ⚡ - - - - en - english - - - - - - - folders - · - files - - - - - -
- - - -
- +
+ + toHtml(); ?> +
+ getHeader(); ?> + toHtml(); ?> + getFooter(); ?> +
+
+ + h5ai %BUILD_VERSION% (php) + ⚡ JavaScript is disabled! ⚡ + + + + en - english + + + + + + + folders + · + files + + + + + +
+ + + +
+ diff --git a/src/_h5ai/js/inc/Connector.js b/src/_h5ai/js/inc/Connector.js index 8d0b1d40..ceaa0619 100644 --- a/src/_h5ai/js/inc/Connector.js +++ b/src/_h5ai/js/inc/Connector.js @@ -1,115 +1,115 @@ (function ($, H5AI) { - H5AI.connector = (function () { + H5AI.connector = (function () { - var cache = {}, - pathnameStatusCache = {}, - contentTypeRegEx = /^text\/html;h5ai=/, - getPath = function (folder, tableRow) { + var cache = {}, + pathnameStatusCache = {}, + contentTypeRegEx = /^text\/html;h5ai=/, + getPath = function (folder, tableRow) { - var absHref = H5AI.util.getAbsHref(folder, tableRow), - path = cache[absHref]; + var absHref = H5AI.util.getAbsHref(folder, tableRow), + path = cache[absHref]; - if (!path) { - path = H5AI.Path(folder, tableRow); - if (!path.isParentFolder) { - cache[path.absHref] = path; - } - } + if (!path) { + path = H5AI.Path(folder, tableRow); + if (!path.isParentFolder) { + cache[path.absHref] = path; + } + } - return path; - }, - fetchStatus = function (pathname, callback) { + return path; + }, + fetchStatus = function (pathname, callback) { - if (H5AI.core.settings.folderStatus[pathname]) { - callback(H5AI.core.settings.folderStatus[pathname]); - return; - } else if (pathnameStatusCache[pathname]) { - callback(pathnameStatusCache[pathname]); - return; - } + if (H5AI.core.settings.folderStatus[pathname]) { + callback(H5AI.core.settings.folderStatus[pathname]); + return; + } else if (pathnameStatusCache[pathname]) { + callback(pathnameStatusCache[pathname]); + return; + } - $.ajax({ - url: pathname, - type: "HEAD", - complete: function (xhr) { + $.ajax({ + url: pathname, + type: "HEAD", + complete: function (xhr) { - var status = xhr.status; + var status = xhr.status; - if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) { - status = "h5ai"; - } - pathnameStatusCache[pathname] = status; - callback(status); - } - }); - }, - updatePath = function (path) { + if (status === 200 && contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) { + status = "h5ai"; + } + pathnameStatusCache[pathname] = status; + callback(status); + } + }); + }, + updatePath = function (path) { - if (path.isFolder && !path.isParentFolder && path.status === undefined) { - fetchStatus(path.absHref, function (status) { + if (path.isFolder && !path.isParentFolder && path.status === undefined) { + fetchStatus(path.absHref, function (status) { - if (status !== "h5ai") { - path.status = status; - } - H5AI.html.updateHtml(path); - H5AI.core.linkHoverStates(); - }); - } - }, - updatePaths = function () { + if (status !== "h5ai") { + path.status = status; + } + H5AI.html.updateHtml(path); + H5AI.core.linkHoverStates(); + }); + } + }, + updatePaths = function () { - $.each(cache, function (ref, cached) { - updatePath(cached); - }); - }, - fetchStatusAndContent = function (pathname, includeParent, callback) { + $.each(cache, function (ref, cached) { + updatePath(cached); + }); + }, + fetchStatusAndContent = function (pathname, includeParent, callback) { - fetchStatus(pathname, function (status) { + fetchStatus(pathname, function (status) { - if (status !== "h5ai") { - callback(status, {}); - return; - } + if (status !== "h5ai") { + callback(status, {}); + return; + } - $.ajax({ - url: pathname, - type: "GET", - dataType: "html", - error: function (xhr) { + $.ajax({ + url: pathname, + type: "GET", + dataType: "html", + error: function (xhr) { - callback(xhr.status, {}); // since it was checked before this should never happen - }, - success: function (html, status, xhr) { + callback(xhr.status, {}); // since it was checked before this should never happen + }, + success: function (html, status, xhr) { - var content = {}; + var content = {}; - if (!contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) { - callback(xhr.status, {}); // since it was checked before this should never happen - return; - } + if (!contentTypeRegEx.test(xhr.getResponseHeader("Content-Type"))) { + callback(xhr.status, {}); // since it was checked before this should never happen + return; + } - $(html).find("#table td").closest("tr").each(function () { + $(html).find("#table td").closest("tr").each(function () { - var path = getPath(pathname, this); + var path = getPath(pathname, this); - if (path.isFolder && (!path.isParentFolder || includeParent)) { - content[path.absHref] = path; - updatePath(path); - } - }); - callback("h5ai", content); - } - }); - }); - }; + if (path.isFolder && (!path.isParentFolder || includeParent)) { + content[path.absHref] = path; + updatePath(path); + } + }); + callback("h5ai", content); + } + }); + }); + }; - return { - getPath: getPath, - updatePaths: updatePaths, - fetchStatusAndContent: fetchStatusAndContent - }; - }()); + return { + getPath: getPath, + updatePaths: updatePaths, + fetchStatusAndContent: fetchStatusAndContent + }; + }()); }(jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index ed979da3..3790e899 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -1,399 +1,399 @@ (function (window, $, H5AI, config) { - H5AI.core = (function () { + H5AI.core = (function () { - var $window = $(window), - defaults = { - store: { - viewmode: "h5ai.pref.viewmode", - lang: "h5ai.pref.lang" - }, - callbacks: { - pathClick: [] - }, + var $window = $(window), + defaults = { + store: { + viewmode: "h5ai.pref.viewmode", + lang: "h5ai.pref.lang" + }, + callbacks: { + pathClick: [] + }, - rootAbsHref: "/", - h5aiAbsHref: "/_h5ai/", - customHeader: "_h5ai.header.html", - customFooter: "_h5ai.footer.html", + rootAbsHref: "/", + h5aiAbsHref: "/_h5ai/", + customHeader: "_h5ai.header.html", + customFooter: "_h5ai.footer.html", - viewmodes: ["details", "icons"], - sortorder: "na", - showTree: true, - slideTree: true, - folderStatus: {}, - lang: null, - useBrowserLang: true, - setParentFolderLabels: true, - linkHoverStates: true, - dateFormat: "yyyy-MM-dd HH:mm", - showThumbs: false, - zippedDownload: false - }, - settings = $.extend({}, defaults, config.options), - currentDateFormat = settings.dateFormat, - extToFileType = (function (types) { - var map = {}; - $.each(types, function (type, exts) { - $.each(exts, function (idx, ext) { - map[ext] = type; - }); - }); - return map; - }(config.types)), - api = function () { + viewmodes: ["details", "icons"], + sortorder: "na", + showTree: true, + slideTree: true, + folderStatus: {}, + lang: null, + useBrowserLang: true, + setParentFolderLabels: true, + linkHoverStates: true, + dateFormat: "yyyy-MM-dd HH:mm", + showThumbs: false, + zippedDownload: false + }, + settings = $.extend({}, defaults, config.options), + currentDateFormat = settings.dateFormat, + extToFileType = (function (types) { + var map = {}; + $.each(types, function (type, exts) { + $.each(exts, function (idx, ext) { + map[ext] = type; + }); + }); + return map; + }(config.types)), + api = function () { - return settings.h5aiAbsHref + "php/api.php"; - }, - image = function (id) { + return settings.h5aiAbsHref + "php/api.php"; + }, + image = function (id) { - return settings.h5aiAbsHref + "images/" + id + ".png"; - }, - icon = function (id, big) { + return settings.h5aiAbsHref + "images/" + id + ".png"; + }, + icon = function (id, big) { - return settings.h5aiAbsHref + "icons/" + (big ? "48x48" : "16x16") + "/" + id + ".png"; - }, - viewmode = function (viewmode) { + return settings.h5aiAbsHref + "icons/" + (big ? "48x48" : "16x16") + "/" + id + ".png"; + }, + viewmode = function (viewmode) { - var $viewDetails = $("#viewdetails"), - $viewIcons = $("#viewicons"), - $extended = $("#extended"); + var $viewDetails = $("#viewdetails"), + $viewIcons = $("#viewicons"), + $extended = $("#extended"); - if (viewmode) { - amplify.store(settings.store.viewmode, viewmode); - } else { - viewmode = amplify.store(settings.store.viewmode); - } - viewmode = $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0]; + if (viewmode) { + amplify.store(settings.store.viewmode, viewmode); + } else { + viewmode = amplify.store(settings.store.viewmode); + } + viewmode = $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0]; - $viewDetails.add($viewIcons).removeClass("current"); - if (viewmode === "details") { - $viewDetails.addClass("current"); - $extended.addClass("details-view").removeClass("icons-view").show(); - } else if (viewmode === "icons") { - $viewIcons.addClass("current"); - $extended.removeClass("details-view").addClass("icons-view").show(); - } else { - $extended.hide(); - } - }, - initTopSpace = function () { + $viewDetails.add($viewIcons).removeClass("current"); + if (viewmode === "details") { + $viewDetails.addClass("current"); + $extended.addClass("details-view").removeClass("icons-view").show(); + } else if (viewmode === "icons") { + $viewIcons.addClass("current"); + $extended.removeClass("details-view").addClass("icons-view").show(); + } else { + $extended.hide(); + } + }, + initTopSpace = function () { - var $body = $("body"), - $tree = $("#tree"), - adjustTopSpace = function () { + var $body = $("body"), + $tree = $("#tree"), + adjustTopSpace = function () { - var winHeight = $window.height(), - navHeight = $("body > nav").outerHeight(), - footerHeight = $("body > footer").outerHeight(), - contentSpacing = 50, - treeSpacing = 30; + var winHeight = $window.height(), + navHeight = $("body > nav").outerHeight(), + footerHeight = $("body > footer").outerHeight(), + contentSpacing = 50, + treeSpacing = 30; - $body.css({ - "margin-top": navHeight + contentSpacing, - "margin-bottom": footerHeight + contentSpacing - }); + $body.css({ + "margin-top": navHeight + contentSpacing, + "margin-bottom": footerHeight + contentSpacing + }); - $tree.css({ - top: navHeight + treeSpacing, - height: winHeight - navHeight - footerHeight - 18 - 2 * treeSpacing - }); + $tree.css({ + top: navHeight + treeSpacing, + height: winHeight - navHeight - footerHeight - 18 - 2 * treeSpacing + }); - try { - $tree.get(0).updateScrollbar(); - } catch (err) {} - }; + try { + $tree.get(0).updateScrollbar(); + } catch (err) {} + }; - $window.resize(function () { - adjustTopSpace(); - }); - adjustTopSpace(); - }, - initViews = function () { + $window.resize(function () { + adjustTopSpace(); + }); + adjustTopSpace(); + }, + initViews = function () { - var $navbar = $("#navbar"), - $extended = $("#extended"); + var $navbar = $("#navbar"), + $extended = $("#extended"); - $("#table").remove(); + $("#table").remove(); - if (settings.viewmodes.length > 1) { - if ($.inArray("icons", settings.viewmodes) >= 0) { - $("
  • view-iconsicons
  • ") - .find("img").attr("src", image("view-icons")).end() - .click(function () { viewmode("icons"); }) - .appendTo($navbar); - } - if ($.inArray("details", settings.viewmodes) >= 0) { - $("
  • view-detailsdetails
  • ") - .find("img").attr("src", image("view-details")).end() - .click(function () { viewmode("details"); }) - .appendTo($navbar); - } - } + if (settings.viewmodes.length > 1) { + if ($.inArray("icons", settings.viewmodes) >= 0) { + $("
  • view-iconsicons
  • ") + .find("img").attr("src", image("view-icons")).end() + .click(function () { viewmode("icons"); }) + .appendTo($navbar); + } + if ($.inArray("details", settings.viewmodes) >= 0) { + $("
  • view-detailsdetails
  • ") + .find("img").attr("src", image("view-details")).end() + .click(function () { viewmode("details"); }) + .appendTo($navbar); + } + } - // status update - $extended.find(".entry a").hover( - function () { - if ($extended.hasClass("icons-view")) { - var $this = $(this); - $(".status.default").hide(); - $(".status.dynamic") - .empty() - .append($this.find(".label").clone()) - .append($("·")) - .append($this.find(".date").clone()) - .show(); + // status update + $extended.find(".entry a").hover( + function () { + if ($extended.hasClass("icons-view")) { + var $this = $(this); + $(".status.default").hide(); + $(".status.dynamic") + .empty() + .append($this.find(".label").clone()) + .append($("·")) + .append($this.find(".date").clone()) + .show(); - if (!$this.closest(".entry").hasClass("folder")) { - $(".status.dynamic") - .append($("·")) - .append($this.find(".size").clone()); - } - } - }, - function () { - $(".status.default").show(); - $(".status.dynamic").empty().hide(); - } - ); - }, - shiftTree = function (forceVisible, dontAnimate) { + if (!$this.closest(".entry").hasClass("folder")) { + $(".status.dynamic") + .append($("·")) + .append($this.find(".size").clone()); + } + } + }, + function () { + $(".status.default").show(); + $(".status.dynamic").empty().hide(); + } + ); + }, + shiftTree = function (forceVisible, dontAnimate) { - var $tree = $("#tree"), - $extended = $("#extended"); + var $tree = $("#tree"), + $extended = $("#extended"); - if ((settings.slideTree && $tree.outerWidth() < $extended.offset().left) || forceVisible) { - if (dontAnimate) { - $tree.stop().css({ left: 0 }); - } else { - $tree.stop().animate({ left: 0 }); - } - } else { - if (dontAnimate) { - $tree.stop().css({ left: 18 - $tree.outerWidth() }); - } else { - $tree.stop().animate({ left: 18 - $tree.outerWidth() }); - } - } - }, - initTree = function () { + if ((settings.slideTree && $tree.outerWidth() < $extended.offset().left) || forceVisible) { + if (dontAnimate) { + $tree.stop().css({ left: 0 }); + } else { + $tree.stop().animate({ left: 0 }); + } + } else { + if (dontAnimate) { + $tree.stop().css({ left: 18 - $tree.outerWidth() }); + } else { + $tree.stop().animate({ left: 18 - $tree.outerWidth() }); + } + } + }, + initTree = function () { - $("#tree").hover( - function () { shiftTree(true); }, - function () { shiftTree(); } - ); - $window.resize(function () { shiftTree(); }); - shiftTree(false, true); - }, - selectLinks = function (href) { + $("#tree").hover( + function () { shiftTree(true); }, + function () { shiftTree(); } + ); + $window.resize(function () { shiftTree(); }); + shiftTree(false, true); + }, + selectLinks = function (href) { - var elements = []; - $("a[href^='/']").each(function () { + var elements = []; + $("a[href^='/']").each(function () { - if ($(this).attr("href") === href) { - elements.push(this); - } - }); - return $(elements); - }, - linkHoverStates = function () { + if ($(this).attr("href") === href) { + elements.push(this); + } + }); + return $(elements); + }, + linkHoverStates = function () { - if (settings.linkHoverStates) { - $("a[href^='/']:not(.linkedHoverStates)").each(function () { + if (settings.linkHoverStates) { + $("a[href^='/']:not(.linkedHoverStates)").each(function () { - var $a = $(this).addClass("linkedHoverStates"), - href = $a.attr("href"); + var $a = $(this).addClass("linkedHoverStates"), + href = $a.attr("href"); - $a.hover( - function () { selectLinks(href).addClass("hover"); }, - function () { selectLinks(href).removeClass("hover"); } - ); - }); - } - }, - formatDates = function (dateFormat) { + $a.hover( + function () { selectLinks(href).addClass("hover"); }, + function () { selectLinks(href).removeClass("hover"); } + ); + }); + } + }, + formatDates = function (dateFormat) { - if (dateFormat) { - currentDateFormat = dateFormat; - } + if (dateFormat) { + currentDateFormat = dateFormat; + } - $("#extended .entry .date").each(function () { + $("#extended .entry .date").each(function () { - var $this = $(this), - time = $this.data("time"), - formattedDate = time ? new Date(time).toString(currentDateFormat) : ""; + var $this = $(this), + time = $this.data("time"), + formattedDate = time ? new Date(time).toString(currentDateFormat) : ""; - $this.text(formattedDate); - }); - }, - localize = function (langs, lang, useBrowserLang) { + $this.text(formattedDate); + }); + }, + localize = function (langs, lang, useBrowserLang) { - var storedLang = amplify.store(settings.store.lang), - browserLang, selected, key; + var storedLang = amplify.store(settings.store.lang), + browserLang, selected, key; - if (langs[storedLang]) { - lang = storedLang; - } else if (useBrowserLang) { - browserLang = navigator.language; - if (langs[browserLang]) { - lang = browserLang; - } else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) { - lang = browserLang.substr(0, 2); - } - } + if (langs[storedLang]) { + lang = storedLang; + } else if (useBrowserLang) { + browserLang = navigator.language; + if (langs[browserLang]) { + lang = browserLang; + } else if (browserLang.length > 2 && langs[browserLang.substr(0, 2)]) { + lang = browserLang.substr(0, 2); + } + } - if (!langs[lang]) { - lang = "en"; - } + if (!langs[lang]) { + lang = "en"; + } - selected = langs[lang]; - if (selected) { - $.each(selected, function (key, value) { - $(".l10n-" + key).text(value); - }); - $(".lang").text(lang); - $(".langOption").removeClass("current"); - $(".langOption." + lang).addClass("current"); - } + selected = langs[lang]; + if (selected) { + $.each(selected, function (key, value) { + $(".l10n-" + key).text(value); + }); + $(".lang").text(lang); + $(".langOption").removeClass("current"); + $(".langOption." + lang).addClass("current"); + } - formatDates(selected.dateFormat || settings.dateFormat); - }, - initLangSelector = function (langs) { + formatDates(selected.dateFormat || settings.dateFormat); + }, + initLangSelector = function (langs) { - var $langOptions = $("#langSelector .langOptions"), - sortedLangsKeys = [], - $ul; + var $langOptions = $("#langSelector .langOptions"), + sortedLangsKeys = [], + $ul; - $.each(langs, function (lang) { - sortedLangsKeys.push(lang); - }); - sortedLangsKeys.sort(); + $.each(langs, function (lang) { + sortedLangsKeys.push(lang); + }); + sortedLangsKeys.sort(); - $ul = $("
      "); - $.each(sortedLangsKeys, function (idx, lang) { - $("
    • ") - .addClass(lang) - .text(lang + " - " + langs[lang].lang) - .appendTo($ul) - .click(function () { - amplify.store(settings.store.lang, lang); - localize(langs, lang, false); - }); - }); - $langOptions - .append($ul) - .scrollpanel(); + $ul = $("
        "); + $.each(sortedLangsKeys, function (idx, lang) { + $("
      • ") + .addClass(lang) + .text(lang + " - " + langs[lang].lang) + .appendTo($ul) + .click(function () { + amplify.store(settings.store.lang, lang); + localize(langs, lang, false); + }); + }); + $langOptions + .append($ul) + .scrollpanel(); - $("#langSelector").hover( - function () { - $langOptions - .css("top", "-" + $langOptions.outerHeight() + "px") - .stop(true, true) - .fadeIn(); - $langOptions.get(0).updateScrollbar(); - }, - function () { - $langOptions - .stop(true, true) - .fadeOut(); - } - ); - }, - onIndicatorClick = function (event) { + $("#langSelector").hover( + function () { + $langOptions + .css("top", "-" + $langOptions.outerHeight() + "px") + .stop(true, true) + .fadeIn(); + $langOptions.get(0).updateScrollbar(); + }, + function () { + $langOptions + .stop(true, true) + .fadeOut(); + } + ); + }, + onIndicatorClick = function (event) { - var $indicator = $(this), - $entry = $indicator.closest(".entry"), - updateTreeScrollbar = $("#tree").get(0).updateScrollbar; + var $indicator = $(this), + $entry = $indicator.closest(".entry"), + updateTreeScrollbar = $("#tree").get(0).updateScrollbar; - if ($indicator.hasClass("unknown")) { - $.get(api(), { "action": "tree", "href": $entry.find("> a").attr("href") }, function (html) { + if ($indicator.hasClass("unknown")) { + $.get(api(), { "action": "tree", "href": $entry.find("> a").attr("href") }, function (html) { - var $content = $(html); + var $content = $(html); - $indicator.removeClass("unknown"); - if ($content.find("> li").size() === 0) { - $indicator.replaceWith($("")); - } else { - $indicator.addClass("open"); - $entry.find("> .content").replaceWith($content); - updateTreeScrollbar(); - $content.find(".indicator:not(.initiated)") - .click(onIndicatorClick) - .addClass("initiated"); - } - }); - } else if ($indicator.hasClass("open")) { - $indicator.removeClass("open"); - updateTreeScrollbar(true); - $entry.find("> .content").slideUp(function () { - updateTreeScrollbar(); - }); - } else { - $indicator.addClass("open"); - updateTreeScrollbar(true); - $entry.find("> .content").slideDown(function () { - updateTreeScrollbar(); - }); - } - }, - initIndicators = function () { + $indicator.removeClass("unknown"); + if ($content.find("> li").size() === 0) { + $indicator.replaceWith($("")); + } else { + $indicator.addClass("open"); + $entry.find("> .content").replaceWith($content); + updateTreeScrollbar(); + $content.find(".indicator:not(.initiated)") + .click(onIndicatorClick) + .addClass("initiated"); + } + }); + } else if ($indicator.hasClass("open")) { + $indicator.removeClass("open"); + updateTreeScrollbar(true); + $entry.find("> .content").slideUp(function () { + updateTreeScrollbar(); + }); + } else { + $indicator.addClass("open"); + updateTreeScrollbar(true); + $entry.find("> .content").slideDown(function () { + updateTreeScrollbar(); + }); + } + }, + initIndicators = function () { - $("#tree .entry.folder .indicator:not(.initiated)") - .click(onIndicatorClick) - .addClass("initiated"); - }, - getFileType = function (filename) { + $("#tree .entry.folder .indicator:not(.initiated)") + .click(onIndicatorClick) + .addClass("initiated"); + }, + getFileType = function (filename) { - var dotidx = filename.lastIndexOf('.'), - ext = dotidx >= 0 ? filename.substr(dotidx) : filename; + var dotidx = filename.lastIndexOf('.'), + ext = dotidx >= 0 ? filename.substr(dotidx) : filename; - return extToFileType[ext.toLowerCase()] || "unknown"; - }, - formatSizes = function () { + return extToFileType[ext.toLowerCase()] || "unknown"; + }, + formatSizes = function () { - $("#extended .entry .size").each(function () { + $("#extended .entry .size").each(function () { - var $this = $(this), - bytes = $this.data("bytes"), - formattedSize = bytes >= 0 ? H5AI.util.formatSize(bytes) : ""; + var $this = $(this), + bytes = $this.data("bytes"), + formattedSize = bytes >= 0 ? H5AI.util.formatSize(bytes) : ""; - $this.text(formattedSize); - }); - }, - setTotals = function () { + $this.text(formattedSize); + }); + }, + setTotals = function () { - var $extended = $("#extended"); + var $extended = $("#extended"); - $(".folderTotal").text($extended.find(".entry.folder:not(.folder-parent)").length); - $(".fileTotal").text($extended.find(".entry.file").length); - }, - init = function () { + $(".folderTotal").text($extended.find(".entry.folder:not(.folder-parent)").length); + $(".fileTotal").text($extended.find(".entry.file").length); + }, + init = function () { - initViews(); - viewmode(); - initTopSpace(); - initTree(); - linkHoverStates(); - initLangSelector(config.langs); - localize(config.langs, settings.lang, settings.useBrowserLang); - formatSizes(); - setTotals(); - initIndicators(); - }; + initViews(); + viewmode(); + initTopSpace(); + initTree(); + linkHoverStates(); + initLangSelector(config.langs); + localize(config.langs, settings.lang, settings.useBrowserLang); + formatSizes(); + setTotals(); + initIndicators(); + }; - return { - settings: settings, - api: api, - image: image, - icon: icon, - shiftTree: shiftTree, - linkHoverStates: linkHoverStates, - initIndicators: initIndicators, - formatDates: formatDates, - getFileType: getFileType, - init: init - }; - }()); + return { + settings: settings, + api: api, + image: image, + icon: icon, + shiftTree: shiftTree, + linkHoverStates: linkHoverStates, + initIndicators: initIndicators, + formatDates: formatDates, + getFileType: getFileType, + init: init + }; + }()); }(window, jQuery, H5AI, H5AI_CONFIG)); diff --git a/src/_h5ai/js/inc/Extended.js b/src/_h5ai/js/inc/Extended.js index 647f80fc..9e48e3da 100644 --- a/src/_h5ai/js/inc/Extended.js +++ b/src/_h5ai/js/inc/Extended.js @@ -1,127 +1,127 @@ (function (document, $, H5AI) { - H5AI.extended = (function () { + H5AI.extended = (function () { - var initBreadcrumb = function () { + var initBreadcrumb = function () { - var $ul = $("body > nav ul"), - pathname = "/", - path = H5AI.connector.getPath(pathname), - pathnameParts = document.location.pathname.split("/"), - lastPart = "", - title = document.domain; + var $ul = $("body > nav ul"), + pathname = "/", + path = H5AI.connector.getPath(pathname), + pathnameParts = document.location.pathname.split("/"), + lastPart = "", + title = document.domain; - $ul.append(H5AI.html.updateCrumbHtml(path)); + $ul.append(H5AI.html.updateCrumbHtml(path)); - $.each(pathnameParts, function (idx, part) { - if (part !== "") { - pathname += part + "/"; - $ul.append(H5AI.html.updateCrumbHtml(H5AI.connector.getPath(pathname))); - lastPart = part + " - "; - title += " > " + part; - } - }); + $.each(pathnameParts, function (idx, part) { + if (part !== "") { + pathname += part + "/"; + $ul.append(H5AI.html.updateCrumbHtml(H5AI.connector.getPath(pathname))); + lastPart = part + " - "; + title += " > " + part; + } + }); - document.title = H5AI.util.checkedDecodeUri(lastPart + title); - }, - initExtendedView = function () { + document.title = H5AI.util.checkedDecodeUri(lastPart + title); + }, + initExtendedView = function () { - var $ul, $li; + var $ul, $li; - $ul = $("
          "); - $li = $("
        • ") - .appendTo($ul) - .append($("")) - .append($("")) - .append($("")) - .append($("")); + $ul = $("
            "); + $li = $("
          • ") + .appendTo($ul) + .append($("")) + .append($("")) + .append($("")) + .append($("")); - // entries - $("#table td").closest("tr").each(function () { - var path = H5AI.connector.getPath(document.location.pathname, this); - $ul.append(H5AI.html.updateExtendedHtml(path)); - }); + // entries + $("#table td").closest("tr").each(function () { + var path = H5AI.connector.getPath(document.location.pathname, this); + $ul.append(H5AI.html.updateExtendedHtml(path)); + }); - $("#extended").append($ul); + $("#extended").append($ul); - // empty - if ($ul.children(".entry:not(.folder-parent)").size() === 0) { - $("#extended").append($("
            empty
            ")); - } - }, - customize = function () { + // empty + if ($ul.children(".entry:not(.folder-parent)").size() === 0) { + $("#extended").append($("
            empty
            ")); + } + }, + customize = function () { - $.ajax({ - url: H5AI.core.settings.customHeader, - dataType: "html", - success: function (data) { - $("#content > header").append($(data)).show(); - } - }); + $.ajax({ + url: H5AI.core.settings.customHeader, + dataType: "html", + success: function (data) { + $("#content > header").append($(data)).show(); + } + }); - $.ajax({ - url: H5AI.core.settings.customFooter, - dataType: "html", - success: function (data) { - $("#content > footer").prepend($(data)).show(); - } - }); - }, - fetchPath = function (pathname, callback) { + $.ajax({ + url: H5AI.core.settings.customFooter, + dataType: "html", + success: function (data) { + $("#content > footer").prepend($(data)).show(); + } + }); + }, + fetchPath = function (pathname, callback) { - H5AI.connector.fetchStatusAndContent(pathname, false, function (status, content) { + H5AI.connector.fetchStatusAndContent(pathname, false, function (status, content) { - var path = H5AI.connector.getPath(pathname); + var path = H5AI.connector.getPath(pathname); - path.status = status; - path.content = content; - callback(path); - }); - }, - fetchTree = function (pathname, callback, childPath) { + path.status = status; + path.content = content; + callback(path); + }); + }, + fetchTree = function (pathname, callback, childPath) { - fetchPath(pathname, function (path) { + fetchPath(pathname, function (path) { - var parent = H5AI.util.splitPath(pathname).parent; + var parent = H5AI.util.splitPath(pathname).parent; - path.treeOpen = true; - if (childPath) { - path.content[childPath.absHref] = childPath; - } - if (parent === null) { - callback(path); - } else { - fetchTree(parent, callback, path); - } - }); - }, - populateTree = function () { + path.treeOpen = true; + if (childPath) { + path.content[childPath.absHref] = childPath; + } + if (parent === null) { + callback(path); + } else { + fetchTree(parent, callback, path); + } + }); + }, + populateTree = function () { - fetchTree(document.location.pathname, function (path) { - $("#tree") - .append(H5AI.html.updateTreeHtml(path)) - .scrollpanel() - .show(); - H5AI.core.shiftTree(false, true); - H5AI.core.linkHoverStates(); - setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1); - }); - }, - init = function () { + fetchTree(document.location.pathname, function (path) { + $("#tree") + .append(H5AI.html.updateTreeHtml(path)) + .scrollpanel() + .show(); + H5AI.core.shiftTree(false, true); + H5AI.core.linkHoverStates(); + setTimeout(function () { $("#tree").get(0).updateScrollbar(); }, 1); + }); + }, + init = function () { - initBreadcrumb(); - initExtendedView(); - customize(); - H5AI.connector.updatePaths(); - if (H5AI.core.settings.showTree) { - populateTree(); - } - }; + initBreadcrumb(); + initExtendedView(); + customize(); + H5AI.connector.updatePaths(); + if (H5AI.core.settings.showTree) { + populateTree(); + } + }; - return { - init: init - }; - }()); + return { + init: init + }; + }()); }(document, jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/Html.js b/src/_h5ai/js/inc/Html.js index d04b1f39..d95a07e8 100644 --- a/src/_h5ai/js/inc/Html.js +++ b/src/_h5ai/js/inc/Html.js @@ -1,264 +1,264 @@ (function ($, H5AI) { - H5AI.html = (function () { + H5AI.html = (function () { - var thumbTypes = ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], - onClick = function (path, context) { + var thumbTypes = ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], + onClick = function (path, context) { - }, - updateCrumbHtml = function (path) { + }, + updateCrumbHtml = function (path) { - var $html, $a; + var $html, $a; - if (path.html.$crumb && path.html.$crumb.data("status") === path.status) { - return path.html.$crumb; - } + if (path.html.$crumb && path.html.$crumb.data("status") === path.status) { + return path.html.$crumb; + } - $html = $("
          • >
          • ") - .addClass(path.isFolder ? "folder" : "file"); + $html = $("
          • >
          • ") + .addClass(path.isFolder ? "folder" : "file"); - if (path.status) { - $html.data("status", path.status); - } + if (path.status) { + $html.data("status", path.status); + } - $a = $html.find("a") - .attr("href", path.absHref) - .click(function() { onClick(path, "crumb"); }) - .find("img").attr("src", H5AI.core.image("crumb")).end() - .find("span").text(path.label).end(); + $a = $html.find("a") + .attr("href", path.absHref) + .click(function() { onClick(path, "crumb"); }) + .find("img").attr("src", H5AI.core.image("crumb")).end() + .find("span").text(path.label).end(); - if (path.isDomain) { - $html.addClass("domain"); - $a.find("img").attr("src", H5AI.core.image("home")); - } + if (path.isDomain) { + $html.addClass("domain"); + $a.find("img").attr("src", H5AI.core.image("home")); + } - if (path.isCurrentFolder) { - $html.addClass("current"); - } + if (path.isCurrentFolder) { + $html.addClass("current"); + } - if (!isNaN(path.status)) { - if (path.status === 200) { - $a.append($("not listable")); - } else { - $a.append($("(" + path.status + ")")); - } - } + if (!isNaN(path.status)) { + if (path.status === 200) { + $a.append($("not listable")); + } else { + $a.append($("(" + path.status + ")")); + } + } - if (path.html.$crumb) { - path.html.$crumb.replaceWith($html); - } - path.html.$crumb = $html; + if (path.html.$crumb) { + path.html.$crumb.replaceWith($html); + } + path.html.$crumb = $html; - return $html; - }, - updateExtendedHtml = function (path) { + return $html; + }, + updateExtendedHtml = function (path) { - var $html, $a, $label, - formattedDate = path.date ? path.date.toString(H5AI.core.settings.dateFormat) : "", - imgClass = "", - icon16 = H5AI.core.icon(path.type), - icon48 = H5AI.core.icon(path.type, true); + var $html, $a, $label, + formattedDate = path.date ? path.date.toString(H5AI.core.settings.dateFormat) : "", + imgClass = "", + icon16 = H5AI.core.icon(path.type), + icon48 = H5AI.core.icon(path.type, true); - if (path.html.$extended && path.html.$extended.data("status") === path.status) { - return path.html.$extended; - } + if (path.html.$extended && path.html.$extended.data("status") === path.status) { + return path.html.$extended; + } - $html = $("
          • ") - .data("path", path) - .addClass(path.isFolder ? "folder" : "file"); + $html = $("
          • ") + .data("path", path) + .addClass(path.isFolder ? "folder" : "file"); - if (path.status) { - $html.data("status", path.status); - } + if (path.status) { + $html.data("status", path.status); + } - if (H5AI.core.settings.showThumbs === true && $.inArray(path.type, thumbTypes) >= 0) { - imgClass = "class='thumb'"; - icon16 = H5AI.core.api() + "?action=thumb&href=" + path.absHref + "&width=16&height=16&mode=square"; - icon48 = H5AI.core.api() + "?action=thumb&href=" + path.absHref + "&width=96&height=46&mode=rational"; - } + if (H5AI.core.settings.showThumbs === true && $.inArray(path.type, thumbTypes) >= 0) { + imgClass = "class='thumb'"; + icon16 = H5AI.core.api() + "?action=thumb&href=" + path.absHref + "&width=16&height=16&mode=square"; + icon48 = H5AI.core.api() + "?action=thumb&href=" + path.absHref + "&width=96&height=46&mode=rational"; + } - $label = $("" + path.label + ""); - $a = $("") - .attr("href", path.absHref) - .click(function() { onClick(path, "extended"); }) - .appendTo($html) - .append($("" + path.type + "")) - .append($("" + path.type + "")) - .append($label) - .append($("")) - .append($("")); + $label = $("" + path.label + ""); + $a = $("") + .attr("href", path.absHref) + .click(function() { onClick(path, "extended"); }) + .appendTo($html) + .append($("" + path.type + "")) + .append($("" + path.type + "")) + .append($label) + .append($("")) + .append($("")); - $a.hover( - function () { - if ($("#extended").hasClass("icons-view")) { - var $this = $(this); - $(".status.default").hide(); - $(".status.dynamic") - .empty() - .append($this.find(".label").clone()) - .append($("·")) - .append($this.find(".date").clone()) - .show(); + $a.hover( + function () { + if ($("#extended").hasClass("icons-view")) { + var $this = $(this); + $(".status.default").hide(); + $(".status.dynamic") + .empty() + .append($this.find(".label").clone()) + .append($("·")) + .append($this.find(".date").clone()) + .show(); - if (!$this.closest(".entry").hasClass("folder")) { - $(".status.dynamic") - .append($("·")) - .append($this.find(".size").clone()); - } - } - }, - function () { - $(".status.default").show(); - $(".status.dynamic").empty().hide(); - } - ); + if (!$this.closest(".entry").hasClass("folder")) { + $(".status.dynamic") + .append($("·")) + .append($this.find(".size").clone()); + } + } + }, + function () { + $(".status.default").show(); + $(".status.dynamic").empty().hide(); + } + ); - if (path.isParentFolder) { - if (!H5AI.core.settings.setParentFolderLabels) { - $label.addClass("l10n-parentDirectory"); - } - $html.addClass("folder-parent"); - } + if (path.isParentFolder) { + if (!H5AI.core.settings.setParentFolderLabels) { + $label.addClass("l10n-parentDirectory"); + } + $html.addClass("folder-parent"); + } - if (!isNaN(path.status)) { - if (path.status === 200) { - $html.addClass("page"); - $a.find(".icon.small img").attr("src", H5AI.core.icon("folder-page")); - $a.find(".icon.big img").attr("src", H5AI.core.icon("folder-page", true)); - } else { - $html.addClass("error"); - $label.append($(" " + path.status + " ")); - } - } + if (!isNaN(path.status)) { + if (path.status === 200) { + $html.addClass("page"); + $a.find(".icon.small img").attr("src", H5AI.core.icon("folder-page")); + $a.find(".icon.big img").attr("src", H5AI.core.icon("folder-page", true)); + } else { + $html.addClass("error"); + $label.append($(" " + path.status + " ")); + } + } - if (path.html.$extended) { - path.html.$extended.replaceWith($html); - H5AI.core.formatDates(); - } - path.html.$extended = $html; + if (path.html.$extended) { + path.html.$extended.replaceWith($html); + H5AI.core.formatDates(); + } + path.html.$extended = $html; - return $html; - }, - updateTreeHtml = function (path) { + return $html; + }, + updateTreeHtml = function (path) { - var $html, $blank, $a, $indicator, $ul, idx; + var $html, $blank, $a, $indicator, $ul, idx; - $html = $("
            ") - .data("path", path) - .addClass(path.isFolder ? "folder" : "file"); + $html = $("
            ") + .data("path", path) + .addClass(path.isFolder ? "folder" : "file"); - $blank = $("").appendTo($html); + $blank = $("").appendTo($html); - $a = $("") - .attr("href", path.absHref) - .click(function() { onClick(path, "tree"); }) - .appendTo($html) - .append($("")) - .append($("" + path.label + "")); + $a = $("") + .attr("href", path.absHref) + .click(function() { onClick(path, "tree"); }) + .appendTo($html) + .append($("")) + .append($("" + path.label + "")); - if (path.isFolder) { - // indicator - if (path.status === undefined || !path.isEmpty()) { - $indicator = $("") - .click(function (event) { + if (path.isFolder) { + // indicator + if (path.status === undefined || !path.isEmpty()) { + $indicator = $("") + .click(function (event) { - var $entry = $indicator.closest(".entry"); // $html + var $entry = $indicator.closest(".entry"); // $html - if ($indicator.hasClass("unknown")) { - H5AI.connector.fetchStatusAndContent(path.absHref, false, function (status, content) { + if ($indicator.hasClass("unknown")) { + H5AI.connector.fetchStatusAndContent(path.absHref, false, function (status, content) { - path.status = status; - path.content = content; - path.treeOpen = true; - $("#tree").get(0).updateScrollbar(true); - updateTreeHtml(path); - $("#tree").get(0).updateScrollbar(); - }); - } else if ($indicator.hasClass("open")) { - path.treeOpen = false; - $indicator.removeClass("open"); - $("#tree").get(0).updateScrollbar(true); - $entry.find("> ul.content").slideUp(function() { + path.status = status; + path.content = content; + path.treeOpen = true; + $("#tree").get(0).updateScrollbar(true); + updateTreeHtml(path); + $("#tree").get(0).updateScrollbar(); + }); + } else if ($indicator.hasClass("open")) { + path.treeOpen = false; + $indicator.removeClass("open"); + $("#tree").get(0).updateScrollbar(true); + $entry.find("> ul.content").slideUp(function() { - $("#tree").get(0).updateScrollbar(); - }); - } else { - path.treeOpen = true; - $indicator.addClass("open"); - $("#tree").get(0).updateScrollbar(true); - $entry.find("> ul.content").slideDown(function() { + $("#tree").get(0).updateScrollbar(); + }); + } else { + path.treeOpen = true; + $indicator.addClass("open"); + $("#tree").get(0).updateScrollbar(true); + $entry.find("> ul.content").slideDown(function() { - $("#tree").get(0).updateScrollbar(); - }); - } + $("#tree").get(0).updateScrollbar(); + }); + } - }); + }); - if (path.status === undefined) { - $indicator.addClass("unknown"); - } else if (path.treeOpen) { - $indicator.addClass("open"); - } + if (path.status === undefined) { + $indicator.addClass("unknown"); + } else if (path.treeOpen) { + $indicator.addClass("open"); + } - $blank.replaceWith($indicator); - } + $blank.replaceWith($indicator); + } - // is path the domain? - if (path.isDomain) { - $html.addClass("domain"); - $a.find(".icon img").attr("src", H5AI.core.icon("folder-home")); - } + // is path the domain? + if (path.isDomain) { + $html.addClass("domain"); + $a.find(".icon img").attr("src", H5AI.core.icon("folder-home")); + } - // is path the current folder? - if (path.isCurrentFolder) { - $html.addClass("current"); - $a.find(".icon img").attr("src", H5AI.core.icon("folder-open")); - } + // is path the current folder? + if (path.isCurrentFolder) { + $html.addClass("current"); + $a.find(".icon img").attr("src", H5AI.core.icon("folder-open")); + } - // does it have subfolders? - if (!path.isEmpty()) { - $ul = $("
              ").appendTo($html); - $.each(path.content, function (idx, entry) { - $("
            • ").append(updateTreeHtml(entry)).appendTo($ul); - }); - if (path.status === undefined || !path.treeOpen) { - $ul.hide(); - } - } + // does it have subfolders? + if (!path.isEmpty()) { + $ul = $("
                ").appendTo($html); + $.each(path.content, function (idx, entry) { + $("
              • ").append(updateTreeHtml(entry)).appendTo($ul); + }); + if (path.status === undefined || !path.treeOpen) { + $ul.hide(); + } + } - // reflect folder status - if (!isNaN(path.status)) { - if (path.status === 200) { - $a.find(".icon img").attr("src", H5AI.core.icon("folder-page")); - $a.append($("")); - } else { - $html.addClass("error"); - $a.append($("" + path.status + "")); - } - } - } + // reflect folder status + if (!isNaN(path.status)) { + if (path.status === 200) { + $a.find(".icon img").attr("src", H5AI.core.icon("folder-page")); + $a.append($("")); + } else { + $html.addClass("error"); + $a.append($("" + path.status + "")); + } + } + } - if (path.html.$tree) { - path.html.$tree.replaceWith($html); - } - path.html.$tree = $html; + if (path.html.$tree) { + path.html.$tree.replaceWith($html); + } + path.html.$tree = $html; - return $html; - }, - updateHtml = function (path) { + return $html; + }, + updateHtml = function (path) { - updateCrumbHtml(path); - updateExtendedHtml(path); - updateTreeHtml(path); - }; + updateCrumbHtml(path); + updateExtendedHtml(path); + updateTreeHtml(path); + }; - return { - updateCrumbHtml: updateCrumbHtml, - updateExtendedHtml: updateExtendedHtml, - updateTreeHtml: updateTreeHtml, - updateHtml: updateHtml - }; - }()); + return { + updateCrumbHtml: updateCrumbHtml, + updateExtendedHtml: updateExtendedHtml, + updateTreeHtml: updateTreeHtml, + updateHtml: updateHtml + }; + }()); }(jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/Path.js b/src/_h5ai/js/inc/Path.js index 9f99e8cf..f699a06f 100644 --- a/src/_h5ai/js/inc/Path.js +++ b/src/_h5ai/js/inc/Path.js @@ -1,95 +1,95 @@ (function (document, $, H5AI) { - H5AI.Path = function (folder, tableRow) { + H5AI.Path = function (folder, tableRow) { - var path = {}, - $tds, $a, date, size, splits; + var path = {}, + $tds, $a, date, size, splits; - // path.parentFolder: undefined - // path.label: undefined - // path.type: undefined - // path.href: undefined - // path.time: undefined - // path.size: undefined - // path.absHref: undefined - // path.isFolder: undefined - // path.isParentFolder: undefined - // path.isCurrentFolder: undefined - // path.isDomain: undefined + // path.parentFolder: undefined + // path.label: undefined + // path.type: undefined + // path.href: undefined + // path.time: undefined + // path.size: undefined + // path.absHref: undefined + // path.isFolder: undefined + // path.isParentFolder: undefined + // path.isCurrentFolder: undefined + // path.isDomain: undefined - path.status = undefined; // undefined, "h5ai" or HTTP response code - path.content = undefined; // associative array path.absHref -> path - path.html = { - $crumb: undefined, - $extended: undefined, - $tree: undefined - }; - path.treeOpen = false; + path.status = undefined; // undefined, "h5ai" or HTTP response code + path.content = undefined; // associative array path.absHref -> path + path.html = { + $crumb: undefined, + $extended: undefined, + $tree: undefined + }; + path.treeOpen = false; - if (!H5AI.util.pathEndsWithSlash(folder)) { - folder += "/"; - } + if (!H5AI.util.pathEndsWithSlash(folder)) { + folder += "/"; + } - if (tableRow) { - $tds = $(tableRow).find("td"); - $a = $tds.eq(1).find("a"); - date = Date.parse($tds.eq(2).text()); - size = H5AI.util.parseSize($tds.eq(3).text()); + if (tableRow) { + $tds = $(tableRow).find("td"); + $a = $tds.eq(1).find("a"); + date = Date.parse($tds.eq(2).text()); + size = H5AI.util.parseSize($tds.eq(3).text()); - path.parentFolder = folder; - path.label = $a.text(); - path.type = $tds.eq(0).find("img").attr("alt") === "[DIR]" ? "folder" : H5AI.core.getFileType(path.label); - path.href = $a.attr("href"); - path.time = date ? date.getTime() : 0; - path.size = size; - } else { - splits = H5AI.util.splitPath(folder); + path.parentFolder = folder; + path.label = $a.text(); + path.type = $tds.eq(0).find("img").attr("alt") === "[DIR]" ? "folder" : H5AI.core.getFileType(path.label); + path.href = $a.attr("href"); + path.time = date ? date.getTime() : 0; + path.size = size; + } else { + splits = H5AI.util.splitPath(folder); - path.parentFolder = splits.parent || ""; - path.label = H5AI.util.checkedDecodeUri(splits.name); - if (path.label === "/") { - path.label = H5AI.util.checkedDecodeUri(document.domain); - } - path.type = "folder"; - path.href = splits.name; - path.time = 0; - path.size = -1; - } + path.parentFolder = splits.parent || ""; + path.label = H5AI.util.checkedDecodeUri(splits.name); + if (path.label === "/") { + path.label = H5AI.util.checkedDecodeUri(document.domain); + } + path.type = "folder"; + path.href = splits.name; + path.time = 0; + path.size = -1; + } - if (H5AI.util.pathEndsWithSlash(path.label)) { - path.label = path.label.slice(0, -1); - } + if (H5AI.util.pathEndsWithSlash(path.label)) { + path.label = path.label.slice(0, -1); + } - path.isFolder = (path.type === "folder"); - path.isParentFolder = (path.label === "Parent Directory"); - if (path.isParentFolder) { - path.isFolder = true; - path.type = "folder-parent"; - } - path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href; - path.isCurrentFolder = (path.absHref === document.location.pathname); - path.isDomain = (path.absHref === "/"); + path.isFolder = (path.type === "folder"); + path.isParentFolder = (path.label === "Parent Directory"); + if (path.isParentFolder) { + path.isFolder = true; + path.type = "folder-parent"; + } + path.absHref = path.isParentFolder ? path.href : path.parentFolder + path.href; + path.isCurrentFolder = (path.absHref === document.location.pathname); + path.isDomain = (path.absHref === "/"); - if (path.isParentFolder && H5AI.core.settings.setParentFolderLabels) { - if (path.isDomain) { - path.label = H5AI.util.checkedDecodeUri(document.domain); - } else { - splits = H5AI.util.splitPath(path.parentFolder); - path.label = H5AI.util.checkedDecodeUri(splits.parentname); - } - } + if (path.isParentFolder && H5AI.core.settings.setParentFolderLabels) { + if (path.isDomain) { + path.label = H5AI.util.checkedDecodeUri(document.domain); + } else { + splits = H5AI.util.splitPath(path.parentFolder); + path.label = H5AI.util.checkedDecodeUri(splits.parentname); + } + } - path.isEmpty = function () { + path.isEmpty = function () { - return !path.content || $.isEmptyObject(path.content); - }; - path.onClick = function (context) { + return !path.content || $.isEmptyObject(path.content); + }; + path.onClick = function (context) { - H5AI.core.triggerPathClick(path, context); - }; + H5AI.core.triggerPathClick(path, context); + }; - return path; - }; + return path; + }; }(document, jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/Sort.js b/src/_h5ai/js/inc/Sort.js index 5142e1b3..0954298d 100644 --- a/src/_h5ai/js/inc/Sort.js +++ b/src/_h5ai/js/inc/Sort.js @@ -1,157 +1,157 @@ (function ($, H5AI) { - H5AI.sort = (function () { + H5AI.sort = (function () { - var type = function (entry) { + var type = function (entry) { - var $entry = $(entry); + var $entry = $(entry); - if ($entry.hasClass("folder-parent")) { - return 0; - } else if ($entry.hasClass("folder")) { - return 1; - } - return 2; - }, - cmp = function (entry1, entry2, rev, getVal) { + if ($entry.hasClass("folder-parent")) { + return 0; + } else if ($entry.hasClass("folder")) { + return 1; + } + return 2; + }, + cmp = function (entry1, entry2, rev, getVal) { - var res, val1, val2; + var res, val1, val2; - res = type(entry1) - type(entry2); - if (res !== 0) { - return res; - } + res = type(entry1) - type(entry2); + if (res !== 0) { + return res; + } - val1 = getVal(entry1); - val2 = getVal(entry2); - if (val1 < val2) { - return rev ? 1 : -1; - } else if (val1 > val2) { - return rev ? -1 : 1; - } - return 0; - }, - cmpName = function (entry1, entry2) { + val1 = getVal(entry1); + val2 = getVal(entry2); + if (val1 < val2) { + return rev ? 1 : -1; + } else if (val1 > val2) { + return rev ? -1 : 1; + } + return 0; + }, + cmpName = function (entry1, entry2) { - return cmp(entry1, entry2, false, function (entry) { - return $(entry).find(".label").text().toLowerCase(); - }); - }, - cmpTime = function (entry1, entry2) { + return cmp(entry1, entry2, false, function (entry) { + return $(entry).find(".label").text().toLowerCase(); + }); + }, + cmpTime = function (entry1, entry2) { - return cmp(entry1, entry2, false, function (entry) { - return $(entry).find(".date").data("time"); - }); - }, - cmpSize = function (entry1, entry2) { + return cmp(entry1, entry2, false, function (entry) { + return $(entry).find(".date").data("time"); + }); + }, + cmpSize = function (entry1, entry2) { - return cmp(entry1, entry2, false, function (entry) { - return $(entry).find(".size").data("bytes"); - }); - }, - cmpNameRev = function (entry1, entry2) { + return cmp(entry1, entry2, false, function (entry) { + return $(entry).find(".size").data("bytes"); + }); + }, + cmpNameRev = function (entry1, entry2) { - return cmp(entry1, entry2, true, function (entry) { - return $(entry).find(".label").text().toLowerCase(); - }); - }, - cmpTimeRev = function (entry1, entry2) { + return cmp(entry1, entry2, true, function (entry) { + return $(entry).find(".label").text().toLowerCase(); + }); + }, + cmpTimeRev = function (entry1, entry2) { - return cmp(entry1, entry2, true, function (entry) { - return $(entry).find(".date").data("time"); - }); - }, - cmpSizeRev = function (entry1, entry2) { + return cmp(entry1, entry2, true, function (entry) { + return $(entry).find(".date").data("time"); + }); + }, + cmpSizeRev = function (entry1, entry2) { - return cmp(entry1, entry2, true, function (entry) { - return $(entry).find(".size").data("bytes"); - }); - }, - sort = function (fn) { + return cmp(entry1, entry2, true, function (entry) { + return $(entry).find(".size").data("bytes"); + }); + }, + sort = function (fn) { - $("#extended .entry").detach().sort(fn).appendTo($("#extended > ul")); - }, - $all, orders, - sortBy = function (id) { + $("#extended .entry").detach().sort(fn).appendTo($("#extended > ul")); + }, + $all, orders, + sortBy = function (id) { - var order = orders[id]; + var order = orders[id]; - $all.removeClass("ascending").removeClass("descending"); - order.head.addClass(order.clas).attr("href", "#!/sort=" + id); - sort(order.fn); - }, - init = function () { + $all.removeClass("ascending").removeClass("descending"); + order.head.addClass(order.clas).attr("href", "#!/sort=" + id); + sort(order.fn); + }, + init = function () { - var $ascending = $("ascending"), - $descending = $("descending"), - initialOrder = /^.*#!.*\/sort=(.*?)(?:\/.*)?$/.exec(document.location), - $header = $("#extended li.header"), - $label = $header.find("a.label"), - $date = $header.find("a.date"), - $size = $header.find("a.size"); + var $ascending = $("ascending"), + $descending = $("descending"), + initialOrder = /^.*#!.*\/sort=(.*?)(?:\/.*)?$/.exec(document.location), + $header = $("#extended li.header"), + $label = $header.find("a.label"), + $date = $header.find("a.date"), + $size = $header.find("a.size"); - $all = $header.find("a.label,a.date,a.size"); - orders = { - na: { - head: $label, - clas: "ascending", - fn: cmpName - }, - nd: { - head: $label, - clas: "descending", - fn: cmpNameRev - }, - da: { - head: $date, - clas: "ascending", - fn: cmpTime - }, - dd: { - head: $date, - clas: "descending", - fn: cmpTimeRev - }, - sa: { - head: $size, - clas: "ascending", - fn: cmpSize - }, - sd: { - head: $size, - clas: "descending", - fn: cmpSizeRev - } - }; + $all = $header.find("a.label,a.date,a.size"); + orders = { + na: { + head: $label, + clas: "ascending", + fn: cmpName + }, + nd: { + head: $label, + clas: "descending", + fn: cmpNameRev + }, + da: { + head: $date, + clas: "ascending", + fn: cmpTime + }, + dd: { + head: $date, + clas: "descending", + fn: cmpTimeRev + }, + sa: { + head: $size, + clas: "ascending", + fn: cmpSize + }, + sd: { + head: $size, + clas: "descending", + fn: cmpSizeRev + } + }; - sortBy(initialOrder ? initialOrder[1] : H5AI.core.settings.sortorder); + sortBy(initialOrder ? initialOrder[1] : H5AI.core.settings.sortorder); - $label - .attr("href", "#!/sort=na") - .append($ascending.clone()).append($descending.clone()) - .click(function () { - sortBy("n" + ($label.hasClass("ascending") ? "d" : "a")); - }); + $label + .attr("href", "#!/sort=na") + .append($ascending.clone()).append($descending.clone()) + .click(function () { + sortBy("n" + ($label.hasClass("ascending") ? "d" : "a")); + }); - $date - .attr("href", "#!/sort=da") - .prepend($ascending.clone()).prepend($descending.clone()) - .click(function () { - sortBy("d" + ($date.hasClass("ascending") ? "d" : "a")); - }); + $date + .attr("href", "#!/sort=da") + .prepend($ascending.clone()).prepend($descending.clone()) + .click(function () { + sortBy("d" + ($date.hasClass("ascending") ? "d" : "a")); + }); - $size - .attr("href", "#!/sort=sa") - .prepend($ascending.clone()).prepend($descending.clone()) - .click(function () { - sortBy("s" + ($size.hasClass("ascending") ? "d" : "a")); - }); - }; + $size + .attr("href", "#!/sort=sa") + .prepend($ascending.clone()).prepend($descending.clone()) + .click(function () { + sortBy("s" + ($size.hasClass("ascending") ? "d" : "a")); + }); + }; - return { - init: init - }; - }()); + return { + init: init + }; + }()); }(jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/Util.js b/src/_h5ai/js/inc/Util.js index cc8791a3..ed3f298e 100644 --- a/src/_h5ai/js/inc/Util.js +++ b/src/_h5ai/js/inc/Util.js @@ -1,115 +1,115 @@ (function ($, H5AI) { - H5AI.util = (function () { + H5AI.util = (function () { - var reSplitPath = /^\/([^\/]+\/?)$/, - reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/, - splitPath = function (pathname) { + var reSplitPath = /^\/([^\/]+\/?)$/, + reSplitPath2 = /^(\/(?:.*\/)*?([^\/]+)\/)([^\/]+\/?)$/, + splitPath = function (pathname) { - var match; + var match; - if (pathname === "/") { - return { - parent: null, - parentname: null, - name: "/" - }; - } - match = reSplitPath2.exec(pathname); - if (match) { - return { - parent: match[1], - parentname: match[2], - name: match[3] - }; - } - match = reSplitPath.exec(pathname); - if (match) { - return { - parent: "/", - parentname: "/", - name: match[1] - }; - } - }, - rePathEndsWithSlash = /\/$/, - pathEndsWithSlash = function (pathname) { + if (pathname === "/") { + return { + parent: null, + parentname: null, + name: "/" + }; + } + match = reSplitPath2.exec(pathname); + if (match) { + return { + parent: match[1], + parentname: match[2], + name: match[3] + }; + } + match = reSplitPath.exec(pathname); + if (match) { + return { + parent: "/", + parentname: "/", + name: match[1] + }; + } + }, + rePathEndsWithSlash = /\/$/, + pathEndsWithSlash = function (pathname) { - return rePathEndsWithSlash.test(pathname); - }, - getAbsHref = function (folder, tableRow) { + return rePathEndsWithSlash.test(pathname); + }, + getAbsHref = function (folder, tableRow) { - var $a, isParentFolder, href; + var $a, isParentFolder, href; - if (!pathEndsWithSlash(folder)) { - folder += "/"; - } - if (!tableRow) { - return folder; - } - $a = $(tableRow).find("td").eq(1).find("a"); - isParentFolder = ($a.text() === "Parent Directory"); - href = $a.attr("href"); - return isParentFolder ? undefined : folder + href; - }, - kilo = 1000.0, - reParseSize = /^\s*([\.\d]+)\s*([kmg]?)b?\s*$/i, - parseSize = function (str) { + if (!pathEndsWithSlash(folder)) { + folder += "/"; + } + if (!tableRow) { + return folder; + } + $a = $(tableRow).find("td").eq(1).find("a"); + isParentFolder = ($a.text() === "Parent Directory"); + href = $a.attr("href"); + return isParentFolder ? undefined : folder + href; + }, + kilo = 1000.0, + reParseSize = /^\s*([\.\d]+)\s*([kmg]?)b?\s*$/i, + parseSize = function (str) { - var match = reParseSize.exec(str), - val, unit; + var match = reParseSize.exec(str), + val, unit; - if (!match) { - return -1; - } + if (!match) { + return -1; + } - val = parseFloat(match[1]); - unit = match[2].toLowerCase(); - if (unit === "k") { - val *= kilo; - } else if (unit === "m") { - val *= kilo * kilo; - } else if (unit === "g") { - val *= kilo * kilo * kilo; - } else if (unit === "t") { - val *= kilo * kilo * kilo * kilo; - } - return val; - }, - sizeUnits = ["B", "KB", "MB", "GB", "TB"], - formatSize = function (size) { + val = parseFloat(match[1]); + unit = match[2].toLowerCase(); + if (unit === "k") { + val *= kilo; + } else if (unit === "m") { + val *= kilo * kilo; + } else if (unit === "g") { + val *= kilo * kilo * kilo; + } else if (unit === "t") { + val *= kilo * kilo * kilo * kilo; + } + return val; + }, + sizeUnits = ["B", "KB", "MB", "GB", "TB"], + formatSize = function (size) { - var th = 1000.0, - i = 0, - maxI = sizeUnits.length - 1; + var th = 1000.0, + i = 0, + maxI = sizeUnits.length - 1; - if (isNaN(size)) { - return size; - } + if (isNaN(size)) { + return size; + } - while (size >= th && i < maxI) { - size /= kilo; - i += 1; - } - return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + " " + sizeUnits[i]; - }, - checkedDecodeUri = function (uri) { + while (size >= th && i < maxI) { + size /= kilo; + i += 1; + } + return (i <= 1 ? Math.round(size) : size.toFixed(1)).toString() + " " + sizeUnits[i]; + }, + checkedDecodeUri = function (uri) { - try { - return decodeURI(uri); - } catch (err) {} - return uri; - }; + try { + return decodeURI(uri); + } catch (err) {} + return uri; + }; - return { - splitPath: splitPath, - pathEndsWithSlash: pathEndsWithSlash, - getAbsHref: getAbsHref, - parseSize: parseSize, - formatSize: formatSize, - checkedDecodeUri: checkedDecodeUri - }; - }()); + return { + splitPath: splitPath, + pathEndsWithSlash: pathEndsWithSlash, + getAbsHref: getAbsHref, + parseSize: parseSize, + formatSize: formatSize, + checkedDecodeUri: checkedDecodeUri + }; + }()); }(jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index 12f81cc0..375b9585 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -1,110 +1,110 @@ (function ($, H5AI) { - H5AI.zippedDownload = (function () { + H5AI.zippedDownload = (function () { - var x = 0, - y = 0, - $document = $(document), - $selectionRect = $("#selection-rect"), - updateDownloadBtn = function () { + var x = 0, + y = 0, + $document = $(document), + $selectionRect = $("#selection-rect"), + updateDownloadBtn = function () { - var $selected = $("#extended a.selected"), - $downloadBtn = $("#download"), - query, href; + var $selected = $("#extended a.selected"), + $downloadBtn = $("#download"), + query, href; - if ($selected.size() > 0) { - $selected.each(function () { - href = $(this).attr("href"); - query = query ? query + ":" + href : href; - }); - query = H5AI.core.api() + "?action=zip&hrefs=" + query; - $downloadBtn.show().find("a").attr("href", query); - } else { - $downloadBtn.hide().find("a").attr("href", "#"); - } - }, - selectionUpdate = function (event) { + if ($selected.size() > 0) { + $selected.each(function () { + href = $(this).attr("href"); + query = query ? query + ":" + href : href; + }); + query = H5AI.core.api() + "?action=zip&hrefs=" + query; + $downloadBtn.show().find("a").attr("href", query); + } else { + $downloadBtn.hide().find("a").attr("href", "#"); + } + }, + selectionUpdate = function (event) { - var l = Math.min(x, event.pageX), - t = Math.min(y, event.pageY), - w = Math.abs(x - event.pageX), - h = Math.abs(y - event.pageY), - selRect; + var l = Math.min(x, event.pageX), + t = Math.min(y, event.pageY), + w = Math.abs(x - event.pageX), + h = Math.abs(y - event.pageY), + selRect; - event.preventDefault(); - $selectionRect.css({left: l, top: t, width: w, height: h}); + event.preventDefault(); + $selectionRect.css({left: l, top: t, width: w, height: h}); - selRect = $selectionRect.fracs("rect"); - $("#extended a").removeClass("selecting").each(function () { + selRect = $selectionRect.fracs("rect"); + $("#extended a").removeClass("selecting").each(function () { - var $a = $(this), - rect = $a.fracs("rect"), - inter = selRect.intersection(rect); - if (inter && !$a.closest(".entry").hasClass("folder-parent")) { - $a.addClass("selecting"); - } - }); - }, - selectionEnd = function (event) { + var $a = $(this), + rect = $a.fracs("rect"), + inter = selRect.intersection(rect); + if (inter && !$a.closest(".entry").hasClass("folder-parent")) { + $a.addClass("selecting"); + } + }); + }, + selectionEnd = function (event) { - event.preventDefault(); - $document.off("mousemove", selectionUpdate); - $selectionRect.hide().css({left: 0, top: 0, width: 0, height: 0}); - $("#extended a.selecting.selected").removeClass("selecting").removeClass("selected"); - $("#extended a.selecting").removeClass("selecting").addClass("selected"); - updateDownloadBtn(); - }, - selectionStart = function (event) { + event.preventDefault(); + $document.off("mousemove", selectionUpdate); + $selectionRect.hide().css({left: 0, top: 0, width: 0, height: 0}); + $("#extended a.selecting.selected").removeClass("selecting").removeClass("selected"); + $("#extended a.selecting").removeClass("selecting").addClass("selected"); + updateDownloadBtn(); + }, + selectionStart = function (event) { - var view = $.fracs.viewport(); + var view = $.fracs.viewport(); - x = event.pageX; - y = event.pageY; - // only on left button and don't block the scrollbars - if (event.button !== 0 || x >= view.right || y >= view.bottom) { - return; - } + x = event.pageX; + y = event.pageY; + // only on left button and don't block the scrollbars + if (event.button !== 0 || x >= view.right || y >= view.bottom) { + return; + } - event.preventDefault(); - if (!event.ctrlKey) { - $("#extended a").removeClass("selected"); - updateDownloadBtn(); - } - $selectionRect.show().css({left: x, top: y, width: 0, height: 0}); - selectionUpdate(event); + event.preventDefault(); + if (!event.ctrlKey) { + $("#extended a").removeClass("selected"); + updateDownloadBtn(); + } + $selectionRect.show().css({left: x, top: y, width: 0, height: 0}); + selectionUpdate(event); - $document - .on("mousemove", selectionUpdate) - .one("mouseup", selectionEnd); - }, - noSelection = function (event) { + $document + .on("mousemove", selectionUpdate) + .one("mouseup", selectionEnd); + }, + noSelection = function (event) { - event.stopPropagation(); - return false; - }, - noSelectionUnlessCtrl = function (event) { + event.stopPropagation(); + return false; + }, + noSelectionUnlessCtrl = function (event) { - if (!event.ctrlKey) { - noSelection(event); - } - }, - init = function () { + if (!event.ctrlKey) { + noSelection(event); + } + }, + init = function () { - if (H5AI.core.settings.zippedDownload) { - $("
              • downloaddownload
              • ") - .find("img").attr("src", H5AI.core.image("download")).end() - .appendTo($("#navbar")); + if (H5AI.core.settings.zippedDownload) { + $("
              • downloaddownload
              • ") + .find("img").attr("src", H5AI.core.image("download")).end() + .appendTo($("#navbar")); - $("body>nav,body>footer,#tree").on("mousedown", noSelection); - $("#extended").on("mousedown", "a", noSelectionUnlessCtrl); - $document.on("mousedown", selectionStart); - } - }; + $("body>nav,body>footer,#tree").on("mousedown", noSelection); + $("#extended").on("mousedown", "a", noSelectionUnlessCtrl); + $document.on("mousedown", selectionStart); + } + }; - return { - init: init - }; - }()); + return { + init: init + }; + }()); }(jQuery, H5AI)); diff --git a/src/_h5ai/js/inc/lib/jquery.mousewheel.js b/src/_h5ai/js/inc/lib/jquery.mousewheel.js index 6e5732ab..2d699030 100644 --- a/src/_h5ai/js/inc/lib/jquery.mousewheel.js +++ b/src/_h5ai/js/inc/lib/jquery.mousewheel.js @@ -6,7 +6,7 @@ * Thanks to: Seamus Leahy for adding deltaX and deltaY * * Version: 3.0.5 - * + * * Requires: 1.2.2+ */ @@ -15,73 +15,70 @@ var types = ['DOMMouseScroll', 'mousewheel']; if ($.event.fixHooks) { - for ( var i=types.length; i; ) { - $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; - } + for ( var i=types.length; i; ) { + $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; + } } $.event.special.mousewheel = { - setup: function() { - if ( this.addEventListener ) { - for ( var i=types.length; i; ) { - this.addEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = handler; - } - }, - - teardown: function() { - if ( this.removeEventListener ) { - for ( var i=types.length; i; ) { - this.removeEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = null; - } - } + setup: function() { + if ( this.addEventListener ) { + for ( var i=types.length; i; ) { + this.addEventListener( types[--i], handler, false ); + } + } else { + this.onmousewheel = handler; + } + }, + + teardown: function() { + if ( this.removeEventListener ) { + for ( var i=types.length; i; ) { + this.removeEventListener( types[--i], handler, false ); + } + } else { + this.onmousewheel = null; + } + } }; $.fn.extend({ - mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); - }, - - unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); - } + mousewheel: function(fn) { + return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); + }, + + unmousewheel: function(fn) { + return this.unbind("mousewheel", fn); + } }); function handler(event) { - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - event = $.event.fix(orgEvent); - event.type = "mousewheel"; - - // Old school scrollwheel delta - if ( event.wheelDelta ) { delta = event.wheelDelta/120; } - if ( event.detail ) { delta = -event.detail/3; } - - // New school multidimensional scroll (touchpads) deltas - deltaY = delta; - - // Gecko - if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { - deltaY = 0; - deltaX = -1*delta; - } - - // Webkit - if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } - if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } - - // Add event and delta to the front of the arguments - args.unshift(event, delta, deltaX, deltaY); - - return ($.event.dispatch || $.event.handle).apply(this, args); + var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; + event = $.event.fix(orgEvent); + event.type = "mousewheel"; + + // Old school scrollwheel delta + if ( event.wheelDelta ) { delta = event.wheelDelta/120; } + if ( event.detail ) { delta = -event.detail/3; } + + // New school multidimensional scroll (touchpads) deltas + deltaY = delta; + + // Gecko + if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { + deltaY = 0; + deltaX = -1*delta; + } + + // Webkit + if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } + if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } + + // Add event and delta to the front of the arguments + args.unshift(event, delta, deltaX, deltaY); + + return ($.event.dispatch || $.event.handle).apply(this, args); } })(jQuery); - - - diff --git a/src/_h5ai/js/inc/lib/jquery.scrollpanel.js b/src/_h5ai/js/inc/lib/jquery.scrollpanel.js index 1e137f80..2b8d0a0c 100644 --- a/src/_h5ai/js/inc/lib/jquery.scrollpanel.js +++ b/src/_h5ai/js/inc/lib/jquery.scrollpanel.js @@ -2,156 +2,156 @@ * jQuery.scrollpanel * author: Lars Jung * license: MIT - * - * bad and ugly coded! + * + * still quick and dirty! */ (function (window, $) { - "use strict"; + "use strict"; - var $window = $(window), - init = function (htmlElement) { + var $window = $(window), + init = function (htmlElement) { - var $element = $(htmlElement), - $scrollbar, $drag, $wrapper, $content, mouseOffsetY, updateId, - update, scroll; + var $element = $(htmlElement), + $scrollbar, $drag, $wrapper, $content, mouseOffsetY, updateId, + update, scroll; - if (!$element.css("position") || $element.css("position") === "static") { - $element.css("position", "relative"); - } + if (!$element.css("position") || $element.css("position") === "static") { + $element.css("position", "relative"); + } - $scrollbar = $("
                "); - $drag = $("
                ").appendTo($scrollbar); - $element - .wrapInner("
                ") - .append($scrollbar); - $wrapper = $element.find("> .wrapper"); - $content = $wrapper.find("> .content"); - mouseOffsetY = 0; + $scrollbar = $("
                "); + $drag = $("
                ").appendTo($scrollbar); + $element + .wrapInner("
                ") + .append($scrollbar); + $wrapper = $element.find("> .wrapper"); + $content = $wrapper.find("> .content"); + mouseOffsetY = 0; - update = function (repeat) { + update = function (repeat) { - var visibleHeight, contentHeight, scrollTop, scrollTopFrac, visVertFrac; + var visibleHeight, contentHeight, scrollTop, scrollTopFrac, visVertFrac; - if (updateId && !repeat) { - clearInterval(updateId); - updateId = undefined; - } else if (!updateId && repeat) { - updateId = setInterval(function() { update(true); }, 50); - } + if (updateId && !repeat) { + clearInterval(updateId); + updateId = undefined; + } else if (!updateId && repeat) { + updateId = setInterval(function() { update(true); }, 50); + } - $wrapper.css("height", $element.height()); - visibleHeight = $element.height(); - contentHeight = $content.outerHeight(); - scrollTop = $wrapper.scrollTop(); - scrollTopFrac = scrollTop / contentHeight; - visVertFrac = Math.min(visibleHeight / contentHeight, 1); + $wrapper.css("height", $element.height()); + visibleHeight = $element.height(); + contentHeight = $content.outerHeight(); + scrollTop = $wrapper.scrollTop(); + scrollTopFrac = scrollTop / contentHeight; + visVertFrac = Math.min(visibleHeight / contentHeight, 1); - if (visVertFrac < 1) { - $scrollbar - .fadeIn(50) - .css({ - height: $element.innerHeight() + $scrollbar.height() - $scrollbar.outerHeight(true) - }); - $drag - .css({ - top: $scrollbar.height() * scrollTopFrac, - height: $scrollbar.height() * visVertFrac - }); - } else { - $scrollbar.fadeOut(50); - } - }; + if (visVertFrac < 1) { + $scrollbar + .fadeIn(50) + .css({ + height: $element.innerHeight() + $scrollbar.height() - $scrollbar.outerHeight(true) + }); + $drag + .css({ + top: $scrollbar.height() * scrollTopFrac, + height: $scrollbar.height() * visVertFrac + }); + } else { + $scrollbar.fadeOut(50); + } + }; - scroll = function (event) { + scroll = function (event) { - var clickFrac = (event.pageY - $scrollbar.offset().top - mouseOffsetY) / $scrollbar.height(); + var clickFrac = (event.pageY - $scrollbar.offset().top - mouseOffsetY) / $scrollbar.height(); - $wrapper.scrollTop($content.outerHeight() * clickFrac); - update(); - event.preventDefault(); - }; + $wrapper.scrollTop($content.outerHeight() * clickFrac); + update(); + event.preventDefault(); + }; - $element - .mousewheel(function (event, delta) { - - $wrapper.scrollTop($wrapper.scrollTop() - 50 * delta); - update(); - event.stopPropagation(); - event.preventDefault(); - }) - .scroll(update); - $element.get(0).updateScrollbar = update; - $wrapper - .css({ - "padding-right": $scrollbar.outerWidth(true), - height: $element.height(), - overflow: "hidden" - }); - $scrollbar - .css({ - position: "absolute", - top: 0, - right: 0, - overflow: "hidden", - cursor: "pointer" - }) - .mousedown(function (event) { + $element + .mousewheel(function (event, delta) { - mouseOffsetY = $drag.outerHeight() / 2; - scroll(event); - $scrollbar.addClass("dragOn"); - $window - .bind("mousemove", scroll) - .one("mouseup", function (event) { + $wrapper.scrollTop($wrapper.scrollTop() - 50 * delta); + update(); + event.stopPropagation(); + event.preventDefault(); + }) + .scroll(update); + $element.get(0).updateScrollbar = update; + $wrapper + .css({ + "padding-right": $scrollbar.outerWidth(true), + height: $element.height(), + overflow: "hidden" + }); + $scrollbar + .css({ + position: "absolute", + top: 0, + right: 0, + overflow: "hidden", + cursor: "pointer" + }) + .mousedown(function (event) { - $scrollbar.removeClass("dragOn"); - $window.unbind("mousemove", scroll); - scroll(event); - event.stopPropagation(); - }); - event.preventDefault(); - }) - .each(function () { + mouseOffsetY = $drag.outerHeight() / 2; + scroll(event); + $scrollbar.addClass("dragOn"); + $window + .bind("mousemove", scroll) + .one("mouseup", function (event) { - this.onselectstart = function () { + $scrollbar.removeClass("dragOn"); + $window.unbind("mousemove", scroll); + scroll(event); + event.stopPropagation(); + }); + event.preventDefault(); + }) + .each(function () { - return false; - }; - }); - $drag - .css({ - position: "absolute", - left: 0, - width: "100%" - }) - .mousedown(function (event) { + this.onselectstart = function () { - mouseOffsetY = event.pageY - $drag.offset().top; - scroll(event); - $scrollbar.addClass("dragOn"); - $window - .bind("mousemove", scroll) - .one("mouseup", function (event) { + return false; + }; + }); + $drag + .css({ + position: "absolute", + left: 0, + width: "100%" + }) + .mousedown(function (event) { - $scrollbar.removeClass("dragOn"); - $window.unbind("mousemove", scroll); - scroll(event); - event.stopPropagation(); - }); - event.stopPropagation(); - }); + mouseOffsetY = event.pageY - $drag.offset().top; + scroll(event); + $scrollbar.addClass("dragOn"); + $window + .bind("mousemove", scroll) + .one("mouseup", function (event) { - update(); - }; + $scrollbar.removeClass("dragOn"); + $window.unbind("mousemove", scroll); + scroll(event); + event.stopPropagation(); + }); + event.stopPropagation(); + }); + + update(); + }; - $.fn.scrollpanel = function () { + $.fn.scrollpanel = function () { - return this.each(function () { + return this.each(function () { - init(this); - }); - }; + init(this); + }); + }; }(window, jQuery)); diff --git a/src/_h5ai/js/main-js.js b/src/_h5ai/js/main-js.js index 2f6441bf..8c31f2a9 100644 --- a/src/_h5ai/js/main-js.js +++ b/src/_h5ai/js/main-js.js @@ -3,27 +3,27 @@ /*global jQuery, amplify, H5AI_CONFIG */ (function ($) { - "use strict"; + "use strict"; - var H5AI = {}; + var H5AI = {}; - // @include "inc/Util.js" - // @include "inc/Core.js" - // @include "inc/Sort.js" - // @include "inc/ZippedDownload.js" + // @include "inc/Util.js" + // @include "inc/Core.js" + // @include "inc/Sort.js" + // @include "inc/ZippedDownload.js" - // @include "inc/Path.js" - // @include "inc/Connector.js" - // @include "inc/Html.js" - // @include "inc/Extended.js" + // @include "inc/Path.js" + // @include "inc/Connector.js" + // @include "inc/Html.js" + // @include "inc/Extended.js" - $(function () { + $(function () { - H5AI.extended.init(); + H5AI.extended.init(); - H5AI.core.init(); - H5AI.sort.init(); - H5AI.zippedDownload.init(); - }); + H5AI.core.init(); + H5AI.sort.init(); + H5AI.zippedDownload.init(); + }); }(jQuery)); diff --git a/src/_h5ai/js/main-php.js b/src/_h5ai/js/main-php.js index 168ad520..0bfc484d 100644 --- a/src/_h5ai/js/main-php.js +++ b/src/_h5ai/js/main-php.js @@ -3,23 +3,23 @@ /*global jQuery, amplify, H5AI_CONFIG */ (function ($) { - "use strict"; + "use strict"; - var H5AI = {}; + var H5AI = {}; - // @include "inc/Util.js" - // @include "inc/Core.js" - // @include "inc/Sort.js" - // @include "inc/ZippedDownload.js" + // @include "inc/Util.js" + // @include "inc/Core.js" + // @include "inc/Sort.js" + // @include "inc/ZippedDownload.js" - $(function () { + $(function () { - H5AI.core.init(); - H5AI.sort.init(); - H5AI.zippedDownload.init(); + H5AI.core.init(); + H5AI.sort.init(); + H5AI.zippedDownload.init(); - $("#tree").scrollpanel(); - H5AI.core.shiftTree(false, true); - }); + $("#tree").scrollpanel(); + H5AI.core.shiftTree(false, true); + }); }(jQuery)); diff --git a/src/_h5ai/php/api.php b/src/_h5ai/php/api.php index 11ddbdca..c997b7d6 100644 --- a/src/_h5ai/php/api.php +++ b/src/_h5ai/php/api.php @@ -2,19 +2,19 @@ function fail($code, $msg, $cond = true) { - if ($cond) { - echo "$code: $msg"; - exit; - } + if ($cond) { + echo "$code: $msg"; + exit; + } } function checkKeys($keys) { - $values = array(); - foreach ($keys as $key) { - fail(1, "parameter '$key' is missing", !array_key_exists($key, $_REQUEST)); - $values[] = $_REQUEST[$key]; - } - return $values; + $values = array(); + foreach ($keys as $key) { + fail(1, "parameter '$key' is missing", !array_key_exists($key, $_REQUEST)); + $values[] = $_REQUEST[$key]; + } + return $values; } @@ -29,97 +29,97 @@ $options = $h5ai->getOptions(); if ($action === "httpcodes") { - list($hrefs) = checkKeys(array("hrefs")); + list($hrefs) = checkKeys(array("hrefs")); - function getHttpCodes($h5ai, $hrefs) { + function getHttpCodes($h5ai, $hrefs) { - $codes = array(); - foreach ($hrefs as $href) { - $href = trim($href); - if (strlen($href) > 0) { - $codes[$href] = $h5ai->getHttpCode($href); - } - } - return $codes; - } + $codes = array(); + foreach ($hrefs as $href) { + $href = trim($href); + if (strlen($href) > 0) { + $codes[$href] = $h5ai->getHttpCode($href); + } + } + return $codes; + } - $hrefs = preg_split("/;/", $hrefs); - $codes = getHttpCodes($h5ai, $hrefs); + $hrefs = preg_split("/;/", $hrefs); + $codes = getHttpCodes($h5ai, $hrefs); - echo count($codes) === 0 ? "{}" : json_encode($codes); + echo count($codes) === 0 ? "{}" : json_encode($codes); } else if ($action === "thumb") { - fail(0, "thumbs are disabled", !$options["showThumbs"]); - list($srcAbsHref, $width, $height, $mode) = checkKeys(array("href", "width", "height", "mode")); + fail(0, "thumbs are disabled", !$options["showThumbs"]); + list($srcAbsHref, $width, $height, $mode) = checkKeys(array("href", "width", "height", "mode")); - require_once "inc/Thumbnail.php"; - require_once "inc/Image.php"; + require_once "inc/Thumbnail.php"; + require_once "inc/Image.php"; - $srcAbsPath = $h5ai->getDocRoot() . rawurldecode($srcAbsHref); + $srcAbsPath = $h5ai->getDocRoot() . rawurldecode($srcAbsHref); - if (!Thumbnail::isUsable()) { - Image::showImage($srcAbsPath); - exit; - } + if (!Thumbnail::isUsable()) { + Image::showImage($srcAbsPath); + exit; + } - $thumbnail = new Thumbnail($h5ai, $srcAbsHref, $mode, $width, $height); - $thumbnail->create(1); - if (file_exists($thumbnail->getPath())) { - Image::showImage($thumbnail->getPath()); - } else { - $image = new Image(); - $image->setSource($srcAbsPath); - $image->thumb($mode, $width, $height); - $image->showDest(); - } + $thumbnail = new Thumbnail($h5ai, $srcAbsHref, $mode, $width, $height); + $thumbnail->create(1); + if (file_exists($thumbnail->getPath())) { + Image::showImage($thumbnail->getPath()); + } else { + $image = new Image(); + $image->setSource($srcAbsPath); + $image->thumb($mode, $width, $height); + $image->showDest(); + } } else if ($action === "tree") { - list($href) = checkKeys(array("href")); + list($href) = checkKeys(array("href")); - require_once "inc/Tree.php"; + require_once "inc/Tree.php"; - $absHref = trim($href); - $absPath = $h5ai->getAbsPath($absHref); + $absHref = trim($href); + $absPath = $h5ai->getAbsPath($absHref); - $tree = new TreeEntry($h5ai, $absPath, $absHref); - $tree->loadContent(); + $tree = new TreeEntry($h5ai, $absPath, $absHref); + $tree->loadContent(); - echo $tree->contentToHtml(); + echo $tree->contentToHtml(); } else if ($action === "zip") { - fail(0, "zipped download is disabled", !$options["zippedDownload"]); - list($hrefs) = checkKeys(array("hrefs")); + fail(0, "zipped download is disabled", !$options["zippedDownload"]); + list($hrefs) = checkKeys(array("hrefs")); - require_once "inc/ZipIt.php"; + require_once "inc/ZipIt.php"; - $zipit = new ZipIt($h5ai); + $zipit = new ZipIt($h5ai); - $hrefs = explode(":", trim($hrefs)); - $zipFile = $zipit->zip($hrefs); + $hrefs = explode(":", trim($hrefs)); + $zipFile = $zipit->zip($hrefs); - if ($zipFile === false) { - fail(2, "something went wrong while building the zip"); - } + if ($zipFile === false) { + fail(2, "something went wrong while building the zip"); + } - header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\""); - header("Content-Type: application/force-download"); - header("Content-Length: " . filesize($zipFile)); - header("Connection: close"); - readfile($zipFile); + header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\""); + header("Content-Type: application/force-download"); + header("Content-Length: " . filesize($zipFile)); + header("Connection: close"); + readfile($zipFile); } else { - fail(1, "unsupported 'action' specified"); + fail(1, "unsupported 'action' specified"); } diff --git a/src/_h5ai/php/inc/Cache.php b/src/_h5ai/php/inc/Cache.php index 6aa01b71..45015e86 100644 --- a/src/_h5ai/php/inc/Cache.php +++ b/src/_h5ai/php/inc/Cache.php @@ -7,87 +7,87 @@ ############################################## class Cache { - private $dir; + private $dir; - function __construct($dir) { + function __construct($dir) { - $this->dir = $dir; - } + $this->dir = $dir; + } - private function _name($key) { + private function _name($key) { - return $this->dir . "/" . sha1($key); - } + return $this->dir . "/" . sha1($key); + } - public function get($key, $expiration = 3600) { + public function get($key, $expiration = 3600) { - if (!is_dir($this->dir) || !is_writable($this->dir)) { - return false; - } + if (!is_dir($this->dir) || !is_writable($this->dir)) { + return false; + } - $cache_path = $this->_name($key); + $cache_path = $this->_name($key); - if (!@file_exists($cache_path)) { - return false; - } + if (!@file_exists($cache_path)) { + return false; + } - if (filemtime($cache_path) < (time() - $expiration)) { - $this->clear($key); - return false; - } + if (filemtime($cache_path) < (time() - $expiration)) { + $this->clear($key); + return false; + } - if (!$fp = @fopen($cache_path, "rb")) { - return false; - } + if (!$fp = @fopen($cache_path, "rb")) { + return false; + } - flock($fp, LOCK_SH); - $cache = ""; + flock($fp, LOCK_SH); + $cache = ""; - if (filesize($cache_path) > 0) { - $cache = unserialize(fread($fp, filesize($cache_path))); - } else { - $cache = null; - } + if (filesize($cache_path) > 0) { + $cache = unserialize(fread($fp, filesize($cache_path))); + } else { + $cache = null; + } - flock($fp, LOCK_UN); - fclose($fp); + flock($fp, LOCK_UN); + fclose($fp); - return $cache; - } + return $cache; + } - public function set($key, $data) { + public function set($key, $data) { - if (!is_dir($this->dir) || !is_writable($this->dir)) { - return false; - } + if (!is_dir($this->dir) || !is_writable($this->dir)) { + return false; + } - $cache_path = $this->_name($key); + $cache_path = $this->_name($key); - if (! $fp = fopen($cache_path, "wb")) { - return false; - } + if (! $fp = fopen($cache_path, "wb")) { + return false; + } - if (flock($fp, LOCK_EX)) { - fwrite($fp, serialize($data)); - flock($fp, LOCK_UN); - } else { - return false; - } - fclose($fp); - @chmod($cache_path, 0777); - return true; - } + if (flock($fp, LOCK_EX)) { + fwrite($fp, serialize($data)); + flock($fp, LOCK_UN); + } else { + return false; + } + fclose($fp); + @chmod($cache_path, 0777); + return true; + } - public function clear($key) { + public function clear($key) { - $cache_path = $this->_name($key); + $cache_path = $this->_name($key); - if (file_exists($cache_path)) { - unlink($cache_path); - return true; - } - return false; - } + if (file_exists($cache_path)) { + unlink($cache_path); + return true; + } + return false; + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/Crumb.php b/src/_h5ai/php/inc/Crumb.php index cb86ae6c..2f415750 100644 --- a/src/_h5ai/php/inc/Crumb.php +++ b/src/_h5ai/php/inc/Crumb.php @@ -1,52 +1,52 @@ h5ai = $h5ai; - $this->parts = array(); + $this->h5ai = $h5ai; + $this->parts = array(); - $href = $h5ai->getAbsHref(); - while ($href !== "/" && $href !== "//") { - $this->parts[] = $href; - $href = dirname($href) . "/"; - } - $this->parts[] = "/"; + $href = $h5ai->getAbsHref(); + while ($href !== "/" && $href !== "//") { + $this->parts[] = $href; + $href = dirname($href) . "/"; + } + $this->parts[] = "/"; - $this->parts = array_reverse($this->parts); - } + $this->parts = array_reverse($this->parts); + } - public function toHtml() { + public function toHtml() { - $html = ""; - $idx = 0; - foreach($this->parts as $href) { - $idx++; - $classes = "crumb folder" . ($idx === 1 ? " domain" : "") . ($idx === count($this->parts) ? " current" : ""); - $image = $this->h5ai->image($idx === 1 ? "home" : "crumb"); - $label = $this->h5ai->getLabel($href); - $hint = ""; + $html = ""; + $idx = 0; + foreach($this->parts as $href) { + $idx++; + $classes = "crumb folder" . ($idx === 1 ? " domain" : "") . ($idx === count($this->parts) ? " current" : ""); + $image = $this->h5ai->image($idx === 1 ? "home" : "crumb"); + $label = $this->h5ai->getLabel($href); + $hint = ""; - $code = $this->h5ai->getHttpCode($href); - $classes .= " checkedHttpCode"; - if ($code !== "h5ai") { - if ($code === 200) { - $hint = "page"; - } else { - $hint = "(" . $code . ")"; - } - } + $code = $this->h5ai->getHttpCode($href); + $classes .= " checkedHttpCode"; + if ($code !== "h5ai") { + if ($code === 200) { + $hint = "page"; + } else { + $hint = "(" . $code . ")"; + } + } - $html .= "
              • \n"; - $html .= "\t\n"; - $html .= "\t\t>" . $label . "" . $hint . "\n"; - $html .= "\t\n"; - $html .= "
              • \n"; - } - return $html; - } + $html .= "
              • \n"; + $html .= "\t\n"; + $html .= "\t\t>" . $label . "" . $hint . "\n"; + $html .= "\t\n"; + $html .= "
              • \n"; + } + return $html; + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/Customize.php b/src/_h5ai/php/inc/Customize.php index 593bc931..aa720efa 100644 --- a/src/_h5ai/php/inc/Customize.php +++ b/src/_h5ai/php/inc/Customize.php @@ -1,30 +1,30 @@ getAbsPath(); - $options = $h5ai->getOptions(); - $this->customHeader = $absPath . "/" . $options["customHeader"]; - $this->customFooter = $absPath . "/" . $options["customFooter"]; - } + $absPath = $h5ai->getAbsPath(); + $options = $h5ai->getOptions(); + $this->customHeader = $absPath . "/" . $options["customHeader"]; + $this->customFooter = $absPath . "/" . $options["customFooter"]; + } - public function getHeader() { + public function getHeader() { - return $this->getContent($this->customHeader, "header"); - } + return $this->getContent($this->customHeader, "header"); + } - public function getFooter() { + public function getFooter() { - return $this->getContent($this->customFooter, "footer"); - } + return $this->getContent($this->customFooter, "footer"); + } - private function getContent($file, $tag) { + private function getContent($file, $tag) { - return file_exists($file) ? ("<" . $tag . ">" . file_get_contents($file) . "") : ""; - } + return file_exists($file) ? ("<" . $tag . ">" . file_get_contents($file) . "") : ""; + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/Extended.php b/src/_h5ai/php/inc/Extended.php index 2b046ea2..ed941635 100644 --- a/src/_h5ai/php/inc/Extended.php +++ b/src/_h5ai/php/inc/Extended.php @@ -4,141 +4,141 @@ require_once "Thumbnail.php"; class Entry { - private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size, $thumbTypes; + private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size, $thumbTypes; - public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) { + public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) { - $this->h5ai = $h5ai; - $this->label = $label !== null ? $label : $this->h5ai->getLabel($absHref); - $this->absPath = $this->h5ai->normalizePath($absPath, false); - $this->isFolder = is_dir($this->absPath); - $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder); + $this->h5ai = $h5ai; + $this->label = $label !== null ? $label : $this->h5ai->getLabel($absHref); + $this->absPath = $this->h5ai->normalizePath($absPath, false); + $this->isFolder = is_dir($this->absPath); + $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder); - $this->date = filemtime($this->absPath); + $this->date = filemtime($this->absPath); - if ($this->isFolder) { - $this->type = $type !== null ? $type : "folder"; - $this->size = ""; - } else { - $this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath); - $this->size = filesize($this->absPath); - } + if ($this->isFolder) { + $this->type = $type !== null ? $type : "folder"; + $this->size = ""; + } else { + $this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath); + $this->size = filesize($this->absPath); + } - $this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff"); - } + $this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff"); + } - public function isFolder() { + public function isFolder() { - return $this->isFolder; - } + return $this->isFolder; + } - public function toHtml() { + public function toHtml() { - $classes = "entry " . ($this->isFolder ? "folder " : "file ") . $this->type; - $imgClass = ""; - $img = $this->type; - $smallImg = $this->h5ai->icon($this->type); - $bigImg = $this->h5ai->icon($this->type, true); - $hint = ""; + $classes = "entry " . ($this->isFolder ? "folder " : "file ") . $this->type; + $imgClass = ""; + $img = $this->type; + $smallImg = $this->h5ai->icon($this->type); + $bigImg = $this->h5ai->icon($this->type, true); + $hint = ""; - if ($this->isFolder && $this->type !== "folder-parent") { - $code = $this->h5ai->getHttpCode($this->absHref); - $classes .= " checkedHttpCode"; - if ($code !== "h5ai") { - if ($code === 200) { - $img = "folder-page"; - $smallImg = $this->h5ai->icon("folder-page"); - $bigImg = $this->h5ai->icon("folder-page", true); - } else { - $classes .= " error"; - $hint = " " . $code . " "; - } - } - } - if ($this->h5ai->showThumbs() && in_array($this->type, $this->thumbTypes)) { - $imgClass = " class='thumb' "; - $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16); - $thumbnail->create(); - $smallImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref(); - $thumbnail = new Thumbnail($this->h5ai,$this->absHref, "rational", 96, 46); - $thumbnail->create(); - $bigImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref(); - } + if ($this->isFolder && $this->type !== "folder-parent") { + $code = $this->h5ai->getHttpCode($this->absHref); + $classes .= " checkedHttpCode"; + if ($code !== "h5ai") { + if ($code === 200) { + $img = "folder-page"; + $smallImg = $this->h5ai->icon("folder-page"); + $bigImg = $this->h5ai->icon("folder-page", true); + } else { + $classes .= " error"; + $hint = " " . $code . " "; + } + } + } + if ($this->h5ai->showThumbs() && in_array($this->type, $this->thumbTypes)) { + $imgClass = " class='thumb' "; + $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16); + $thumbnail->create(); + $smallImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref(); + $thumbnail = new Thumbnail($this->h5ai,$this->absHref, "rational", 96, 46); + $thumbnail->create(); + $bigImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref(); + } - $html = "\t
              • \n"; - $html .= "\t\t\n"; - $html .= "\t\t\t" . $img . "\n"; - $html .= "\t\t\t" . $img . "\n"; - $html .= "\t\t\t" . $this->label . $hint . "\n"; - $html .= "\t\t\t\n"; - $html .= "\t\t\t" . $this->size . "\n"; - $html .= "\t\t\n"; - $html .= "\t
              • \n"; - return $html; - } + $html = "\t
              • \n"; + $html .= "\t\t\n"; + $html .= "\t\t\t" . $img . "\n"; + $html .= "\t\t\t" . $img . "\n"; + $html .= "\t\t\t" . $this->label . $hint . "\n"; + $html .= "\t\t\t\n"; + $html .= "\t\t\t" . $this->size . "\n"; + $html .= "\t\t\n"; + $html .= "\t
              • \n"; + return $html; + } } class Extended { - private $h5ai, $parent, $content; + private $h5ai, $parent, $content; - public function __construct($h5ai) { + public function __construct($h5ai) { - $this->h5ai = $h5ai; - $this->parent = null; - $this->content = array(); - $this->loadContent(); - } + $this->h5ai = $h5ai; + $this->parent = null; + $this->content = array(); + $this->loadContent(); + } - private function loadContent() { + private function loadContent() { - if ($this->h5ai->getAbsHref() !== "/") { - $options = $this->h5ai->getOptions(); - $parentPath = dirname($this->h5ai->getAbsPath()); - $parentHref = dirname($this->h5ai->getAbsHref()); - $label = $options["setParentFolderLabels"] === true ? $this->h5ai->getLabel($parentHref) : "Parent Directory"; - $this->parent = new Entry($this->h5ai, $parentPath, $parentHref, "folder-parent", $label); - } + if ($this->h5ai->getAbsHref() !== "/") { + $options = $this->h5ai->getOptions(); + $parentPath = dirname($this->h5ai->getAbsPath()); + $parentHref = dirname($this->h5ai->getAbsHref()); + $label = $options["setParentFolderLabels"] === true ? $this->h5ai->getLabel($parentHref) : "Parent Directory"; + $this->parent = new Entry($this->h5ai, $parentPath, $parentHref, "folder-parent", $label); + } - $this->content = array(); + $this->content = array(); - $files = $this->h5ai->readDir($this->h5ai->getAbsPath()); - foreach ($files as $file) { - $absPath = $this->h5ai->getAbsPath() . "/" . $file; - $absHref = $this->h5ai->getAbsHref() . rawurlencode($file); - $this->content[$absPath] = new Entry($this->h5ai, $absPath, $absHref); - } - } + $files = $this->h5ai->readDir($this->h5ai->getAbsPath()); + foreach ($files as $file) { + $absPath = $this->h5ai->getAbsPath() . "/" . $file; + $absHref = $this->h5ai->getAbsHref() . rawurlencode($file); + $this->content[$absPath] = new Entry($this->h5ai, $absPath, $absHref); + } + } - public function toHtml() { + public function toHtml() { - $html = "
                \n"; - $html .= "
                  \n"; - $html .= $this->generateHeaders(); - if ($this->parent !== null) { - $html .= $this->parent->toHtml(); - } - foreach($this->content as $entry) { - $html .= $entry->toHtml(); - } - $html .= "
                \n"; - if (count($this->content) === 0) { - $html .= "
                empty
                "; - } - $html .="
                "; - return $html; - } + $html = "
                \n"; + $html .= "
                  \n"; + $html .= $this->generateHeaders(); + if ($this->parent !== null) { + $html .= $this->parent->toHtml(); + } + foreach($this->content as $entry) { + $html .= $entry->toHtml(); + } + $html .= "
                \n"; + if (count($this->content) === 0) { + $html .= "
                empty
                "; + } + $html .="
                "; + return $html; + } - public function generateHeaders() { + public function generateHeaders() { - $html = "\t
              • \n"; - $html .= "\t\t\n"; - $html .= "\t\tName\n"; - $html .= "\t\tLast modified\n"; - $html .= "\t\tSize\n"; - $html .= "\t
              • \n"; - return $html; - } + $html = "\t
              • \n"; + $html .= "\t\t\n"; + $html .= "\t\tName\n"; + $html .= "\t\tLast modified\n"; + $html .= "\t\tSize\n"; + $html .= "\t
              • \n"; + return $html; + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index f7abd0f9..b14a9e65 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -3,301 +3,301 @@ require_once "Cache.php"; class H5ai { - private static $VIEWMODES = array("details", "icons"); + private static $VIEWMODES = array("details", "icons"); - private $docRoot, $h5aiRoot, $h5aiAbsHref, $domain, - $config, $options, $types, $langs, - $cache, - $absHref, $absPath, - $ignore, $ignoreRE, - $view; + private $docRoot, $h5aiRoot, $h5aiAbsHref, $domain, + $config, $options, $types, $langs, + $cache, + $absHref, $absPath, + $ignore, $ignoreRE, + $view; - public function __construct() { + public function __construct() { - global $H5AI_CONFIG; + global $H5AI_CONFIG; - $this->docRoot = $H5AI_CONFIG["DOCUMENT_ROOT"]; - $this->h5aiRoot = $H5AI_CONFIG["H5AI_ROOT"]; - $this->ignore = $H5AI_CONFIG["IGNORE"]; - $this->ignoreRE = $H5AI_CONFIG["IGNORE_PATTERNS"]; + $this->docRoot = $H5AI_CONFIG["DOCUMENT_ROOT"]; + $this->h5aiRoot = $H5AI_CONFIG["H5AI_ROOT"]; + $this->ignore = $H5AI_CONFIG["IGNORE"]; + $this->ignoreRE = $H5AI_CONFIG["IGNORE_PATTERNS"]; - $this->config = $this->loadConfig($this->h5aiRoot . "/config.js"); - $this->options = $this->config["options"]; - $this->types = $this->config["types"]; - $this->langs = $this->config["langs"]; + $this->config = $this->loadConfig($this->h5aiRoot . "/config.js"); + $this->options = $this->config["options"]; + $this->types = $this->config["types"]; + $this->langs = $this->config["langs"]; - $this->cache = new Cache($this->h5aiRoot . "/cache"); + $this->cache = new Cache($this->h5aiRoot . "/cache"); - $this->hrefRoot = $this->options["rootAbsHref"]; - $this->h5aiAbsHref = $this->options["h5aiAbsHref"]; - $this->domain = getenv("HTTP_HOST"); + $this->hrefRoot = $this->options["rootAbsHref"]; + $this->h5aiAbsHref = $this->options["h5aiAbsHref"]; + $this->domain = getenv("HTTP_HOST"); - $this->absHref = $this->normalizePath(preg_replace('/\\?.*/', '', getenv("REQUEST_URI")), true); - $this->absPath = $this->getAbsPath($this->absHref); + $this->absHref = $this->normalizePath(preg_replace('/\\?.*/', '', getenv("REQUEST_URI")), true); + $this->absPath = $this->getAbsPath($this->absHref); - $this->view = $this->options["viewmodes"][0]; - if (!in_array($this->view, H5ai::$VIEWMODES)) { - $this->view = H5ai::$VIEWMODES[0]; - } - } + $this->view = $this->options["viewmodes"][0]; + if (!in_array($this->view, H5ai::$VIEWMODES)) { + $this->view = H5ai::$VIEWMODES[0]; + } + } - private function loadConfig($file) { + private function loadConfig($file) { - $str = file_exists($file) ? file_get_contents($file) : ""; + $str = file_exists($file) ? file_get_contents($file) : ""; - // remove comments and change expression to pure json - $str = preg_replace("/\/\*.*?\*\//s", "", $str); - $str = preg_replace("/^.*H5AI_CONFIG\s*=\s*/s", "", $str); - $str = preg_replace("/;.*/s", "", $str); - $config = json_decode($str, true); + // remove comments and change expression to pure json + $str = preg_replace("/\/\*.*?\*\//s", "", $str); + $str = preg_replace("/^.*H5AI_CONFIG\s*=\s*/s", "", $str); + $str = preg_replace("/;.*/s", "", $str); + $config = json_decode($str, true); - return $config; - } + return $config; + } - public function getDocRoot() { + public function getDocRoot() { - return $this->docRoot; - } + return $this->docRoot; + } - public function getH5aiRoot() { + public function getH5aiRoot() { - return $this->h5aiRoot; - } + return $this->h5aiRoot; + } - public function getHrefRoot() { + public function getHrefRoot() { - return $this->hrefRoot; - } + return $this->hrefRoot; + } - public function getH5aiAbsHref() { + public function getH5aiAbsHref() { - return $this->h5aiAbsHref; - } + return $this->h5aiAbsHref; + } - public function getDomain() { + public function getDomain() { - return $this->domain; - } + return $this->domain; + } - public function getView() { + public function getView() { - return $this->view; - } + return $this->view; + } - public function api() { + public function api() { - return $this->h5aiAbsHref . "php/api.php"; - } + return $this->h5aiAbsHref . "php/api.php"; + } - public function image($id) { + public function image($id) { - return $this->h5aiAbsHref . "images/" . $id . ".png"; - } + return $this->h5aiAbsHref . "images/" . $id . ".png"; + } - public function icon($id, $big = false) { + public function icon($id, $big = false) { - return $this->h5aiAbsHref . "icons/" . ($big ? "48x48" : "16x16") . "/" . $id . ".png"; - } + return $this->h5aiAbsHref . "icons/" . ($big ? "48x48" : "16x16") . "/" . $id . ".png"; + } - public function getOptions() { + public function getOptions() { - return $this->options; - } + return $this->options; + } - public function getLangs() { + public function getLangs() { - return $this->langs; - } + return $this->langs; + } - public function getAbsHref($absPath = null, $endWithSlash = true) { + public function getAbsHref($absPath = null, $endWithSlash = true) { - if ($absPath === null) { - return $this->absHref; - } + if ($absPath === null) { + return $this->absHref; + } - // - $absPath=substr($absPath, strlen($this->docRoot)); + // + $absPath=substr($absPath, strlen($this->docRoot)); - $absHref = preg_replace("!^" . $this->docRoot . "!", "", $absPath); - $parts = explode("/", $absHref); - $encodedParts = array(); - foreach ($parts as $part) { - $encodedParts[] = rawurlencode($part); - } - $endodedAbsHref = implode("/", $encodedParts); + $absHref = preg_replace("!^" . $this->docRoot . "!", "", $absPath); + $parts = explode("/", $absHref); + $encodedParts = array(); + foreach ($parts as $part) { + $encodedParts[] = rawurlencode($part); + } + $endodedAbsHref = implode("/", $encodedParts); - // - $endodedAbsHref = $this->hrefRoot . $endodedAbsHref; + // + $endodedAbsHref = $this->hrefRoot . $endodedAbsHref; - return $this->normalizePath($endodedAbsHref, $endWithSlash); - } + return $this->normalizePath($endodedAbsHref, $endWithSlash); + } - public function getAbsPath($absHref = null) { + public function getAbsPath($absHref = null) { - if ($absHref === null) { - return $this->absPath; - } + if ($absHref === null) { + return $this->absPath; + } - // - $absHref=substr($absHref, strlen($this->hrefRoot)); + // + $absHref=substr($absHref, strlen($this->hrefRoot)); - return $this->normalizePath($this->docRoot . "/" . rawurldecode($absHref), false); - } + return $this->normalizePath($this->docRoot . "/" . rawurldecode($absHref), false); + } - public function showThumbs() { + public function showThumbs() { - return $this->options["showThumbs"] === true; - } + return $this->options["showThumbs"] === true; + } - public function getTitle() { + public function getTitle() { - $title = $this->domain . rawurldecode($this->absHref); - $title = preg_replace("/\/$/", "", $title); - $title = preg_replace("/\//", " > ", $title); - if ($this->absHref !== "/") { - $title = basename($this->absPath) . " - " . $title; - } - return $title; - } + $title = $this->domain . rawurldecode($this->absHref); + $title = preg_replace("/\/$/", "", $title); + $title = preg_replace("/\//", " > ", $title); + if ($this->absHref !== "/") { + $title = basename($this->absPath) . " - " . $title; + } + return $title; + } - public function getType($absPath) { + public function getType($absPath) { - foreach($this->types as $type => $exts) { - foreach($exts as $ext) { - if ($this->endsWith($absPath, $ext)) { - return $type; - } - } - } - return "unknown"; - } + foreach($this->types as $type => $exts) { + foreach($exts as $ext) { + if ($this->endsWith($absPath, $ext)) { + return $type; + } + } + } + return "unknown"; + } - public function ignoreThisFile($file) { + public function ignoreThisFile($file) { - # always ignore - if ($file === "." || $file === ".." || $this->startsWith($file, '.ht')) { - return true; - } + # always ignore + if ($file === "." || $file === ".." || $this->startsWith($file, '.ht')) { + return true; + } - if (in_array($file, $this->ignore)) { - return true; - } - foreach ($this->ignoreRE as $re) { - if (preg_match($re, $file)) { - return true; - } - } - - return false; - } - - public function readDir($path) { - - $content = array(); - if (is_dir($path)) { - if ($dir = opendir($path)) { - while (($file = readdir($dir)) !== false) { - if (!$this->ignoreThisFile($file)) { - $content[] = $file; - } - } - closedir($dir); - } - } - return $content; - } - - public function getLabel($absHref) { - - return $absHref === "/" ? $this->domain : rawurldecode(basename($absHref)); - } - - public function normalizePath($path, $endWithSlash) { - - return ($path === "/") ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); - } - - public function startsWith($sequence, $start) { - - return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0; - } - - public function endsWith($sequence, $end) { - - return strcasecmp(substr($sequence, -strlen($end)), $end) === 0; - } - - public function getHttpCode($absHref) { - - return $this->cachedHttpCode($absHref); - #return $this->fetchHttpCode($absHref); - #return $this->guessHttpCode($absHref); - } - - public function cachedHttpCode($absHref) { - - $cached = $this->cache->get($absHref); - if ($cached === false) { - $folderStatus = $this->options["folderStatus"]; - if (array_key_exists($absHref, $folderStatus)) { - $code = $folderStatus[$absHref]; - } else { - $code = $this->fetchHttpCode($absHref); - } - $cached = array("href" => $absHref, "code" => $code); - $this->cache->set($absHref, $cached); - } - return $cached["code"]; - } - - public function fetchHttpCode($absHref) { - - $contentType = "Content-Type:"; - $h5aiContentType = "Content-Type: text/html;h5ai="; - $host = getenv("HTTP_HOST"); - $port = getenv("SERVER_PORT"); - $msg = "HEAD $absHref HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n"; - if (isset($_SERVER['PHP_AUTH_USER'])) { - $msg .= "Authorization: Basic " . base64_encode($_SERVER['PHP_AUTH_USER'] . ":" . $_SERVER['PHP_AUTH_PW']) . "\r\n"; - } - $msg .= "\r\n"; - - $errno = ""; - $errstr = ""; - $socket = fsockopen($host, $port, $errno, $errstr, 30); - if($socket === 0) { - return null; - } - - fwrite($socket, $msg); - $content = fgets($socket); - $code = intval(trim(substr($content, 9, 4))); - if ($code === 200) { - while (! $this->startsWith($content, $contentType)) { - $content = fgets($socket); - } - if ($this->startsWith($content, $h5aiContentType)) { - $code = "h5ai"; - } - } - fclose($socket); - return $code; - } - - public function guessHttpCode($absHref) { - - $indexFiles = array("index.html", "index.cgi", "index.pl", "index.php", "index.xhtml", "index.htm"); - $absPath = $this->getAbsPath($absHref); - $files = $this->readDir($absPath); - foreach ($files as $file) { - if (in_array($file, $indexFiles)) { - return 200; - } - } - return "h5ai"; - } + if (in_array($file, $this->ignore)) { + return true; + } + foreach ($this->ignoreRE as $re) { + if (preg_match($re, $file)) { + return true; + } + } + + return false; + } + + public function readDir($path) { + + $content = array(); + if (is_dir($path)) { + if ($dir = opendir($path)) { + while (($file = readdir($dir)) !== false) { + if (!$this->ignoreThisFile($file)) { + $content[] = $file; + } + } + closedir($dir); + } + } + return $content; + } + + public function getLabel($absHref) { + + return $absHref === "/" ? $this->domain : rawurldecode(basename($absHref)); + } + + public function normalizePath($path, $endWithSlash) { + + return ($path === "/") ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); + } + + public function startsWith($sequence, $start) { + + return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0; + } + + public function endsWith($sequence, $end) { + + return strcasecmp(substr($sequence, -strlen($end)), $end) === 0; + } + + public function getHttpCode($absHref) { + + return $this->cachedHttpCode($absHref); + #return $this->fetchHttpCode($absHref); + #return $this->guessHttpCode($absHref); + } + + public function cachedHttpCode($absHref) { + + $cached = $this->cache->get($absHref); + if ($cached === false) { + $folderStatus = $this->options["folderStatus"]; + if (array_key_exists($absHref, $folderStatus)) { + $code = $folderStatus[$absHref]; + } else { + $code = $this->fetchHttpCode($absHref); + } + $cached = array("href" => $absHref, "code" => $code); + $this->cache->set($absHref, $cached); + } + return $cached["code"]; + } + + public function fetchHttpCode($absHref) { + + $contentType = "Content-Type:"; + $h5aiContentType = "Content-Type: text/html;h5ai="; + $host = getenv("HTTP_HOST"); + $port = getenv("SERVER_PORT"); + $msg = "HEAD $absHref HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n"; + if (isset($_SERVER['PHP_AUTH_USER'])) { + $msg .= "Authorization: Basic " . base64_encode($_SERVER['PHP_AUTH_USER'] . ":" . $_SERVER['PHP_AUTH_PW']) . "\r\n"; + } + $msg .= "\r\n"; + + $errno = ""; + $errstr = ""; + $socket = fsockopen($host, $port, $errno, $errstr, 30); + if($socket === 0) { + return null; + } + + fwrite($socket, $msg); + $content = fgets($socket); + $code = intval(trim(substr($content, 9, 4))); + if ($code === 200) { + while (! $this->startsWith($content, $contentType)) { + $content = fgets($socket); + } + if ($this->startsWith($content, $h5aiContentType)) { + $code = "h5ai"; + } + } + fclose($socket); + return $code; + } + + public function guessHttpCode($absHref) { + + $indexFiles = array("index.html", "index.cgi", "index.pl", "index.php", "index.xhtml", "index.htm"); + $absPath = $this->getAbsPath($absHref); + $files = $this->readDir($absPath); + foreach ($files as $file) { + if (in_array($file, $indexFiles)) { + return 200; + } + } + return "h5ai"; + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/Image.php b/src/_h5ai/php/inc/Image.php index 4572fc49..69356b24 100644 --- a/src/_h5ai/php/inc/Image.php +++ b/src/_h5ai/php/inc/Image.php @@ -2,202 +2,202 @@ class Image { - private $sourceFile; - private $source; - private $width; - private $height; - private $type; + private $sourceFile; + private $source; + private $width; + private $height; + private $type; - private $dest; + private $dest; - public static function isUsable() { + public static function isUsable() { - return GD_VERSION != "GD_VERSION"; - } + return GD_VERSION != "GD_VERSION"; + } - public static function showImage($filename) { + public static function showImage($filename) { - $image = file_get_contents($filename); - header("content-type: image"); - echo $image; - } + $image = file_get_contents($filename); + header("content-type: image"); + echo $image; + } - public function __construct($filename = null) { + public function __construct($filename = null) { - $this->sourceFile = null; - $this->source = null; - $this->width = null; - $this->height = null; - $this->type = null; + $this->sourceFile = null; + $this->source = null; + $this->width = null; + $this->height = null; + $this->type = null; - $this->dest = null; + $this->dest = null; - $this->setSource($filename); - } + $this->setSource($filename); + } - public function __destruct() { + public function __destruct() { - $this->releaseSource(); - $this->releaseDest(); - } + $this->releaseSource(); + $this->releaseDest(); + } - public function setSource($filename) { + public function setSource($filename) { - $this->releaseSource(); - $this->releaseDest(); + $this->releaseSource(); + $this->releaseDest(); - if (is_null($filename)) { - return; - } + if (is_null($filename)) { + return; + } - $this->sourceFile = $filename; + $this->sourceFile = $filename; - list($this->width, $this->height, $this->type) = getimagesize($this->sourceFile); + list($this->width, $this->height, $this->type) = getimagesize($this->sourceFile); - $this->source = imagecreatefromstring(file_get_contents($this->sourceFile)); - } + $this->source = imagecreatefromstring(file_get_contents($this->sourceFile)); + } - public function showDest() { + public function showDest() { - if (!is_null($this->dest)) { - header("Content-type: image/jpeg"); - imagejpeg($this->dest, null, 100); - } - } + if (!is_null($this->dest)) { + header("Content-type: image/jpeg"); + imagejpeg($this->dest, null, 100); + } + } - public function saveDest($filename) { + public function saveDest($filename) { - if (!is_null($this->dest)) { - @imagejpeg($this->dest, $filename, 90); - @chmod($filename, 0775); - } - } + if (!is_null($this->dest)) { + @imagejpeg($this->dest, $filename, 90); + @chmod($filename, 0775); + } + } - public function releaseDest() { + public function releaseDest() { - if (!is_null($this->dest)) { - imagedestroy($this->dest); - $this->dest = null; - } - } + if (!is_null($this->dest)) { + imagedestroy($this->dest); + $this->dest = null; + } + } - public function releaseSource() { + public function releaseSource() { - if (!is_null($this->source)) { - imagedestroy($this->source); - $this->sourceFile = null; - $this->source = null; - $this->width = null; - $this->height = null; - $this->type = null; - } - } + if (!is_null($this->source)) { + imagedestroy($this->source); + $this->sourceFile = null; + $this->source = null; + $this->width = null; + $this->height = null; + $this->type = null; + } + } - private function magic($destX, $destY, $srcX, $srcY, $destWidth, $destHeight, $srcWidth, $srcHeight, $canWidth = null, $canHeight = null, $color = null) { + private function magic($destX, $destY, $srcX, $srcY, $destWidth, $destHeight, $srcWidth, $srcHeight, $canWidth = null, $canHeight = null, $color = null) { - if (!is_null($canWidth) && !is_null($canHeight)) { - $this->dest = imagecreatetruecolor($canWidth, $canHeight); - } else { - $this->dest = imagecreatetruecolor($destWidth, $destHeight); - } + if (!is_null($canWidth) && !is_null($canHeight)) { + $this->dest = imagecreatetruecolor($canWidth, $canHeight); + } else { + $this->dest = imagecreatetruecolor($destWidth, $destHeight); + } - if (is_null($color)) { - $color = array(255, 255, 255); - } - $icol = imagecolorallocate($this->dest, $color[0], $color[1], $color[2]); - imagefill($this->dest, 0, 0, $icol); + if (is_null($color)) { + $color = array(255, 255, 255); + } + $icol = imagecolorallocate($this->dest, $color[0], $color[1], $color[2]); + imagefill($this->dest, 0, 0, $icol); - imagecopyresampled($this->dest, $this->source, $destX, $destY, $srcX, $srcY, $destWidth, $destHeight, $srcWidth, $srcHeight); - } + imagecopyresampled($this->dest, $this->source, $destX, $destY, $srcX, $srcY, $destWidth, $destHeight, $srcWidth, $srcHeight); + } - public function thumb($mode, $width, $height = null, $color = null) { + public function thumb($mode, $width, $height = null, $color = null) { - if ($height === null) { - $height = $width; - } - if ($mode === "square") { - $this->squareThumb($width); - } elseif ($mode === "rational") { - $this->rationalThumb($width, $height); - } elseif ($mode === "center") { - $this->centerThumb($width, $height, $color); - } else { - $this->freeThumb($width, $height); - } - } + if ($height === null) { + $height = $width; + } + if ($mode === "square") { + $this->squareThumb($width); + } elseif ($mode === "rational") { + $this->rationalThumb($width, $height); + } elseif ($mode === "center") { + $this->centerThumb($width, $height, $color); + } else { + $this->freeThumb($width, $height); + } + } - public function squareThumb($width) { + public function squareThumb($width) { - $a = min($this->width, $this->height); - $x = intval(($this->width - $a) / 2); - $y = intval(($this->height - $a) / 2); + $a = min($this->width, $this->height); + $x = intval(($this->width - $a) / 2); + $y = intval(($this->height - $a) / 2); - $this->magic(0, 0, $x, $y, $width, $width, $a, $a); - } + $this->magic(0, 0, $x, $y, $width, $width, $a, $a); + } - public function rationalThumb($width, $height) { + public function rationalThumb($width, $height) { - $r = 1.0 * $this->width / $this->height; + $r = 1.0 * $this->width / $this->height; - $h = $height; - $w = $r * $h; + $h = $height; + $w = $r * $h; - if ($w > $width) { + if ($w > $width) { - $w = $width; - $h = 1.0 / $r * $w; - } + $w = $width; + $h = 1.0 / $r * $w; + } - $w = intval($w); - $h = intval($h); + $w = intval($w); + $h = intval($h); - $this->magic(0, 0, 0, 0, $w, $h, $this->width, $this->height); - } + $this->magic(0, 0, 0, 0, $w, $h, $this->width, $this->height); + } - public function centerThumb($width, $height, $color = null) { + public function centerThumb($width, $height, $color = null) { - $r = 1.0 * $this->width / $this->height; + $r = 1.0 * $this->width / $this->height; - $h = $height; - $w = $r * $h; + $h = $height; + $w = $r * $h; - if ($w > $width) { + if ($w > $width) { - $w = $width; - $h = 1.0 / $r * $w; - } + $w = $width; + $h = 1.0 / $r * $w; + } - $w = intval($w); - $h = intval($h); + $w = intval($w); + $h = intval($h); - $x = intval(($width - $w) / 2); - $y = intval(($height - $h) / 2); + $x = intval(($width - $w) / 2); + $y = intval(($height - $h) / 2); - $this->magic($x, $y, 0, 0, $w, $h, $this->width, $this->height, $width, $height, $color); - } + $this->magic($x, $y, 0, 0, $w, $h, $this->width, $this->height, $width, $height, $color); + } - public function freeThumb($width, $height) { + public function freeThumb($width, $height) { - $w = intval($width); - $h = intval($height); + $w = intval($width); + $h = intval($height); - $this->magic(0, 0, 0, 0, $w, $h, $this->width, $this->height); - } + $this->magic(0, 0, 0, 0, $w, $h, $this->width, $this->height); + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/Thumbnail.php b/src/_h5ai/php/inc/Thumbnail.php index 153c41b1..1443b651 100644 --- a/src/_h5ai/php/inc/Thumbnail.php +++ b/src/_h5ai/php/inc/Thumbnail.php @@ -5,55 +5,55 @@ require_once "Image.php"; class Thumbnail { - private $srcAbsHref, $srcAbsPath, $width, $height, $name, $href, $path; + private $srcAbsHref, $srcAbsPath, $width, $height, $name, $href, $path; - public static function isUsable() { + public static function isUsable() { - return Image::isUsable(); - } + return Image::isUsable(); + } - public function __construct($h5ai, $absHref, $mode, $width, $height) { + public function __construct($h5ai, $absHref, $mode, $width, $height) { - $this->h5ai = $h5ai; - $this->srcAbsHref = $absHref; - $this->srcAbsPath = $this->h5ai->getDocRoot() . urldecode($absHref); - $this->width = $width; - $this->height = $height; - $this->mode = $mode; - $this->name = sha1("$this->srcAbsPath-$this->width-$this->height-$this->mode"); - $this->href = $this->h5ai->getH5aiAbsHref() . "/cache/thumb-" . $this->name . ".jpg"; - $this->path = $this->h5ai->getDocRoot() . $this->href; - $this->liveHref = $this->h5ai->api() . "?action=thumb&href=" . $this->srcAbsHref . "&width=" . $this->width . "&height=" . $this->height . "&mode=" . $this->mode; - } + $this->h5ai = $h5ai; + $this->srcAbsHref = $absHref; + $this->srcAbsPath = $this->h5ai->getDocRoot() . urldecode($absHref); + $this->width = $width; + $this->height = $height; + $this->mode = $mode; + $this->name = sha1("$this->srcAbsPath-$this->width-$this->height-$this->mode"); + $this->href = $this->h5ai->getH5aiAbsHref() . "/cache/thumb-" . $this->name . ".jpg"; + $this->path = $this->h5ai->getDocRoot() . $this->href; + $this->liveHref = $this->h5ai->api() . "?action=thumb&href=" . $this->srcAbsHref . "&width=" . $this->width . "&height=" . $this->height . "&mode=" . $this->mode; + } - public function create($force = 0) { + public function create($force = 0) { - if ( - $force === 2 - || ($force === 1 && !file_exists($this->path)) - || (file_exists($this->path) && filemtime($this->srcAbsPath) >= filemtime($this->path)) - ) { - $image = new Image(); - $image->setSource($this->srcAbsPath); - $image->thumb($this->mode, $this->width, $this->height); - $image->saveDest($this->path); - } - } + if ( + $force === 2 + || ($force === 1 && !file_exists($this->path)) + || (file_exists($this->path) && filemtime($this->srcAbsPath) >= filemtime($this->path)) + ) { + $image = new Image(); + $image->setSource($this->srcAbsPath); + $image->thumb($this->mode, $this->width, $this->height); + $image->saveDest($this->path); + } + } - public function getHref() { + public function getHref() { - return $this->href; - } + return $this->href; + } - public function getPath() { + public function getPath() { - return $this->path; - } + return $this->path; + } - public function getLiveHref() { + public function getLiveHref() { - return $this->liveHref; - } + return $this->liveHref; + } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/Tree.php b/src/_h5ai/php/inc/Tree.php index 2d0f51f0..be1a9bb8 100644 --- a/src/_h5ai/php/inc/Tree.php +++ b/src/_h5ai/php/inc/Tree.php @@ -1,146 +1,146 @@ h5ai = $h5ai; + $this->h5ai = $h5ai; - $this->label = $this->h5ai->getLabel($absHref); - $this->absPath = $this->h5ai->normalizePath($absPath, false); - $this->isFolder = is_dir($this->absPath); - $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder); + $this->label = $this->h5ai->getLabel($absHref); + $this->absPath = $this->h5ai->normalizePath($absPath, false); + $this->isFolder = is_dir($this->absPath); + $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder); - $this->type = $type !== null ? $type : ($this->isFolder ? "folder" : $this->h5ai->getType($this->absPath)); - $this->content = null; - } + $this->type = $type !== null ? $type : ($this->isFolder ? "folder" : $this->h5ai->getType($this->absPath)); + $this->content = null; + } - public function loadContent() { + public function loadContent() { - $this->content = array(); + $this->content = array(); - if ($this->h5ai->getHttpCode($this->absHref) !== "h5ai") { - return; - } + if ($this->h5ai->getHttpCode($this->absHref) !== "h5ai") { + return; + } - $files = $this->h5ai->readDir($this->absPath); - foreach ($files as $file) { - $tree = new TreeEntry($this->h5ai, $this->absPath . "/" . $file, $this->absHref . rawurlencode($file)); + $files = $this->h5ai->readDir($this->absPath); + foreach ($files as $file) { + $tree = new TreeEntry($this->h5ai, $this->absPath . "/" . $file, $this->absHref . rawurlencode($file)); - if ($tree->isFolder) { - $this->content[$tree->absPath] = $tree; - } - } + if ($tree->isFolder) { + $this->content[$tree->absPath] = $tree; + } + } - $this->sort(); - } + $this->sort(); + } - public function cmpTrees($t1, $t2) { + public function cmpTrees($t1, $t2) { - if ($t1->isFolder && !$t2->isFolder) { - return -1; - } - if (!$t1->isFolder && $t2->isFolder) { - return 1; - } - return strcasecmp($t1->absPath, $t2->absPath); - } + if ($t1->isFolder && !$t2->isFolder) { + return -1; + } + if (!$t1->isFolder && $t2->isFolder) { + return 1; + } + return strcasecmp($t1->absPath, $t2->absPath); + } - public function sort() { + public function sort() { - if ($this->content !== null) { - uasort($this->content, array($this, "cmpTrees")); - } - } + if ($this->content !== null) { + uasort($this->content, array($this, "cmpTrees")); + } + } - public function toHtml() { + public function toHtml() { - $classes = "entry " . $this->type . ($this->absHref === $this->h5ai->getAbsHref() ? " current" : ""); - $icon = $this->type; - if ($this->absHref === "/") { - $icon = "folder-home"; - } - $hint = ""; - $code = "h5ai"; + $classes = "entry " . $this->type . ($this->absHref === $this->h5ai->getAbsHref() ? " current" : ""); + $icon = $this->type; + if ($this->absHref === "/") { + $icon = "folder-home"; + } + $hint = ""; + $code = "h5ai"; - if ($this->isFolder) { - $code = $this->h5ai->getHttpCode($this->absHref); - $classes .= " checkedHttpCode"; - if ($code !== "h5ai") { - if ($code === 200) { - $icon = "folder-page"; - $hint = "page"; - } else { - $classes .= " error"; - $hint = " " . $code . " "; - } - } - } + if ($this->isFolder) { + $code = $this->h5ai->getHttpCode($this->absHref); + $classes .= " checkedHttpCode"; + if ($code !== "h5ai") { + if ($code === 200) { + $icon = "folder-page"; + $hint = "page"; + } else { + $classes .= " error"; + $hint = " " . $code . " "; + } + } + } - $html = "
                \n"; - if ($this->content !== null && count($this->content) === 0 || $code !== "h5ai") { - $html .= "\n"; - } else { - $indicatorState = $this->content === null ? " unknown" : " open"; - $html .= ">\n"; - } - $html .= "\n"; - $html .= "" . $icon . "\n"; - $html .= "" . $this->label . "" . $hint . "\n"; - $html .= "\n"; - $html .= $this->contentToHtml(); - $html .= "
                \n"; - return $html; - } + $html = "
                \n"; + if ($this->content !== null && count($this->content) === 0 || $code !== "h5ai") { + $html .= "\n"; + } else { + $indicatorState = $this->content === null ? " unknown" : " open"; + $html .= ">\n"; + } + $html .= "\n"; + $html .= "" . $icon . "\n"; + $html .= "" . $this->label . "" . $hint . "\n"; + $html .= "\n"; + $html .= $this->contentToHtml(); + $html .= "
                \n"; + return $html; + } - public function contentToHtml() { + public function contentToHtml() { - $html = "
                  \n"; - if ($this->content !== null) { - foreach($this->content as $tree) { - $html .= "
                • " . $tree->toHtml() . "
                • "; - } - } - $html .= "
                \n"; - return $html; - } + $html = "
                  \n"; + if ($this->content !== null) { + foreach($this->content as $tree) { + $html .= "
                • " . $tree->toHtml() . "
                • "; + } + } + $html .= "
                \n"; + return $html; + } - public function getRoot() { + public function getRoot() { - if ($this->absHref === "/") { - return $this; - }; + if ($this->absHref === "/") { + return $this; + }; - $tree = new TreeEntry($this->h5ai, dirname($this->absPath), dirname($this->absHref)); - $tree->loadContent(); - $tree->content[$this->absPath] = $this; + $tree = new TreeEntry($this->h5ai, dirname($this->absPath), dirname($this->absHref)); + $tree->loadContent(); + $tree->content[$this->absPath] = $this; - return $tree->getRoot(); - } + return $tree->getRoot(); + } } class Tree { - private $h5ai; + private $h5ai; - public function __construct($h5ai) { + public function __construct($h5ai) { - $this->h5ai = $h5ai; - } + $this->h5ai = $h5ai; + } - public function toHtml() { + public function toHtml() { - $options = $this->h5ai->getOptions(); - if ($options["showTree"] === false) { - return ""; - } + $options = $this->h5ai->getOptions(); + if ($options["showTree"] === false) { + return ""; + } - $tree = new TreeEntry($this->h5ai, $this->h5ai->getAbsPath(), $this->h5ai->getAbsHref()); - $tree->loadContent(); - $root = $tree->getRoot(); - return "
                \n" . $root->toHtml() . "
                \n"; - } + $tree = new TreeEntry($this->h5ai, $this->h5ai->getAbsPath(), $this->h5ai->getAbsHref()); + $tree->loadContent(); + $root = $tree->getRoot(); + return "
                \n" . $root->toHtml() . "
                \n"; + } } diff --git a/src/_h5ai/php/inc/ZipIt.php b/src/_h5ai/php/inc/ZipIt.php index c4be9ec9..a86a7279 100644 --- a/src/_h5ai/php/inc/ZipIt.php +++ b/src/_h5ai/php/inc/ZipIt.php @@ -1,63 +1,63 @@ h5ai = $h5ai; - } + $this->h5ai = $h5ai; + } - public function zip($hrefs) { + public function zip($hrefs) { - $zipFile = tempnam("/tmp", "h5ai-download"); - $zip = new ZipArchive(); + $zipFile = tempnam("/tmp", "h5ai-download"); + $zip = new ZipArchive(); - if (!$zip->open($zipFile, ZIPARCHIVE::CREATE)) { - return false; - } + if (!$zip->open($zipFile, ZIPARCHIVE::CREATE)) { + return false; + } - foreach ($hrefs as $href) { - $d = dirname($href); - $n = basename($href); - if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($d)) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) { - $localFile = $this->h5ai->getAbsPath($href); - $file = preg_replace("!^" . $this->h5ai->getDocRoot() . "!", "", $localFile); - if (is_dir($localFile)) { - $this->zipDir($zip, $localFile, $file); - } else { - $this->zipFile($zip, $localFile, $file); - } - } - } + foreach ($hrefs as $href) { + $d = dirname($href); + $n = basename($href); + if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($d)) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) { + $localFile = $this->h5ai->getAbsPath($href); + $file = preg_replace("!^" . $this->h5ai->getDocRoot() . "!", "", $localFile); + if (is_dir($localFile)) { + $this->zipDir($zip, $localFile, $file); + } else { + $this->zipFile($zip, $localFile, $file); + } + } + } - $zip->close(); - return $zipFile; - } + $zip->close(); + return $zipFile; + } - private function zipFile($zip, $localFile, $file) { + private function zipFile($zip, $localFile, $file) { - if (is_readable($localFile)) { - $zip->addFile($localFile, $file); - } - } + if (is_readable($localFile)) { + $zip->addFile($localFile, $file); + } + } - private function zipDir($zip, $localDir, $dir) { + private function zipDir($zip, $localDir, $dir) { - if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") { - $zip->addEmptyDir($dir); - $files = $this->h5ai->readDir($localDir); - foreach ($files as $file) { - $localFile = $localDir . "/" . $file; - $file = $dir . "/" . $file; - if (is_dir($localFile)) { - $this->zipDir($zip, $localFile, $file); - } else { - $this->zipFile($zip, $localFile, $file); - } - } - } - } + if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") { + $zip->addEmptyDir($dir); + $files = $this->h5ai->readDir($localDir); + foreach ($files as $file) { + $localFile = $localDir . "/" . $file; + $file = $dir . "/" . $file; + if (is_dir($localFile)) { + $this->zipDir($zip, $localFile, $file); + } else { + $this->zipFile($zip, $localFile, $file); + } + } + } + } } ?> \ No newline at end of file diff --git a/tools/wepp.ant.xml b/tools/wepp.ant.xml index 2339652e..8bac3544 100644 --- a/tools/wepp.ant.xml +++ b/tools/wepp.ant.xml @@ -1,40 +1,40 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + From cbdd185602d0e32edf177c4b2633b8916b90eba1 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sun, 12 Feb 2012 23:56:19 +0100 Subject: [PATCH 04/36] Makes custom headers/footers optional. Disabled by default. --- README.md | 1 + src/_h5ai/config.js | 11 ++++++++--- src/_h5ai/js/inc/Extended.js | 32 ++++++++++++++++++-------------- src/_h5ai/php/inc/Customize.php | 6 +++--- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index f1e8fe96..0ac1bdea 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * updates year in `LICENSE.TXT` * updates es translation +* custom headers/footers are now optional and disabled by default ### v0.17 - *2011-11-28* diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index b95f9d8f..3292a649 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -18,10 +18,15 @@ var H5AI_CONFIG = { /* * Filenames of customized header and footer files to look for - * in each folder. + * in each folder. For Example: + * + * "customHeader": "_h5ai.header.html", + * "customFooter": "_h5ai.footer.html", + * + * This is disabled by default. */ - "customHeader": "_h5ai.header.html", - "customFooter": "_h5ai.footer.html", + "customHeader": false, + "customFooter": false, /* * An array of view modes the user may choose from. Currently there diff --git a/src/_h5ai/js/inc/Extended.js b/src/_h5ai/js/inc/Extended.js index 9e48e3da..ef12bf79 100644 --- a/src/_h5ai/js/inc/Extended.js +++ b/src/_h5ai/js/inc/Extended.js @@ -52,21 +52,25 @@ }, customize = function () { - $.ajax({ - url: H5AI.core.settings.customHeader, - dataType: "html", - success: function (data) { - $("#content > header").append($(data)).show(); - } - }); + if (H5AI.core.settings.customHeader) { + $.ajax({ + url: H5AI.core.settings.customHeader, + dataType: "html", + success: function (data) { + $("#content > header").append($(data)).show(); + } + }); + } - $.ajax({ - url: H5AI.core.settings.customFooter, - dataType: "html", - success: function (data) { - $("#content > footer").prepend($(data)).show(); - } - }); + if (H5AI.core.settings.customFooter) { + $.ajax({ + url: H5AI.core.settings.customFooter, + dataType: "html", + success: function (data) { + $("#content > footer").prepend($(data)).show(); + } + }); + } }, fetchPath = function (pathname, callback) { diff --git a/src/_h5ai/php/inc/Customize.php b/src/_h5ai/php/inc/Customize.php index aa720efa..689977c3 100644 --- a/src/_h5ai/php/inc/Customize.php +++ b/src/_h5ai/php/inc/Customize.php @@ -7,8 +7,8 @@ class Customize { $absPath = $h5ai->getAbsPath(); $options = $h5ai->getOptions(); - $this->customHeader = $absPath . "/" . $options["customHeader"]; - $this->customFooter = $absPath . "/" . $options["customFooter"]; + $this->customHeader = $options["customHeader"] ? $absPath . "/" . $options["customHeader"] : false; + $this->customFooter = $options["customFooter"] ? $absPath . "/" . $options["customFooter"] : false; } public function getHeader() { @@ -23,7 +23,7 @@ class Customize { private function getContent($file, $tag) { - return file_exists($file) ? ("<" . $tag . ">" . file_get_contents($file) . "") : ""; + return (is_string($file) && file_exists($file)) ? ("<" . $tag . ">" . file_get_contents($file) . "") : ""; } } From 76f107cbfe9aeb4a18dabb34f6da07e76b5452f3 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 13 Feb 2012 00:11:19 +0100 Subject: [PATCH 05/36] Fixes problems with folder recognition in the JS version. --- README.md | 1 + src/_h5ai/js/inc/Path.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ac1bdea..2f9352ea 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * updates year in `LICENSE.TXT` * updates es translation * custom headers/footers are now optional and disabled by default +* fixes problems with folder recognition in the JS version ### v0.17 - *2011-11-28* diff --git a/src/_h5ai/js/inc/Path.js b/src/_h5ai/js/inc/Path.js index f699a06f..f250fc97 100644 --- a/src/_h5ai/js/inc/Path.js +++ b/src/_h5ai/js/inc/Path.js @@ -39,7 +39,7 @@ path.parentFolder = folder; path.label = $a.text(); - path.type = $tds.eq(0).find("img").attr("alt") === "[DIR]" ? "folder" : H5AI.core.getFileType(path.label); + path.type = H5AI.util.pathEndsWithSlash(path.label) ? "folder" : H5AI.core.getFileType(path.label); path.href = $a.attr("href"); path.time = date ? date.getTime() : 0; path.size = size; From d72ea22fb056e42a634baf587f502a30c433dcbf Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Tue, 14 Feb 2012 13:16:28 +0100 Subject: [PATCH 06/36] Small fix on initial tree view display. --- src/_h5ai/css/inc/tree.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_h5ai/css/inc/tree.less b/src/_h5ai/css/inc/tree.less index 0862cef0..c4d2845b 100644 --- a/src/_h5ai/css/inc/tree.less +++ b/src/_h5ai/css/inc/tree.less @@ -3,7 +3,7 @@ display: none; position: fixed; left: 0; - top: 82px; + top: 62px; z-index: 1; overflow: auto; font-size: 0.85em; From 9f10e921757287cb059976b6050c11edba8d0464 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 15 Feb 2012 18:41:13 +0100 Subject: [PATCH 07/36] Fixes include problems as well as Win path problems. --- src/_h5ai/config.js | 8 ++-- src/_h5ai/{php => }/config.php | 4 +- src/_h5ai/php/api.php | 34 +++++++++----- src/_h5ai/php/inc/Cache.php | 6 +++ src/_h5ai/php/inc/Crumb.php | 5 +- src/_h5ai/php/inc/Customize.php | 7 ++- src/_h5ai/php/inc/Extended.php | 15 ++++-- src/_h5ai/php/inc/H5ai.php | 81 +++++++++++++++++++++------------ src/_h5ai/php/inc/Image.php | 8 +--- src/_h5ai/php/inc/Thumbnail.php | 14 ++++-- src/_h5ai/php/inc/Tree.php | 13 +++++- src/_h5ai/php/inc/ZipIt.php | 9 +++- src/_h5ai/php/main.php | 24 +++++++--- 13 files changed, 158 insertions(+), 70 deletions(-) rename src/_h5ai/{php => }/config.php (81%) diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index 3292a649..d0b7035e 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -25,8 +25,8 @@ var H5AI_CONFIG = { * * This is disabled by default. */ - "customHeader": false, - "customFooter": false, + "customHeader": "_h5ai.header.html", + "customFooter": "_h5ai.footer.html", /* * An array of view modes the user may choose from. Currently there @@ -105,13 +105,13 @@ var H5AI_CONFIG = { * Requires PHP on the server. * Show thumbnails for image files. */ - "showThumbs": false, + "showThumbs": true, /* * Requires PHP on the server. * Enable zipped download of selected entries. */ - "zippedDownload": false + "zippedDownload": true }, diff --git a/src/_h5ai/php/config.php b/src/_h5ai/config.php similarity index 81% rename from src/_h5ai/php/config.php rename to src/_h5ai/config.php index 8602b824..f901fa31 100644 --- a/src/_h5ai/php/config.php +++ b/src/_h5ai/config.php @@ -12,9 +12,9 @@ $H5AI_CONFIG = array(); /* * This configuration assumes that h5ai is installed * in the webroot directory of the Apache server. + * Assumed to end with a slash. */ -$H5AI_CONFIG["H5AI_ROOT"] = dirname(dirname(__FILE__)); -$H5AI_CONFIG["DOCUMENT_ROOT"] = dirname($H5AI_CONFIG["H5AI_ROOT"]); +$H5AI_CONFIG["ROOT_ABS_PATH"] = dirname(dirname(str_replace('\\', '/', __FILE__))); /* * Files/folders that should not be listed. Specified diff --git a/src/_h5ai/php/api.php b/src/_h5ai/php/api.php index c997b7d6..c3d12b30 100644 --- a/src/_h5ai/php/api.php +++ b/src/_h5ai/php/api.php @@ -1,5 +1,23 @@ getOptions(); + function fail($code, $msg, $cond = true) { if ($cond) { @@ -21,12 +39,6 @@ function checkKeys($keys) { list($action) = checkKeys(array("action")); -require_once "config.php"; -require_once "inc/H5ai.php"; -$h5ai = new H5ai(); -$options = $h5ai->getOptions(); - - if ($action === "httpcodes") { list($hrefs) = checkKeys(array("hrefs")); @@ -55,10 +67,10 @@ else if ($action === "thumb") { fail(0, "thumbs are disabled", !$options["showThumbs"]); list($srcAbsHref, $width, $height, $mode) = checkKeys(array("href", "width", "height", "mode")); - require_once "inc/Thumbnail.php"; - require_once "inc/Image.php"; + require_h5ai("/php/inc/Thumbnail.php"); + require_h5ai("/php/inc/Image.php"); - $srcAbsPath = $h5ai->getDocRoot() . rawurldecode($srcAbsHref); + $srcAbsPath = $h5ai->getRootAbsPath() . rawurldecode($srcAbsHref); if (!Thumbnail::isUsable()) { Image::showImage($srcAbsPath); @@ -82,7 +94,7 @@ else if ($action === "tree") { list($href) = checkKeys(array("href")); - require_once "inc/Tree.php"; + require_h5ai("/php/inc/Tree.php"); $absHref = trim($href); $absPath = $h5ai->getAbsPath($absHref); @@ -99,7 +111,7 @@ else if ($action === "zip") { fail(0, "zipped download is disabled", !$options["zippedDownload"]); list($hrefs) = checkKeys(array("hrefs")); - require_once "inc/ZipIt.php"; + require_h5ai("/php/inc/ZipIt.php"); $zipit = new ZipIt($h5ai); diff --git a/src/_h5ai/php/inc/Cache.php b/src/_h5ai/php/inc/Cache.php index 45015e86..0a507a41 100644 --- a/src/_h5ai/php/inc/Cache.php +++ b/src/_h5ai/php/inc/Cache.php @@ -7,18 +7,22 @@ ############################################## class Cache { + private $dir; + function __construct($dir) { $this->dir = $dir; } + private function _name($key) { return $this->dir . "/" . sha1($key); } + public function get($key, $expiration = 3600) { if (!is_dir($this->dir) || !is_writable($this->dir)) { @@ -55,6 +59,7 @@ class Cache { return $cache; } + public function set($key, $data) { if (!is_dir($this->dir) || !is_writable($this->dir)) { @@ -78,6 +83,7 @@ class Cache { return true; } + public function clear($key) { $cache_path = $this->_name($key); diff --git a/src/_h5ai/php/inc/Crumb.php b/src/_h5ai/php/inc/Crumb.php index 2f415750..9d10ab00 100644 --- a/src/_h5ai/php/inc/Crumb.php +++ b/src/_h5ai/php/inc/Crumb.php @@ -1,8 +1,10 @@ h5ai = $h5ai; @@ -11,13 +13,14 @@ class Crumb { $href = $h5ai->getAbsHref(); while ($href !== "/" && $href !== "//") { $this->parts[] = $href; - $href = dirname($href) . "/"; + $href = safe_dirname($href, true); } $this->parts[] = "/"; $this->parts = array_reverse($this->parts); } + public function toHtml() { $html = ""; diff --git a/src/_h5ai/php/inc/Customize.php b/src/_h5ai/php/inc/Customize.php index 689977c3..967770f0 100644 --- a/src/_h5ai/php/inc/Customize.php +++ b/src/_h5ai/php/inc/Customize.php @@ -1,8 +1,10 @@ getAbsPath(); @@ -11,19 +13,22 @@ class Customize { $this->customFooter = $options["customFooter"] ? $absPath . "/" . $options["customFooter"] : false; } + public function getHeader() { return $this->getContent($this->customHeader, "header"); } + public function getFooter() { return $this->getContent($this->customFooter, "footer"); } + private function getContent($file, $tag) { - return (is_string($file) && file_exists($file)) ? ("<" . $tag . ">" . file_get_contents($file) . "") : ""; + return (is_string($file) && file_exists($file)) ? ("<$tag>" . file_get_contents($file) . "") : ""; } } diff --git a/src/_h5ai/php/inc/Extended.php b/src/_h5ai/php/inc/Extended.php index ed941635..f2b8ee7c 100644 --- a/src/_h5ai/php/inc/Extended.php +++ b/src/_h5ai/php/inc/Extended.php @@ -1,11 +1,13 @@ h5ai = $h5ai; @@ -27,11 +29,13 @@ class Entry { $this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff"); } + public function isFolder() { return $this->isFolder; } + public function toHtml() { $classes = "entry " . ($this->isFolder ? "folder " : "file ") . $this->type; @@ -80,8 +84,10 @@ class Entry { class Extended { + private $h5ai, $parent, $content; + public function __construct($h5ai) { $this->h5ai = $h5ai; @@ -90,12 +96,13 @@ class Extended { $this->loadContent(); } + private function loadContent() { if ($this->h5ai->getAbsHref() !== "/") { $options = $this->h5ai->getOptions(); - $parentPath = dirname($this->h5ai->getAbsPath()); - $parentHref = dirname($this->h5ai->getAbsHref()); + $parentPath = safe_dirname($this->h5ai->getAbsPath()); + $parentHref = safe_dirname($this->h5ai->getAbsHref(), true); $label = $options["setParentFolderLabels"] === true ? $this->h5ai->getLabel($parentHref) : "Parent Directory"; $this->parent = new Entry($this->h5ai, $parentPath, $parentHref, "folder-parent", $label); } @@ -110,6 +117,7 @@ class Extended { } } + public function toHtml() { $html = "
                \n"; @@ -129,6 +137,7 @@ class Extended { return $html; } + public function generateHeaders() { $html = "\t
              • \n"; diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index b14a9e65..98e88965 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -1,34 +1,38 @@ h5aiAbsPath = H5AI_ABS_PATH; - $this->docRoot = $H5AI_CONFIG["DOCUMENT_ROOT"]; - $this->h5aiRoot = $H5AI_CONFIG["H5AI_ROOT"]; + global $H5AI_CONFIG; + $this->rootAbsPath = $H5AI_CONFIG["ROOT_ABS_PATH"]; $this->ignore = $H5AI_CONFIG["IGNORE"]; $this->ignoreRE = $H5AI_CONFIG["IGNORE_PATTERNS"]; - $this->config = $this->loadConfig($this->h5aiRoot . "/config.js"); + $this->config = $this->loadConfig($this->h5aiAbsPath . "/config.js"); $this->options = $this->config["options"]; $this->types = $this->config["types"]; $this->langs = $this->config["langs"]; - $this->cache = new Cache($this->h5aiRoot . "/cache"); + $this->cache = new Cache($this->h5aiAbsPath . "/cache"); - $this->hrefRoot = $this->options["rootAbsHref"]; + $this->rootAbsHref = $this->options["rootAbsHref"]; $this->h5aiAbsHref = $this->options["h5aiAbsHref"]; $this->domain = getenv("HTTP_HOST"); @@ -56,101 +60,111 @@ class H5ai { } - public function getDocRoot() { + public function getH5aiAbsPath() { - return $this->docRoot; + return $this->h5aiAbsPath; } - public function getH5aiRoot() { - return $this->h5aiRoot; + public function getRootAbsPath() { + + return $this->rootAbsPath; } - public function getHrefRoot() { - return $this->hrefRoot; + public function getRootAbsHref() { + + return $this->rootAbsHref; } + public function getH5aiAbsHref() { return $this->h5aiAbsHref; } + public function getDomain() { return $this->domain; } + public function getView() { return $this->view; } + public function api() { return $this->h5aiAbsHref . "php/api.php"; } + public function image($id) { return $this->h5aiAbsHref . "images/" . $id . ".png"; } + public function icon($id, $big = false) { return $this->h5aiAbsHref . "icons/" . ($big ? "48x48" : "16x16") . "/" . $id . ".png"; } + public function getOptions() { return $this->options; } + public function getLangs() { return $this->langs; } + public function getAbsHref($absPath = null, $endWithSlash = true) { if ($absPath === null) { return $this->absHref; } - // - $absPath=substr($absPath, strlen($this->docRoot)); + $absPath=substr($absPath, strlen($this->rootAbsPath)); - $absHref = preg_replace("!^" . $this->docRoot . "!", "", $absPath); - $parts = explode("/", $absHref); + $parts = explode("/", $absPath); $encodedParts = array(); foreach ($parts as $part) { $encodedParts[] = rawurlencode($part); } $endodedAbsHref = implode("/", $encodedParts); - // - $endodedAbsHref = $this->hrefRoot . $endodedAbsHref; + $endodedAbsHref = $this->rootAbsHref . $endodedAbsHref; return $this->normalizePath($endodedAbsHref, $endWithSlash); } + public function getAbsPath($absHref = null) { if ($absHref === null) { return $this->absPath; } - // - $absHref=substr($absHref, strlen($this->hrefRoot)); + $absHref=substr($absHref, strlen($this->rootAbsHref)); - return $this->normalizePath($this->docRoot . "/" . rawurldecode($absHref), false); + return $this->normalizePath($this->rootAbsPath . "/" . rawurldecode($absHref), false); } + public function showThumbs() { return $this->options["showThumbs"] === true; } + public function getTitle() { $title = $this->domain . rawurldecode($this->absHref); @@ -162,6 +176,7 @@ class H5ai { return $title; } + public function getType($absPath) { foreach($this->types as $type => $exts) { @@ -174,9 +189,10 @@ class H5ai { return "unknown"; } + public function ignoreThisFile($file) { - # always ignore + // always ignore if ($file === "." || $file === ".." || $this->startsWith($file, '.ht')) { return true; } @@ -193,6 +209,7 @@ class H5ai { return false; } + public function readDir($path) { $content = array(); @@ -209,33 +226,39 @@ class H5ai { return $content; } + public function getLabel($absHref) { return $absHref === "/" ? $this->domain : rawurldecode(basename($absHref)); } + public function normalizePath($path, $endWithSlash) { - return ($path === "/") ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); + return $path === "/" ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); } + public function startsWith($sequence, $start) { return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0; } + public function endsWith($sequence, $end) { return strcasecmp(substr($sequence, -strlen($end)), $end) === 0; } + public function getHttpCode($absHref) { return $this->cachedHttpCode($absHref); - #return $this->fetchHttpCode($absHref); - #return $this->guessHttpCode($absHref); + // return $this->fetchHttpCode($absHref); + // return $this->guessHttpCode($absHref); } + public function cachedHttpCode($absHref) { $cached = $this->cache->get($absHref); @@ -252,6 +275,7 @@ class H5ai { return $cached["code"]; } + public function fetchHttpCode($absHref) { $contentType = "Content-Type:"; @@ -286,6 +310,7 @@ class H5ai { return $code; } + public function guessHttpCode($absHref) { $indexFiles = array("index.html", "index.cgi", "index.pl", "index.php", "index.xhtml", "index.htm"); diff --git a/src/_h5ai/php/inc/Image.php b/src/_h5ai/php/inc/Image.php index 69356b24..198d04b3 100644 --- a/src/_h5ai/php/inc/Image.php +++ b/src/_h5ai/php/inc/Image.php @@ -2,13 +2,7 @@ class Image { - private $sourceFile; - private $source; - private $width; - private $height; - private $type; - - private $dest; + private $sourceFile, $source, $width, $height, $type, $dest; public static function isUsable() { diff --git a/src/_h5ai/php/inc/Thumbnail.php b/src/_h5ai/php/inc/Thumbnail.php index 1443b651..6085f368 100644 --- a/src/_h5ai/php/inc/Thumbnail.php +++ b/src/_h5ai/php/inc/Thumbnail.php @@ -1,31 +1,34 @@ h5ai = $h5ai; $this->srcAbsHref = $absHref; - $this->srcAbsPath = $this->h5ai->getDocRoot() . urldecode($absHref); + $this->srcAbsPath = $this->h5ai->getRootAbsPath() . urldecode($absHref); $this->width = $width; $this->height = $height; $this->mode = $mode; $this->name = sha1("$this->srcAbsPath-$this->width-$this->height-$this->mode"); - $this->href = $this->h5ai->getH5aiAbsHref() . "/cache/thumb-" . $this->name . ".jpg"; - $this->path = $this->h5ai->getDocRoot() . $this->href; + $this->href = $this->h5ai->getH5aiAbsHref() . "cache/thumb-" . $this->name . ".jpg"; + $this->path = $this->h5ai->getRootAbsPath() . $this->href; $this->liveHref = $this->h5ai->api() . "?action=thumb&href=" . $this->srcAbsHref . "&width=" . $this->width . "&height=" . $this->height . "&mode=" . $this->mode; } + public function create($force = 0) { if ( @@ -40,16 +43,19 @@ class Thumbnail { } } + public function getHref() { return $this->href; } + public function getPath() { return $this->path; } + public function getLiveHref() { return $this->liveHref; diff --git a/src/_h5ai/php/inc/Tree.php b/src/_h5ai/php/inc/Tree.php index be1a9bb8..7c4d0644 100644 --- a/src/_h5ai/php/inc/Tree.php +++ b/src/_h5ai/php/inc/Tree.php @@ -1,8 +1,10 @@ h5ai = $h5ai; @@ -16,6 +18,7 @@ class TreeEntry { $this->content = null; } + public function loadContent() { $this->content = array(); @@ -36,6 +39,7 @@ class TreeEntry { $this->sort(); } + public function cmpTrees($t1, $t2) { if ($t1->isFolder && !$t2->isFolder) { @@ -47,6 +51,7 @@ class TreeEntry { return strcasecmp($t1->absPath, $t2->absPath); } + public function sort() { if ($this->content !== null) { @@ -54,6 +59,7 @@ class TreeEntry { } } + public function toHtml() { $classes = "entry " . $this->type . ($this->absHref === $this->h5ai->getAbsHref() ? " current" : ""); @@ -94,6 +100,7 @@ class TreeEntry { return $html; } + public function contentToHtml() { $html = "
                  \n"; @@ -106,13 +113,14 @@ class TreeEntry { return $html; } + public function getRoot() { if ($this->absHref === "/") { return $this; }; - $tree = new TreeEntry($this->h5ai, dirname($this->absPath), dirname($this->absHref)); + $tree = new TreeEntry($this->h5ai, safe_dirname($this->absPath), safe_dirname($this->absHref, true)); $tree->loadContent(); $tree->content[$this->absPath] = $this; @@ -122,13 +130,16 @@ class TreeEntry { class Tree { + private $h5ai; + public function __construct($h5ai) { $this->h5ai = $h5ai; } + public function toHtml() { $options = $this->h5ai->getOptions(); diff --git a/src/_h5ai/php/inc/ZipIt.php b/src/_h5ai/php/inc/ZipIt.php index a86a7279..5e2c9022 100644 --- a/src/_h5ai/php/inc/ZipIt.php +++ b/src/_h5ai/php/inc/ZipIt.php @@ -1,13 +1,16 @@ h5ai = $h5ai; } + public function zip($hrefs) { $zipFile = tempnam("/tmp", "h5ai-download"); @@ -18,11 +21,11 @@ class ZipIt { } foreach ($hrefs as $href) { - $d = dirname($href); + $d = safe_dirname($href, true); $n = basename($href); if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($d)) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) { $localFile = $this->h5ai->getAbsPath($href); - $file = preg_replace("!^" . $this->h5ai->getDocRoot() . "!", "", $localFile); + $file = preg_replace("!^" . $this->h5ai->getRootAbsPath() . "!", "", $localFile); if (is_dir($localFile)) { $this->zipDir($zip, $localFile, $file); } else { @@ -35,6 +38,7 @@ class ZipIt { return $zipFile; } + private function zipFile($zip, $localFile, $file) { if (is_readable($localFile)) { @@ -42,6 +46,7 @@ class ZipIt { } } + private function zipDir($zip, $localDir, $dir) { if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") { diff --git a/src/_h5ai/php/main.php b/src/_h5ai/php/main.php index a11e837a..2e4af69b 100644 --- a/src/_h5ai/php/main.php +++ b/src/_h5ai/php/main.php @@ -1,11 +1,23 @@ Date: Thu, 16 Feb 2012 00:34:55 +0100 Subject: [PATCH 08/36] Moves thumbTypes to config.js. --- README.md | 2 ++ src/_h5ai/config.js | 1 + src/_h5ai/config.php | 3 +-- src/_h5ai/php/inc/Crumb.php | 2 +- src/_h5ai/php/inc/Extended.php | 8 +++----- src/_h5ai/php/inc/H5ai.php | 27 +++++++++++++++------------ src/_h5ai/php/inc/Image.php | 4 ++-- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 2f9352ea..bc23087e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * updates es translation * custom headers/footers are now optional and disabled by default * fixes problems with folder recognition in the JS version +* fixes include problems in PHP version +* fixes path problems on servers running on Windows in PHP version ### v0.17 - *2011-11-28* diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index d0b7035e..ba29658f 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -106,6 +106,7 @@ var H5AI_CONFIG = { * Show thumbnails for image files. */ "showThumbs": true, + "thumbTypes": ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], /* * Requires PHP on the server. diff --git a/src/_h5ai/config.php b/src/_h5ai/config.php index f901fa31..8096a5b2 100644 --- a/src/_h5ai/config.php +++ b/src/_h5ai/config.php @@ -12,9 +12,8 @@ $H5AI_CONFIG = array(); /* * This configuration assumes that h5ai is installed * in the webroot directory of the Apache server. - * Assumed to end with a slash. */ -$H5AI_CONFIG["ROOT_ABS_PATH"] = dirname(dirname(str_replace('\\', '/', __FILE__))); +$H5AI_CONFIG["ROOT_ABS_PATH"] = safe_dirname(safe_dirname(__FILE__)); /* * Files/folders that should not be listed. Specified diff --git a/src/_h5ai/php/inc/Crumb.php b/src/_h5ai/php/inc/Crumb.php index 9d10ab00..76ac81b8 100644 --- a/src/_h5ai/php/inc/Crumb.php +++ b/src/_h5ai/php/inc/Crumb.php @@ -11,7 +11,7 @@ class Crumb { $this->parts = array(); $href = $h5ai->getAbsHref(); - while ($href !== "/" && $href !== "//") { + while ($href !== "/") { $this->parts[] = $href; $href = safe_dirname($href, true); } diff --git a/src/_h5ai/php/inc/Extended.php b/src/_h5ai/php/inc/Extended.php index f2b8ee7c..e8a47878 100644 --- a/src/_h5ai/php/inc/Extended.php +++ b/src/_h5ai/php/inc/Extended.php @@ -5,7 +5,7 @@ require_h5ai("/php/inc/Thumbnail.php"); class Entry { - private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size, $thumbTypes; + private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size; public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) { @@ -25,8 +25,6 @@ class Entry { $this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath); $this->size = filesize($this->absPath); } - - $this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff"); } @@ -59,7 +57,7 @@ class Entry { } } } - if ($this->h5ai->showThumbs() && in_array($this->type, $this->thumbTypes)) { + if ($this->h5ai->showThumbs() && in_array($this->type, $this->h5ai->getThumbTypes())) { $imgClass = " class='thumb' "; $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16); $thumbnail->create(); @@ -138,7 +136,7 @@ class Extended { } - public function generateHeaders() { + private function generateHeaders() { $html = "\t
                • \n"; $html .= "\t\t\n"; diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index 98e88965..6d25807c 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -126,24 +126,27 @@ class H5ai { } + public function normalizePath($path, $endWithSlash) { + + return preg_match("#^(\w:)?/$#", $path) ? $path : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); + } + + public function getAbsHref($absPath = null, $endWithSlash = true) { if ($absPath === null) { return $this->absHref; } - $absPath=substr($absPath, strlen($this->rootAbsPath)); + $absPath = substr($absPath, strlen($this->rootAbsPath)); $parts = explode("/", $absPath); $encodedParts = array(); foreach ($parts as $part) { $encodedParts[] = rawurlencode($part); } - $endodedAbsHref = implode("/", $encodedParts); - $endodedAbsHref = $this->rootAbsHref . $endodedAbsHref; - - return $this->normalizePath($endodedAbsHref, $endWithSlash); + return $this->normalizePath($this->rootAbsHref . implode("/", $encodedParts), $endWithSlash); } @@ -153,7 +156,7 @@ class H5ai { return $this->absPath; } - $absHref=substr($absHref, strlen($this->rootAbsHref)); + $absHref = substr($absHref, strlen($this->rootAbsHref)); return $this->normalizePath($this->rootAbsPath . "/" . rawurldecode($absHref), false); } @@ -165,6 +168,12 @@ class H5ai { } + public function getThumbTypes() { + + return $this->options["thumbTypes"]; + } + + public function getTitle() { $title = $this->domain . rawurldecode($this->absHref); @@ -233,12 +242,6 @@ class H5ai { } - public function normalizePath($path, $endWithSlash) { - - return $path === "/" ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); - } - - public function startsWith($sequence, $start) { return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0; diff --git a/src/_h5ai/php/inc/Image.php b/src/_h5ai/php/inc/Image.php index 198d04b3..ae71db64 100644 --- a/src/_h5ai/php/inc/Image.php +++ b/src/_h5ai/php/inc/Image.php @@ -78,7 +78,7 @@ class Image { public function releaseDest() { if (!is_null($this->dest)) { - imagedestroy($this->dest); + @imagedestroy($this->dest); $this->dest = null; } } @@ -87,7 +87,7 @@ class Image { public function releaseSource() { if (!is_null($this->source)) { - imagedestroy($this->source); + @imagedestroy($this->source); $this->sourceFile = null; $this->source = null; $this->width = null; From ba121545667c7447b648ca78cc5c28402a7a63b8 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 16 Feb 2012 00:55:13 +0100 Subject: [PATCH 09/36] Updates build process. --- build.properties | 4 +-- build.xml | 79 +++++++++++++++++++++++++++++++++------------- tools/wepp | 4 --- tools/wepp.ant.xml | 40 ----------------------- 4 files changed, 58 insertions(+), 69 deletions(-) delete mode 100755 tools/wepp delete mode 100644 tools/wepp.ant.xml diff --git a/build.properties b/build.properties index 7df81595..d4865527 100644 --- a/build.properties +++ b/build.properties @@ -16,8 +16,6 @@ release.dir = release # tools -tool.wepp = tools/wepp +tool.wepp = wepp tool.jslint = jslint -tool.jshint = jshint -tool.jsxint.file = ${build.dir}/_h5ai/js/main-js.js diff --git a/build.xml b/build.xml index 7b6b1313..8010312b 100644 --- a/build.xml +++ b/build.xml @@ -5,8 +5,6 @@ default="release" > - - @@ -37,13 +35,13 @@ - - + + - - + + @@ -51,25 +49,62 @@ - - + + + - - JSLint "${tool.jsxint.file}" - - - - - - JSHint "${tool.jsxint.file}" - - - - + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JSLint @{files} + + + + + diff --git a/tools/wepp b/tools/wepp deleted file mode 100755 index a6d0cb94..00000000 --- a/tools/wepp +++ /dev/null @@ -1,4 +0,0 @@ -#! /usr/bin/env node -// -*- js -*- - -require("wepp").processArgs(process.argv); diff --git a/tools/wepp.ant.xml b/tools/wepp.ant.xml deleted file mode 100644 index 8bac3544..00000000 --- a/tools/wepp.ant.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From ca4d3ae315efac51961990311732f5f56c961f41 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 01:18:57 +0100 Subject: [PATCH 10/36] Adds classes to to distinguish h5ai versions. --- src/_h5ai/header.html | 2 +- src/_h5ai/header.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_h5ai/header.html b/src/_h5ai/header.html index ab84245f..ef671b42 100644 --- a/src/_h5ai/header.html +++ b/src/_h5ai/header.html @@ -2,7 +2,7 @@ - + diff --git a/src/_h5ai/header.php b/src/_h5ai/header.php index c3c2ef59..c4dd2dd0 100644 --- a/src/_h5ai/header.php +++ b/src/_h5ai/header.php @@ -2,7 +2,7 @@ - + From ecf91b506eb9c81f9c8fb8bb6125de5c98a2a95a Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 01:21:43 +0100 Subject: [PATCH 11/36] Disallows indexing the _h5ai folder by default. --- src/_h5ai/.htaccess | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/_h5ai/.htaccess b/src/_h5ai/.htaccess index ec4f2924..be958da7 100644 --- a/src/_h5ai/.htaccess +++ b/src/_h5ai/.htaccess @@ -1,5 +1,7 @@ +Options -Indexes + AddType text/html .php From 1a8ef621888a546c3c37f4529dfd519ca4eb2c66 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 03:23:42 +0100 Subject: [PATCH 12/36] Fixes broken links in custom headers/footers. Updates default options. --- src/_h5ai/js/inc/Core.js | 10 +++++++--- src/_h5ai/js/inc/ZippedDownload.js | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index 3790e899..b4738be8 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -15,20 +15,24 @@ rootAbsHref: "/", h5aiAbsHref: "/_h5ai/", - customHeader: "_h5ai.header.html", - customFooter: "_h5ai.footer.html", + + customHeader: null, + customFooter: null, viewmodes: ["details", "icons"], sortorder: "na", showTree: true, slideTree: true, folderStatus: {}, - lang: null, + lang: "en", useBrowserLang: true, setParentFolderLabels: true, linkHoverStates: true, dateFormat: "yyyy-MM-dd HH:mm", + showThumbs: false, + thumbTypes: ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], + zippedDownload: false }, settings = $.extend({}, defaults, config.options), diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index 375b9585..b2388ab0 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -97,7 +97,7 @@ .appendTo($("#navbar")); $("body>nav,body>footer,#tree").on("mousedown", noSelection); - $("#extended").on("mousedown", "a", noSelectionUnlessCtrl); + $("#content").on("mousedown", "a", noSelectionUnlessCtrl); $document.on("mousedown", selectionStart); } }; From 42d3dfe80e0da61e76e2ae96bdf3678e78c4e2e5 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 03:25:57 +0100 Subject: [PATCH 13/36] Updates readme. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bc23087e..68981461 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * fixes problems with folder recognition in the JS version * fixes include problems in PHP version * fixes path problems on servers running on Windows in PHP version +* fixes broken links in custom headers/footers while zipped download enabled ### v0.17 - *2011-11-28* From d56d0716cb451a3014b923e68dc1185f8835ef57 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 11:28:08 +0100 Subject: [PATCH 14/36] Fixes problems with thumbnails for filenames with single and double quotes. --- README.md | 2 +- src/_h5ai/js/inc/Html.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 68981461..f71a4470 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * fixes include problems in PHP version * fixes path problems on servers running on Windows in PHP version * fixes broken links in custom headers/footers while zipped download enabled - +* fixes problems with thumbnails for files with single or double quotes in filename ### v0.17 - *2011-11-28* diff --git a/src/_h5ai/js/inc/Html.js b/src/_h5ai/js/inc/Html.js index d95a07e8..6b092e47 100644 --- a/src/_h5ai/js/inc/Html.js +++ b/src/_h5ai/js/inc/Html.js @@ -74,8 +74,9 @@ if (H5AI.core.settings.showThumbs === true && $.inArray(path.type, thumbTypes) >= 0) { imgClass = "class='thumb'"; - icon16 = H5AI.core.api() + "?action=thumb&href=" + path.absHref + "&width=16&height=16&mode=square"; - icon48 = H5AI.core.api() + "?action=thumb&href=" + path.absHref + "&width=96&height=46&mode=rational"; + var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22"); + icon16 = H5AI.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square"; + icon48 = H5AI.core.api() + "?action=thumb&href=" + escapedHref + "&width=96&height=46&mode=rational"; } $label = $("" + path.label + ""); From f51a0b80a712e3e36adf86f60272beac9e4dae4f Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 13:47:09 +0100 Subject: [PATCH 15/36] Js version uses settings.thumbTypes too. --- src/_h5ai/js/inc/Html.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/_h5ai/js/inc/Html.js b/src/_h5ai/js/inc/Html.js index 6b092e47..12bd1b6d 100644 --- a/src/_h5ai/js/inc/Html.js +++ b/src/_h5ai/js/inc/Html.js @@ -3,8 +3,7 @@ H5AI.html = (function () { - var thumbTypes = ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], - onClick = function (path, context) { + var onClick = function (path, context) { }, updateCrumbHtml = function (path) { @@ -72,7 +71,7 @@ $html.data("status", path.status); } - if (H5AI.core.settings.showThumbs === true && $.inArray(path.type, thumbTypes) >= 0) { + if (H5AI.core.settings.showThumbs === true && $.inArray(path.type, H5AI.core.settings.thumbTypes) >= 0) { imgClass = "class='thumb'"; var escapedHref = path.absHref.replace(/'/g, "%27").replace(/"/g, "%22"); icon16 = H5AI.core.api() + "?action=thumb&href=" + escapedHref + "&width=16&height=16&mode=square"; From bc6e9fb150d88cd20bcf8afd9efbe3eadf67e6e8 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 17 Feb 2012 23:21:13 +0100 Subject: [PATCH 16/36] Improves zipped download. --- README.md | 2 ++ src/_h5ai/css/inc/main.less | 8 +++++ src/_h5ai/js/inc/ZippedDownload.js | 50 +++++++++++++++++++++++++----- src/_h5ai/php/api.php | 20 ++++++++++-- src/_h5ai/php/inc/ZipIt.php | 9 +++--- 5 files changed, 74 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f71a4470..208825f8 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * fixes path problems on servers running on Windows in PHP version * fixes broken links in custom headers/footers while zipped download enabled * fixes problems with thumbnails for files with single or double quotes in filename +* improves zipped download + ### v0.17 - *2011-11-28* diff --git a/src/_h5ai/css/inc/main.less b/src/_h5ai/css/inc/main.less index b1df578f..55ed8cd1 100644 --- a/src/_h5ai/css/inc/main.less +++ b/src/_h5ai/css/inc/main.less @@ -94,6 +94,14 @@ body > nav { display: none; float: right; border-left: 1px solid rgb(231,231,231); + .transition(all 0.2s ease-in-out); + + &.zipping { + + } + &.failed { + background-color: rgba(255,0,0,0.5); + } } } diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index b2388ab0..b9afae6d 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -7,21 +7,22 @@ y = 0, $document = $(document), $selectionRect = $("#selection-rect"), + selectedHrefsStr = "", updateDownloadBtn = function () { var $selected = $("#extended a.selected"), - $downloadBtn = $("#download"), - query, href; + $downloadBtn = $("#download"); - if ($selected.size() > 0) { + selectedHrefsStr = ""; + if ($selected.length) { $selected.each(function () { - href = $(this).attr("href"); - query = query ? query + ":" + href : href; + + var href = $(this).attr("href"); + selectedHrefsStr = selectedHrefsStr ? selectedHrefsStr + ":" + href : href; }); - query = H5AI.core.api() + "?action=zip&hrefs=" + query; - $downloadBtn.show().find("a").attr("href", query); + $downloadBtn.show(); } else { - $downloadBtn.hide().find("a").attr("href", "#"); + $downloadBtn.hide(); } }, selectionUpdate = function (event) { @@ -94,6 +95,39 @@ if (H5AI.core.settings.zippedDownload) { $("
                • downloaddownload
                • ") .find("img").attr("src", H5AI.core.image("download")).end() + .find("a").click(function () { + + $('#download').addClass('zipping'); + $('#download img').attr('src', H5AI.core.image("loading")); + $.ajax({ + url: H5AI.core.api(), + data: { + action: 'zip', + hrefs: selectedHrefsStr + }, + type: 'POST', + dataType: 'json', + success: function (response) { + + $('#download img').attr('src', H5AI.core.image("download")); + $('#download').removeClass('zipping'); + if (response.status === 'ok') { + console.log("download worked!", response); + window.location = H5AI.core.api() + '?action=getzip&id=' + response.id; + } else { + console.log("download failed!", response); + $('#download').addClass('failed'); + setTimeout(function () { + $('#download').removeClass('failed'); + }, 1000); + } + }, + failed: function () { + $('#download img').attr('src', H5AI.core.image("download")); + $('#download').removeClass('zipping'); + } + }); + }).end() .appendTo($("#navbar")); $("body>nav,body>footer,#tree").on("mousedown", noSelection); diff --git a/src/_h5ai/php/api.php b/src/_h5ai/php/api.php index c3d12b30..72330882 100644 --- a/src/_h5ai/php/api.php +++ b/src/_h5ai/php/api.php @@ -118,12 +118,26 @@ else if ($action === "zip") { $hrefs = explode(":", trim($hrefs)); $zipFile = $zipit->zip($hrefs); - if ($zipFile === false) { - fail(2, "something went wrong while building the zip"); + if ($zipFile) { + $response = array('status' => 'ok', 'id' => basename($zipFile), 'size' => filesize($zipFile)); + } else { + $response = array('status' => 'failed', 'msg' => 'none'); } + echo json_encode($response); +} + + +else if ($action === "getzip") { + + list($id) = checkKeys(array("id")); + fail(1, "zipped file not found: " . $id, !preg_match("/^h5ai-zip-/", $id)); + + $zipFile = str_replace("\\", "/", sys_get_temp_dir()) . "/" . $id; + fail(2, "zipped file not found: " . $id, !file_exists($zipFile)); header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\""); - header("Content-Type: application/force-download"); + // header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($zipFile)); header("Connection: close"); readfile($zipFile); diff --git a/src/_h5ai/php/inc/ZipIt.php b/src/_h5ai/php/inc/ZipIt.php index 5e2c9022..cb67a953 100644 --- a/src/_h5ai/php/inc/ZipIt.php +++ b/src/_h5ai/php/inc/ZipIt.php @@ -13,17 +13,18 @@ class ZipIt { public function zip($hrefs) { - $zipFile = tempnam("/tmp", "h5ai-download"); + $zipFile = tempnam(sys_get_temp_dir(), "h5ai-zip-"); $zip = new ZipArchive(); if (!$zip->open($zipFile, ZIPARCHIVE::CREATE)) { - return false; + return null; } + $zip->addEmptyDir("/"); foreach ($hrefs as $href) { $d = safe_dirname($href, true); $n = basename($href); - if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($d)) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) { + if ($this->h5ai->getHttpCode($d) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) { $localFile = $this->h5ai->getAbsPath($href); $file = preg_replace("!^" . $this->h5ai->getRootAbsPath() . "!", "", $localFile); if (is_dir($localFile)) { @@ -35,7 +36,7 @@ class ZipIt { } $zip->close(); - return $zipFile; + return filesize($zipFile) ? $zipFile : null; } From 6bfbdb4d057e921f9e0f77e8524b7c49b820f7c1 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sun, 19 Feb 2012 22:29:42 +0100 Subject: [PATCH 17/36] Adds optional QRCodes and filtering for displayed files. --- README.md | 9 +- build.properties | 2 +- src/_h5ai/config.js | 15 +- src/_h5ai/css/inc/context.less | 21 + src/_h5ai/css/inc/main.less | 25 +- src/_h5ai/footer.html | 2 +- src/_h5ai/header.php | 2 +- src/_h5ai/images/filter.png | Bin 0 -> 706 bytes src/_h5ai/js/inc/Context.js | 55 + src/_h5ai/js/inc/Core.js | 8 +- src/_h5ai/js/inc/Finder.js | 87 ++ src/_h5ai/js/inc/ZippedDownload.js | 4 +- src/_h5ai/js/inc/lib/jquery.qrcode.js | 129 ++ src/_h5ai/js/inc/lib/qrcode.js | 1634 +++++++++++++++++++++++++ src/_h5ai/js/libs.js | 1 + src/_h5ai/js/main-php.js | 25 - src/_h5ai/js/{main-js.js => main.js} | 16 +- src/_h5ai/php/inc/Tree.php | 2 +- 18 files changed, 1991 insertions(+), 46 deletions(-) create mode 100644 src/_h5ai/css/inc/context.less create mode 100644 src/_h5ai/images/filter.png create mode 100644 src/_h5ai/js/inc/Context.js create mode 100644 src/_h5ai/js/inc/Finder.js create mode 100644 src/_h5ai/js/inc/lib/jquery.qrcode.js create mode 100644 src/_h5ai/js/inc/lib/qrcode.js delete mode 100644 src/_h5ai/js/main-php.js rename src/_h5ai/js/{main-js.js => main.js} (67%) diff --git a/README.md b/README.md index 208825f8..e56b7211 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * [jQuery](http://jquery.com) (MIT/GPL) * [jQuery.mousewheel](http://github.com/brandonaaron/jquery-mousewheel) (MIT) * [modernizr](http://www.modernizr.com) (MIT/BSD) +* [qrcode](http://www.d-project.com/qrcode/index.html) (MIT) ## Changelog @@ -30,15 +31,17 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h ### v0.18 - *2012-02-??* -* updates year in `LICENSE.TXT` -* updates es translation +* adds optional QRCode display +* adds optional filtering for displayed files and folders +* improves zipped download * custom headers/footers are now optional and disabled by default * fixes problems with folder recognition in the JS version * fixes include problems in PHP version * fixes path problems on servers running on Windows in PHP version * fixes broken links in custom headers/footers while zipped download enabled * fixes problems with thumbnails for files with single or double quotes in filename -* improves zipped download +* updates year in `LICENSE.TXT` +* updates es translation ### v0.17 - *2011-11-28* diff --git a/build.properties b/build.properties index d4865527..cecbe82e 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ custom = true # project project.name = h5ai -project.version = 0.18 +project.version = pre0.18 # src diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index ba29658f..df218795 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -112,7 +112,20 @@ var H5AI_CONFIG = { * Requires PHP on the server. * Enable zipped download of selected entries. */ - "zippedDownload": true + "zippedDownload": true, + + /* + * Show QRCodes on hovering files. + * Set this to the desired size in pixel or null to not display QRCodes. + * A good size to start with might be 150. + */ + "qrCodesSize": 150, + + /* + * Allow filtering the displayed files and folders. + * Filters are ment to be JavaScript regular expressions. + */ + "showFilter": true }, diff --git a/src/_h5ai/css/inc/context.less b/src/_h5ai/css/inc/context.less new file mode 100644 index 00000000..08c8ecc9 --- /dev/null +++ b/src/_h5ai/css/inc/context.less @@ -0,0 +1,21 @@ + +#context { + position: fixed; + display: none; + right: 16px; + bottom: 50px; + + background-color: #fff; + border: 2px solid #ddd; + padding: 8px; + + span { + display: block; + } + + .qrcode { + canvas { + display: block; + } + } +} diff --git a/src/_h5ai/css/inc/main.less b/src/_h5ai/css/inc/main.less index 55ed8cd1..13baed80 100644 --- a/src/_h5ai/css/inc/main.less +++ b/src/_h5ai/css/inc/main.less @@ -42,7 +42,7 @@ body > nav { padding: 0 10px; color: #999; } - a, a:active, a:visited { + a, a:active, a:visited, span.element { color: #555; cursor: pointer; text-decoration: none; @@ -60,9 +60,11 @@ body > nav { opacity: 1.0; } } - .current a { - background-color: rgba(255,255,255,0.5); - opacity: 1.0; + .current { + a, span.element { + background-color: rgba(255,255,255,0.5); + opacity: 1.0; + } } img { position: relative; @@ -70,7 +72,7 @@ body > nav { width: 16px; height: 16px; } - img + span { + img + span, img + input { margin-left: 6px; } .crumb { @@ -103,6 +105,18 @@ body > nav { background-color: rgba(255,0,0,0.5); } } + #filter { + float: right; + border-left: 1px solid rgb(231,231,231); + + input { + border: none; + font-family: Ubuntu, sans-serif; + color: #555; + background-color: rgba(0,0,0,0); + width: 100px; + } + } } @@ -128,6 +142,7 @@ body > nav { @import "table"; @import "extended"; @import "tree"; +@import "context"; body > footer { diff --git a/src/_h5ai/footer.html b/src/_h5ai/footer.html index 3f67a409..e8ca080d 100644 --- a/src/_h5ai/footer.html +++ b/src/_h5ai/footer.html @@ -29,6 +29,6 @@ - + \ No newline at end of file diff --git a/src/_h5ai/header.php b/src/_h5ai/header.php index c4dd2dd0..f9ce0a3e 100644 --- a/src/_h5ai/header.php +++ b/src/_h5ai/header.php @@ -55,6 +55,6 @@ - +
                  diff --git a/src/_h5ai/images/filter.png b/src/_h5ai/images/filter.png new file mode 100644 index 0000000000000000000000000000000000000000..0d55aeecbbdb8c17cf1993103774b94923b0f85e GIT binary patch literal 706 zcmV;z0zLhSP)#?;<-i0rJzv7gHU?YOD~?xK}6_D3?=^ABv38VSV6L6p(PvI?ekz# z;!;H)49vhcKi<4~0g~uY7{CbtO6%MNumhluKZztr21#m@latqk5U&7y2CylFcx@QQ z4U#%Z(VG2j1zHZY-rnBZwryXD$K!8J(<})g4)XbYv{)>Thr{8Qj^o@1@D%|44#LS~ z@;U%(et!NQ$*UwsNsf@rEG;eF0q|*PXy_KnlYR#vsdaUAJx?SOk4Ro5DRm44NRFpc zsYM~g3z7qVfCNC^-`@`<5{VLkj{puj4FV_|hEei7Pp#Ezsy{;sKp+?l?pT&(`!2V2 zU|Cj8mgSATy*&v)zz=Zy`ua8sg~Bj^$Ps|#okGh$;bxr>ExtJPw6I4@eGnKH*=aHk(azW@hG8 oxm*rgmi6p^0qvhiwSv$81aO*bjK4flD*ylh07*qoM6N<$f=vJ~cmMzZ literal 0 HcmV?d00001 diff --git a/src/_h5ai/js/inc/Context.js b/src/_h5ai/js/inc/Context.js new file mode 100644 index 00000000..af2ac902 --- /dev/null +++ b/src/_h5ai/js/inc/Context.js @@ -0,0 +1,55 @@ + +(function ($, H5AI) { + + H5AI.context = (function () { + + var $context, + qrCodesSize, + showQrCode = function ($a) { + + var absHref = $a.attr('href'), + url = 'http://' + document.domain + absHref; + + $context.find('.qrcode').empty().qrcode({ + render: Modernizr.canvas ? 'canvas' : 'div', + width: qrCodesSize, + height: qrCodesSize, + color: '#333', + text: url + }); + }, + init = function () { + + qrCodesSize = H5AI.core.settings.qrCodesSize; + if (!qrCodesSize) { + return; + } + + var hideTimeoutId = null; + + $context = $('
                  '); + $context.appendTo('body'); + + $('#extended') + .on('mouseenter', '.entry.file a', function () { + + showQrCode($(this)); + clearTimeout(hideTimeoutId); + $context.stop(true, true).fadeIn(400); + }) + .on('mouseleave', '.entry.file a', function () { + + hideTimeoutId = setTimeout(function () { + + $context.stop(true, true).fadeOut(400); + }, 200); + }); + }; + + + return { + init: init + } + }()) + +}(jQuery, H5AI)); \ No newline at end of file diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index b4738be8..583a92f8 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -15,10 +15,8 @@ rootAbsHref: "/", h5aiAbsHref: "/_h5ai/", - customHeader: null, customFooter: null, - viewmodes: ["details", "icons"], sortorder: "na", showTree: true, @@ -29,11 +27,11 @@ setParentFolderLabels: true, linkHoverStates: true, dateFormat: "yyyy-MM-dd HH:mm", - showThumbs: false, thumbTypes: ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], - - zippedDownload: false + zippedDownload: false, + qrCodesSize: null, + showFilter: false }, settings = $.extend({}, defaults, config.options), currentDateFormat = settings.dateFormat, diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js new file mode 100644 index 00000000..dd7ef99b --- /dev/null +++ b/src/_h5ai/js/inc/Finder.js @@ -0,0 +1,87 @@ + +(function ($, H5AI) { + + H5AI.finder = (function () { + + var filter = function (re) { + + var match = [], + noMatch = []; + + if (re) { + $('#extended .entry').each(function () { + + var label = $(this).find('.label').text(); + + if (label.match(re)) { + match.push(this); + } else { + noMatch.push(this); + } + }); + } else { + match = $('#extended .entry'); + } + + $(match).fadeIn(200); + $(noMatch).fadeOut(200); + }, + checkState = function (focus) { + + var $filter = $('#filter'), + $input = $filter.find('input'), + val = $input.val(); + + console.log('checkState', val, focus); + + if (val || focus) { + $filter.addClass('current'); + } else { + $filter.removeClass('current'); + } + }, + init = function () { + + if (H5AI.core.settings.showFilter) { + $("
                • filter
                • ") + .on('click', function () { + + var $input = $(this).find('input'); + $input.focus(); + }) + .find("img").attr("src", H5AI.core.image("filter")).end() + .find("input") + .on('focus', function () { + + checkState(true); + }) + .on('blur', function () { + + checkState(false); + }) + .on('keyup', function () { + + var $input = $(this), + val = $input.val(); + + if (val) { + filter(new RegExp(val)); + } else { + filter(); + } + checkState($input.is(':focus')); + }) + .end() + .appendTo($("#navbar")); + } + + }; + + + return { + init: init, + filter: filter + } + }()) + +}(jQuery, H5AI)); \ No newline at end of file diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index b9afae6d..5ad5f784 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -68,12 +68,12 @@ } event.preventDefault(); + $(':focus').blur(); if (!event.ctrlKey) { $("#extended a").removeClass("selected"); updateDownloadBtn(); } $selectionRect.show().css({left: x, top: y, width: 0, height: 0}); - selectionUpdate(event); $document .on("mousemove", selectionUpdate) @@ -81,7 +81,7 @@ }, noSelection = function (event) { - event.stopPropagation(); + event.stopImmediatePropagation(); return false; }, noSelectionUnlessCtrl = function (event) { diff --git a/src/_h5ai/js/inc/lib/jquery.qrcode.js b/src/_h5ai/js/inc/lib/jquery.qrcode.js new file mode 100644 index 00000000..d4c8dcb0 --- /dev/null +++ b/src/_h5ai/js/inc/lib/jquery.qrcode.js @@ -0,0 +1,129 @@ +/*! + * jQuery.qrcode + * author: Lars Jung + * license: MIT + * + * kudos to http://github.com/jeromeetienne/jquery-qrcode + */ +(function ($) { + + // @include "qrcode.js" + + var createQr = function (typeNumber, correctLevel, text) { + + var qr = new qrcode(typeNumber, correctLevel); + qr.addData(text); + qr.make(); + + return qr; + }, + createBestQr = function (text) { + + for (var type = 2; type <= 10; type += 1) { + try { + return createQr(type, 'L', text); + } catch (err) {} + } + + return null; + }, + createCanvas = function (settings) { + + var qr = createBestQr(settings.text), + $canvas = $('').attr('width', settings.width).attr('height', settings.height), + ctx = $canvas[0].getContext('2d'); + + if (settings.bgColor) { + ctx.fillStyle = settings.bgColor; + ctx.fillRect(0, 0, settings.width, settings.height); + } + + if (qr) { + var moduleCount = qr.getModuleCount(), + moduleWidth = settings.width / moduleCount, + moduleHeight = settings.height / moduleCount, + row, col; + + ctx.beginPath(); + for (row = 0; row < moduleCount; row += 1) { + for (col = 0; col < moduleCount; col += 1) { + if (qr.isDark(row, col)) { + ctx.rect(col * moduleWidth, row * moduleHeight, moduleWidth, moduleHeight); + } + } + } + ctx.fillStyle = settings.color; + ctx.fill(); + } + + return $canvas; + }, + createDiv = function (settings) { + + var qr = createBestQr(settings.text), + $div = $('
                  ').css({ + position: 'relative', + left: 0, + top: 0, + padding: 0, + margin: 0, + width: settings.width, + height: settings.height + }); + + if (settings.bgColor) { + $div.css('background-color', settings.bgColor); + } + + if (qr) { + var moduleCount = qr.getModuleCount(), + moduleWidth = Math.floor(settings.width / moduleCount), + moduleHeight = Math.floor(settings.height / moduleCount), + offsetLeft = Math.floor(0.5 * (settings.width - moduleWidth * moduleCount)), + offsetTop = Math.floor(0.5 * (settings.height - moduleHeight * moduleCount)), + row, col; + + for (row = 0; row < moduleCount; row++) { + for (col = 0; col < moduleCount; col++) { + if (qr.isDark(row, col)) { + $('
                  ') + .css({ + left: offsetLeft + col * moduleWidth, + top: offsetTop + row * moduleHeight + }) + .appendTo($div); + } + } + } + + $div.children() + .css({ + position: 'absolute', + padding: 0, + margin: 0, + width: moduleWidth, + height: moduleHeight, + 'background-color': settings.color + }); + } + + return $div; + }, + + defaults = { + render: 'canvas', + width: 256, + height: 256, + color: '#000', + bgColor: null, + text: 'no text' + }; + + $.fn.qrcode = function(options) { + + var settings = $.extend({}, defaults, options); + + $(this).append(settings.render === 'canvas' ? createCanvas(settings) : createDiv(settings)); + }; + +}(jQuery)); diff --git a/src/_h5ai/js/inc/lib/qrcode.js b/src/_h5ai/js/inc/lib/qrcode.js new file mode 100644 index 00000000..c80e8177 --- /dev/null +++ b/src/_h5ai/js/inc/lib/qrcode.js @@ -0,0 +1,1634 @@ +//--------------------------------------------------------------------- +// +// QR Code Generator for JavaScript +// +// Copyright (c) 2009 Kazuhiko Arase +// +// URL: http://www.d-project.com/ +// +// Licensed under the MIT license: +// http://www.opensource.org/licenses/mit-license.php +// +// The word 'QR Code' is registered trademark of +// DENSO WAVE INCORPORATED +// http://www.denso-wave.com/qrcode/faqpatent-e.html +// +//--------------------------------------------------------------------- + +var qrcode = function() { + + //--------------------------------------------------------------------- + // qrcode + //--------------------------------------------------------------------- + + /** + * qrcode + * @param typeNumber 1 to 10 + * @param errorCorrectLevel 'L','M','Q','H' + */ + var qrcode = function(typeNumber, errorCorrectLevel) { + + var PAD0 = 0xEC; + var PAD1 = 0x11; + + var _typeNumber = typeNumber; + var _errorCorrectLevel = QRErrorCorrectLevel[errorCorrectLevel]; + var _modules = null; + var _moduleCount = 0; + var _dataCache = null; + var _dataList = new Array(); + + var _this = {}; + + var makeImpl = function(test, maskPattern) { + + _moduleCount = _typeNumber * 4 + 17; + _modules = function(moduleCount) { + var modules = new Array(moduleCount); + for (var row = 0; row < moduleCount; row += 1) { + modules[row] = new Array(moduleCount); + for (var col = 0; col < moduleCount; col += 1) { + modules[row][col] = null; + } + } + return modules; + }(_moduleCount); + + setupPositionProbePattern(0, 0); + setupPositionProbePattern(_moduleCount - 7, 0); + setupPositionProbePattern(0, _moduleCount - 7); + setupPositionAdjustPattern(); + setupTimingPattern(); + setupTypeInfo(test, maskPattern); + + if (_typeNumber >= 7) { + setupTypeNumber(test); + } + + if (_dataCache == null) { + _dataCache = createData(_typeNumber, _errorCorrectLevel, _dataList); + } + + mapData(_dataCache, maskPattern); + }; + + var setupPositionProbePattern = function(row, col) { + + for (var r = -1; r <= 7; r += 1) { + + if (row + r <= -1 || _moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c += 1) { + + if (col + c <= -1 || _moduleCount <= col + c) continue; + + if ( (0 <= r && r <= 6 && (c == 0 || c == 6) ) + || (0 <= c && c <= 6 && (r == 0 || r == 6) ) + || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) { + _modules[row + r][col + c] = true; + } else { + _modules[row + r][col + c] = false; + } + } + } + }; + + var getBestMaskPattern = function() { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i += 1) { + + makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(_this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }; + + var setupTimingPattern = function() { + + for (var r = 8; r < _moduleCount - 8; r += 1) { + if (_modules[r][6] != null) { + continue; + } + _modules[r][6] = (r % 2 == 0); + } + + for (var c = 8; c < _moduleCount - 8; c += 1) { + if (_modules[6][c] != null) { + continue; + } + _modules[6][c] = (c % 2 == 0); + } + }; + + var setupPositionAdjustPattern = function() { + + var pos = QRUtil.getPatternPosition(_typeNumber); + + for (var i = 0; i < pos.length; i += 1) { + + for (var j = 0; j < pos.length; j += 1) { + + var row = pos[i]; + var col = pos[j]; + + if (_modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r += 1) { + + for (var c = -2; c <= 2; c += 1) { + + if (r == -2 || r == 2 || c == -2 || c == 2 + || (r == 0 && c == 0) ) { + _modules[row + r][col + c] = true; + } else { + _modules[row + r][col + c] = false; + } + } + } + } + } + }; + + var setupTypeNumber = function(test) { + + var bits = QRUtil.getBCHTypeNumber(_typeNumber); + + for (var i = 0; i < 18; i += 1) { + var mod = (!test && ( (bits >> i) & 1) == 1); + _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i += 1) { + var mod = (!test && ( (bits >> i) & 1) == 1); + _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }; + + var setupTypeInfo = function(test, maskPattern) { + + var data = (_errorCorrectLevel << 3) | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i += 1) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 6) { + _modules[i][8] = mod; + } else if (i < 8) { + _modules[i + 1][8] = mod; + } else { + _modules[_moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i += 1) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 8) { + _modules[8][_moduleCount - i - 1] = mod; + } else if (i < 9) { + _modules[8][15 - i - 1 + 1] = mod; + } else { + _modules[8][15 - i - 1] = mod; + } + } + + // fixed module + _modules[_moduleCount - 8][8] = (!test); + }; + + var mapData = function(data, maskPattern) { + + var inc = -1; + var row = _moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + var maskFunc = QRUtil.getMaskFunction(maskPattern); + + for (var col = _moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col -= 1; + + while (true) { + + for (var c = 0; c < 2; c += 1) { + + if (_modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1); + } + + var mask = maskFunc(row, col - c); + + if (mask) { + dark = !dark; + } + + _modules[row][col - c] = dark; + bitIndex -= 1; + + if (bitIndex == -1) { + byteIndex += 1; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || _moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + }; + + var createBytes = function(buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r += 1) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i += 1) { + dcdata[r][i] = 0xff & buffer.getBuffer()[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i += 1) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0; + } + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i += 1) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i += 1) { + for (var r = 0; r < rsBlocks.length; r += 1) { + if (i < dcdata[r].length) { + data[index] = dcdata[r][i]; + index += 1; + } + } + } + + for (var i = 0; i < maxEcCount; i += 1) { + for (var r = 0; r < rsBlocks.length; r += 1) { + if (i < ecdata[r].length) { + data[index] = ecdata[r][i]; + index += 1; + } + } + } + + return data; + }; + + var createData = function(typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = qrBitBuffer(); + + for (var i = 0; i < dataList.length; i += 1) { + var data = dataList[i]; + buffer.put(data.getMode(), 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) ); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i += 1) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error('code length overflow. (' + + buffer.getLengthInBits() + + '>' + + totalDataCount * 8 + + ')'); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(PAD1, 8); + } + + return createBytes(buffer, rsBlocks); + }; + + _this.addData = function(data) { + var newData = qr8BitByte(data); + _dataList.push(newData); + _dataCache = null; + }; + + _this.isDark = function(row, col) { + if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) { + throw new Error(row + ',' + col); + } + return _modules[row][col]; + }; + + _this.getModuleCount = function() { + return _moduleCount; + }; + + _this.make = function() { + makeImpl(false, getBestMaskPattern() ); + }; + + _this.createTableTag = function(cellSize, margin) { + + cellSize = cellSize || 2; + margin = (typeof margin == 'undefined')? cellSize * 4 : margin; + + var qrHtml = ''; + + qrHtml += ''; + qrHtml += ''; + + for (var r = 0; r < _this.getModuleCount(); r += 1) { + + qrHtml += ''; + + for (var c = 0; c < _this.getModuleCount(); c += 1) { + qrHtml += ''; + } + + qrHtml += ''; + qrHtml += '
                  '; + } + + qrHtml += '
                  '; + + return qrHtml; + }; + + _this.createImgTag = function(cellSize, margin) { + + cellSize = cellSize || 2; + margin = (typeof margin == 'undefined')? cellSize * 4 : margin; + + var size = _this.getModuleCount() * cellSize + margin * 2; + var min = margin; + var max = size - margin; + + return createImgTag(size, size, function(x, y) { + if (min <= x && x < max && min <= y && y < max) { + var c = Math.floor( (x - min) / cellSize); + var r = Math.floor( (y - min) / cellSize); + return _this.isDark(r, c)? 0 : 1; + } else { + return 1; + } + } ); + }; + + return _this; + }; + + //--------------------------------------------------------------------- + // qrcode.stringToBytes + //--------------------------------------------------------------------- + + qrcode.stringToBytes = function(s) { + var bytes = new Array(); + for (var i = 0; i < s.length; i += 1) { + var c = s.charCodeAt(i); + bytes.push(c & 0xff); + } + return bytes; + }; + + //--------------------------------------------------------------------- + // qrcode.createStringToBytes + //--------------------------------------------------------------------- + + /** + * @param unicodeData base64 string of byte array. + * [16bit Unicode],[16bit Bytes], ... + * @param numChars + */ + qrcode.createStringToBytes = function(unicodeData, numChars) { + + // create conversion map. + + var unicodeMap = function() { + + var bin = base64DecodeInputStream(unicodeData); + var read = function() { + var b = bin.read(); + if (b == -1) throw new Error(); + return b; + }; + + var count = 0; + var unicodeMap = {}; + while (true) { + var b0 = bin.read(); + if (b0 == -1) break; + var b1 = read(); + var b2 = read(); + var b3 = read(); + var k = String.fromCharCode( (b0 << 8) | b1); + var v = (b2 << 8) | b3; + unicodeMap[k] = v; + count += 1; + } + if (count != numChars) { + throw new Error(count + ' != ' + numChars); + } + + return unicodeMap; + }(); + + var unknownChar = '?'.charCodeAt(0); + + return function(s) { + var bytes = new Array(); + for (var i = 0; i < s.length; i += 1) { + var c = s.charCodeAt(i); + if (c < 128) { + bytes.push(c); + } else { + var b = unicodeMap[s.charAt(i)]; + if (typeof b == 'number') { + if ( (b & 0xff) == b) { + // 1byte + bytes.push(b); + } else { + // 2bytes + bytes.push(b >>> 8); + bytes.push(b & 0xff); + } + } else { + bytes.push(unknownChar); + } + } + } + return bytes; + }; + }; + + //--------------------------------------------------------------------- + // QRMode + //--------------------------------------------------------------------- + + var QRMode = { + MODE_NUMBER : 1 << 0, + MODE_ALPHA_NUM : 1 << 1, + MODE_8BIT_BYTE : 1 << 2, + MODE_KANJI : 1 << 3 + }; + + //--------------------------------------------------------------------- + // QRErrorCorrectLevel + //--------------------------------------------------------------------- + + var QRErrorCorrectLevel = { + L : 1, + M : 0, + Q : 3, + H : 2 + }; + + //--------------------------------------------------------------------- + // QRMaskPattern + //--------------------------------------------------------------------- + + var QRMaskPattern = { + PATTERN000 : 0, + PATTERN001 : 1, + PATTERN010 : 2, + PATTERN011 : 3, + PATTERN100 : 4, + PATTERN101 : 5, + PATTERN110 : 6, + PATTERN111 : 7 + }; + + //--------------------------------------------------------------------- + // QRUtil + //--------------------------------------------------------------------- + + var QRUtil = function() { + + var PATTERN_POSITION_TABLE = [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ]; + var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0); + var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0); + var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1); + + var _this = {}; + + var getBCHDigit = function(data) { + var digit = 0; + while (data != 0) { + digit += 1; + data >>>= 1; + } + return digit; + }; + + _this.getBCHTypeInfo = function(data) { + var d = data << 10; + while (getBCHDigit(d) - getBCHDigit(G15) >= 0) { + d ^= (G15 << (getBCHDigit(d) - getBCHDigit(G15) ) ); + } + return ( (data << 10) | d) ^ G15_MASK; + }; + + _this.getBCHTypeNumber = function(data) { + var d = data << 12; + while (getBCHDigit(d) - getBCHDigit(G18) >= 0) { + d ^= (G18 << (getBCHDigit(d) - getBCHDigit(G18) ) ); + } + return (data << 12) | d; + }; + + _this.getPatternPosition = function(typeNumber) { + return PATTERN_POSITION_TABLE[typeNumber - 1]; + }; + + _this.getMaskFunction = function(maskPattern) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000 : + return function(i, j) { return (i + j) % 2 == 0; }; + case QRMaskPattern.PATTERN001 : + return function(i, j) { return i % 2 == 0; }; + case QRMaskPattern.PATTERN010 : + return function(i, j) { return j % 3 == 0; }; + case QRMaskPattern.PATTERN011 : + return function(i, j) { return (i + j) % 3 == 0; }; + case QRMaskPattern.PATTERN100 : + return function(i, j) { return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; }; + case QRMaskPattern.PATTERN101 : + return function(i, j) { return (i * j) % 2 + (i * j) % 3 == 0; }; + case QRMaskPattern.PATTERN110 : + return function(i, j) { return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; }; + case QRMaskPattern.PATTERN111 : + return function(i, j) { return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; }; + + default : + throw new Error('bad maskPattern:' + maskPattern); + } + }; + + _this.getErrorCorrectPolynomial = function(errorCorrectLength) { + var a = qrPolynomial([1], 0); + for (var i = 0; i < errorCorrectLength; i += 1) { + a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0) ); + } + return a; + }; + + _this.getLengthInBits = function(mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch(mode) { + case QRMode.MODE_NUMBER : return 10; + case QRMode.MODE_ALPHA_NUM : return 9; + case QRMode.MODE_8BIT_BYTE : return 8; + case QRMode.MODE_KANJI : return 8; + default : + throw new Error('mode:' + mode); + } + + } else if (type < 27) { + + // 10 - 26 + + switch(mode) { + case QRMode.MODE_NUMBER : return 12; + case QRMode.MODE_ALPHA_NUM : return 11; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 10; + default : + throw new Error('mode:' + mode); + } + + } else if (type < 41) { + + // 27 - 40 + + switch(mode) { + case QRMode.MODE_NUMBER : return 14; + case QRMode.MODE_ALPHA_NUM : return 13; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 12; + default : + throw new Error('mode:' + mode); + } + + } else { + throw new Error('type:' + type); + } + }; + + _this.getLostPoint = function(qrcode) { + + var moduleCount = qrcode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row += 1) { + for (var col = 0; col < moduleCount; col += 1) { + + var sameCount = 0; + var dark = qrcode.isDark(row, col); + + for (var r = -1; r <= 1; r += 1) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c += 1) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrcode.isDark(row + r, col + c) ) { + sameCount += 1; + } + } + } + + if (sameCount > 5) { + lostPoint += (3 + sameCount - 5); + } + } + }; + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row += 1) { + for (var col = 0; col < moduleCount - 1; col += 1) { + var count = 0; + if (qrcode.isDark(row, col) ) count += 1; + if (qrcode.isDark(row + 1, col) ) count += 1; + if (qrcode.isDark(row, col + 1) ) count += 1; + if (qrcode.isDark(row + 1, col + 1) ) count += 1; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row += 1) { + for (var col = 0; col < moduleCount - 6; col += 1) { + if (qrcode.isDark(row, col) + && !qrcode.isDark(row, col + 1) + && qrcode.isDark(row, col + 2) + && qrcode.isDark(row, col + 3) + && qrcode.isDark(row, col + 4) + && !qrcode.isDark(row, col + 5) + && qrcode.isDark(row, col + 6) ) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col += 1) { + for (var row = 0; row < moduleCount - 6; row += 1) { + if (qrcode.isDark(row, col) + && !qrcode.isDark(row + 1, col) + && qrcode.isDark(row + 2, col) + && qrcode.isDark(row + 3, col) + && qrcode.isDark(row + 4, col) + && !qrcode.isDark(row + 5, col) + && qrcode.isDark(row + 6, col) ) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col += 1) { + for (var row = 0; row < moduleCount; row += 1) { + if (qrcode.isDark(row, col) ) { + darkCount += 1; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + }; + + return _this; + }(); + + //--------------------------------------------------------------------- + // QRMath + //--------------------------------------------------------------------- + + var QRMath = function() { + + var EXP_TABLE = new Array(256); + var LOG_TABLE = new Array(256); + + // initialize tables + for (var i = 0; i < 8; i += 1) { + EXP_TABLE[i] = 1 << i; + } + for (var i = 8; i < 256; i += 1) { + EXP_TABLE[i] = EXP_TABLE[i - 4] + ^ EXP_TABLE[i - 5] + ^ EXP_TABLE[i - 6] + ^ EXP_TABLE[i - 8]; + } + for (var i = 0; i < 255; i += 1) { + LOG_TABLE[EXP_TABLE[i] ] = i; + } + + var _this = {}; + + _this.glog = function(n) { + + if (n < 1) { + throw new Error('glog(' + n + ')'); + } + + return LOG_TABLE[n]; + }; + + _this.gexp = function(n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return EXP_TABLE[n]; + }; + + return _this; + }(); + + //--------------------------------------------------------------------- + // qrPolynomial + //--------------------------------------------------------------------- + + function qrPolynomial(num, shift) { + + if (typeof num.length == 'undefined') { + throw new Error(num.length + '/' + shift); + } + + var _num = function() { + var offset = 0; + while (offset < num.length && num[offset] == 0) { + offset += 1; + } + var _num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i += 1) { + _num[i] = num[i + offset]; + } + return _num; + }(); + + var _this = {}; + + _this.get = function(index) { + return _num[index]; + }; + + _this.getLength = function() { + return _num.length; + }; + + _this.multiply = function(e) { + + var num = new Array(_this.getLength() + e.getLength() - 1); + + for (var i = 0; i < _this.getLength(); i += 1) { + for (var j = 0; j < e.getLength(); j += 1) { + num[i + j] ^= QRMath.gexp(QRMath.glog(_this.get(i) ) + QRMath.glog(e.get(j) ) ); + } + } + + return qrPolynomial(num, 0); + }; + + _this.mod = function(e) { + + if (_this.getLength() - e.getLength() < 0) { + return _this; + } + + var ratio = QRMath.glog(_this.get(0) ) - QRMath.glog(e.get(0) ); + + var num = new Array(_this.getLength() ); + for (var i = 0; i < _this.getLength(); i += 1) { + num[i] = _this.get(i); + } + + for (var i = 0; i < e.getLength(); i += 1) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio); + } + + // recursive call + return qrPolynomial(num, 0).mod(e); + }; + + return _this; + }; + + //--------------------------------------------------------------------- + // QRRSBlock + //--------------------------------------------------------------------- + + var QRRSBlock = function() { + + var RS_BLOCK_TABLE = [ + + // L + // M + // Q + // H + + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16] + ]; + + var qrRSBlock = function(totalCount, dataCount) { + var _this = {}; + _this.totalCount = totalCount; + _this.dataCount = dataCount; + return _this; + }; + + var _this = {}; + + var getRsBlockTable = function(typeNumber, errorCorrectLevel) { + + switch(errorCorrectLevel) { + case QRErrorCorrectLevel.L : + return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M : + return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q : + return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H : + return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default : + return undefined; + } + }; + + _this.getRSBlocks = function(typeNumber, errorCorrectLevel) { + + var rsBlock = getRsBlockTable(typeNumber, errorCorrectLevel); + + if (typeof rsBlock == 'undefined') { + throw new Error('bad rs block @ typeNumber:' + typeNumber + + '/errorCorrectLevel:' + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i += 1) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j += 1) { + list.push(qrRSBlock(totalCount, dataCount) ); + } + } + + return list; + }; + + return _this; + }(); + + //--------------------------------------------------------------------- + // qrBitBuffer + //--------------------------------------------------------------------- + + var qrBitBuffer = function() { + + var _buffer = new Array(); + var _length = 0; + + var _this = {}; + + _this.getBuffer = function() { + return _buffer; + }; + + _this.get = function(index) { + var bufIndex = Math.floor(index / 8); + return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1; + }; + + _this.put = function(num, length) { + for (var i = 0; i < length; i += 1) { + _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1); + } + }; + + _this.getLengthInBits = function() { + return _length; + }; + + _this.putBit = function(bit) { + + var bufIndex = Math.floor(_length / 8); + if (_buffer.length <= bufIndex) { + _buffer.push(0); + } + + if (bit) { + _buffer[bufIndex] |= (0x80 >>> (_length % 8) ); + } + + _length += 1; + }; + + return _this; + }; + + //--------------------------------------------------------------------- + // qr8BitByte + //--------------------------------------------------------------------- + + var qr8BitByte = function(data) { + + var _mode = QRMode.MODE_8BIT_BYTE; + var _data = data; + var _bytes = qrcode.stringToBytes(data); + + var _this = {}; + + _this.getMode = function() { + return _mode; + }; + + _this.getLength = function(buffer) { + return _bytes.length; + }; + + _this.write = function(buffer) { + for (var i = 0; i < _bytes.length; i += 1) { + buffer.put(_bytes[i], 8); + } + }; + + return _this; + }; + + //===================================================================== + // GIF Support etc. + // + + //--------------------------------------------------------------------- + // byteArrayOutputStream + //--------------------------------------------------------------------- + + var byteArrayOutputStream = function() { + + var _bytes = new Array(); + + var _this = {}; + + _this.writeByte = function(b) { + _bytes.push(b & 0xff); + }; + + _this.writeShort = function(i) { + _this.writeByte(i); + _this.writeByte(i >>> 8); + }; + + _this.writeBytes = function(b, off, len) { + off = off || 0; + len = len || b.length; + for (var i = 0; i < len; i += 1) { + _this.writeByte(b[i + off]); + } + }; + + _this.writeString = function(s) { + for (var i = 0; i < s.length; i += 1) { + _this.writeByte(s.charCodeAt(i) ); + } + }; + + _this.toByteArray = function() { + return _bytes; + }; + + _this.toString = function() { + var s = ''; + s += '['; + for (var i = 0; i < _bytes.length; i += 1) { + if (i > 0) { + s += ','; + } + s += _bytes[i]; + } + s += ']'; + return s; + }; + + return _this; + }; + + //--------------------------------------------------------------------- + // base64EncodeOutputStream + //--------------------------------------------------------------------- + + var base64EncodeOutputStream = function() { + + var _buffer = 0; + var _buflen = 0; + var _length = 0; + var _base64 = ''; + + var _this = {}; + + var writeEncoded = function(b) { + _base64 += String.fromCharCode(encode(b & 0x3f) ); + }; + + var encode = function(n) { + if (n < 0) { + // error. + } else if (n < 26) { + return 0x41 + n; + } else if (n < 52) { + return 0x61 + (n - 26); + } else if (n < 62) { + return 0x30 + (n - 52); + } else if (n == 62) { + return 0x2b; + } else if (n == 63) { + return 0x2f; + } + throw new Error('n:' + n); + }; + + _this.writeByte = function(n) { + + _buffer = (_buffer << 8) | (n & 0xff); + _buflen += 8; + _length += 1; + + while (_buflen >= 6) { + writeEncoded(_buffer >>> (_buflen - 6) ); + _buflen -= 6; + } + }; + + _this.flush = function() { + + if (_buflen > 0) { + writeEncoded(_buffer << (6 - _buflen) ); + _buffer = 0; + _buflen = 0; + } + + if (_length % 3 != 0) { + // padding + var padlen = 3 - _length % 3; + for (var i = 0; i < padlen; i += 1) { + _base64 += '='; + } + } + }; + + _this.toString = function() { + return _base64; + }; + + return _this; + }; + + //--------------------------------------------------------------------- + // base64DecodeInputStream + //--------------------------------------------------------------------- + + var base64DecodeInputStream = function(str) { + + var _str = str; + var _pos = 0; + var _buffer = 0; + var _buflen = 0; + + var _this = {}; + + _this.read = function() { + + while (_buflen < 8) { + + if (_pos >= _str.length) { + if (_buflen == 0) { + return -1; + } + throw new Error('unexpected end of file./' + _buflen); + } + + var c = _str.charAt(_pos); + _pos += 1; + + if (c == '=') { + _buflen = 0; + return -1; + } else if (c.match(/^\s$/) ) { + // ignore if whitespace. + continue; + } + + _buffer = (_buffer << 6) | decode(c.charCodeAt(0) ); + _buflen += 6; + } + + var n = (_buffer >>> (_buflen - 8) ) & 0xff; + _buflen -= 8; + return n; + }; + + var decode = function(c) { + if (0x41 <= c && c <= 0x5a) { + return c - 0x41; + } else if (0x61 <= c && c <= 0x7a) { + return c - 0x61 + 26; + } else if (0x30 <= c && c <= 0x39) { + return c - 0x30 + 52; + } else if (c == 0x2b) { + return 62; + } else if (c == 0x2f) { + return 63; + } else { + throw new Error('c:' + c); + } + }; + + return _this; + }; + + //--------------------------------------------------------------------- + // gifImage (B/W) + //--------------------------------------------------------------------- + + var gifImage = function(width, height) { + + var _width = width; + var _height = height; + var _data = new Array(width * height); + + var _this = {}; + + _this.setPixel = function(x, y, pixel) { + _data[y * _width + x] = pixel; + }; + + _this.write = function(out) { + + //--------------------------------- + // GIF Signature + + out.writeString('GIF87a'); + + //--------------------------------- + // Screen Descriptor + + out.writeShort(_width); + out.writeShort(_height); + + out.writeByte(0x80); // 2bit + out.writeByte(0); + out.writeByte(0); + + //--------------------------------- + // Global Color Map + + // black + out.writeByte(0x00); + out.writeByte(0x00); + out.writeByte(0x00); + + // white + out.writeByte(0xff); + out.writeByte(0xff); + out.writeByte(0xff); + + //--------------------------------- + // Image Descriptor + + out.writeString(','); + out.writeShort(0); + out.writeShort(0); + out.writeShort(_width); + out.writeShort(_height); + out.writeByte(0); + + //--------------------------------- + // Local Color Map + + //--------------------------------- + // Raster Data + + var lzwMinCodeSize = 2; + var raster = getLZWRaster(lzwMinCodeSize); + + out.writeByte(lzwMinCodeSize); + + var offset = 0; + + while (raster.length - offset > 255) { + out.writeByte(255); + out.writeBytes(raster, offset, 255); + offset += 255; + } + + out.writeByte(raster.length - offset); + out.writeBytes(raster, offset, raster.length - offset); + out.writeByte(0x00); + + //--------------------------------- + // GIF Terminator + out.writeString(';'); + }; + + var bitOutputStream = function(out) { + + var _out = out; + var _bitLength = 0; + var _bitBuffer = 0; + + var _this = {}; + + _this.write = function(data, length) { + + if ( (data >>> length) != 0) { + throw new Error('length over'); + } + + while (_bitLength + length >= 8) { + _out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) ); + length -= (8 - _bitLength); + data >>>= (8 - _bitLength); + _bitBuffer = 0; + _bitLength = 0; + } + + _bitBuffer = (data << _bitLength) | _bitBuffer; + _bitLength = _bitLength + length; + }; + + _this.flush = function() { + if (_bitLength > 0) { + _out.writeByte(_bitBuffer); + } + }; + + return _this; + }; + + var getLZWRaster = function(lzwMinCodeSize) { + + var clearCode = 1 << lzwMinCodeSize; + var endCode = (1 << lzwMinCodeSize) + 1; + var bitLength = lzwMinCodeSize + 1; + + // Setup LZWTable + var table = lzwTable(); + + for (var i = 0; i < clearCode; i += 1) { + table.add(String.fromCharCode(i) ); + } + table.add(String.fromCharCode(clearCode) ); + table.add(String.fromCharCode(endCode) ); + + var byteOut = byteArrayOutputStream(); + var bitOut = bitOutputStream(byteOut); + + // clear code + bitOut.write(clearCode, bitLength); + + var dataIndex = 0; + + var s = String.fromCharCode(_data[dataIndex]); + dataIndex += 1; + + while (dataIndex < _data.length) { + + var c = String.fromCharCode(_data[dataIndex]); + dataIndex += 1; + + if (table.contains(s + c) ) { + + s = s + c; + + } else { + + bitOut.write(table.indexOf(s), bitLength); + + if (table.size() < 0xfff) { + + if (table.size() == (1 << bitLength) ) { + bitLength += 1; + } + + table.add(s + c); + } + + s = c; + } + } + + bitOut.write(table.indexOf(s), bitLength); + + // end code + bitOut.write(endCode, bitLength); + + bitOut.flush(); + + return byteOut.toByteArray(); + }; + + var lzwTable = function() { + + var _map = {}; + var _size = 0; + + var _this = {}; + + _this.add = function(key) { + if (_this.contains(key) ) { + throw new Error('dup key:' + key); + } + _map[key] = _size; + _size += 1; + }; + + _this.size = function() { + return _size; + }; + + _this.indexOf = function(key) { + return _map[key]; + }; + + _this.contains = function(key) { + return typeof _map[key] != 'undefined'; + }; + + return _this; + }; + + return _this; + }; + + var createImgTag = function(width, height, getPixel, alt) { + + var gif = gifImage(width, height); + for (var y = 0; y < height; y += 1) { + for (var x = 0; x < width; x += 1) { + gif.setPixel(x, y, getPixel(x, y) ); + } + } + + var b = byteArrayOutputStream(); + gif.write(b); + + var base64 = base64EncodeOutputStream(); + var bytes = b.toByteArray(); + for (var i = 0; i < bytes.length; i += 1) { + base64.writeByte(bytes[i]); + } + base64.flush(); + + var img = ''; + img += ' 0; + + if (!isPhp) { + H5AI.extended.init(); + } H5AI.core.init(); H5AI.sort.init(); + H5AI.finder.init(); H5AI.zippedDownload.init(); + H5AI.context.init(); + + if (isPhp) { + $("#tree").scrollpanel(); + H5AI.core.shiftTree(false, true); + } + }); }(jQuery)); diff --git a/src/_h5ai/php/inc/Tree.php b/src/_h5ai/php/inc/Tree.php index 7c4d0644..3f9455cd 100644 --- a/src/_h5ai/php/inc/Tree.php +++ b/src/_h5ai/php/inc/Tree.php @@ -92,7 +92,7 @@ class TreeEntry { $html .= ">\n"; } $html .= "\n"; - $html .= "" . $icon . "\n"; + $html .= "" . $icon . ""; $html .= "" . $this->label . "" . $hint . "\n"; $html .= "\n"; $html .= $this->contentToHtml(); From 8ee901517b046c8dc5314d88ef74ce7500fb65ba Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 20 Feb 2012 02:46:02 +0100 Subject: [PATCH 18/36] Removes some redundancy. --- src/_h5ai/css/inc/content.less | 18 ++ src/_h5ai/css/inc/footer.less | 111 +++++++++ src/_h5ai/css/inc/main.less | 260 --------------------- src/_h5ai/css/inc/nav.less | 94 ++++++++ src/_h5ai/css/main-js.less | 2 - src/_h5ai/css/main-php.less | 17 -- src/_h5ai/css/main.less | 58 +++++ src/_h5ai/footer.html | 6 +- src/_h5ai/footer.php | 4 - src/_h5ai/header.html | 6 +- src/_h5ai/header.php | 34 +-- src/_h5ai/js/inc/lib/jquery.qrcode.js | 1 + src/_h5ai/js/inc/lib/jquery.scrollpanel.js | 1 - src/h5ai.htaccess | 4 +- 14 files changed, 293 insertions(+), 323 deletions(-) create mode 100644 src/_h5ai/css/inc/content.less create mode 100644 src/_h5ai/css/inc/footer.less delete mode 100644 src/_h5ai/css/inc/main.less create mode 100644 src/_h5ai/css/inc/nav.less delete mode 100644 src/_h5ai/css/main-js.less delete mode 100644 src/_h5ai/css/main-php.less create mode 100644 src/_h5ai/css/main.less delete mode 100644 src/_h5ai/footer.php diff --git a/src/_h5ai/css/inc/content.less b/src/_h5ai/css/inc/content.less new file mode 100644 index 00000000..cd84d554 --- /dev/null +++ b/src/_h5ai/css/inc/content.less @@ -0,0 +1,18 @@ + +#content { + max-width: 960px; + margin: 0 auto; + + > header { + display: none; + padding-bottom: 10px; + margin-bottom: 80px; + border-bottom: 2px dashed #ddd; + } + > footer { + display: none; + padding-top: 10px; + margin-top: 80px; + border-top: 2px dashed #ddd; + } +} diff --git a/src/_h5ai/css/inc/footer.less b/src/_h5ai/css/inc/footer.less new file mode 100644 index 00000000..5a00fffe --- /dev/null +++ b/src/_h5ai/css/inc/footer.less @@ -0,0 +1,111 @@ + +body > footer { + position: fixed; + z-index: 1; + width: 100%; + left: 0; + bottom: 0; + padding: 6px 0 8px 0; + background-color: rgb(241,241,241); + border-top: 2px solid rgb(210,210,210); + + color: #999; + font-size: 0.85em; + text-align: center; + + a, a:active, a:visited { + color: #555; + text-decoration: none; + .transition(all 0.2s ease-in-out); + opacity: 0.7; + + &:hover { + color: #e80; + opacity: 1; + } + } + .left { + display: block; + padding: 0 8px; + float: left + } + .center { + display: block; + margin: 0 100px; + } + .right { + display: block; + padding: 0 8px; + float: right + } + .noJsMsg { + color: #c33; + margin-left: 16px; + } + .status { + .sep { + display: inline-block; + padding: 0 6px; + } + &.default { + } + &.dynamic { + display: none; + } + } + #langSelector { + position: relative; + cursor: pointer; + + .langOptions { + position: absolute; + z-index: 2; + overflow: auto; + display: none; + right: 0; + top: 0; + max-height: 200px; + background-color: rgb(241,241,241); + border: 1px solid rgb(210,210,210); + + > .scrollbar { + margin: 0; + width: 6px; + background-color: rgb(210,210,210); + + .drag { + background-color: rgb(180,180,180); + } + &.dragOn .drag { + background-color: rgb(150,150,150); + } + } + + ul { + margin: 0; + padding: 0; + list-style: none; + text-align: left; + + li { + padding: 8px 24px 10px 24px; + white-space: nowrap; + border-top: 1px solid rgb(231,231,231); + .transition(all 0.2s ease-in-out); + + &.current { + color: #333; + background-color: rgba(255,255,255,0.8); + } + &:hover { + color: #e80; + background-color: rgba(255,255,255,0.8); + } + } + li:nth-child(3n+1) { + + } + } + } + } +} diff --git a/src/_h5ai/css/inc/main.less b/src/_h5ai/css/inc/main.less deleted file mode 100644 index 13baed80..00000000 --- a/src/_h5ai/css/inc/main.less +++ /dev/null @@ -1,260 +0,0 @@ - -@import "h5bp-norm"; -@import "mixins"; - - -html.js { - .hideOnJs { - display: none; - } -} -html.no-js { - .hideOnNoJs { - display: none; - } -} - - -body { - font-family: Ubuntu, sans-serif; - font-size: 16px; - color: #555; - background-color: #fff; - margin: 80px 30px; -} - - - -body > nav { - position: fixed; - z-index: 1; - width: 100%; - left: 0; - top: 0; - font-size: 0.85em; - background-color: rgb(241,241,241); - border-bottom: 2px solid rgb(210,210,210); - - span.jsDisabledFallback { - display: block; - height: 30px; - line-height: 30px; - padding: 0 10px; - color: #999; - } - a, a:active, a:visited, span.element { - color: #555; - cursor: pointer; - text-decoration: none; - opacity: 0.7; - .transition(all 0.2s ease-in-out); - - display: block; - height: 30px; - line-height: 30px; - padding: 0 10px; - - &:hover, &.hover { - color: #e80; - background-color: rgba(255,255,255,0.5); - opacity: 1.0; - } - } - .current { - a, span.element { - background-color: rgba(255,255,255,0.5); - opacity: 1.0; - } - } - img { - position: relative; - top: -2px; - width: 16px; - height: 16px; - } - img + span, img + input { - margin-left: 6px; - } - .crumb { - float: left; - border-right: 1px solid rgb(231,231,231); - .hint { - margin-left: 8px; - font-style: italic; - color: #999; - } - img.hint { - width: 10px; - height: 10px; - } - } - .view { - float: right; - border-left: 1px solid rgb(231,231,231); - } - #download { - display: none; - float: right; - border-left: 1px solid rgb(231,231,231); - .transition(all 0.2s ease-in-out); - - &.zipping { - - } - &.failed { - background-color: rgba(255,0,0,0.5); - } - } - #filter { - float: right; - border-left: 1px solid rgb(231,231,231); - - input { - border: none; - font-family: Ubuntu, sans-serif; - color: #555; - background-color: rgba(0,0,0,0); - width: 100px; - } - } -} - - -#content { - max-width: 960px; - margin: 0 auto; - - > header { - display: none; - padding-bottom: 10px; - margin-bottom: 80px; - border-bottom: 2px dashed #ddd; - } - > footer { - display: none; - padding-top: 10px; - margin-top: 80px; - border-top: 2px dashed #ddd; - } -} - - -@import "table"; -@import "extended"; -@import "tree"; -@import "context"; - - -body > footer { - position: fixed; - z-index: 1; - width: 100%; - left: 0; - bottom: 0; - padding: 6px 0 8px 0; - background-color: rgb(241,241,241); - border-top: 2px solid rgb(210,210,210); - - color: #999; - font-size: 0.85em; - text-align: center; - - a, a:active, a:visited { - color: #555; - text-decoration: none; - .transition(all 0.2s ease-in-out); - opacity: 0.7; - - &:hover { - color: #e80; - opacity: 1; - } - } - .left { - display: block; - padding: 0 8px; - float: left - } - .center { - display: block; - margin: 0 100px; - } - .right { - display: block; - padding: 0 8px; - float: right - } - .noJsMsg { - color: #c33; - margin-left: 16px; - } - .status { - .sep { - display: inline-block; - padding: 0 6px; - } - &.default { - } - &.dynamic { - display: none; - } - } - #langSelector { - position: relative; - cursor: pointer; - - .langOptions { - position: absolute; - z-index: 2; - overflow: auto; - display: none; - right: 0; - top: 0; - max-height: 200px; - background-color: rgb(241,241,241); - border: 1px solid rgb(210,210,210); - - > .scrollbar { - margin: 0; - width: 6px; - background-color: rgb(210,210,210); - - .drag { - background-color: rgb(180,180,180); - } - &.dragOn .drag { - background-color: rgb(150,150,150); - } - } - - ul { - margin: 0; - padding: 0; - list-style: none; - text-align: left; - - li { - padding: 8px 24px 10px 24px; - white-space: nowrap; - border-top: 1px solid rgb(231,231,231); - .transition(all 0.2s ease-in-out); - - &.current { - color: #333; - background-color: rgba(255,255,255,0.8); - } - &:hover { - color: #e80; - background-color: rgba(255,255,255,0.8); - } - } - li:nth-child(3n+1) { - - } - } - } - } -} - -@import "responsive"; - diff --git a/src/_h5ai/css/inc/nav.less b/src/_h5ai/css/inc/nav.less new file mode 100644 index 00000000..4c753f82 --- /dev/null +++ b/src/_h5ai/css/inc/nav.less @@ -0,0 +1,94 @@ + +body > nav { + position: fixed; + z-index: 1; + width: 100%; + left: 0; + top: 0; + font-size: 0.85em; + background-color: rgb(241,241,241); + border-bottom: 2px solid rgb(210,210,210); + + span.jsDisabledFallback { + display: block; + height: 30px; + line-height: 30px; + padding: 0 10px; + color: #999; + } + a, a:active, a:visited, span.element { + color: #555; + cursor: pointer; + text-decoration: none; + opacity: 0.7; + .transition(all 0.2s ease-in-out); + + display: block; + height: 30px; + line-height: 30px; + padding: 0 10px; + + &:hover, &.hover { + color: #e80; + background-color: rgba(255,255,255,0.5); + opacity: 1.0; + } + } + .current { + a, span.element { + background-color: rgba(255,255,255,0.5); + opacity: 1.0; + } + } + img { + position: relative; + top: -2px; + width: 16px; + height: 16px; + } + img + span, img + input { + margin-left: 6px; + } + .crumb { + float: left; + border-right: 1px solid rgb(231,231,231); + .hint { + margin-left: 8px; + font-style: italic; + color: #999; + } + img.hint { + width: 10px; + height: 10px; + } + } + .view { + float: right; + border-left: 1px solid rgb(231,231,231); + } + #download { + display: none; + float: right; + border-left: 1px solid rgb(231,231,231); + .transition(all 0.2s ease-in-out); + + &.zipping { + + } + &.failed { + background-color: rgba(255,0,0,0.5); + } + } + #filter { + float: right; + border-left: 1px solid rgb(231,231,231); + + input { + border: none; + font-family: Ubuntu, sans-serif; + color: #555; + background-color: rgba(0,0,0,0); + width: 100px; + } + } +} diff --git a/src/_h5ai/css/main-js.less b/src/_h5ai/css/main-js.less deleted file mode 100644 index f72967ff..00000000 --- a/src/_h5ai/css/main-js.less +++ /dev/null @@ -1,2 +0,0 @@ - -@import "inc/main"; diff --git a/src/_h5ai/css/main-php.less b/src/_h5ai/css/main-php.less deleted file mode 100644 index 5efa7731..00000000 --- a/src/_h5ai/css/main-php.less +++ /dev/null @@ -1,17 +0,0 @@ - -@import "inc/main"; - - -#table { - display: none; -} - -#tree, #content > header, #content > footer { - display: block; -} - -html.no-js { - #extended.details-view, #extended.icons-view { - display: block; - } -} diff --git a/src/_h5ai/css/main.less b/src/_h5ai/css/main.less new file mode 100644 index 00000000..a803f9cc --- /dev/null +++ b/src/_h5ai/css/main.less @@ -0,0 +1,58 @@ + +@import "inc/h5bp-norm"; +@import "inc/mixins"; + + +body { + font-family: Ubuntu, sans-serif; + font-size: 16px; + color: #555; + background-color: #fff; + margin: 80px 30px; +} + + +@import "inc/nav"; +@import "inc/content"; +@import "inc/table"; +@import "inc/extended"; +@import "inc/tree"; +@import "inc/context"; +@import "inc/footer"; +@import "inc/responsive"; + + +html.js { + .hideOnJs { + display: none; + } +} +html.no-js { + .hideOnNoJs { + display: none; + } +} +html.h5ai-js { + #h5ai-reference:after { + content: " (js)"; + } +} +html.h5ai-php { + #h5ai-reference:after { + content: " (php)"; + } + + #table { + display: none; + } + + #tree, #content > header, #content > footer { + display: block; + } + + html.no-js { + #extended.details-view, #extended.icons-view { + display: block; + } + } +} diff --git a/src/_h5ai/footer.html b/src/_h5ai/footer.html index e8ca080d..d32323cc 100644 --- a/src/_h5ai/footer.html +++ b/src/_h5ai/footer.html @@ -1,12 +1,10 @@
                  -
                  -
              • -
                +
                - h5ai %BUILD_VERSION% (js) + h5ai %BUILD_VERSION% ⚡ JavaScript is disabled! ⚡ diff --git a/src/_h5ai/footer.php b/src/_h5ai/footer.php deleted file mode 100644 index ee6c2b75..00000000 --- a/src/_h5ai/footer.php +++ /dev/null @@ -1,4 +0,0 @@ - -
    - - diff --git a/src/_h5ai/header.html b/src/_h5ai/header.html index ef671b42..1cada171 100644 --- a/src/_h5ai/header.html +++ b/src/_h5ai/header.html @@ -13,16 +13,18 @@ - + -
    +
    +
    +
    +
    + diff --git a/src/_h5ai/js/inc/lib/jquery.qrcode.js b/src/_h5ai/js/inc/lib/jquery.qrcode.js index d4c8dcb0..1d990be3 100644 --- a/src/_h5ai/js/inc/lib/jquery.qrcode.js +++ b/src/_h5ai/js/inc/lib/jquery.qrcode.js @@ -6,6 +6,7 @@ * kudos to http://github.com/jeromeetienne/jquery-qrcode */ (function ($) { + 'use strict'; // @include "qrcode.js" diff --git a/src/_h5ai/js/inc/lib/jquery.scrollpanel.js b/src/_h5ai/js/inc/lib/jquery.scrollpanel.js index 2b8d0a0c..dfe675c5 100644 --- a/src/_h5ai/js/inc/lib/jquery.scrollpanel.js +++ b/src/_h5ai/js/inc/lib/jquery.scrollpanel.js @@ -5,7 +5,6 @@ * * still quick and dirty! */ - (function (window, $) { "use strict"; diff --git a/src/h5ai.htaccess b/src/h5ai.htaccess index 10a0ea89..c98fe61a 100644 --- a/src/h5ai.htaccess +++ b/src/h5ai.htaccess @@ -8,11 +8,11 @@ # pure JavaScript version HeaderName /_h5ai/header.html -ReadmeName /_h5ai/footer.html # PHP version # HeaderName /_h5ai/header.php -# ReadmeName /_h5ai/footer.php + +ReadmeName /_h5ai/footer.html IndexIgnore _h5ai* From c8d079b82662aa6e746841ed80026894395a15db Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 20 Feb 2012 02:47:00 +0100 Subject: [PATCH 19/36] Updates readme. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e56b7211..53cf88cb 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * adds optional QRCode display * adds optional filtering for displayed files and folders * improves zipped download +* changes h5ai.htaccess * custom headers/footers are now optional and disabled by default * fixes problems with folder recognition in the JS version * fixes include problems in PHP version From d7b3bd79f8aa77d175e7d94dd1be4f781809265f Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 20 Feb 2012 03:06:01 +0100 Subject: [PATCH 20/36] Fixes build process. --- build.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build.xml b/build.xml index 8010312b..a1a2852d 100644 --- a/build.xml +++ b/build.xml @@ -37,11 +37,19 @@ + + + + + + + + From b39fbb8dc06e863d8001f3ff9add5d2a4fdbc359 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 20 Feb 2012 03:12:12 +0100 Subject: [PATCH 21/36] Removes console.log lines. --- src/_h5ai/js/inc/Finder.js | 2 -- src/_h5ai/js/inc/ZippedDownload.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index dd7ef99b..696d5f8b 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -32,8 +32,6 @@ $input = $filter.find('input'), val = $input.val(); - console.log('checkState', val, focus); - if (val || focus) { $filter.addClass('current'); } else { diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index 5ad5f784..d49dfc63 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -112,10 +112,8 @@ $('#download img').attr('src', H5AI.core.image("download")); $('#download').removeClass('zipping'); if (response.status === 'ok') { - console.log("download worked!", response); window.location = H5AI.core.api() + '?action=getzip&id=' + response.id; } else { - console.log("download failed!", response); $('#download').addClass('failed'); setTimeout(function () { $('#download').removeClass('failed'); From 690104451898d8fb24d5b7148b5c3b76fd9edd57 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 20 Feb 2012 15:08:29 +0100 Subject: [PATCH 22/36] Small js fixes. --- build.xml | 4 ++-- src/_h5ai/js/inc/Context.js | 4 ++-- src/_h5ai/js/inc/Finder.js | 4 ++-- src/_h5ai/js/main.js | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/build.xml b/build.xml index a1a2852d..31082a02 100644 --- a/build.xml +++ b/build.xml @@ -58,8 +58,8 @@ - - + + diff --git a/src/_h5ai/js/inc/Context.js b/src/_h5ai/js/inc/Context.js index af2ac902..0c169696 100644 --- a/src/_h5ai/js/inc/Context.js +++ b/src/_h5ai/js/inc/Context.js @@ -49,7 +49,7 @@ return { init: init - } - }()) + }; + }()); }(jQuery, H5AI)); \ No newline at end of file diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index 696d5f8b..6ef9fd90 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -79,7 +79,7 @@ return { init: init, filter: filter - } - }()) + }; + }()); }(jQuery, H5AI)); \ No newline at end of file diff --git a/src/_h5ai/js/main.js b/src/_h5ai/js/main.js index 5a54b7ca..29b6b672 100644 --- a/src/_h5ai/js/main.js +++ b/src/_h5ai/js/main.js @@ -1,9 +1,8 @@ -/*jslint browser: true, confusion: true, regexp: true, white: true */ -/*jshint browser: true, confusion: true, regexp: false, white: false */ -/*global jQuery, amplify, H5AI_CONFIG */ (function ($) { - "use strict"; +'use strict'; +/*jslint browser: true, confusion: true, regexp: true, vars: true, white: true */ +/*global Modernizr, jQuery, amplify, H5AI_CONFIG */ var H5AI = {}; @@ -34,7 +33,7 @@ H5AI.context.init(); if (isPhp) { - $("#tree").scrollpanel(); + $('#tree').scrollpanel(); H5AI.core.shiftTree(false, true); } From 749a87eaf707abc965b5dfaca353651fcfbe9069 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Mon, 20 Feb 2012 16:35:48 +0100 Subject: [PATCH 23/36] Reduces number of HTTP requests. --- build.xml | 18 ++++++++---------- src/_h5ai/footer.html | 3 +-- src/_h5ai/js/{ => inc}/main.js | 20 ++++++++++---------- src/_h5ai/js/libs.js | 2 ++ 4 files changed, 21 insertions(+), 22 deletions(-) rename src/_h5ai/js/{ => inc}/main.js (63%) diff --git a/build.xml b/build.xml index 31082a02..eadb4674 100644 --- a/build.xml +++ b/build.xml @@ -37,19 +37,11 @@ - - - - - - - - @@ -58,8 +50,8 @@ - - + + @@ -94,6 +86,9 @@ + + + @@ -102,6 +97,9 @@ + + + diff --git a/src/_h5ai/footer.html b/src/_h5ai/footer.html index d32323cc..e1f65ffe 100644 --- a/src/_h5ai/footer.html +++ b/src/_h5ai/footer.html @@ -25,8 +25,7 @@ - - + \ No newline at end of file diff --git a/src/_h5ai/js/main.js b/src/_h5ai/js/inc/main.js similarity index 63% rename from src/_h5ai/js/main.js rename to src/_h5ai/js/inc/main.js index 29b6b672..9fa0b7f1 100644 --- a/src/_h5ai/js/main.js +++ b/src/_h5ai/js/inc/main.js @@ -6,17 +6,17 @@ var H5AI = {}; - // @include "inc/Util.js" - // @include "inc/Core.js" - // @include "inc/Sort.js" - // @include "inc/ZippedDownload.js" - // @include "inc/Finder.js" - // @include "inc/Context.js" + // @include "Util.js" + // @include "Core.js" + // @include "Sort.js" + // @include "ZippedDownload.js" + // @include "Finder.js" + // @include "Context.js" - // @include "inc/Path.js" - // @include "inc/Connector.js" - // @include "inc/Html.js" - // @include "inc/Extended.js" + // @include "Path.js" + // @include "Connector.js" + // @include "Html.js" + // @include "Extended.js" $(function () { diff --git a/src/_h5ai/js/libs.js b/src/_h5ai/js/libs.js index 12299eb8..1df256fb 100644 --- a/src/_h5ai/js/libs.js +++ b/src/_h5ai/js/libs.js @@ -7,3 +7,5 @@ // @include "inc/lib/amplify.min.js" // @include "inc/lib/date.js" + +// @include "inc/main.js" From 84f543aca5cd2bf2fa9906a5b7d990e7d22a2fa4 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Tue, 21 Feb 2012 01:59:19 +0100 Subject: [PATCH 24/36] Filter accepts RegExp and primitive search sequences. --- src/_h5ai/config.php | 29 ++++++++++++++++------------- src/_h5ai/js/inc/Finder.js | 14 +++++++++++++- src/_h5ai/js/inc/Util.js | 7 ++++++- src/_h5ai/php/api.php | 10 +++++----- src/_h5ai/php/inc/H5ai.php | 4 ++-- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/_h5ai/config.php b/src/_h5ai/config.php index 8096a5b2..8ab74296 100644 --- a/src/_h5ai/config.php +++ b/src/_h5ai/config.php @@ -7,20 +7,23 @@ */ global $H5AI_CONFIG; -$H5AI_CONFIG = array(); -/* - * This configuration assumes that h5ai is installed - * in the webroot directory of the Apache server. - */ -$H5AI_CONFIG["ROOT_ABS_PATH"] = safe_dirname(safe_dirname(__FILE__)); +$H5AI_CONFIG = array( -/* - * Files/folders that should not be listed. Specified - * by the complete filename or by a regular expression. - * http://www.php.net/manual/en/function.preg-match.php - */ -$H5AI_CONFIG["IGNORE"] = array(); -$H5AI_CONFIG["IGNORE_PATTERNS"] = array("/^\\./", "/^_h5ai/"); + /* + * This configuration assumes that h5ai is installed + * in the webroot directory of the Apache server. + */ + "ROOT_ABS_PATH" => safe_dirname(safe_dirname(__FILE__)), + + /* + * Files/folders that should not be listed. Specified + * by the complete filename or by a regular expression. + * http://www.php.net/manual/en/function.preg-match.php + */ + "IGNORE" => array(), + "IGNORE_PATTERNS" => array("/^\\./", "/^_h5ai/") + +); ?> \ No newline at end of file diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index 6ef9fd90..60771f7b 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -38,6 +38,18 @@ $filter.removeClass('current'); } }, + parseFilterSequence = function (sequence) { + + if (sequence.substr(0,3) === 're:') { + return new RegExp(sequence.substr(3)); + } + + sequence = $.map($.trim(sequence).split(/\s+/), function (part) { + + return H5AI.util.reEscape(part); + }).join('|'); + return new RegExp(sequence); + }, init = function () { if (H5AI.core.settings.showFilter) { @@ -63,7 +75,7 @@ val = $input.val(); if (val) { - filter(new RegExp(val)); + filter(parseFilterSequence(val)); } else { filter(); } diff --git a/src/_h5ai/js/inc/Util.js b/src/_h5ai/js/inc/Util.js index ed3f298e..3fa02f5d 100644 --- a/src/_h5ai/js/inc/Util.js +++ b/src/_h5ai/js/inc/Util.js @@ -100,6 +100,10 @@ return decodeURI(uri); } catch (err) {} return uri; + }, + reEscape = function (sequence) { + + return sequence.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); }; return { @@ -108,7 +112,8 @@ getAbsHref: getAbsHref, parseSize: parseSize, formatSize: formatSize, - checkedDecodeUri: checkedDecodeUri + checkedDecodeUri: checkedDecodeUri, + reEscape: reEscape }; }()); diff --git a/src/_h5ai/php/api.php b/src/_h5ai/php/api.php index 72330882..c2a8de1c 100644 --- a/src/_h5ai/php/api.php +++ b/src/_h5ai/php/api.php @@ -14,11 +14,6 @@ function require_h5ai($lib) { } -require_h5ai("/php/inc/H5ai.php"); -$h5ai = new H5ai(); -$options = $h5ai->getOptions(); - - function fail($code, $msg, $cond = true) { if ($cond) { echo "$code: $msg"; @@ -36,6 +31,11 @@ function checkKeys($keys) { } +require_h5ai("/php/inc/H5ai.php"); +$h5ai = new H5ai(); +$options = $h5ai->getOptions(); + + list($action) = checkKeys(array("action")); diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index 6d25807c..4a70aced 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -256,8 +256,8 @@ class H5ai { public function getHttpCode($absHref) { - return $this->cachedHttpCode($absHref); - // return $this->fetchHttpCode($absHref); + //return $this->cachedHttpCode($absHref); + return $this->fetchHttpCode($absHref); // return $this->guessHttpCode($absHref); } From 1b0c9d81acc17e19b04fe5088a502b70db9ed239 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Tue, 21 Feb 2012 21:29:47 +0100 Subject: [PATCH 25/36] Adds animated loading gif. --- src/_h5ai/images/loading.gif | Bin 0 -> 847 bytes src/_h5ai/js/inc/Core.js | 4 ++-- src/_h5ai/js/inc/ZippedDownload.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 src/_h5ai/images/loading.gif diff --git a/src/_h5ai/images/loading.gif b/src/_h5ai/images/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..1b3280ef98d672fb8c8e80e41dd92fe664d6e0e8 GIT binary patch literal 847 zcmZ?wbhEHb6krfw_`<;O|NnnuW8>Uf%AY4_+!FE7;yMx_!l}EY-SE9}BbSx)X+!TV z9xY7|**x@SsNCFG$-p77@8TKO8(G|Xjo~g1claV178!VOinZz(^f_JO>dO}JdiItl z)ZVn5nWaW0n>R+2pQjtEr9qHjZBUrPWGHgfVMVjE9NQZ4W7*wJa~Kt!o+Q{aG;U|w zH$mC8$)d_BFrp!OckZGxZXuXN$NjhA8stpCkV#!C8H>m&MeWS!~VrCworWK*zpwZK-g4NP^sHGl2k8vz> zFkv{f>6oLE=R}STvlb?B*yXjddK##7Nc75in{VRv&|yE=saw*l)zs`NB_goouN2N#u}s9-J_<+U=2#1U;qF@#0NM4 literal 0 HcmV?d00001 diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index 583a92f8..666f707d 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -48,9 +48,9 @@ return settings.h5aiAbsHref + "php/api.php"; }, - image = function (id) { + image = function (id, noPngExt) { - return settings.h5aiAbsHref + "images/" + id + ".png"; + return settings.h5aiAbsHref + "images/" + id + (noPngExt ? "" : ".png"); }, icon = function (id, big) { diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index d49dfc63..f38d56be 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -98,7 +98,7 @@ .find("a").click(function () { $('#download').addClass('zipping'); - $('#download img').attr('src', H5AI.core.image("loading")); + $('#download img').attr('src', H5AI.core.image("loading.gif", true)); $.ajax({ url: H5AI.core.api(), data: { From 4e90a416141e729675cf5b74aff5f88636a5a6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yao=20Wei=20=28=E9=AD=8F=E9=8A=98=E5=BB=B7=29?= Date: Wed, 22 Feb 2012 13:24:49 +0800 Subject: [PATCH 26/36] added zh-tw translation. fix zh-cn translation. --- src/_h5ai/config.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index df218795..58029181 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -424,7 +424,21 @@ var H5AI_CONFIG = { "empty": "空文件夹", "folders": "文件夹", "files": "文件", - "download": "download" + "download": "下载" + }, + + "zh-tw": { + "lang": "正體中文", + "details": "詳細資料", + "icons": "圖示", + "name": "檔名", + "lastModified": "上次修改", + "size": "大小", + "parentDirectory": "上層目錄", + "empty": "空資料夾", + "folders": "資料夾", + "files": "檔案", + "download": "下載" } } }; From 32023fc86edd8937fd2bd440731f9de092368a57 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 22 Feb 2012 07:22:04 +0100 Subject: [PATCH 27/36] Updates readme. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 53cf88cb..032efbab 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * fixes problems with thumbnails for files with single or double quotes in filename * updates year in `LICENSE.TXT` * updates es translation +* adds zh-tw translation by [Yao Wei](http://github.com/medicalwei) +* updates zh-cn translation ### v0.17 - *2011-11-28* From bfebcb3bcdc7a8682b3d43ac148c61e5fb2a63ef Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 22 Feb 2012 11:38:53 +0100 Subject: [PATCH 28/36] Changes design. --- src/_h5ai/css/inc/context.less | 1 + src/_h5ai/css/inc/footer.less | 6 ++-- src/_h5ai/css/inc/mixins.less | 57 +++++++++++++++++++++++----------- src/_h5ai/css/inc/nav.less | 14 ++++----- src/_h5ai/css/inc/tree.less | 7 ++--- src/_h5ai/js/inc/Core.js | 4 +-- 6 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/_h5ai/css/inc/context.less b/src/_h5ai/css/inc/context.less index 08c8ecc9..62db2474 100644 --- a/src/_h5ai/css/inc/context.less +++ b/src/_h5ai/css/inc/context.less @@ -1,6 +1,7 @@ #context { position: fixed; + z-index: 1; display: none; right: 16px; bottom: 50px; diff --git a/src/_h5ai/css/inc/footer.less b/src/_h5ai/css/inc/footer.less index 5a00fffe..2e0498c9 100644 --- a/src/_h5ai/css/inc/footer.less +++ b/src/_h5ai/css/inc/footer.less @@ -1,13 +1,13 @@ body > footer { position: fixed; - z-index: 1; + z-index: 5; width: 100%; left: 0; bottom: 0; padding: 6px 0 8px 0; - background-color: rgb(241,241,241); - border-top: 2px solid rgb(210,210,210); + .vert-gradient(rgb(241,241,241), rgb(228,228,228)); + border-top: 1px solid rgb(210,210,210); color: #999; font-size: 0.85em; diff --git a/src/_h5ai/css/inc/mixins.less b/src/_h5ai/css/inc/mixins.less index 4e2f8847..a9691734 100644 --- a/src/_h5ai/css/inc/mixins.less +++ b/src/_h5ai/css/inc/mixins.less @@ -1,38 +1,59 @@ + .border-radius (@radius) { - -moz-border-radius: @radius; - -webkit-border-radius: @radius; - border-radius: @radius; + -webkit-border-radius: @radius; /* Saf3-4, iOS 1-3.2, Android <1.6 */ + -moz-border-radius: @radius; /* FF1-3.6 */ + border-radius: @radius; /* Opera 10.5, IE9, Saf5, Chrome, FF4, iOS 4, Android 2.1+ */ +} + + +.background-clip () { + -webkit-background-clip: padding-box; + -moz-background-clip: padding; + background-clip: padding-box; } .box-shadow (@shadow) { - -moz-box-shadow: @shadow; - -webkit-box-shadow: @shadow; - box-shadow: @shadow; + -webkit-box-shadow: @shadow; /* Saf3-4 */ + -moz-box-shadow: @shadow; /* FF3.5 - 3.6 */ + box-shadow: @shadow; /* Opera 10.5, IE9, FF4+, Chrome 10+ */ } .transition (@transition) { - -moz-transition: @transition; - -ms-transition: @transition; - -o-transition: @transition; - -webkit-transition: @transition; - transition: @transition; + -webkit-transition: @transition; /* Saf3.2+, Chrome */ + -moz-transition: @transition; /* FF4+ */ + -ms-transition: @transition; /* IE10? */ + -o-transition: @transition; /* Opera 10.5+ */ + transition: @transition; } .transform (@transform) { - -moz-transform: @transform; - -o-transform: @transform; - -webkit-transform: @transform; - transform: @transform; + -webkit-transform: @transform; /* Saf3.1+, Chrome */ + -moz-transform: @transform; /* FF3.5+ */ + -ms-transform: @transform; /* IE9 */ + -o-transform: @transform; /* Opera 10.5 */ + transform: @transform; + zoom: 1; +} + + +.vert-gradient (@top, @bottom) { + background-color: @top; + background-image: -webkit-gradient(linear, left top, left bottom, from(@top), to(@bottom)); /* Saf4+, Chrome */ + background-image: -webkit-linear-gradient(top, @top, @bottom); /* Chrome 10+, Saf5.1+, iOS 5+ */ + background-image: -moz-linear-gradient(top, @top, @bottom); /* FF3.6 */ + background-image: -ms-linear-gradient(top, @top, @bottom); /* IE10 */ + background-image: -o-linear-gradient(top, @top, @bottom); /* Opera 11.10+ */ + background-image: linear-gradient(top, @top, @bottom); } .background-size (@size) { - -moz-background-size: @size; - -webkit-background-size: @size; - background-size: @size; + -webkit-background-size: @size; /* Saf3-4 */ + -moz-background-size: @size; /* FF3.6 */ + background-size: @size; /* Opera, IE9, Saf5, Chrome, FF4 */ } diff --git a/src/_h5ai/css/inc/nav.less b/src/_h5ai/css/inc/nav.less index 4c753f82..b3d94681 100644 --- a/src/_h5ai/css/inc/nav.less +++ b/src/_h5ai/css/inc/nav.less @@ -1,13 +1,13 @@ body > nav { position: fixed; - z-index: 1; + z-index: 5; width: 100%; left: 0; top: 0; font-size: 0.85em; - background-color: rgb(241,241,241); - border-bottom: 2px solid rgb(210,210,210); + .vert-gradient(rgb(241,241,241), rgb(228,228,228)); + border-bottom: 1px solid rgb(210,210,210); span.jsDisabledFallback { display: block; @@ -51,7 +51,7 @@ body > nav { } .crumb { float: left; - border-right: 1px solid rgb(231,231,231); + border-right: 1px solid rgba(0,0,0,0.05); .hint { margin-left: 8px; font-style: italic; @@ -64,12 +64,12 @@ body > nav { } .view { float: right; - border-left: 1px solid rgb(231,231,231); + border-left: 1px solid rgba(0,0,0,0.05); } #download { display: none; float: right; - border-left: 1px solid rgb(231,231,231); + border-left: 1px solid rgba(0,0,0,0.05); .transition(all 0.2s ease-in-out); &.zipping { @@ -81,7 +81,7 @@ body > nav { } #filter { float: right; - border-left: 1px solid rgb(231,231,231); + border-left: 1px solid rgba(0,0,0,0.05); input { border: none; diff --git a/src/_h5ai/css/inc/tree.less b/src/_h5ai/css/inc/tree.less index c4d2845b..656a4f93 100644 --- a/src/_h5ai/css/inc/tree.less +++ b/src/_h5ai/css/inc/tree.less @@ -3,15 +3,14 @@ display: none; position: fixed; left: 0; - top: 62px; + top: 31px; + height: 100%; z-index: 1; overflow: auto; font-size: 0.85em; padding: 8px; background-color: rgb(241,241,241); - border: 1px solid rgb(210,210,210); - border-left: none; - .border-radius(0 10px 10px 0); + border-right: 2px solid rgb(221,221,221); > .scrollbar { margin: 8px 8px 8px 0; diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index 666f707d..ad48cda2 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -90,7 +90,7 @@ navHeight = $("body > nav").outerHeight(), footerHeight = $("body > footer").outerHeight(), contentSpacing = 50, - treeSpacing = 30; + treeSpacing = 0; $body.css({ "margin-top": navHeight + contentSpacing, @@ -99,7 +99,7 @@ $tree.css({ top: navHeight + treeSpacing, - height: winHeight - navHeight - footerHeight - 18 - 2 * treeSpacing + height: winHeight - navHeight - footerHeight - 16 - 2 * treeSpacing }); try { From 556d206ab8f5f420e171838fd50a546d37ec5eb7 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 22 Feb 2012 13:18:46 +0100 Subject: [PATCH 29/36] Hide filter input field if no filter is set. --- README.md | 1 + src/_h5ai/css/inc/nav.less | 7 +++++++ src/_h5ai/js/inc/Finder.js | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 032efbab..31eb9d22 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * adds optional QRCode display * adds optional filtering for displayed files and folders +* updates design * improves zipped download * changes h5ai.htaccess * custom headers/footers are now optional and disabled by default diff --git a/src/_h5ai/css/inc/nav.less b/src/_h5ai/css/inc/nav.less index b3d94681..4a758693 100644 --- a/src/_h5ai/css/inc/nav.less +++ b/src/_h5ai/css/inc/nav.less @@ -84,11 +84,18 @@ body > nav { border-left: 1px solid rgba(0,0,0,0.05); input { + display: none; border: none; font-family: Ubuntu, sans-serif; color: #555; background-color: rgba(0,0,0,0); width: 100px; } + + &.current { + input { + display: inline; + } + } } } diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index 60771f7b..e4aab214 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -53,7 +53,7 @@ init = function () { if (H5AI.core.settings.showFilter) { - $("
  • filter
  • ") + $("
  • filter
  • ") .on('click', function () { var $input = $(this).find('input'); From f1175f5149cb2f251268569111aaadacbf71122e Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 22 Feb 2012 23:47:05 +0100 Subject: [PATCH 30/36] More design changes. --- src/_h5ai/config.js | 51 ++++++++++++++++++++++----------- src/_h5ai/css/inc/extended.less | 13 ++++++--- src/_h5ai/css/inc/footer.less | 3 -- src/_h5ai/css/inc/nav.less | 41 +++++++++++++++++--------- src/_h5ai/js/inc/Extended.js | 1 + src/_h5ai/js/inc/Finder.js | 9 +++++- src/_h5ai/php/inc/Extended.php | 1 + 7 files changed, 81 insertions(+), 38 deletions(-) diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index 58029181..34733b34 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -214,7 +214,8 @@ var H5AI_CONFIG = { "empty": "empty", "folders": "folders", "files": "files", - "download": "download" + "download": "download", + "noMatch": "no match" }, "bg": { @@ -228,7 +229,8 @@ var H5AI_CONFIG = { "empty": "празно", "folders": "папки", "files": "файлове", - "download": "download" + "download": "download", + "noMatch": "no match" }, "cs": { @@ -242,7 +244,8 @@ var H5AI_CONFIG = { "empty": "prázdný", "folders": "složek", "files": "souborů", - "download": "download" + "download": "download", + "noMatch": "no match" }, "de": { @@ -256,7 +259,8 @@ var H5AI_CONFIG = { "empty": "leer", "folders": "Ordner", "files": "Dateien", - "download": "Download" + "download": "Download", + "noMatch": "keine Treffer" }, "es": { @@ -270,7 +274,8 @@ var H5AI_CONFIG = { "empty": "vacío", "folders": "Directorios", "files": "Archivos", - "download": "Descargar" + "download": "Descargar", + "noMatch": "no match" }, "fr": { @@ -284,7 +289,8 @@ var H5AI_CONFIG = { "empty": "vide", "folders": "Répertoires", "files": "Fichiers", - "download": "télécharger" + "download": "télécharger", + "noMatch": "no match" }, "it": { @@ -298,7 +304,8 @@ var H5AI_CONFIG = { "empty": "vuota", "folders": "cartelle", "files": "file", - "download": "download" + "download": "download", + "noMatch": "no match" }, "lv": { @@ -312,7 +319,8 @@ var H5AI_CONFIG = { "empty": "tukšs", "folders": "mapes", "files": "faili", - "download": "lejupielādēt" + "download": "lejupielādēt", + "noMatch": "no match" }, "nl": { @@ -326,7 +334,8 @@ var H5AI_CONFIG = { "empty": "lege", "folders": "folders", "files": "files", - "download": "download" + "download": "download", + "noMatch": "no match" }, "pl": { @@ -340,7 +349,8 @@ var H5AI_CONFIG = { "empty": "pusty", "folders": "foldery", "files": "pliki", - "download": "download" + "download": "download", + "noMatch": "no match" }, "pt": { @@ -354,7 +364,8 @@ var H5AI_CONFIG = { "empty": "vazio", "folders": "pastas", "files": "arquivos", - "download": "download" + "download": "download", + "noMatch": "no match" }, "ru": { @@ -368,7 +379,8 @@ var H5AI_CONFIG = { "empty": "пусто", "folders": "папки", "files": "файлы", - "download": "download" + "download": "download", + "noMatch": "no match" }, "sk": { @@ -382,7 +394,8 @@ var H5AI_CONFIG = { "empty": "prázdny", "folders": "priečinkov", "files": "súborov", - "download": "download" + "download": "download", + "noMatch": "no match" }, "sv": { @@ -396,7 +409,8 @@ var H5AI_CONFIG = { "empty": "tom", "folders": "folders", "files": "files", - "download": "download" + "download": "download", + "noMatch": "no match" }, "tr": { @@ -410,7 +424,8 @@ var H5AI_CONFIG = { "empty": "boş", "folders": "klasörler", "files": "dosyalar", - "download": "indir" + "download": "indir", + "noMatch": "no match" }, "zh-cn": { @@ -424,7 +439,8 @@ var H5AI_CONFIG = { "empty": "空文件夹", "folders": "文件夹", "files": "文件", - "download": "下载" + "download": "下载", + "noMatch": "no match" }, "zh-tw": { @@ -438,7 +454,8 @@ var H5AI_CONFIG = { "empty": "空資料夾", "folders": "資料夾", "files": "檔案", - "download": "下載" + "download": "下載", + "noMatch": "no match" } } }; diff --git a/src/_h5ai/css/inc/extended.less b/src/_h5ai/css/inc/extended.less index 733360a6..5ef2e69e 100644 --- a/src/_h5ai/css/inc/extended.less +++ b/src/_h5ai/css/inc/extended.less @@ -146,13 +146,16 @@ } } } - .empty { + .empty, .no-match { text-align: center; margin: 50px 0; color: #ddd; font-size: 5em; font-weight: bold; } + .no-match { + display: none; + } } @@ -170,8 +173,6 @@ #extended.icons-view { display: none; padding: 3px; - border: 1px solid #eee; - border-radius: 15px; ul { margin: 0; @@ -269,7 +270,8 @@ } } } - .empty { + .empty, .no-match { + margin: 0 120px; padding: 16px; height: 120px; text-align: center; @@ -277,4 +279,7 @@ font-size: 5em; font-weight: bold; } + .no-match { + display: none; + } } diff --git a/src/_h5ai/css/inc/footer.less b/src/_h5ai/css/inc/footer.less index 2e0498c9..02495140 100644 --- a/src/_h5ai/css/inc/footer.less +++ b/src/_h5ai/css/inc/footer.less @@ -102,9 +102,6 @@ body > footer { background-color: rgba(255,255,255,0.8); } } - li:nth-child(3n+1) { - - } } } } diff --git a/src/_h5ai/css/inc/nav.less b/src/_h5ai/css/inc/nav.less index 4a758693..c07bf3d4 100644 --- a/src/_h5ai/css/inc/nav.less +++ b/src/_h5ai/css/inc/nav.less @@ -1,4 +1,26 @@ +.nav-highlight { + background-color: rgba(255,255,255,0.5); + opacity: 1.0; +} + +.nav-hover { + .nav-highlight; + color: #e80; +} + +@nav-sep-border: 1px solid rgba(0,0,0,0.05); + +.nav-left { + float: left; + border-right: @nav-sep-border; +} + +.nav-right { + float: right; + border-left: @nav-sep-border; +} + body > nav { position: fixed; z-index: 5; @@ -29,15 +51,12 @@ body > nav { padding: 0 10px; &:hover, &.hover { - color: #e80; - background-color: rgba(255,255,255,0.5); - opacity: 1.0; + .nav-hover; } } .current { a, span.element { - background-color: rgba(255,255,255,0.5); - opacity: 1.0; + .nav-highlight; } } img { @@ -50,8 +69,7 @@ body > nav { margin-left: 6px; } .crumb { - float: left; - border-right: 1px solid rgba(0,0,0,0.05); + .nav-left; .hint { margin-left: 8px; font-style: italic; @@ -63,13 +81,11 @@ body > nav { } } .view { - float: right; - border-left: 1px solid rgba(0,0,0,0.05); + .nav-right; } #download { display: none; - float: right; - border-left: 1px solid rgba(0,0,0,0.05); + .nav-right; .transition(all 0.2s ease-in-out); &.zipping { @@ -80,8 +96,7 @@ body > nav { } } #filter { - float: right; - border-left: 1px solid rgba(0,0,0,0.05); + .nav-right; input { display: none; diff --git a/src/_h5ai/js/inc/Extended.js b/src/_h5ai/js/inc/Extended.js index ef12bf79..93fb62c0 100644 --- a/src/_h5ai/js/inc/Extended.js +++ b/src/_h5ai/js/inc/Extended.js @@ -49,6 +49,7 @@ if ($ul.children(".entry:not(.folder-parent)").size() === 0) { $("#extended").append($("
    empty
    ")); } + $("#extended").append($("
    no match
    ")); }, customize = function () { diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index e4aab214..62ea0107 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -23,6 +23,14 @@ match = $('#extended .entry'); } + if ($(match).length) { + $('#extended .no-match').hide(); + } else { + setTimeout(function () { + + $('#extended .no-match').show(); + }, 200); + } $(match).fadeIn(200); $(noMatch).fadeOut(200); }, @@ -84,7 +92,6 @@ .end() .appendTo($("#navbar")); } - }; diff --git a/src/_h5ai/php/inc/Extended.php b/src/_h5ai/php/inc/Extended.php index e8a47878..fd4ad5c0 100644 --- a/src/_h5ai/php/inc/Extended.php +++ b/src/_h5ai/php/inc/Extended.php @@ -131,6 +131,7 @@ class Extended { if (count($this->content) === 0) { $html .= "
    empty
    "; } + $html .= "
    no match
    "; $html .="
    "; return $html; } From 7c1feaebc066a610a25a362a6c1bacd5894962f9 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 23 Feb 2012 12:38:11 +0100 Subject: [PATCH 31/36] Changes download button style while zipping. --- src/_h5ai/css/inc/nav.less | 3 --- src/_h5ai/css/inc/tree.less | 2 +- src/_h5ai/js/inc/ZippedDownload.js | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/_h5ai/css/inc/nav.less b/src/_h5ai/css/inc/nav.less index c07bf3d4..88eec564 100644 --- a/src/_h5ai/css/inc/nav.less +++ b/src/_h5ai/css/inc/nav.less @@ -88,9 +88,6 @@ body > nav { .nav-right; .transition(all 0.2s ease-in-out); - &.zipping { - - } &.failed { background-color: rgba(255,0,0,0.5); } diff --git a/src/_h5ai/css/inc/tree.less b/src/_h5ai/css/inc/tree.less index 656a4f93..6bd2e477 100644 --- a/src/_h5ai/css/inc/tree.less +++ b/src/_h5ai/css/inc/tree.less @@ -5,7 +5,7 @@ left: 0; top: 31px; height: 100%; - z-index: 1; + z-index: 3; overflow: auto; font-size: 0.85em; padding: 8px; diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index f38d56be..2f0a954e 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -97,7 +97,7 @@ .find("img").attr("src", H5AI.core.image("download")).end() .find("a").click(function () { - $('#download').addClass('zipping'); + $('#download').addClass('current'); $('#download img').attr('src', H5AI.core.image("loading.gif", true)); $.ajax({ url: H5AI.core.api(), @@ -109,8 +109,8 @@ dataType: 'json', success: function (response) { + $('#download').removeClass('current'); $('#download img').attr('src', H5AI.core.image("download")); - $('#download').removeClass('zipping'); if (response.status === 'ok') { window.location = H5AI.core.api() + '?action=getzip&id=' + response.id; } else { @@ -121,8 +121,8 @@ } }, failed: function () { + $('#download').removeClass('current'); $('#download img').attr('src', H5AI.core.image("download")); - $('#download').removeClass('zipping'); } }); }).end() From 997f1cd80f3394015f5360eac2595429467c27f5 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 23 Feb 2012 22:41:17 +0100 Subject: [PATCH 32/36] Improves URL hashs. --- README.md | 1 + src/_h5ai/js/inc/Core.js | 42 ++++++++++++++++++++++++++++++++++++-- src/_h5ai/js/inc/Finder.js | 7 +++++++ src/_h5ai/js/inc/Sort.js | 19 +++++++++-------- 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 31eb9d22..7b344991 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * fixes path problems on servers running on Windows in PHP version * fixes broken links in custom headers/footers while zipped download enabled * fixes problems with thumbnails for files with single or double quotes in filename +* improves url hashes * updates year in `LICENSE.TXT` * updates es translation * adds zh-tw translation by [Yao Wei](http://github.com/medicalwei) diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index ad48cda2..a692fc3b 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -44,6 +44,35 @@ }); return map; }(config.types)), + hash = function (obj) { + + if ($.isPlainObject(obj)) { + var hashStr = ''; + $.each($.extend({}, hash(), obj), function (key, value) { + if (value) { + hashStr += '/' + key + '=' + value; + } + }); + hashStr = '#!' + hashStr; + window.location.hash = hashStr; + return hashStr; + } else { + var result = {}, + parts = document.location.hash.split('/'); + + if (parts.length >= 2 || parts[0] === '#!') { + parts.shift(); + $.each(parts, function (idx, part) { + + var match = /^([^=]*)=(.*?)$/.exec(part); + if (match) { + result[match[1]] = match[2]; + } + }); + } + return typeof obj === 'string' ? result[obj] : result; + } + }, api = function () { return settings.h5aiAbsHref + "php/api.php"; @@ -68,6 +97,7 @@ viewmode = amplify.store(settings.store.viewmode); } viewmode = $.inArray(viewmode, settings.viewmodes) >= 0 ? viewmode : settings.viewmodes[0]; + H5AI.core.hash({view: viewmode}); $viewDetails.add($viewIcons).removeClass("current"); if (viewmode === "details") { @@ -123,13 +153,19 @@ if ($.inArray("icons", settings.viewmodes) >= 0) { $("
  • view-iconsicons
  • ") .find("img").attr("src", image("view-icons")).end() - .click(function () { viewmode("icons"); }) + .find("a").click(function (event) { + viewmode("icons"); + event.preventDefault(); + }).end() .appendTo($navbar); } if ($.inArray("details", settings.viewmodes) >= 0) { $("
  • view-detailsdetails
  • ") .find("img").attr("src", image("view-details")).end() - .click(function () { viewmode("details"); }) + .find("a").click(function (event) { + viewmode("details"); + event.preventDefault(); + }).end() .appendTo($navbar); } } @@ -257,6 +293,7 @@ $(".lang").text(lang); $(".langOption").removeClass("current"); $(".langOption." + lang).addClass("current"); + H5AI.core.hash({lang: lang}); } formatDates(selected.dateFormat || settings.dateFormat); @@ -386,6 +423,7 @@ return { settings: settings, + hash: hash, api: api, image: image, icon: icon, diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index 62ea0107..060fc2e6 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -45,6 +45,7 @@ } else { $filter.removeClass('current'); } + H5AI.core.hash({filter: val}); }, parseFilterSequence = function (sequence) { @@ -91,6 +92,12 @@ }) .end() .appendTo($("#navbar")); + + var initialFilter = H5AI.core.hash('filter'); + if (initialFilter) { + $('#filter input').val(initialFilter); + checkState(false); + } } }; diff --git a/src/_h5ai/js/inc/Sort.js b/src/_h5ai/js/inc/Sort.js index 0954298d..074ccf0b 100644 --- a/src/_h5ai/js/inc/Sort.js +++ b/src/_h5ai/js/inc/Sort.js @@ -78,14 +78,15 @@ var order = orders[id]; $all.removeClass("ascending").removeClass("descending"); - order.head.addClass(order.clas).attr("href", "#!/sort=" + id); + order.head.addClass(order.clas); sort(order.fn); + H5AI.core.hash({sort: id}); }, init = function () { var $ascending = $("ascending"), $descending = $("descending"), - initialOrder = /^.*#!.*\/sort=(.*?)(?:\/.*)?$/.exec(document.location), + initialOrder = H5AI.core.hash('sort'), $header = $("#extended li.header"), $label = $header.find("a.label"), $date = $header.find("a.date"), @@ -125,27 +126,27 @@ } }; - sortBy(initialOrder ? initialOrder[1] : H5AI.core.settings.sortorder); + sortBy(initialOrder ? initialOrder : H5AI.core.settings.sortorder); $label - .attr("href", "#!/sort=na") .append($ascending.clone()).append($descending.clone()) - .click(function () { + .click(function (event) { sortBy("n" + ($label.hasClass("ascending") ? "d" : "a")); + event.preventDefault(); }); $date - .attr("href", "#!/sort=da") .prepend($ascending.clone()).prepend($descending.clone()) - .click(function () { + .click(function (event) { sortBy("d" + ($date.hasClass("ascending") ? "d" : "a")); + event.preventDefault(); }); $size - .attr("href", "#!/sort=sa") .prepend($ascending.clone()).prepend($descending.clone()) - .click(function () { + .click(function (event) { sortBy("s" + ($size.hasClass("ascending") ? "d" : "a")); + event.preventDefault(); }); }; From 08cc2834df1a6542dd05e3039bb19fb2a50da109 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 24 Feb 2012 00:01:43 +0100 Subject: [PATCH 33/36] Adds en- and decoding for URL hashes. --- src/_h5ai/js/inc/Core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_h5ai/js/inc/Core.js b/src/_h5ai/js/inc/Core.js index a692fc3b..ea259088 100644 --- a/src/_h5ai/js/inc/Core.js +++ b/src/_h5ai/js/inc/Core.js @@ -50,7 +50,7 @@ var hashStr = ''; $.each($.extend({}, hash(), obj), function (key, value) { if (value) { - hashStr += '/' + key + '=' + value; + hashStr += '/' + encodeURIComponent(key) + '=' + encodeURIComponent(value); } }); hashStr = '#!' + hashStr; @@ -66,7 +66,7 @@ var match = /^([^=]*)=(.*?)$/.exec(part); if (match) { - result[match[1]] = match[2]; + result[decodeURIComponent(match[1])] = decodeURIComponent(match[2]); } }); } From 041c172a554a97087d58465c40436047b7786bbd Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 24 Feb 2012 16:31:47 +0100 Subject: [PATCH 34/36] Adds support for zipped download of htaccess restricted files. --- README.md | 1 + src/_h5ai/css/inc/nav.less | 22 +++++ src/_h5ai/js/inc/ZippedDownload.js | 109 ++++++++++++++++------- src/_h5ai/js/inc/lib/base64.js | 135 +++++++++++++++++++++++++++++ src/_h5ai/js/libs.js | 1 + src/_h5ai/php/api.php | 5 +- src/_h5ai/php/inc/H5ai.php | 15 ---- src/_h5ai/php/inc/ZipIt.php | 22 ++++- 8 files changed, 258 insertions(+), 52 deletions(-) create mode 100644 src/_h5ai/js/inc/lib/base64.js diff --git a/README.md b/README.md index 7b344991..ebd4c7ea 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * adds optional filtering for displayed files and folders * updates design * improves zipped download +* adds support for zipped download of htaccess restricted files * changes h5ai.htaccess * custom headers/footers are now optional and disabled by default * fixes problems with folder recognition in the JS version diff --git a/src/_h5ai/css/inc/nav.less b/src/_h5ai/css/inc/nav.less index 88eec564..89c4f580 100644 --- a/src/_h5ai/css/inc/nav.less +++ b/src/_h5ai/css/inc/nav.less @@ -111,3 +111,25 @@ body > nav { } } } + + +#download-auth { + display: none; + position: fixed; + z-index: 5; + left: 0; + top: 0; + font-size: 0.85em; + .vert-gradient(rgb(241,241,241), rgb(228,228,228)); + border: 1px solid rgb(210,210,210); + + input { + display: block; + margin: 4px 6px; + border: 1px solid rgb(210,210,210); + font-family: Ubuntu, sans-serif; + color: #555; + background-color: rgba(255,255,255,1); + width: 100px; + } +} diff --git a/src/_h5ai/js/inc/ZippedDownload.js b/src/_h5ai/js/inc/ZippedDownload.js index 2f0a954e..45d7c1cc 100644 --- a/src/_h5ai/js/inc/ZippedDownload.js +++ b/src/_h5ai/js/inc/ZippedDownload.js @@ -8,6 +8,8 @@ $document = $(document), $selectionRect = $("#selection-rect"), selectedHrefsStr = "", + $download, $img, $downloadAuth, $downloadUser, $downloadPassword, + updateDownloadBtn = function () { var $selected = $("#extended a.selected"), @@ -23,6 +25,7 @@ $downloadBtn.show(); } else { $downloadBtn.hide(); + $downloadAuth.hide(); } }, selectionUpdate = function (event) { @@ -90,45 +93,91 @@ noSelection(event); } }, + failed = function () { + + $download.addClass('failed'); + setTimeout(function () { + $download.removeClass('failed'); + }, 1000); + }, + handleResponse = function (response) { + + + $download.removeClass('current'); + $img.attr('src', H5AI.core.image("download")); + + if (response) { + if (response.status === 'ok') { + window.location = H5AI.core.api() + '?action=getzip&id=' + response.id; + } else { + if (response.code === 401) { + $downloadAuth + .css({ + left: $download.offset().left, + top: $download.offset().top + $download.outerHeight() + }) + .show(); + $downloadUser.focus(); + } + failed(); + } + } else { + failed(); + } + }, + requestZipping = function (hrefsStr) { + + $download.addClass('current'); + $img.attr('src', H5AI.core.image("loading.gif", true)); + $.ajax({ + url: H5AI.core.api(), + data: { + action: 'zip', + hrefs: selectedHrefsStr + }, + type: 'POST', + dataType: 'json', + beforeSend: function (xhr) { + + var user = $downloadUser.val(), + password = $downloadPassword.val(); + + if (user) { + xhr.setRequestHeader ('Authorization', 'Basic ' + Base64.encode(user + ':' + password)); + } + }, + success: function (response) { + + handleResponse(response); + }, + failed: function () { + + handleResponse(); + } + }); + }, init = function () { if (H5AI.core.settings.zippedDownload) { $("
  • downloaddownload
  • ") .find("img").attr("src", H5AI.core.image("download")).end() - .find("a").click(function () { + .find("a").click(function (event) { - $('#download').addClass('current'); - $('#download img').attr('src', H5AI.core.image("loading.gif", true)); - $.ajax({ - url: H5AI.core.api(), - data: { - action: 'zip', - hrefs: selectedHrefsStr - }, - type: 'POST', - dataType: 'json', - success: function (response) { - - $('#download').removeClass('current'); - $('#download img').attr('src', H5AI.core.image("download")); - if (response.status === 'ok') { - window.location = H5AI.core.api() + '?action=getzip&id=' + response.id; - } else { - $('#download').addClass('failed'); - setTimeout(function () { - $('#download').removeClass('failed'); - }, 1000); - } - }, - failed: function () { - $('#download').removeClass('current'); - $('#download img').attr('src', H5AI.core.image("download")); - } - }); + event.preventDefault(); + $downloadAuth.hide(); + requestZipping(selectedHrefsStr); }).end() .appendTo($("#navbar")); + $("
    ") + .appendTo($("body")); - $("body>nav,body>footer,#tree").on("mousedown", noSelection); + $download = $('#download'); + $downloadAuth = $('#download-auth'); + $downloadUser = $('#download-auth-user'); + $downloadPassword = $('#download-auth-password'); + $img = $download.find('img'); + + $("body>nav,body>footer,#tree,input").on("mousedown", noSelection); $("#content").on("mousedown", "a", noSelectionUnlessCtrl); $document.on("mousedown", selectionStart); } diff --git a/src/_h5ai/js/inc/lib/base64.js b/src/_h5ai/js/inc/lib/base64.js new file mode 100644 index 00000000..61e4c290 --- /dev/null +++ b/src/_h5ai/js/inc/lib/base64.js @@ -0,0 +1,135 @@ +var Base64 = { + +// private property +_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + +// public method for encoding +encode : function (input) { + var output = ""; + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var i = 0; + + input = Base64._utf8_encode(input); + + while (i < input.length) { + + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + + output = output + + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); + + } + + return output; +}, + +// public method for decoding +decode : function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + while (i < input.length) { + + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } + + } + + output = Base64._utf8_decode(output); + + return output; + +}, + +// private method for UTF-8 encoding +_utf8_encode : function (string) { + string = string.replace(/\r\n/g,"\n"); + var utftext = ""; + + for (var n = 0; n < string.length; n++) { + + var c = string.charCodeAt(n); + + if (c < 128) { + utftext += String.fromCharCode(c); + } + else if((c > 127) && (c < 2048)) { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); + } + else { + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); + } + + } + + return utftext; +}, + +// private method for UTF-8 decoding +_utf8_decode : function (utftext) { + var string = ""; + var i = 0; + var c = c1 = c2 = 0; + + while ( i < utftext.length ) { + + c = utftext.charCodeAt(i); + + if (c < 128) { + string += String.fromCharCode(c); + i++; + } + else if((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } + else { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + + } + + return string; +} + +} diff --git a/src/_h5ai/js/libs.js b/src/_h5ai/js/libs.js index 1df256fb..236cc1b0 100644 --- a/src/_h5ai/js/libs.js +++ b/src/_h5ai/js/libs.js @@ -6,6 +6,7 @@ // @include "inc/lib/jquery.qrcode.js" // @include "inc/lib/amplify.min.js" +// @include "inc/lib/base64.js" // @include "inc/lib/date.js" // @include "inc/main.js" diff --git a/src/_h5ai/php/api.php b/src/_h5ai/php/api.php index c2a8de1c..0edbd45a 100644 --- a/src/_h5ai/php/api.php +++ b/src/_h5ai/php/api.php @@ -118,10 +118,10 @@ else if ($action === "zip") { $hrefs = explode(":", trim($hrefs)); $zipFile = $zipit->zip($hrefs); - if ($zipFile) { + if (is_string($zipFile)) { $response = array('status' => 'ok', 'id' => basename($zipFile), 'size' => filesize($zipFile)); } else { - $response = array('status' => 'failed', 'msg' => 'none'); + $response = array('status' => 'failed', 'code' => $zipFile); } echo json_encode($response); } @@ -136,7 +136,6 @@ else if ($action === "getzip") { fail(2, "zipped file not found: " . $id, !file_exists($zipFile)); header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\""); - // header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Length: " . filesize($zipFile)); header("Connection: close"); diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index 4a70aced..bf8251a0 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -258,7 +258,6 @@ class H5ai { //return $this->cachedHttpCode($absHref); return $this->fetchHttpCode($absHref); - // return $this->guessHttpCode($absHref); } @@ -312,20 +311,6 @@ class H5ai { fclose($socket); return $code; } - - - public function guessHttpCode($absHref) { - - $indexFiles = array("index.html", "index.cgi", "index.pl", "index.php", "index.xhtml", "index.htm"); - $absPath = $this->getAbsPath($absHref); - $files = $this->readDir($absPath); - foreach ($files as $file) { - if (in_array($file, $indexFiles)) { - return 200; - } - } - return "h5ai"; - } } ?> \ No newline at end of file diff --git a/src/_h5ai/php/inc/ZipIt.php b/src/_h5ai/php/inc/ZipIt.php index cb67a953..a926b3bc 100644 --- a/src/_h5ai/php/inc/ZipIt.php +++ b/src/_h5ai/php/inc/ZipIt.php @@ -24,11 +24,19 @@ class ZipIt { foreach ($hrefs as $href) { $d = safe_dirname($href, true); $n = basename($href); - if ($this->h5ai->getHttpCode($d) === "h5ai" && !$this->h5ai->ignoreThisFile($n)) { + $code = $this->h5ai->getHttpCode($d); + if ($code == 401) { + return $code; + } + + if ($code == "h5ai" && !$this->h5ai->ignoreThisFile($n)) { $localFile = $this->h5ai->getAbsPath($href); $file = preg_replace("!^" . $this->h5ai->getRootAbsPath() . "!", "", $localFile); if (is_dir($localFile)) { - $this->zipDir($zip, $localFile, $file); + $rcode = $this->zipDir($zip, $localFile, $file); + if ($rcode == 401) { + return $rcode; + } } else { $this->zipFile($zip, $localFile, $file); } @@ -50,19 +58,25 @@ class ZipIt { private function zipDir($zip, $localDir, $dir) { - if ($this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)) === "h5ai") { + $code = $this->h5ai->getHttpCode($this->h5ai->getAbsHref($localDir)); + + if ($code == 'h5ai') { $zip->addEmptyDir($dir); $files = $this->h5ai->readDir($localDir); foreach ($files as $file) { $localFile = $localDir . "/" . $file; $file = $dir . "/" . $file; if (is_dir($localFile)) { - $this->zipDir($zip, $localFile, $file); + $rcode = $this->zipDir($zip, $localFile, $file); + if ($rcode == 401) { + return $rcode; + } } else { $this->zipFile($zip, $localFile, $file); } } } + return code; } } From cdb0f9035da8b333cc747f038a789bdaf9dbed81 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 24 Feb 2012 16:37:37 +0100 Subject: [PATCH 35/36] Minor changes. --- README.md | 2 +- src/_h5ai/js/inc/lib/base64.js | 206 +++++++++++++++++---------------- 2 files changed, 105 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index ebd4c7ea..d0ea6294 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h ## Changelog -### v0.18 - *2012-02-??* +### v0.18 - *2012-02-24* * adds optional QRCode display * adds optional filtering for displayed files and folders diff --git a/src/_h5ai/js/inc/lib/base64.js b/src/_h5ai/js/inc/lib/base64.js index 61e4c290..322b008c 100644 --- a/src/_h5ai/js/inc/lib/base64.js +++ b/src/_h5ai/js/inc/lib/base64.js @@ -1,135 +1,137 @@ + +/* + * taken from here: + * http://www.webtoolkit.info/javascript-base64.html + * with minor modifications + */ var Base64 = { -// private property -_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + // private property + _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", -// public method for encoding -encode : function (input) { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; + // public method for encoding + encode : function (input) { + var output = ""; + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var i = 0; - input = Base64._utf8_encode(input); + input = Base64._utf8_encode(input); - while (i < input.length) { + while (i < input.length) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); + output = output + + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - } + } - return output; -}, + return output; + }, -// public method for decoding -decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; + // public method for decoding + decode : function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - while (i < input.length) { + while (i < input.length) { - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; - output = output + String.fromCharCode(chr1); + output = output + String.fromCharCode(chr1); - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } - } + } - output = Base64._utf8_decode(output); + return Base64._utf8_decode(output); + }, - return output; + // private method for UTF-8 encoding + _utf8_encode : function (string) { + string = string.replace(/\r\n/g,"\n"); + var utftext = ""; -}, + for (var n = 0; n < string.length; n++) { -// private method for UTF-8 encoding -_utf8_encode : function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; + var c = string.charCodeAt(n); - for (var n = 0; n < string.length; n++) { + if (c < 128) { + utftext += String.fromCharCode(c); + } + else if((c > 127) && (c < 2048)) { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); + } + else { + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); + } - var c = string.charCodeAt(n); + } - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } + return utftext; + }, - } + // private method for UTF-8 decoding + _utf8_decode : function (utftext) { + var string = ""; + var i = 0; + var c = c1 = c2 = 0; - return utftext; -}, + while ( i < utftext.length ) { -// private method for UTF-8 decoding -_utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; + c = utftext.charCodeAt(i); - while ( i < utftext.length ) { + if (c < 128) { + string += String.fromCharCode(c); + i++; + } + else if((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } + else { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; -} + } + return string; + } } From cc13005a1dcf91612808c937454e39e8a4d971ad Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 24 Feb 2012 16:52:31 +0100 Subject: [PATCH 36/36] Prepares release. --- build.properties | 2 +- src/_h5ai/config.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.properties b/build.properties index cecbe82e..d4865527 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ custom = true # project project.name = h5ai -project.version = pre0.18 +project.version = 0.18 # src diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index 34733b34..5b7705b1 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -25,8 +25,8 @@ var H5AI_CONFIG = { * * This is disabled by default. */ - "customHeader": "_h5ai.header.html", - "customFooter": "_h5ai.footer.html", + "customHeader": null, + "customFooter": null, /* * An array of view modes the user may choose from. Currently there @@ -112,20 +112,20 @@ var H5AI_CONFIG = { * Requires PHP on the server. * Enable zipped download of selected entries. */ - "zippedDownload": true, + "zippedDownload": false, /* * Show QRCodes on hovering files. * Set this to the desired size in pixel or null to not display QRCodes. * A good size to start with might be 150. */ - "qrCodesSize": 150, + "qrCodesSize": null, /* * Allow filtering the displayed files and folders. * Filters are ment to be JavaScript regular expressions. */ - "showFilter": true + "showFilter": false },