adding numpad support

This commit is contained in:
raven 2022-12-21 23:58:55 -05:00
parent 850810de17
commit de53661ff2
1 changed files with 20 additions and 26 deletions

View File

@ -3,15 +3,9 @@
<!--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!--> <!--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></head> <head></head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Samsung TVController</title> <title>Samsung TVController</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<center>
<div id="view"></div>
<center>
<style> <style>
body { body {
background-color: #101010; background-color: #101010;
color: #ffffff; color: #ffffff;
@ -40,7 +34,7 @@
.then(function (data) { .then(function (data) {
if (data == "1") { if (data == "1") {
if (pass == null || pass == "") { if (pass == null || pass == "") {
document.getElementById("view").innerHTML = "<meta http-equiv=\"refresh\" content=0;>" document.getElementById("view").innerHTML = "WOO"
} else { } else {
document.getElementById("view").innerHTML = "CURRENT COMMAND SHORTCUTS: <BR>HOME: H<BR> UP: W<BR> LEFT: A<BR> DOWN: S <BR> RIGHT: D<BR> Back: X<BR> Volume Up: P<BR> Volume Down: O<BR>MUTE: M<BR> Enter: Enter<BR>Picture Mode: L<BR><BR><BR><a href=\"javascript:window.open('input.html','Click to Send Text Imput!','width=600,height=400')\">Open Text Input</a><BR><BR>Not Working? Issue a new Token using: r"; document.getElementById("view").innerHTML = "CURRENT COMMAND SHORTCUTS: <BR>HOME: H<BR> UP: W<BR> LEFT: A<BR> DOWN: S <BR> RIGHT: D<BR> Back: X<BR> Volume Up: P<BR> Volume Down: O<BR>MUTE: M<BR> Enter: Enter<BR>Picture Mode: L<BR><BR><BR><a href=\"javascript:window.open('input.html','Click to Send Text Imput!','width=600,height=400')\">Open Text Input</a><BR><BR>Not Working? Issue a new Token using: r";
@ -60,7 +54,7 @@
e = e || window.event; e = e || window.event;
// Handle // Handle
if (e.key == "w") { if (e.key == "w" || e.code == "Numpad8" ) {
fetch(rootURL + "/up") fetch(rootURL + "/up")
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -71,8 +65,8 @@
} }
// Handle // Handle
if (e.key == "a") { if (e.key == "a" || e.code == "Numpad4") {
fetch(rootURL + "/left") fetch(rootURL + "/left" )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
@ -81,7 +75,7 @@
}) })
} }
// Handle // Handle
if (e.key == "s") { if (e.key == "s" || e.key == "2") {
fetch(rootURL + "/down") fetch(rootURL + "/down")
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -91,8 +85,9 @@
}) })
} }
// Handle // Handle
if (e.key == "d") { // Handle
fetch(rootURL + "/right") if (e.key == "d" || e.code == "Numpad6") {
fetch(rootURL + "/right" )
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
@ -102,7 +97,7 @@
} }
if (e.key == "Enter") { if (e.key == "Enter") {
fetch(rootURL + "/enter") fetch(rootURL + "/enter" || e.code == "Numpad5")
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
@ -110,7 +105,7 @@
if (data == 1) return console.log("Command: ENTER - SENT!") if (data == 1) return console.log("Command: ENTER - SENT!")
}) })
} }
if (e.key == "x") { if (e.key == "x" || e.code == "NumpadDecimal") {
fetch(rootURL + "/back") fetch(rootURL + "/back")
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
@ -120,30 +115,29 @@
}) })
} }
if (e.key == "p") { if (e.key == "p" || e.code == "NumpadAdd") {
fetch(rootURL + "/volumeUp") fetch(rootURL + "/volumeUp")
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (data) { .then(function (data) {
if (data == 1) return console.log("Command: BACK - SENT!") if (data == 1) return console.log("Command: VOL UP - SENT!")
}) })
} }
if (e.key == "o") { if (e.key == "o" || e.code == "NumpadSubtract") {
fetch(rootURL + "/volumeDown") fetch(rootURL + "/volumeDown")
.then(function (response) { .then(function (response) {
return response.json(); return response.json();
}) })
.then(function (data) { .then(function (data) {
if (data == 1) return console.log("Command: BACK - SENT!") if (data == 1) return console.log("Command: VOL DOWN - SENT!")
}) })
} }
if (e.key == "r") { if (e.key == "r") {
fetch(rootURL + "/newToken") fetch(rootURL + "/newToken")
.then(function (response) { .then(function (response) {
commandData
return response.json(); return response.json();
}) })
.then(function (data) { .then(function (data) {
@ -153,10 +147,9 @@
if (e.key == "m") { if (e.key == "m" || e.code == "Numpad0") {
fetch(rootURL + "/mute") fetch(rootURL + "/mute")
.then(function (response) { .then(function (response) {
commandData
return response.json(); return response.json();
}) })
.then(function (data) { .then(function (data) {
@ -167,7 +160,6 @@
if (e.key == "l") { if (e.key == "l") {
fetch(rootURL + "/pmode") fetch(rootURL + "/pmode")
.then(function (response) { .then(function (response) {
commandData
return response.json(); return response.json();
}) })
.then(function (data) { .then(function (data) {
@ -175,10 +167,9 @@
}) })
} }
if (e.key == "h") { if (e.key == "h" || e.code == "Numpad5") {
fetch(rootURL + "/home") fetch(rootURL + "/home")
.then(function (response) { .then(function (response) {
commandData
return response.json(); return response.json();
}) })
.then(function (data) { .then(function (data) {
@ -197,6 +188,9 @@
</head> </head>
<body> <body>
<center>
<div id="view"></div>
<center>
</body> </body>
</html> </html>