<?php
/*
 @copyright 2021 Double Bastion LLC <www.doublebastion.com>

 @author Double Bastion LLC

 @license GNU AGPL version 3 or any later version

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 License as published by the Free Software Foundation; either
 version 3 of the License, or 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 AFFERO GENERAL PUBLIC LICENSE for more details.

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



 This is a modified version of the original file "index.html".
 Below is the copyright notice of ctxSip phone (https://github.com/collecttix/ctxSip)
 which also applies to the original "index.html" file, as part of ctxSip phone:


   The MIT License (MIT)

   Copyright (c) 2014 Collecttix

   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.
*/

declare(strict_types=1);
?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
  <title>SIP Trip Phone</title>
  <link rel="icon" href="data:," />
  <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" href="css/font-awesome-4.7.0/css/font-awesome.min.css" />
  <link rel="stylesheet" type="text/css" href="css/ctxSip.css" />
  <script type="text/javascript" src="../js/crypto-js-4.1.1.min.js"></script>
  <script type="text/javascript" src="scripts/jquery-1.11.3.min.js"></script>
  <script type="text/javascript" src="scripts/bootstrap.min.js"></script>
  <script type="text/javascript" src="scripts/moment.min.js"></script>
  <script type="text/javascript" src="scripts/fix-webm-duration.js"></script>
  <script type="text/javascript" src="scripts/sip.min.js"></script>
  <script type="text/javascript" src="scripts/app.js"></script>
</head>

<body id="sipClient">

  <div id="flContainer" class="container-fluid">

    <div class="clearfix sipStatus">
        <div id="txtCallStatus" class="pull-right">&nbsp;</div>
        <div id="txtRegStatus"></div>
        <div id="volumeBtn">
             <button id="btnVol" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown" title="Volume"><i class="fa fa-fw fa-volume-up"></i></button>
             <div class="dropdown-menu volumeDropdown"><input id="sldVolume" type="range" min="0" max="100" value="100" step="1" /></div>
        </div>
    </div>

    <div class="form-group" id="phoneUI">
        <div class="input-group">
            <div class="input-group-btn">
                <button id="dropDownButton" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown" title="Show keypad">
                    <i class="fa fa-th"></i>
                </button>
                <div id="sip-dialpad" class="dropdown-menu">
                  <div id="dialpadWrap">
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="1">1<span>&nbsp;</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="2,A,B,C">2<span>ABC</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="3,D,E,F">3<span>DEF</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="4,G,H,I">4<span>GHI</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="5,J,K,L">5<span>JKL</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="6,M,N,O">6<span>MNO</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="7,P,Q,R,S">7<span>PQRS</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="8,T,U,V">8<span>TUV</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="9,W,X,Y,Z">9<span>WXYZ</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="*">*<span>&nbsp;</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="0,+">0<span>+</span></button>
                    <button type="button" onclick="document.getElementById('dtmfTone').cloneNode(true).play()" class="btn btn-default digit" data-digit="#">#<span>&nbsp;</span></button>
                    <div class="clearfix">&nbsp;</div>
                    <button id="callButton" class="btn btn-success btn-block btnCall" title="Call"><i class="fa fa-phone"></i>Call</button>
                  </div>
                </div>
            </div>
            <div id="selectFromNmbr"><div id="fromNmbrTitle"><i class="fa fa-sign-out" title="'From' number"></i></div><select id="fromNumber" title="Choose a number to call from"></select></div>
            <input type="text" name="number" id="numDisplay" class="form-control text-center input-sm" value="" placeholder="Enter recipient's number" autocomplete="false" title="Recipient" />
            <div id="deleteInput" title="Backspace"></div>
            <div class="input-group-btn input-group-btn-sm">
                 <div id="contactsUsersList" title="Show list of phone numbers of contacts and Nextcloud users"><div id="ctctsUsrsLst" class="contUsrsLst"></div></div>
            </div>
        </div>
    </div>

    <div id="wndSpace" class="well-sip">
        <div id="sip-splash" class="text-muted text-center panel panel-default">
            <div class="panel-body">
                <div class="page-header">
                  <span><img src="images/sip_trip_phone_logo_large.svg" style="display:block;margin:0px auto;width:80px;height:80px" /></span>
                  <h3>SIP Trip Phone</h3>
                </div>
                <p class="lead">To make a call click on the button in the upper-left corner, enter a phone number and press 'Call'.
                   You can also use your keyboard to enter phone numbers and press 'Enter' to make calls.</p>
            </div>
        </div>

        <div id="sip-log" class="panel panel-default">
            <div class="panel-heading">
                <span class="text-muted panel-title">Recent Calls <span class="pull-right" style="cursor:pointer;"><i class="fa fa-trash text-muted sipLogClear" title="Clear log"></i></span></span>
            </div>
            <div id="sip-logitems" class="list-group">
                <p class="text-muted text-center">No recent calls from this browser.</p>
            </div>
        </div>
    </div>

    <div id="mdlError" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">Sip Error</h4>
                </div>
                <div class="modal-body text-center text-danger">
                    <h3><i class="fa fa-3x fa-ban"></i></h3>
                    <p class="lead">Sip registration failed. No calls can be handled.</p>
                </div>
            </div>
        </div>
    </div>

  </div>

  <audio id="ringtone" src="sounds/incoming.ogg" loop></audio>
  <audio id="ringbacktone" src="sounds/outgoing.ogg" loop></audio>
  <audio id="dtmfTone" src="sounds/dtmf.ogg" preload></audio>
  <audio id="warnUser" src="sounds/warnrec.ogg" preload></audio>

  <video id="outputVideo"></video>
  <audio id="outputAudio"></audio>

</body>
</html>
