SamsungTVController/htdocs/index.html
2022-12-22 03:30:34 -05:00

332 lines
15 KiB
HTML

<!DOCTYPE html>
<html>
<!--Hello! You have found my TV Controller. The API provided in this source is behind a firewall and will be of no use to you. Move along!-->
<head>
<div id="view2"></div>
</head>
<title>Samsung TVController</title>
<style>
body {
background-color: #101010;
color: #ffffff;
}
h1 {
color: #ffffff;
}
nav a {
color: #ffffff;
}
footer {
color: #ffffff;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
<script>
let rootURL = "https://grwh.work:3031"
var timer;
// Youtube Shorts Timer -
function startTimer() {
console.log("Shorts timer started!")
showSuccessAlert("Started Shorts Timer")
timer = setInterval(function () {
console.log("Time is up, going to next short");
fetch(rootURL + "/down")
.then(function (response) {
return response.json();
}).then(function (data) {
console.log("Resonse from AutoScroll Request: " + data)
if (data == 1) {
showSuccessAlert("Next Short Requested Successfully!")
console.log("Command: Next Short - SENT!")
} else {
showSuccessAlert("Next Short Request FAILED!")
console.log("Command: Next Short FAILED!")
}
})
}, 55000);
}
function stopTimer() {
showSuccessAlert("Shorts Timer Disabled!")
clearInterval(timer);
}
function showSuccessAlert(message) {
document.getElementById("view2").innerHTML = "<div class=\"alert alert-success\" role=\"alert\"><CENTER>" + message + "</CENTER></div>";
setInterval(function () {
document.getElementById("view2").innerHTML = "<BR><BR><BR>";
}, 15000);
}
function showFailAlert(message) {
document.getElementById("view2").innerHTML = "<div class=\"alert alert-danger\" role=\"alert\"><CENTER>" + message + "</CENTER></div>";
setInterval(function () {
console.log("60 seconds are up, going to next short");
document.getElementById("view2").innerHTML = "<BR><BR><BR>";
}, 15000);
}
showSuccessAlert("You have logged in successfully!")
let pass = prompt("Enter the password!", "");
let text;
fetch(rootURL + "/checkPass?pass=" + pass)
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == "1") {
if (pass == null || pass == "") {
document.getElementById("view").innerHTML = "WOO"
} else {
document.getElementById("view").innerHTML = "<CENTER><IMG SRC=\"../images/icon.png\"></CENTER><a href=\"javascript:window.open('help.html','Click for Key ShortCuts!','width=600,height=400')\">Click for Key ShortCuts!</a><BR><BR><a href=\"javascript:window.open('input.html','Click to Send Text Imput!','width=600,height=400')\"><button type=\"button\" class=\"btn btn-primary\">Open Text Input</button></a><BR><BR><button type=\"button\" class=\"btn btn-primary\" onclick=\"startTimer()\">Enable AutoScroll</button> / <button type=\"button\" class=\"btn btn-primary\" onclick=\"stopTimer()\"> Disable</button> <BR><BR>Commands Not Working? Issue a new Token using: R";
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
} else if (element.attachEvent) {
element.attachEvent("on" + eventName, callback);
} else {
element["on" + eventName] = callback;
}
}
addEvent(document, "keypress", function (e) {
e = e || window.event;
if (e.key == "w" || e.code == "Numpad8") {
fetch(rootURL + "/up")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("UP Sent Successfully!")
return console.log("Command: UP - SENT!")
} else {
showSuccessAlert("UP FAILED!")
return console.log("Command: UP FAILED!")
}
})
}
if (e.key == "a" || e.code == "Numpad4") {
fetch(rootURL + "/left")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("LEFT Sent Successfully!")
return console.log("Command: LEFT - SENT!")
} else {
showSuccessAlert("LEFT FAILED!")
return console.log("Command: LEFT FAILED!")
}
})
}
if (e.key == "s" || e.key == "2") {
fetch(rootURL + "/down")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("DOWN Sent Successfully!")
return console.log("Command: DOWN - SENT!")
} else {
showSuccessAlert("DOWN FAILED!")
return console.log("Command: DOWN FAILED!")
}
})
}
if (e.key == "d" || e.code == "Numpad6") {
fetch(rootURL + "/right")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("RIGHT Sent Successfully!")
return console.log("Command: RIGHT - SENT!")
} else {
showSuccessAlert("UP FAILED!")
return console.log("Command: RIGHT FAILED!")
}
})
}
if (e.key == "Enter" || e.code == "Numpad5") {
fetch(rootURL + "/enter")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("ENTER Sent Successfully!")
return console.log("Command: ENTER - SENT!")
} else {
showSuccessAlert("ENTER FAILED!")
return console.log("Command: ENTEr FAILED!")
}
})
}
if (e.key == "x" || e.code == "NumpadDecimal") {
fetch(rootURL + "/back")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("BACK Sent Successfully!")
return console.log("Command: BACK - SENT!")
} else {
showSuccessAlert("BACK FAILED!")
return console.log("Command: BACK FAILED!")
}
})
}
if (e.key == "p" || e.code == "NumpadAdd") {
fetch(rootURL + "/volumeUp")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("VOLUME UP Sent Successfully!")
return console.log("Command: VOLUME UP - SENT!")
} else {
showSuccessAlert("VOLUME UP FAILED!")
return console.log("Command: VOLUME UP FAILED!")
}
})
}
if (e.key == "o" || e.code == "NumpadSubtract") {
fetch(rootURL + "/volumeDown")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("VOLUME DOWN Sent Successfully!")
return console.log("Command: VOLUME DOWN - SENT!")
} else {
showSuccessAlert("VOLUME DOWN FAILED!")
return console.log("Command: VOLUME DOWN FAILED!")
}
})
}
if (e.key == "r") {
fetch(rootURL + "/newToken")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("New Token Request Sent Successfully!")
return console.log("Command: New Token Request - SENT!")
} else {
showSuccessAlert("New Token Request FAILED!")
return console.log("Command: New Token Request FAILED!")
}
})
}
if (e.key == "m" || e.code == "Numpad0") {
fetch(rootURL + "/mute")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("Mute Sent Successfully!")
return console.log("Command: BACK - SENT!")
} else {
showSuccessAlert("Mute FAILED!")
return console.log("Command: Mute FAILED!")
}
})
}
if (e.key == "l") {
fetch(rootURL + "/pmode")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("Picture Mode Sent Successfully!")
return console.log("Command: Picutr Mode - SENT!")
} else {
showSuccessAlert("Picture Mode FAILED!")
return console.log("Command: Picture Mode FAILED!")
}
})
}
if (e.key == "h") {
fetch(rootURL + "/home")
.then(function (response) {
return response.json();
})
.then(function (data) {
if (data == 1) {
showSuccessAlert("HOME Sent Successfully!")
return console.log("Command: HOME - SENT!")
} else {
showSuccessAlert("HOME FAILED!")
return console.log("Command: HOME FAILED!")
}
})
}
});
}
} else {
document.getElementById("view").innerHTML = "<meta http-equiv=\"refresh\" content=3;> <CENTER>THE PASSWORD PROVIDED WAS INCORRECT!"
}
})
</script>
</head>
<body>
<center>
<div id="view"></div>
<center>
</body>
</html>