-
Notifications
You must be signed in to change notification settings - Fork 1
/
i4-Button.js
6 lines (6 loc) · 3.26 KB
/
i4-Button.js
1
2
3
4
5
6
let ip = '192.168.178.222', ht = "<td><div class='room'><h4", et = "</h4></div>", ep = "<i class='relay mdi mdi-gesture-tap'></i></b><br>", dp = "<i class='relay mdi mdi-gesture-double-tap'></i></b><br>", tp = "<i class='relay mdi mdi-chevron-triple-down'></i></b><br>", lp = "<i class='relay mdi mdi-gesture-tap-hold'></i></b></td>";
function i4trigger(request, response) {
response.body = "<html><head><title>i4 Button</title><link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/5.9.55/css/materialdesignicons.min.css' integrity='sha512-vIgFb4o1CL8iMGoIF7cYiEVFrel13k/BkTGvs0hGfVnlbV6XjAA0M0oEHdWqGdAVRTDID3vIZPOHmKdrMAUChA==' crossorigin='anonymous' /><style>*{font-family:verdana, serif; color: rgb(245,245,245); background-color: #37474f;} .room{background-color:#455a64;padding:5px;border-radius:20px;color:#eee;margin-bottom:1px;width:100%;} .room > div{display:inline-block;width:88px;height:110px;background-color:#56676f;border-radius:10px;padding:5px;} .relay{font-size:4em;cursor:pointer;} .relay:hover{background-color:#666;} h4{margin:0;margin-bottom:3px;font-size:2em;text-align:center;background-image: linear-gradient(to left, violet, cornflowerblue, lightblue, lime, yellow, orange, red); -webkit-background-clip: text; color: transparent;} i{color:#00ffff;} table{vertical-align:top;margin:0;height:1%;} td{width:50%; text-align: center;}</style><script>let ip = '" + ip + "', event1 = 'single_push', event2 = 'double_push', event3 = 'triple_push', event4 = 'long_push'; function TriggerButton(ip, id, event) { fetch('http://' + ip + '/rpc/input.trigger?id=' + id + '&event_type=' + event , {mode : 'no-cors'}) .then() .catch(err => alert('Befehl ' + event + ' der Taste ' + (id + 1) + ' konnte nicht ausgeführt werden')); if(event === 'single_push'){lastsequence = '•<br>SinglePush';} else if(event === 'double_push'){lastsequence = '• •<br>DoublePush';} else if(event === 'triple_push'){lastsequence = '• • •<br>TriplePush';} else if(event === 'long_push'){lastsequence = '<i><big>—</big></i><br>LongPush';} else {lastsequence = '';} document.getElementById(id).innerHTML = lastsequence; return;}</script></head><body><h4>i4-Button</h4><table><tr>" + ht + " id='0'>Taste 1" + et + "<b onclick='TriggerButton(ip, 0, event1);'>" + ep + "<b onclick='TriggerButton(ip, 0, event2);'>" + dp + "<b onclick='TriggerButton(ip, 0, event3);'>" + tp + "<b onclick='TriggerButton(ip, 0, event4);'>" + lp + ht + " id='1'>Taste 2" + et + "<b onclick='TriggerButton(ip, 1, event1);'>" + ep + "<b onclick='TriggerButton(ip, 1, event2);'>" + dp + "<b onclick='TriggerButton(ip, 1, event3);'>" + tp + "<b onclick='TriggerButton(ip, 1, event4);'>" + lp + "</tr><tr>" + ht + " id='2'>Taste 3" + et + "<b onclick='TriggerButton(ip, 2, event1);'>" + ep + "<b onclick='TriggerButton(ip, 2, event2);'>" + dp + "<b onclick='TriggerButton(ip, 2, event3);'>" + tp + "<b onclick='TriggerButton(ip, 2, event4);'>" + lp + ht + " id='3'>Taste 4" + et + "<b onclick='TriggerButton(ip, 3, event1);'>" + ep + "<b onclick='TriggerButton(ip, 3, event2);'>" + dp + "<b onclick='TriggerButton(ip, 3, event3);'>" + tp + "<b onclick='TriggerButton(ip, 3, event4);'>" + lp + "</tr></table></body></html>";
response.send();
}
HTTPServer.registerEndpoint('i4trigger', i4trigger);