<!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>goRoku Controller</title>
        <!--<link rel="stylesheet" href="static/css/foundation.css">-->
        <link rel="stylesheet" href="css/foundation.css">
    </head>
    <body>
        <div class="grid-x">
            <h1 class="large-12 medium-12 small-12 cell text-center">goRoku Controller</h1>
            <div class="large-12 medium-12 small-12 cell text-center">
                <h3 id="at">TV</h3>
                <p>
                    <button type="button" class="alert button" onclick="sendCommandTV('power')">Power</button> <button type="button" class="alert button" onclick="sendCommandTV('display')">Display</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')">V</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('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>
                    <br>
                    <button type="button" class="button" onclick="sendCommandTV('pluto')">Pluto Tv</button> <br><!--
                    <button type="button" class="button" onclick="sendCommandTV('pluto-cops')">Cops</button> <button type="button" class="button" onclick="sendCommandTV('pluto-thefirst')">The First</button> <button type="button" class="button" onclick="sendCommandTV('pluto-mst3k')">MST3K</button><br>
                    <button type="button" class="button" onclick="sendCommandTV('pluto-rifftrax')">Riff Trax</button> <button type="button" class="button" onclick="sendCommandTV('pluto-startrek')">Star Trek</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.onreadystatechange = function() {
                    if (this.readyState == 4 && this.status == 200 && cmd == "display") {
                     document.getElementById("at").innerHTML = this.responseText;
                    }
                  };
                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>
