mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-21 21:10:00 +01:00
Clean code.
This commit is contained in:
parent
e497612b6c
commit
9c414c92e2
@ -9,43 +9,37 @@ modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/e
|
||||
|
||||
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
||||
|
||||
var h, f;
|
||||
var has_header, has_footer, data, content;
|
||||
|
||||
if (response) {
|
||||
resource.loadMarkdown(function (md) {
|
||||
|
||||
if (response.custom.header) {
|
||||
if (response.custom.header_type === 'md') {
|
||||
resource.loadMarkdown(function (md) {
|
||||
data = response.custom;
|
||||
|
||||
if (md) {
|
||||
$('#content-header').html(md.toHTML(response.custom.header)).stop().slideDown(200);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#content-header').html(response.custom.header).stop().slideDown(200);
|
||||
if (data.header) {
|
||||
content = data.header;
|
||||
if (md && data.header_type === 'md') {
|
||||
content = md.toHTML(content);
|
||||
}
|
||||
$('#content-header').html(content).stop().slideDown(200);
|
||||
has_header = true;
|
||||
}
|
||||
h = true;
|
||||
}
|
||||
|
||||
if (response.custom.footer) {
|
||||
if (response.custom.footer_type === 'md') {
|
||||
resource.loadMarkdown(function (md) {
|
||||
|
||||
if (md) {
|
||||
$('#content-footer').html(md.toHTML(response.custom.footer)).stop().slideDown(200);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('#content-footer').html(response.custom.footer).stop().slideDown(200);
|
||||
if (data.footer) {
|
||||
content = data.footer;
|
||||
if (md && data.footer_type === 'md') {
|
||||
content = md.toHTML(content);
|
||||
}
|
||||
$('#content-footer').html(content).stop().slideDown(200);
|
||||
has_footer = true;
|
||||
}
|
||||
f = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!h) {
|
||||
if (!has_header) {
|
||||
$('#content-header').stop().slideUp(200);
|
||||
}
|
||||
if (!f) {
|
||||
if (!has_footer) {
|
||||
$('#content-footer').stop().slideUp(200);
|
||||
}
|
||||
});
|
||||
|
@ -4,6 +4,7 @@ class App {
|
||||
|
||||
private static $RE_DELIMITER = "|";
|
||||
private static $ICON_EXTS = array("svg", "png", "jpg");
|
||||
private static $CUSTOM_EXTS = array("html", "md");
|
||||
|
||||
|
||||
private $options;
|
||||
@ -269,7 +270,7 @@ class App {
|
||||
|
||||
private function read_custom_file($path, $name, &$content, &$type) {
|
||||
|
||||
foreach (array("html", "md") as $ext) {
|
||||
foreach (APP::$CUSTOM_EXTS as $ext) {
|
||||
$file = "$path/" . FILE_PREFIX . ".$name.$ext";
|
||||
if (is_readable($file)) {
|
||||
$content = file_get_contents($file);
|
||||
|
Loading…
x
Reference in New Issue
Block a user