
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>TBuddy | aheadmin &copy; aheadware GmbH</title>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="font-awesome/css/font-awesome.css" rel="stylesheet">

    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

</head>

<body class="">

<!-- start: Templates -->

<?php

// Include all templates
$pagesPath = __DIR__ . '/tmpl/';

// Create recursive dir iterator which skips dot folders
$dir = new RecursiveDirectoryIterator( $pagesPath, FilesystemIterator::SKIP_DOTS );

// Flatten the recursive iterator, folders come before their files
$it  = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST );

// Maximum depth is 1 level deeper than the base folder
$it->setMaxDepth( 1 );

// Write javascript includes
foreach ( $it as $fileinfo ) {

    if ( $fileinfo->isFile() ) {
        echo '<script type="application/x-template" id="tpl_' . $fileinfo->getBasename( ".html" ) . '">' . "\n";
        echo file_get_contents( $pagesPath . $fileinfo->getFilename() );
        echo '</script>' . "\n";
    }
}

?>

<!-- end: Templates -->


<!-- Mainly scripts -->
<script src="js/jquery-2.1.1.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<!-- Custom and plugin javascript -->
<script src="js/inspinia.js"></script>
<script src="js/plugins/toastr/toastr.min.js"></script>
<script src="js/plugins/pace/pace.min.js"></script>

<!-- Application specific libraries -->
<script src="js/libs/moment.js"></script>
<script src="js/libs/AHDF.min.js"></script>

<!-- Application javascript-->

<?php

// Custom code
$incs = array( 'js/app/core', 'js/app/gui', 'js/app/ctrl' );
foreach( $incs as $jspath ) {
    // Create recursive dir iterator which skips dot folders
    $dir = new RecursiveDirectoryIterator( __DIR__ . '/' . $jspath,
        FilesystemIterator::SKIP_DOTS);

    // Flatten the recursive iterator, folders come before their files
    $it  = new RecursiveIteratorIterator($dir,
        RecursiveIteratorIterator::SELF_FIRST);

    // Maximum depth is 1 level deeper than the base folder
    $it->setMaxDepth(1);

    // Get javascript includes
    foreach ($it as $fileinfo) {
        if ($fileinfo->isFile()) {
            echo '<script type="text/javascript" src="' . $jspath . '/' . $fileinfo->getFilename() . '"></script>' . "\n";
        }
    }
}

?>

<script type="text/javascript">
    $(document).ready( function() {
        app.core.App.run();
    });
</script>


</body>

</html>
