adding comments

This commit is contained in:
raven
2022-12-22 04:19:27 -05:00
parent 1a9b8532d5
commit 65c7735804
2 changed files with 100 additions and 48 deletions

View File

@ -7,6 +7,7 @@
</head>
<title>Samsung TVController</title>
<!--Styles-->+
<style>
body {
background-color: #101010;
@ -25,16 +26,22 @@
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>
<!--END Styles-->
<!--MAIN JS-->
<script>
// Set API URL
let rootURL = "https://grwh.work:3031"
// Init timer VAR
var timer;
// Youtube Shorts Timer -
// Youtube Shorts Timer - Skip Every 55 Seconds
function startTimer() {
console.log("Shorts timer started!")
showSuccessAlert("Started Shorts Timer")
@ -56,11 +63,13 @@
}, 55000);
}
// Kill the Timer
function stopTimer() {
showSuccessAlert("Shorts Timer Disabled!")
clearInterval(timer);
}
// Settng up success alerts
function showSuccessAlert(message) {
document.getElementById("view2").innerHTML = "<div class=\"alert alert-success\" role=\"alert\"><CENTER>" + message + "</CENTER></div>";
@ -70,6 +79,7 @@
}, 15000);
}
// Setting up Failed Alerts
function showFailAlert(message) {
document.getElementById("view2").innerHTML = "<div class=\"alert alert-danger\" role=\"alert\"><CENTER>" + message + "</CENTER></div>";
@ -81,9 +91,8 @@
}
showSuccessAlert("You have logged in successfully!")
// This function is only used for the Refresh Button
function generateNewToken() {
fetch(rootURL + "/newToken")
.then(function (response) {
@ -100,23 +109,26 @@
})
}
// Ask the user for the password.
let pass = prompt("Enter the password!", "");
let text;
// Ask the API if the password is correct
fetch(rootURL + "/checkPass?pass=" + pass)
.then(function (response) {
return response.json();
})
}) // Check for a positive 1 response back
.then(function (data) {
if (data == "1") {
// If they do not submit a password OR hit cancel, fail the login!
if (pass == null || pass == "") {
document.getElementById("view").innerHTML = "WOO"
} else {
// If we got this far, we have logged in, lets tell the user that
showSuccessAlert("You have logged in successfully!")
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: <BR> <button type=\"button\" class=\"btn btn-primary\" onclick=\"generateNewToken()\">Request new Token</button>";
// Adding the event Listening Function
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
@ -127,9 +139,11 @@
}
}
// Lets now listen for events
addEvent(document, "keypress", function (e) {
e = e || window.event;
// Command UP
if (e.key == "w" || e.code == "Numpad8") {
fetch(rootURL + "/up")
.then(function (response) {
@ -146,6 +160,7 @@
})
}
// Command LEFT
if (e.key == "a" || e.code == "Numpad4") {
fetch(rootURL + "/left")
.then(function (response) {
@ -162,6 +177,7 @@
})
}
// Command DOWN
if (e.key == "s" || e.key == "2") {
fetch(rootURL + "/down")
.then(function (response) {
@ -178,6 +194,7 @@
})
}
// Command RIGHT
if (e.key == "d" || e.code == "Numpad6") {
fetch(rootURL + "/right")
.then(function (response) {
@ -194,6 +211,7 @@
})
}
// Command ENTER
if (e.key == "Enter" || e.code == "Numpad5") {
fetch(rootURL + "/enter")
.then(function (response) {
@ -210,6 +228,7 @@
})
}
// Command BACK
if (e.key == "x" || e.code == "NumpadDecimal") {
fetch(rootURL + "/back")
.then(function (response) {
@ -226,6 +245,7 @@
})
}
// Command VOL UP
if (e.key == "p" || e.code == "NumpadAdd") {
fetch(rootURL + "/volumeUp")
.then(function (response) {
@ -242,6 +262,7 @@
})
}
// Command VOL DOWN
if (e.key == "o" || e.code == "NumpadSubtract") {
fetch(rootURL + "/volumeDown")
.then(function (response) {
@ -258,6 +279,7 @@
})
}
// Request new token using the R shortcut
if (e.key == "r") {
fetch(rootURL + "/newToken")
.then(function (response) {
@ -274,7 +296,7 @@
})
}
// Command MUTE
if (e.key == "m" || e.code == "Numpad0") {
fetch(rootURL + "/mute")
.then(function (response) {
@ -291,6 +313,7 @@
})
}
// Command Picture Mode
if (e.key == "l") {
fetch(rootURL + "/pmode")
.then(function (response) {
@ -307,6 +330,7 @@
})
}
// Command HOME
if (e.key == "h") {
fetch(rootURL + "/home")
.then(function (response) {
@ -323,26 +347,27 @@
})
}
});
}
} else {
// Login Failed!
showFailAlert("The password was incorrect!")
document.getElementById("view").innerHTML = "<meta http-equiv=\"refresh\" content=3;>"
}
})
</script>
<!--END MAIN JS-->
</head>
<body>
<!--MAIN VIEWPORT-->
<center>
<div id="view"></div>
<center>
<!--END MAIN VIEWPORT-->
</body>
</html>