Commit 070248ac authored by echicken's avatar echicken 🐔

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
Pipeline #216 passed with stage
in 17 minutes and 53 seconds
......@@ -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 {
?>
<p>&copy; <?xjs write(system.name + ", " + strftime("%Y")); ?></p>
<?xjs
}
?>
<?xjs if (!loadComponent('footer.xjs')) { ?>
<p>&copy; <?xjs write(system.name + ", " + strftime("%Y")); ?></p>
<?xjs } ?>
</footer>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment