<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>IRremote Controller</title>
        <link rel="stylesheet" href="static/css/foundation.css">
    </head>
    <body>
        <div class="grid-x">
            <h1 class="large-12 medium-12 small-12 cell text-center">IRremote Controller</h1>
            <div class="large-6 medium-6 small-6 cell text-center">
                <h3>TV:</h3>
                <p>
                    <button type="button" class="alert button" onclick="sendCommandTV('power')">Power</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('back')">Back</button> <button type="button" class="button" onclick="sendCommandTV('home')">Home</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('up')">/\</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('left')"><</button> <button type="button" class="success button" onclick="sendCommandTV('ok')">Ok</button> <button type="button" class="button" onclick="sendCommandTV('right')">></button><br>
                    <button type="button" class="button" onclick="sendCommandTV('down')">\/</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('reload')">Reload</button> <button type="button" class="button" onclick="sendCommandTV('star')">*</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('rewind')"><<</button> <button type="button" class="button" onclick="sendCommandTV('play-pause')">Play/Pause</button> <button type="button" class="button" onclick="sendCommandTV('fast-forward')">>></button><br>
                    <button type="button" class="button" onclick="sendCommandTV('vol+')">Vol +</button> <button type="button" class="button" onclick="sendCommandTV('mute')">Vol Mute</button> <button type="button" class="button" onclick="sendCommandTV('vol-')">Vol -</button><br>
                </p>
            </div>
            <div class="large-6 medium-6 small6 cell text-center">
                <h3>MOVIE BOX:</h3>
                <p>
                    <button type="button" class="alert button" onclick="sendCommandMB('power')">Power</button><br>
                    <button type="button" class="button" onclick="sendCommandMB('home')">Home</button> <button type="button" class="button" onclick="sendCommandMB('back')">Back</button><br>
                    <button type="button" class="button" onclick="sendCommandMB('up')">/\</button><br>
                    <button type="button" class="button" onclick="sendCommandMB('left')"><</button> <button type="button" class="success button" onclick="sendCommandMB('ok')">Ok</button> <button type="button" class="button" onclick="sendCommandMB('right')">></button><br>
                    <button type="button" class="button" onclick="sendCommandMB('down')">\/</button><br>
                </p>
            </div>
        </div>
        <script>
            function sendCommandTV(cmd) {
                const xhttp = new XMLHttpRequest();
                xhttp.onload = function() {}
                xhttp.open("GET", "tv/"+cmd, true);
                xhttp.send();
            }
            function sendCommandMB(cmd) {
                const xhttp = new XMLHttpRequest();
                xhttp.onload = function() {}
                xhttp.open("GET", "mb/"+cmd, true);
                xhttp.send();
            }
        </script>
    </body>
</html>