Skip to content
Snippets Groups Projects
Commit 070248ac authored by echicken's avatar echicken :chicken:
Browse files

Added loadComponent function. Should load and output the named

component (xjs) file from webv4/mods/components/ if available,
or from webv4/components if available there, or output nothing
at all (and return false) otherwise. Semi-tested, the best kind
of tested.
parent 4c185470
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,23 @@
}
?>
<?xjs
function loadComponent(fn) {
return (function () {
const cdir = backslash(fullpath(settings.web_mods + 'components'));
if (file_isdir(cdir) && file_exists(cdir + fn)) {
load(xjs_compile(cdir + fn));
return true;
}
if (file_exists(settings.web_components + fn)) {
load(xjs_compile(settings.web_components + fn));
return true;
}
return false;
})();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
......@@ -49,19 +66,9 @@
<script src="./js/common.js"></script>
<?xjs
(function () {
load(xjs_compile(settings.web_components + 'modal.xjs'));
})();
if (file_exists(settings.web_components + 'header.xjs')) {
(function () {
load(xjs_compile(settings.web_components + 'header.xjs'));
})();
}
(function () {
load(xjs_compile(settings.web_components + 'navbar.xjs'));
})();
loadComponent('modal.xjs');
loadComponent('header.xjs');
loadComponent('navbar.xjs');
?>
<div class="container<?xjs if (settings.layout_full_width) write('-fluid'); ?>">
......@@ -79,17 +86,9 @@
</div>
<hr>
<footer>
<?xjs
if (file_exists(settings.web_components + 'footer.xjs')) {
(function () {
load(xjs_compile(settings.web_components + 'footer.xjs'));
})();
} else {
?>
<?xjs if (!loadComponent('footer.xjs')) { ?>
<p>&copy; <?xjs write(system.name + ", " + strftime("%Y")); ?></p>
<?xjs
}
?>
<?xjs } ?>
</footer>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment