<!DOCTYPE html>
<!--
    SPDX-License-Identifier: GPL-3.0-or-later OR CC-BY-SA-4.0

    Haketilo's settings page

    This file is part of Haketilo.

    Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>

    File is dual-licensed. You can choose either GPLv3+, CC BY-SA or both.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.

    I, Wojtek Kosior, thereby promise not to sue for violation of this file's
    licenses. Although I request that you do not make use of this code in a
    proprietary program, I am not going to enforce this in court.
  -->
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Haketilo options</title>
#LOADCSS html/reset.css
#LOADCSS html/base.css
#LOADCSS html/grid.css
    <style>
      .full_page_msg {
	  margin: auto;
	  padding: 1em;
	  max-width: 800px;
      }
      .full_page_msg p {
	  margin-bottom: 1em;
      }

      /* Style top menu items. */
      #tab_heads>* {
	  background-color: #70AF70;
	  font-size: 115%;
	  padding: 0.6em;
	  display: inline-block;
	  cursor: pointer;
	  margin: 0.25em 0 0 0;
      }
      body {
	  /* 0.25em margin + 1em height + 2*0.6em padding, multiple font size */
	  --heading-height: calc(2.45em * 1.15);
	  --tab-content-height: calc(100vh - var(--heading-height));
      }
      #tab_heads>:hover {
	  box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
      }
      #tab_heads>.active_head {
	  background-color: #65A065;
	  color: #222;
	  box-shadow: none;
	  cursor: default;
      }

      /* Style the top menu itself. */
      #tab_heads {
	  -moz-user-select: none;
	  user-select: none;
	  background-color: #e0e0e0;
      }
      #top_menu_line {
	  position: absolute;
	  width: 100vw;
	  z-index: 1;
      }

      /* Style content */
      body {
	  --content-max-width: 1000px;
	  height: 100vh;
	  overflow-x: hidden;
	  overflow-y: hidden;
      }
      div.tab {
	  display: none;
      }
      div.tab.active_tab {
	  display: block;
      }

      /* Style the Script blocking and Repositories tabs. */
      #blocking_list_container, #allowing_list_container,
      #default_policy_dialog, #blocking_dialog_container,
      #repos_list_container, #repos_dialog_container {
	  padding: 0.8em 0.4em 0.4em 0.4em;
      }
      #blocking_editable_container, #blocking_dialog_container,
      #repos_list_container, #repos_dialog_container {
	  max-width: var(--content-max-width);
	  margin: 0 auto;
      }
      #blocking_editable_container {
	  /* Leave space for default policy dialog and headings. */
	  --content-height: calc(var(--tab-content-height) - 3em);
      }

      /* Pass height information to html in all tabs. */
      .tab {
	  --content-height: var(--tab-content-height);
      }
    </style>
  </head>
  <body>
    <!-- Those contain just templates, we can include them at the top -->
#INCLUDE html/dialog.html
#INCLUDE html/item_list.html
#INCLUDE html/item_preview.html
#INCLUDE html/text_entry_list.html
#INCLUDE html/payload_create.html
    <div id="loader" class="full_page_msg">
      <p>
	Loading settings page...
      </p>
    </div>
    <div id="indexeddb_error" class="hide full_page_msg">
      <p>
	Cannot display settings page.
      </p>
      <p>
	Haketilo could not access IndexedDB. IndexedDB is an in-browser
	database in which Haketilo stores all its configuration. Without it, the
	settings page is non-operational.
      <p>
    </div>
#IF MOZILLA
    <div id="private_mode_error" class="hide full_page_msg">
      <p>
	The settings page could not be displayed in a private window.
      </p>
      <p>
	Due to bug <a href="https://hydrillabugs.koszko.org/issues/115">#115</a>
	it is currently impossible to access Haketilo settings when in Private
	Browsing mode. You can instead open this settings page in a non-private
	window. Changes you make there shall affect websites browsed in Private
	Mode as well.
      </p>
    </div>
#ENDIF
    <div id="main_view" class="hide">
      <ul id="tab_heads">
	<li id="blocking_head"> Blocking </li>
	<li id="mappings_head"> Mappings </li>
	<li id="resources_head"> Resources </li>
	<li id="new_payload_head" class="active_head"> New payload </li>
	<li id="repos_head"> Repositories </li>
      </ul>
      <div id="top_menu_line" class="top_line"></div>
      <div id="blocking_tab" class="tab">
	<div id="blocking_editable_container" class="grid_2">
	  <div id="blocking_list_container">
	    <h3>Block scripts on</h3>
	  </div>
	  <div id="allowing_list_container">
	    <h3>Allow scripts on</h3>
	  </div>
	  <div id="default_policy_dialog" class="grid_col_both text_center">
#INCLUDE html/default_blocking_policy.html
	  </div>
	</div>
	<div id="blocking_dialog_container" class="hide"></div>
      </div>
      <div id="mappings_tab" class="tab"></div>
      <div id="resources_tab" class="tab"></div>
      <div id="new_payload_tab" class="tab active_tab"></div>
      <div id="repos_tab" class="tab">
	<div id="repos_list_container"></div>
	<div id="repos_dialog_container" class="hide"></div>
      </div>
    </div>
#LOADJS html/settings.js
  </body>
</html>