<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>{{ title }}</title>
  <link rel="icon" href="favicon.ico">
  <!-- bulma -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
  <!-- vue.js 3 -->
  <script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
  <!-- markdown converter to html (cdn) -->
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</head>

<body>

<div class="container" id="app">

<h1 class="title">Index</h1>
{% if not no_mark %}
<h2 class="subtitle is-6">generated by <a href="https://github.com/byoso/madoc/wiki" target="_blank">Madoc </a>- {{ date_created }}</h2>
{% endif %}


<div class="mt-1">
  <span class="visibilityButton is-small mr-4" @click="switchAllVisibility()">+/- all</span>
</div>
<br>
<nav>

{% for  stage in datas %}
  {% if stage.directory %}
  <div class="">
    {% if stage.files %}
      {% if stage.foldable %}
      <span class="visibilityButton is-small mr-4" @click="switchVisibility('{{stage.id}}')">+/-</span>
      {% else %}
      <span class="noVisibilityButton is-small mr-4">+/-</span>
      {% endif %}
      <a href="documentation.madoc.html">{{ title }}</a>
    {% endif %}

  </div>
    <ul id="{{ stage.id }}" class="hiddable">
      {% for file in stage.files %}
        <li class="is-size-7">{{ file[:-3] }}</li>
      {% endfor %}
    </ul>
  {% endif %}

  {% if stage.subdirs %}
  <div style="margin-left:20px;">
    {% with datas=stage.subdirs, base_dir="." %}
      {% include 'madoc/_recursive_menu.html' %}
    {% endwith %}
  </div>
  {% endif %}

{% endfor %}

</nav>
</div>

</body>

<script>
  const { createApp } = Vue

  createApp({
    delimiters: ['[[', ']]'],
    data() {
      return {
        allVisible: false,
      }
    },
    computed: {
    },
    methods: {
      switchAllVisibility() {
        let els = document.getElementsByClassName('hiddable')
        this.allVisible = !this.allVisible
        for (let i = 0; i < els.length; i++) {
          if (this.allVisible) {
            els[i].style.display = 'block'
          } else {
            els[i].style.display = 'none'
          }
        }
      },
      switchVisibility(id) {
        let el = document.getElementById(id)
        if (el.style.display === 'none') {
          el.style.display = 'block'
        } else {
          el.style.display = 'none'
        }
      },
    },
    mounted(){
        let els = document.getElementsByClassName('hiddable')
        for (let i = 0; i < els.length; i++) {
          if (this.allVisible) {
            els[i].style.display = 'block'
          } else {
            els[i].style.display = 'none'
          }
        }
    }
  }).mount('#app')
</script>

<style scoped>
.menu {
  position: sticky;
  display: inline-block;
  vertical-align: top;
  max-height: 100vh;
  overflow-y: auto;
  min-width: 400px;
  top: 0;
  bottom: 0;
  padding: 30px;
}

.content {
  display: inline-block;
  width: 80%;
  overflow-x: scroll;

}

html {
    background-color: {{ bg_color }};
}

body {
    font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #111;
    -webkit-text-size-adjust: 100%;
    -webkit-font-feature-settings: "kern" 1;
    -moz-font-feature-settings: "kern" 1;
    -o-font-feature-settings: "kern" 1;
    font-feature-settings: "kern" 1;
    font-kerning: normal;
    padding: 30px;
}


.button.has-text-left {
  justify-content: flex-start;
}

.index {
  font-size: 1.2em;
  font-weight: bold;
}

@media only screen and (max-width: 600px) {
    body {
        padding: 5px;
    }
    body>#content {
        padding: 0px 20px 20px 20px !important;
    }
}

.visibilityButton {
  cursor: pointer;
  border: 1px solid black;
  padding: 2px;
  user-select: none;
}

.noVisibilityButton {
  border: 1px solid rgb(200, 200, 200);
  color : rgb(200, 200, 200);
  padding: 2px;
  user-select: none;
}

body>#content {
    margin: 0px;
    max-width: 900px;
    border: 1px solid #e1e4e8;
    padding: 10px 40px;
    padding-bottom: 20px;
    border-radius: 2px;
    margin-left: auto;
    margin-right: auto;
}

summary {
    cursor: pointer;
    text-decoration: underline;
}

hr {
    color: #bbb;
    background-color: #bbb;
    height: 1px;
    flex: 0 1 auto;
    margin: 1em 0;
    padding: 0;
    border: none;
}


/**
 * Links
 */

a {
    color: #0366d6;
    text-decoration: none;
}

a:visited {
    color: #0366d6;
}

a:hover {
    color: #0366d6;
    text-decoration: underline;
}

pre {
    background-color: #dbdbdb;
    font-size: 1.1em;
    border-radius: 3px;
    line-height: 1.45;
    overflow: auto;
    padding: 16px;
}


/**
  * Code blocks
  */

code {
    background-color: rgba(27, 31, 35, .05);
    border-radius: 3px;
    font-size: 85%;
    margin: 0;
    word-wrap: break-word;
    padding: .2em .4em;
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace;
}

pre>code {
    background-color: transparent;
    border: 0;
    display: inline;
    line-height: inherit;
    margin: 0;
    overflow: visible;
    padding: 0;
    word-wrap: normal;
    font-size: 100%;
}


/**
 * Blockquotes
 */

blockquote {
    margin-left: 30px;
    margin-top: 0px;
    margin-bottom: 16px;
    border-left-width: 3px;
    padding: 0 1em;
    color: #828282;
    border-left: 4px solid #e8e8e8;
    padding-left: 15px;
    font-size: 18px;
    letter-spacing: -1px;
    font-style: italic;
}

blockquote * {
    font-style: normal !important;
    letter-spacing: 0;
    color: #6a737d !important;
}


/**
 * Tables
 */

table {
    border-spacing: 2px;
    display: block;
    font-size: 14px;
    overflow: auto;
    width: 100%;
    margin-bottom: 16px;
    border-spacing: 0;
    border-collapse: collapse;
}

td {
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

th {
    font-weight: 600;
    padding: 6px 13px;
    border: 1px solid #dfe2e5;
}

tr {
    background-color: #fff;
    border-top: 1px solid #c6cbd1;
}

table tr:nth-child(2n) {
    background-color: #f6f8fa;
}


/**
 * Others
 */

img {
    max-width: 100%;
}

p {
    line-height: 24px;
    font-weight: 400;
    font-size: 16px;
    color: #24292e;
}

ul {
    margin-top: 0;
}

li {
    color: #24292e;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
}

li+li {
    margin-top: 0.25em;
}

* {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    color: #24292e;
}

a:visited {
    color: #0366d6;
}

h1,
h2,
h3 {
    border-bottom: 1px solid #eaecef;
    color: #111;
    /* Darker */
}

code>* {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace !important;
}

</style>

</html>
