<!DOCTYPE html>
<html>

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
    crossorigin="anonymous">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
    crossorigin="anonymous"></script>
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1"
    crossorigin="anonymous">

  <link rel="stylesheet" type="text/css" href="{{root_path}}mi2template.css">
  <link rel="stylesheet" type="text/css" href="{{root_path}}style.css">
  {{#extra_css}}
  <link rel="stylesheet" type="text/css" href="{{.}}">
  {{/extra_css}}

  <script>
    function makeHelpPanel(help_link, docs_link) {
      return '\
            <div class="help-panel">\
              <div class="title"><i class="fa fa-question" aria-hidden="true"></i> Helpful resources</div>\
              <a href="' + docs_link + '" target="_blank">Technical documentation</a>\
              <a href="' + help_link + '" target="_blank">Business description</a>\
            </div>\
            ';
    };

    function renderHelpPanels() {
      var panel = document.getElementsByTagName("help-panel")[0];

      while(panel) {
        var docs_url = panel.attributes["docs-url"].value; 
        var help_url = panel.attributes["help-url"].value;
        
        var html = makeHelpPanel(help_url, docs_url);
        panel.outerHTML = html;

        panel = document.getElementsByTagName("help-panel")[0]; 
        // Not iterating the result because it changes after each iteration
      }
    }

    $(document).ready(function(){
      renderHelpPanels();
    });
  </script>
</head>

<body>

  <div class="container template-home">

    <header>
      <div class="navbar navbar-default navbar-fixed-top navbar-mi2" role="navigation">
        <div class="container">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            </a>
            <a class="navbar-brand navbar-mi2" href="{{root_path}}index.html">modelDown</a>
          </div>
          <div id="navbar" class="navbar-collapse collapse">
            <ul class="navbar-mi2 nav navbar-nav">
              <li>
                <a href="{{root_path}}index.html">
                  <span class="fa fa-home fa-lg"></span>

                </a>
              </li>

              {{#menu_links}}
              <li>
                  <a href="{{root_path}}{{link}}">{{name}}</a>
              </li>
              {{/menu_links}}
            </ul>
            <ul class="nav navbar-nav navbar-right"></ul>
          </div>
          <!--/.nav-collapse -->
        </div>
        <!--/.container -->
      </div>
      <!--/.navbar -->
    </header>

    <div class="row" style="position: relative; margin-bottom:60px;">
      {{&content}}
    </div>


  <footer>
    <div class="footer">
      <div class="text-center">Site built with <a href="https://github.com/MI2DataLab/modelDown">modelDown</a>.</div>
      <div class="text-center" style="margin: 0px 0px 5px;">Last updated: {{datetime}} (session_info: <a href="session_info/session_info.txt">.txt</a>, <a href="session_info/session_info.rda">.rda</a>)</div>
    </div>
  </footer>

  </div>

</body>
</html>
