<!--
-
-
-
- Copyright (C) 2019 Xilinx, Inc.  All rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy of
- this software and associated documentation files (the "Software"), to deal in
- the Software without restriction, including without limitation the rights to
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
- of the Software, and to permit persons to whom the Software is furnished to do
- so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Author: Michael Chyziak <chyziak@xilinx.com>
-
-->


{% extends "Default/default.html" %}
{% block content %}

<div class="page-header">
  <h1 class="display-4"><b>{% block title %}Webpages and Documents{% endblock %}</b></h1>
</div>


<div class="alert alert-success alert-dismissable" style="display: {{ file_good }}">
  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong>Successfully uploaded file</strong>
</div>

<div class="alert alert-danger alert-dismissable" style="display: {{ file_bad }}">
  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong>Failed to upload file</strong>
</div>

<div class="well">
  <p>On this page you can select a variety of different custom HTML pages and PDF documents created or uploaded by you.</p>
</div>

<form action="pages_documents.html" method="post" enctype="multipart/form-data">
  <div class="form-group">
    <label for="inputfile">Upload HTML Page or Document</label>
    <input type="file" name="file" class="form-control-file" id="inputfile" aria-describedby="fileHelp">
  </div>
  <button type="submit" class="btn btn-primary">Upload</button>
</form>
<br>

<table class="table table-bordered">
  <thead>
    <tr>
      <th>Custom Webpage or Document</th>
    </tr>
  </thead>
  <tbody id="table-id">
    <script>
      var file_list = ['{{ ', '.join(files) }}'];
      file_list = file_list[0].split(", ");
      var table = document.getElementById("table-id");
      for (var i = 0; i < file_list.length; i++) {
	var row = table.insertRow(0);
	var cell1 = row.insertCell(0);
	var link = document.createElement("a");
	link.setAttribute("href", "/static/pages_documents/"+file_list[i]);
	link.setAttribute("target", "iframe-webpage");
	link.innerHTML = file_list[i];
	cell1.appendChild(link);
      }
    </script>
  </tbody>
</table>

<div class="embed-responsive embed-responsive-16by9">
  <iframe class="embed-responsive-item" name="iframe-webpage">
    <p>Your browser does not support iframes.</p>
  </iframe>
</div>


{% endblock %}
