Move app script code to a template file

This commit is contained in:
Niko 2022-02-15 19:55:12 +01:00
parent a38470a561
commit 4e43a0adee
2 changed files with 22 additions and 18 deletions

View File

@ -15,24 +15,7 @@
<?php tpl_styles(['themes.'.($theme ?? DEFAULT_THEME)]) ?> <?php tpl_styles(['themes.'.($theme ?? DEFAULT_THEME)]) ?>
<?php tpl_styles($styles ?? null) ?> <?php tpl_styles($styles ?? null) ?>
<script> var env = { <?php tpl('app.js') ?>
prod: '<?php echo PROD ?>' === '<?php echo env() ?>',
dev: '<?php echo DEV ?>' === '<?php echo env() ?>',
}; </script>
<script> var app = {
pages: {},
hashHandlers: [],
vars: {
app_dir: '<?php echo APP_DIR ?>',
js_dir: '<?php echo APP_DIR ?>/js',
defaults: {
icon: '/assets/images/default_profile.png',
meet: {
text_bgcolor: '#93227ce8',
},
},
},
}; </script>
<?php tpl_scripts(['base', 'navmenu', 'carousel', 'app']) ?> <?php tpl_scripts(['base', 'navmenu', 'carousel', 'app']) ?>
<?php tpl_scripts($scripts ?? null) ?> <?php tpl_scripts($scripts ?? null) ?>
</head> </head>

View File

@ -0,0 +1,21 @@
<script>
var env = {
prod: '<?php echo PROD ?>' === '<?php echo env() ?>',
dev: '<?php echo DEV ?>' === '<?php echo env() ?>',
};
var app = {
strings: JSON.parse(atob('<?php echo base64_encode(json_encode(strings())) ?>')),
pages: {},
hashHandlers: [],
vars: {
app_dir: '<?php echo APP_DIR ?>',
js_dir: '<?php echo APP_DIR ?>/js',
defaults: {
icon: '/assets/images/default_profile.png',
meet: {
text_bgcolor: '#93227ce8',
},
},
},
};
</script>