Cleans code.

This commit is contained in:
Lars Jung 2012-10-17 00:17:22 +02:00
parent 70f4500232
commit 396bc6662f
7 changed files with 12 additions and 87 deletions

View File

@ -1,5 +1,5 @@
#data-apache-autoindex, #data-php-no-js-fallback {
#no-js-fallback {
max-width: 960px;
margin: 0 auto 80px auto;

View File

@ -26,7 +26,7 @@
@import "inc/extended-grid";
// @import "inc/context-menu";
@import "inc/dropbox";
@import "inc/fallback-table";
@import "inc/no-js-fallback";
@import "inc/responsive";

View File

@ -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) {
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'));
var entry = Entry.get();
entry.status = '=h5ai=';
return entry;

View File

@ -31,9 +31,7 @@
// @include "inc/**/*.js"
var $ = jQuery,
filename = 'client/js/scripts.js',
$script = $('script[src$="' + filename + '"]'),
mode = $script.data('mode');
mode = $('script[src$="scripts.js"]').data('mode');
if (mode === 'info') {
@ -41,7 +39,7 @@
} 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);
$(function () { modulejs.require('main'); });

View File

@ -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": "正體中文"
}

View File

@ -35,7 +35,6 @@ if (array_key_exists("action", $_REQUEST)) {
} else {
$HREF = $app->get_app_abs_href();
$JSON = $app->get_generic_json();
$FALLBACK = $app->get_no_js_fallback();
}

View File

@ -1,7 +1,6 @@
|<?php require_once(str_replace("\\", "/", dirname(__FILE__)) . "/inc/init.php"); ?>
- var href = "<?php echo $HREF; ?>"
- var json = "<?php echo $JSON; ?>"
- var fallback = "<?php echo $FALLBACK; ?>"
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="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" )
script( src!="#{href}client/js/scripts.js", data-mode="php" )
script( src!="#{href}client/js/scripts.js" )
body#h5ai-main
body
div#topbar.clearfix
ul#navbar
@ -44,6 +43,4 @@ html.no-js( lang="en" )
span.right
span.center
div#data-generic-json.hidden !{json}
div#data-php-no-js-fallback.hideOnJs !{fallback}
div#no-js-fallback.hideOnJs !{fallback}