mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-31 07:18:21 -04:00
Cleans code.
This commit is contained in:
parent
70f4500232
commit
396bc6662f
7 changed files with 12 additions and 87 deletions
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
#data-apache-autoindex, #data-php-no-js-fallback {
|
#no-js-fallback {
|
||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
margin: 0 auto 80px auto;
|
margin: 0 auto 80px auto;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
@import "inc/extended-grid";
|
@import "inc/extended-grid";
|
||||||
// @import "inc/context-menu";
|
// @import "inc/context-menu";
|
||||||
@import "inc/dropbox";
|
@import "inc/dropbox";
|
||||||
@import "inc/fallback-table";
|
@import "inc/no-js-fallback";
|
||||||
|
|
||||||
@import "inc/responsive";
|
@import "inc/responsive";
|
||||||
|
|
||||||
|
|
|
@ -1,47 +1,12 @@
|
||||||
|
|
||||||
modulejs.define('core/entry', ['_', '$', 'core/format', 'model/entry'], function (_, $, format, Entry) {
|
modulejs.define('core/entry', ['_', 'config', 'model/entry'], function (_, config, Entry) {
|
||||||
|
|
||||||
var parseGenericJson = function (absHref, $container) {
|
_.each(config.entries || [], function (entry) {
|
||||||
|
|
||||||
return JSON.parse($.trim($container.text()) || '{}').entries;
|
Entry.get(entry.absHref, entry.time, entry.size, entry.status, entry.content);
|
||||||
},
|
});
|
||||||
|
|
||||||
parseApacheTable = function (absHref, $table) {
|
var entry = Entry.get();
|
||||||
|
|
||||||
return _.compact(_.map($table.find('td').closest('tr'), function (tr) {
|
|
||||||
|
|
||||||
var $tds = $(tr).find('td'),
|
|
||||||
$a = $tds.eq(1).find('a');
|
|
||||||
|
|
||||||
return $a.text() === 'Parent Directory' ? null : {
|
|
||||||
absHref: absHref + $a.attr('href'),
|
|
||||||
time: format.parseDate($tds.eq(2).text(), ['YYYY-MM-DD HH:mm', 'DD-MMM-YYYY HH:mm']),
|
|
||||||
size: format.parseSize($tds.eq(3).text())
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
parse = function (absHref, $html) {
|
|
||||||
|
|
||||||
var $generic = $html.find('#data-generic-json'),
|
|
||||||
$apache = $html.find('#data-apache-autoindex table'),
|
|
||||||
json = [];
|
|
||||||
|
|
||||||
if ($generic.length) {
|
|
||||||
json = parseGenericJson(absHref, $generic);
|
|
||||||
} else if ($apache.length) {
|
|
||||||
json = parseApacheTable(absHref, $apache);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _.map(json, function (entry) {
|
|
||||||
|
|
||||||
return Entry.get(entry.absHref, entry.time, entry.size, entry.status, entry.content);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
entry = Entry.get();
|
|
||||||
|
|
||||||
parse(entry.absHref, $('body'));
|
|
||||||
entry.status = '=h5ai=';
|
entry.status = '=h5ai=';
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
// @include "inc/**/*.js"
|
// @include "inc/**/*.js"
|
||||||
|
|
||||||
var $ = jQuery,
|
var $ = jQuery,
|
||||||
filename = 'client/js/scripts.js',
|
mode = $('script[src$="scripts.js"]').data('mode');
|
||||||
$script = $('script[src$="' + filename + '"]'),
|
|
||||||
mode = $script.data('mode');
|
|
||||||
|
|
||||||
if (mode === 'info') {
|
if (mode === 'info') {
|
||||||
|
|
||||||
|
@ -41,7 +39,7 @@
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$.getJSON('.', {action: 'get', options: true, types: true, langs: true, server: true}, function (config) {
|
$.getJSON('.', {action: 'get', options: true, types: true, langs: true, server: true, entries: true}, function (config) {
|
||||||
|
|
||||||
modulejs.define('config', config);
|
modulejs.define('config', config);
|
||||||
$(function () { modulejs.require('main'); });
|
$(function () { modulejs.require('main'); });
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
{{pkg.name}} {{pkg.version}}
|
|
||||||
{{pkg.url}}
|
|
||||||
|
|
||||||
Available translations
|
|
||||||
*/
|
|
||||||
|
|
||||||
{
|
|
||||||
"en": "english",
|
|
||||||
|
|
||||||
"bg": "български",
|
|
||||||
"cs": "čeština",
|
|
||||||
"de": "deutsch",
|
|
||||||
"el": "ελληνικά",
|
|
||||||
"es": "español",
|
|
||||||
"fr": "français",
|
|
||||||
"he": "עברית",
|
|
||||||
"hu": "magyar",
|
|
||||||
"it": "italiano",
|
|
||||||
"ja": "日本語",
|
|
||||||
"lv": "latviešu",
|
|
||||||
"nb": "norwegian",
|
|
||||||
"nl": "nederlands",
|
|
||||||
"pl": "polski",
|
|
||||||
"pt": "português",
|
|
||||||
"ro": "română",
|
|
||||||
"ru": "русский",
|
|
||||||
"sk": "slovenčina",
|
|
||||||
"sr": "srpski",
|
|
||||||
"sv": "svenska",
|
|
||||||
"tr": "türkçe",
|
|
||||||
"zh-cn": "简体中文",
|
|
||||||
"zh-tw": "正體中文"
|
|
||||||
}
|
|
|
@ -35,7 +35,6 @@ if (array_key_exists("action", $_REQUEST)) {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$HREF = $app->get_app_abs_href();
|
$HREF = $app->get_app_abs_href();
|
||||||
$JSON = $app->get_generic_json();
|
|
||||||
$FALLBACK = $app->get_no_js_fallback();
|
$FALLBACK = $app->get_no_js_fallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|<?php require_once(str_replace("\\", "/", dirname(__FILE__)) . "/inc/init.php"); ?>
|
|<?php require_once(str_replace("\\", "/", dirname(__FILE__)) . "/inc/init.php"); ?>
|
||||||
|
|
||||||
- var href = "<?php echo $HREF; ?>"
|
- var href = "<?php echo $HREF; ?>"
|
||||||
- var json = "<?php echo $JSON; ?>"
|
|
||||||
- var fallback = "<?php echo $FALLBACK; ?>"
|
- var fallback = "<?php echo $FALLBACK; ?>"
|
||||||
|
|
||||||
doctype 5
|
doctype 5
|
||||||
|
@ -21,9 +20,9 @@ html.no-js( lang="en" )
|
||||||
link( rel="apple-touch-icon", type="image/png", href!="#{href}client/images/app-48x48.png" )
|
link( rel="apple-touch-icon", type="image/png", href!="#{href}client/images/app-48x48.png" )
|
||||||
link( rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic|Ubuntu:400,700,400italic,700italic" )
|
link( rel="stylesheet", href="//fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic,700italic|Ubuntu:400,700,400italic,700italic" )
|
||||||
link( rel="stylesheet", href!="#{href}client/css/styles.css" )
|
link( rel="stylesheet", href!="#{href}client/css/styles.css" )
|
||||||
script( src!="#{href}client/js/scripts.js", data-mode="php" )
|
script( src!="#{href}client/js/scripts.js" )
|
||||||
|
|
||||||
body#h5ai-main
|
body
|
||||||
|
|
||||||
div#topbar.clearfix
|
div#topbar.clearfix
|
||||||
ul#navbar
|
ul#navbar
|
||||||
|
@ -44,6 +43,4 @@ html.no-js( lang="en" )
|
||||||
span.right
|
span.right
|
||||||
span.center
|
span.center
|
||||||
|
|
||||||
div#data-generic-json.hidden !{json}
|
div#no-js-fallback.hideOnJs !{fallback}
|
||||||
|
|
||||||
div#data-php-no-js-fallback.hideOnJs !{fallback}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue