<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Trilium</title>
  </head>
  <body>
    <div id="loader-wrapper"><div id="loader"></div></div>

    <div id="container" style="display: none;">
      <div id="header" class="hide-toggle">
        <div id="header-title">
          <img src="images/app-icons/png/24x24.png">

          Trilium
        </div>

        <div style="flex-grow: 100;">
          <button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button>
          <button class="btn btn-xs" onclick="recentNotes.showDialog();">Recent notes</button>
          <button class="btn btn-xs" onclick="jumpToNote.showDialog();">Jump to note</button>
          <button class="btn btn-xs" onclick="eventLog.showDialog();">Event log</button>
        </div>

        <div>
          <button class="btn btn-xs" onclick="syncNow();">Sync now (<span id="changes-to-push-count">0</span>)</button>

          <button class="btn btn-xs" onclick="settings.showDialog();">Settings</button>

          <form action="logout" method="POST" style="display: inline;">
            <input type="submit" class="btn btn-xs" value="Logout">
          </form>
        </div>
      </div>

      <div class="hide-toggle" style="grid-area: tree-actions;">
        <div style="display: flex; justify-content: space-around; padding: 10px 0 10px 0; margin: 0 20px 0 20px; border: 1px solid #ccc;">
          <a onclick="noteTree.createNewTopLevelNote()" title="Create new top level note" class="icon-action">
            <img src="images/icons/file-plus.png" alt="Create new top level note"/>
          </a>

          <a onclick="noteTree.collapseTree()" title="Collapse tree" class="icon-action">
            <img src="images/icons/list.png" alt="Collapse tree"/>
          </a>

          <a onclick="noteTree.scrollToCurrentNote()" title="Scroll to current note" class="icon-action">
            <img src="images/icons/crosshair.png" alt="Collapse tree"/>
          </a>

          <a onclick="searchTree.toggleSearch()" title="Search in notes" class="icon-action">
            <img src="images/icons/search.png" alt="Search in notes"/>
          </a>
        </div>

        <div id="search-box" style="display: none; padding: 10px; margin-top: 10px;">
          <p>
            <label>Search:</label>
            <input name="search-text" autocomplete="off">
            <button id="reset-search-button">&times;</button>
            <span id="matches"></span>
          </p>
        </div>
      </div>

      <div id="tree" class="hide-toggle" style="grid-area: tree; overflow: auto;">
      </div>

      <div id="parent-list">
      </div>

      <div class="hide-toggle" style="grid-area: title;">
        <div style="display: flex; align-items: center;">
          <a onclick="protected_session.protectNoteAndSendToServer()"
             title="Protect the note so that password will be required to view the note"
             class="icon-action"
             id="protect-button"
             style="display: none;">
            <img src="images/icons/lock.png" alt="Protect note"/>
          </a>

          <a onclick="protected_session.unprotectNoteAndSendToServer()"
             title="Unprotect note so that password will not be required to access this note in the future"
             class="icon-action"
             id="unprotect-button"
             style="display: none;">
            <img src="images/icons/unlock.png" alt="Unprotect note"/>
          </a>

          &nbsp;

          <input autocomplete="off" value="" id="note-title" style="font-size: x-large; border: 0; flex-grow: 100;" tabindex="1">

          <button class="btn btn-xs" onclick="noteHistory.showCurrentNoteHistory();">History</button>
        </div>
      </div>

      <div style="overflow: auto; grid-area: note-content; padding-left: 10px;">
        <div id="note-detail"></div>
      </div>
    </div>

    <div id="recent-notes-dialog" title="Recent notes" style="display: none;">
      <select id="recent-notes-select-box" size="20" style="width: 100%">
      </select>

      <br/><br/>

      <p>
        <button class="btn btn-sm" id="recent-notes-jump-to">Jump to (enter)</button>
        &nbsp;
        <button class="btn btn-sm" id="recent-notes-add-link">Add link (l)</button>

        <button class="btn btn-sm" id="recent-notes-add-current-as-child">Add current as child (c)</button>

        <button class="btn btn-sm" id="recent-notes-add-recent-as-child">Add recent as child (r)</button>
      </p>
    </div>

    <div id="insert-link-dialog" title="Insert link" style="display: none;">
      <form id="insert-link-form">
        <div class="form-group">
          <label for="note-autocomplete">Link to note</label>
          <input id="note-autocomplete" style="width: 100%;">
        </div>

        <div class="form-group">
          <label for="link-title">Link title</label>
          <input id="link-title" style="width: 100%;">
        </div>

        <button class="btn btn-sm">Add link</button>
      </form>
    </div>

    <div id="jump-to-note-dialog" title="Jump to note" style="display: none;">
      <form id="jump-to-note-form">
        <div class="form-group">
          <label for="jump-to-note-autocomplete">Jump to note</label>
          <input id="jump-to-note-autocomplete" style="width: 100%;">
        </div>

        <button name="action" value="jump" class="btn btn-sm">Jump</button>

        <button name="action" value="add-link" class="btn btn-sm">Add link</button>

        <button name="action" value="add-current-as-child" class="btn btn-sm">Add current as child</button>

        <button name="action" value="add-selected-as-child" class="btn btn-sm">Add selected as child</button>
      </form>
    </div>

    <div id="protected-session-password-dialog" title="Protected session" style="display: none;">
      <form id="protected-session-password-form">
        <div class="form-group">
          <label for="protected-session-password">To proceed with requested action you need to enter protected session by entering password:</label>
          <input id="protected-session-password" style="width: 250px;" type="password">
          <button class="btn btn-sm">Show</button>
        </div>
      </form>
    </div>

    <div id="settings-dialog" title="Settings" style="display: none;">
      <div id="settings-tabs">
        <ul>
          <li><a href="#change-password">Change password</a></li>
          <li><a href="#protected-session-timeout">Protected session</a></li>
          <li><a href="#history-snapshot-time-interval">History snapshots</a></li>
          <li><a href="#sync">Sync</a></li>
          <li><a href="#about">About Trilium</a></li>
        </ul>
        <div id="change-password">
          <form id="change-password-form">
            <div class="form-group">
              <label for="old-password">Old password</label>
              <input class="form-control" id="old-password" type="password">
            </div>

            <div class="form-group">
              <label for="new-password1">New password</label>
              <input class="form-control" id="new-password1" type="password">
            </div>

            <div class="form-group">
              <label for="new-password2">New password once more</label>
              <input class="form-control" id="new-password2" type="password">
            </div>

            <button class="btn btn-sm">Change password</button>
          </form>
        </div>
        <div id="protected-session-timeout">
          <p>Protected session timeout is a time period after which the protected session is wiped out from
            browser's memory. This is measured from the last interaction with protected notes.</p>

          <form id="protected-session-timeout-form">
            <div class="form-group">
              <label for="protected-session-timeout-in-seconds">Protected session timeout (in seconds)</label>
              <input class="form-control" id="protected-session-timeout-in-seconds" type="number">
            </div>

            <button class="btn btn-sm">Save</button>
          </form>
        </div>
        <div id="history-snapshot-time-interval">
          <p>History snapshot time interval is time in seconds after which new history record will be created for the note.</p>

          <form id="history-snapshot-time-interval-form">
            <div class="form-group">
              <label for="history-snapshot-time-interval-in-seconds">History snapshot time interval (in seconds)</label>
              <input class="form-control" id="history-snapshot-time-interval-in-seconds" type="number">
            </div>

            <button class="btn btn-sm">Save</button>
          </form>
        </div>
        <div id="sync">
          <button id="force-full-sync-button" class="btn btn-sm">Force full sync</button>
        </div>
        <div id="about">
          <table class="table">
            <tr>
              <th>App version:</th>
              <td id="app-version"></td>
            </tr>

            <tr>
              <th>DB version:</th>
              <td id="db-version"></td>
            </tr>

            <tr>
              <th>Build date:</th>
              <td id="build-date"></td>
            </tr>

            <tr>
              <th>Build revision:</th>
              <td><a href="" target="_blank" id="build-revision"></a></td>
            </tr>
          </table>
        </div>
      </div>
    </div>

    <div id="note-history-dialog" title="Note history" style="display: none;">
      <div style="display: flex;">
        <select id="note-history-list" size="25" style="width: 150px; height: 630px;">
        </select>

        <div id="note-history-content-wrapper" style="flex-grow: 1; margin-left: 20px;">
          <h3 id="note-history-title" style="margin: 3px;"></h3>

          <div id="note-history-content" style="height: 600px; width: 600px; overflow: auto;"></div>
        </div>
      </div>
    </div>

    <div id="recent-changes-dialog" title="Recent changes" style="display: none; padding: 20px;">
    </div>

    <div id="event-log-dialog" title="Event log" style="display: none; padding: 20px;">
      <ul id="event-log-list"></ul>
    </div>

    <div id="edit-tree-prefix-dialog" title="Edit tree prefix" style="display: none; padding: 20px;">
      <form id="edit-tree-prefix-form">
        <div class="form-group">
          <label for="tree-prefix-input">Prefix</label>
          <input id="tree-prefix-input" style="width: 20em;"> - <span id="tree-prefix-note-title"></span>
        </div>

        <button name="action" class="btn btn-sm">Save</button>
      </form>
    </div>

    <div id="tooltip" style="display: none;"></div>

    <script type="text/javascript">
      const baseApiUrl = 'api/';
    </script>

    <!-- Required for correct loading of scripts in Electron -->
    <script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>

    <script src="libraries/jquery.min.js"></script>

    <!-- bootstrap needs to be included before jQuery UI, otherwise close icon in the dialog will be missing -->
    <link href="libraries/bootstrap/css/bootstrap.css" rel="stylesheet">
    <script src="libraries/bootstrap/js/bootstrap.js"></script>

    <link href="libraries/jqueryui/jquery-ui.min.css" rel="stylesheet">
    <script src="libraries/jqueryui/jquery-ui.min.js"></script>

    <script src="libraries/bootstrap-notify.min.js"></script>

    <!-- Include Fancytree skin and library -->
    <link href="libraries/fancytree/skin-win8/ui.fancytree.css" rel="stylesheet">
    <script src="libraries/fancytree/jquery.fancytree-all.js"></script>

    <script src="libraries/ckeditor/ckeditor.js"></script>

    <script src="libraries/jquery.hotkeys.js"></script>
    <script src="libraries/jquery.fancytree.hotkeys.js"></script>

    <script src="libraries/jquery.ui-contextmenu.min.js"></script>

    <link href="stylesheets/style.css" rel="stylesheet">

    <script src="javascripts/utils.js"></script>
    <script src="javascripts/init.js"></script>
    <script src="javascripts/server.js"></script>

    <!-- Tree scripts -->
    <script src="javascripts/note_tree.js"></script>
    <script src="javascripts/tree_changes.js"></script>
    <script src="javascripts/tree_utils.js"></script>
    <script src="javascripts/drag_and_drop.js"></script>
    <script src="javascripts/context_menu.js"></script>
    <script src="javascripts/search_tree.js"></script>

    <!-- Note detail -->
    <script src="javascripts/note_editor.js"></script>
    <script src="javascripts/protected_session.js"></script>

    <!-- dialogs -->
    <script src="javascripts/dialogs/recent_notes.js"></script>
    <script src="javascripts/dialogs/add_link.js"></script>
    <script src="javascripts/dialogs/jump_to_note.js"></script>
    <script src="javascripts/dialogs/settings.js"></script>
    <script src="javascripts/dialogs/note_history.js"></script>
    <script src="javascripts/dialogs/recent_changes.js"></script>
    <script src="javascripts/dialogs/event_log.js"></script>
    <script src="javascripts/dialogs/edit_tree_prefix.js"></script>

    <script src="javascripts/link.js"></script>
    <script src="javascripts/sync.js"></script>
    <script src="javascripts/messaging.js"></script>
  </body>
</html>