<div class="reveal">
    <!-- Any section element inside of this container is displayed as a slide -->
    <div class="slides">    
<?php
$i=0;
foreach ($slides as $slide) :
    $i++;
    if (isset($slide['closesection']) && $slide['closesection']) {
        echo '</section> <!-- end vertical section -->'."\n";
    }
    if (isset($slide['opensection']) && $slide['opensection']) {
        echo '<section> <!-- vertical section -->'."\n";
    }
?>
    
    <section id="slide<?php echo $i; ?>" >
        <?php
        if (isset($slide['title'])) : ?>
        <h2><?php echo $slide['title']; ?></h2>
        <?php
        endif; ?>
        <?php echo $slide['html']; ?>
      </section>
<?php endforeach; ?>
    </div> <!-- /div.slides -->
</div> <!-- /div.reveal -->

<?php
// parameters for sockets
if (isset($_GET['id'])) {
    $multiplex = true;
} else {
    $multiplex = false;
}

$GLOBALS['wiki']->AddJavascriptFile('tools/templates/libs/vendor/reveal.js/lib/js/head.min.js');
$GLOBALS['wiki']->AddJavascriptFile('tools/templates/libs/vendor/reveal.js/js/reveal.js');
$GLOBALS['wiki']->AddCSSFile('tools/templates/libs/vendor/reveal.js/css/reveal.css');
$GLOBALS['wiki']->AddCSSFile('tools/templates/libs/vendor/reveal.js/css/theme/black.css');

$js = '// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
$(document).ready(function () {
    Reveal.initialize({
        controls: true,
        progress: true,
        history: true,
        center: true,
        '.($multiplex ? 'multiplex: {        
            '.((isset($_GET['secret'])) ? 'secret: \''.$_GET['secret'].'\',' : 'secret: null,')."\n".
            'id: \''.$_GET['id'].'\', // Obtained from socket.io server
            url: \'revealjs.jit.su:80\' // Location of socket.io server
        },' : '').'

        transition: \'slide\', // none/fade/slide/convex/concave/zoom

        // Optional reveal.js plugins
        dependencies: [
            { src: \'tools/templates/libs/vendor/reveal.js/lib/js/classList.js\', condition: function() {
                return !document.body.classList;
            } 
        }'.($multiplex ? ',
            { src: \'//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.10/socket.io.min.js\', async: true },
        { src: \'tools/templates/libs/vendor/reveal.js/plugin/multiplex/'
        .((isset($_GET['secret'])) ? 'master' : 'client').'.js\', async: true }' : '')
        .'
        ]
    });
});';
$GLOBALS['wiki']->AddJavascript($js);
