Reformatting code (moving javascript to own file)

This commit is contained in:
slawkens 2021-06-08 07:43:06 +02:00
parent 14870d74df
commit 9b84532e57
2 changed files with 43 additions and 42 deletions

View File

@ -0,0 +1,42 @@
<?php
$menus = get_template_menus();
function get_template_pages($category) {
global $menus;
$ret = array();
foreach($menus[$category] as $menu) {
$ret[] = $menu['link'];
}
return $ret;
}
?>
var category = '<?php
if(strpos(URI, 'subtopic=') !== false) {
$tmp = array($_REQUEST['subtopic']);
}
else {
$tmp = URI;
if(empty($tmp)) {
$tmp = array('news');
}
else {
$tmp = explode('/', URI);
}
}
if(in_array($tmp[0], get_template_pages(MENU_CATEGORY_NEWS)))
echo 'news';
elseif(in_array($tmp[0], get_template_pages(MENU_CATEGORY_LIBRARY)))
echo 'library';
elseif(in_array($tmp[0], get_template_pages(MENU_CATEGORY_COMMUNITY)))
echo 'community';
elseif(in_array($tmp[0], array_merge(get_template_pages(MENU_CATEGORY_ACCOUNT), array('account'))))
echo 'account';
elseif(in_array($tmp[0], get_template_pages(MENU_CATEGORY_SHOP)))
echo 'shops';
else {
echo 'news';
}
?>';

View File

@ -13,48 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
</script>
<script type="text/javascript" src="tools/basic.js"></script>
<script type="text/javascript">
<?php
$menus = get_template_menus();
function get_template_pages($category) {
global $menus;
$ret = array();
foreach($menus[$category] as $menu) {
$ret[] = $menu['link'];
}
return $ret;
}
?>
var category = '<?php
if(strpos(URI, 'subtopic=') !== false) {
$tmp = array($_REQUEST['subtopic']);
}
else {
$tmp = URI;
if(empty($tmp)) {
$tmp = array('news');
}
else {
$tmp = explode('/', URI);
}
}
if(in_array($tmp[0], get_template_pages(MENU_CATEGORY_NEWS)))
echo 'news';
elseif(in_array($tmp[0], get_template_pages(MENU_CATEGORY_LIBRARY)))
echo 'library';
elseif(in_array($tmp[0], get_template_pages(MENU_CATEGORY_COMMUNITY)))
echo 'community';
elseif(in_array($tmp[0], array_merge(get_template_pages(MENU_CATEGORY_ACCOUNT), array('account'))))
echo 'account';
elseif(in_array($tmp[0], get_template_pages(MENU_CATEGORY_SHOP)))
echo 'shops';
else {
echo 'news';
}
?>';
<?php require 'javascript.php'; ?>
</script>
<?php echo template_place_holder('head_end'); ?>
</head>