Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta name="viewport" content = "height = device-height, width = device-width, user-scalable = no" />
- <title>Garage Door Opener</title>
- <script type="text/javascript" src="/webiopi.js"></script>
- <script type="text/javascript">
- webiopi().ready(function() {
- var content, content2, buttonLeft, buttonRight;
- content = $("#content");
- content2 = $("#openCloseButton");
- webiopi().setFunction(7,"in");
- webiopi().setFunction(8,"in");
- webiopi().setFunction(18,"in");
- webiopi().setFunction(17,"in");
- // create an "OPEN" labeled button for GPIO 18
- button = webiopi().createGPIOButton(18, "");
- content2.append(button); // append button to content div
- // create an "OPEN" labeled button for GPIO 17
- button = webiopi().createGPIOButton(17, "");
- content2.append(button); // append button to content div
- // create button that calls the mousedown function below
- buttonLeft = webiopi().createButton("buttonLeft", "LEFT", showConfirmLeft );
- content.append(buttonLeft); // append button to content div
- // create button that calls the mousedown function below
- buttonRight = webiopi().createButton("buttonRight", "RIGHT", showConfirmRight );
- content.append(buttonRight); // append button to content div
- // this function gets called by the mousedown function below - it sets gpio7 back to 'IN'
- function mouseupLeft() {
- webiopi().setFunction(7,"in");
- }
- function mouseupRight() {
- webiopi().setFunction(8,"in");
- }
- // this function sets gpio7 to 'OUT' which will trip the relay. After .5 second it calls mouseup above.
- // hides the confirmation div and makes doge face change
- function mousedownLeft() {
- webiopi().setFunction(7,"out");
- document.getElementById('confirmBoxLeft').style.display = "none";
- document.getElementById('confirmTextLeft').style.display = "none";
- setTimeout(mouseupLeft, 500);
- }
- function mousedownRight() {
- webiopi().setFunction(8,"out");
- document.getElementById('confirmBoxRight').style.display = "none";
- document.getElementById('confirmTextRight').style.display = "none";
- setTimeout(mouseupRight, 500);
- }
- // after pressing no hide the confirmation div
- function hideConfirmLeft() {
- document.getElementById('confirmBoxLeft').style.display = "none";
- document.getElementById('confirmTextLeft').style.display = "none";
- }
- function hideConfirmRight() {
- document.getElementById('confirmBoxRight').style.display = "none";
- document.getElementById('confirmTextRight').style.display = "none";
- }
- // show confirmation div after pressing garage door button
- function showConfirmLeft() {
- document.getElementById('yesLeft').onclick = mousedownLeft;
- document.getElementById('noLeft').onclick = hideConfirmLeft;
- document.getElementById('confirmBoxLeft').style.display = "block";
- document.getElementById('confirmTextLeft').style.display = "block";
- document.getElementById('confirmBoxRight').style.display = "none";
- document.getElementById('confirmTextRight').style.display = "none";
- }
- function showConfirmRight() {
- document.getElementById('yesRight').onclick = mousedownRight;
- document.getElementById('noRight').onclick = hideConfirmRight;
- document.getElementById('confirmBoxRight').style.display = "block";
- document.getElementById('confirmTextRight').style.display = "block";
- document.getElementById('confirmBoxLeft').style.display = "none";
- document.getElementById('confirmTextLeft').style.display = "none";
- }
- // constantly refresh status to see if door is open or closed
- webiopi().refreshGPIO(true)
- });
- </script>
- <style type="text/css">
- body {
- font-family: Arial, Helvetica, Sans-Serif;
- padding: 0px;
- margin: 0px;
- background: #CCCCCC;
- }
- button {
- display: block;
- margin: 10px 10px;
- margin-left: auto;
- margin-right: auto;
- padding: 0px;
- width: 300px;
- height: 50px;
- font-size: 24pt;
- font-weight: bold;
- color: black;
- border-radius: 10px !important;
- }
- button#button {
- height: 250px !important;
- border-radius: 10px !important;
- cursor: pointer !important;
- }
- input[type="range"] {
- display: block;
- width: 160px;
- height: 45px;
- }
- #gpio17.LOW {
- background: red url('closed.png') no-repeat center !important;
- float: left;
- width: 145px;
- }
- #gpio17.HIGH {
- background: black url('open.png') no-repeat center !important;
- float: left;
- width: 145px;
- }
- #gpio18.LOW{
- background: red url('closed.png') no-repeat center !important;
- float: right;
- width: 145px;
- }
- #gpio18.HIGH{
- background: black url('open.png') no-repeat center !important;
- float: right;
- width: 145px;
- }
- #header {
- margin-left: auto;
- margin-right: auto;
- margin-top: 0px !important;
- padding-top: 0px !important;
- }
- #confirmTextLeft {
- margin-left: auto;
- margin-right: auto;
- padding: 0px;
- margin-top: 0px;
- display: none;
- }
- #confirmTextRight {
- margin-left: auto;
- margin-right: auto;
- padding: 0px;
- margin-top: 0px;
- display: none;
- }
- h2 {
- text-align: center;
- margin-top: 0px !important;
- margin-bottom: 10px !important;
- }
- #confirmBoxLeft {
- height: 60px;
- width: 300px;
- margin-left: auto;
- margin-right: auto;
- position:relative;
- display: none;
- }
- #confirmBoxRight {
- height: 60px;
- width: 300px;
- margin-left: auto;
- margin-right: auto;
- position:relative;
- display: none;
- }
- #yesLeft {
- background-color: green;
- float: left;
- }
- #noLeft {
- background-color: red;
- float: right;
- }
- #yesRight {
- background-color: green;
- float: left;
- }
- #noRight {
- background-color: red;
- float: right;
- }
- .confirmButton {
- border: 3px solid #000000;
- border-radius: 10px;
- cursor: pointer;
- height: 50px;
- width: 125px;
- font-size: 24pt;
- font-weight: bold;
- text-align: center;
- line-height: 50px;
- }
- #openCloseButton {
- width: 300px !important;
- height: 60px;
- position: relative;
- margin-left: auto;
- margin-right: auto;
- }
- #buttonLeft {
- float: left !important;
- width: 145px !important;
- height: 250px !important;
- }
- #buttonRight {
- float: right !important;
- width: 145px !important;
- height: 250px !important;
- }
- </style>
- </head>
- <body>
- <div id="header"><h2>Door Status</h2></div>
- <div id="openCloseButton" style="margin-left: auto; margin-right: auto; position:relative"></div>
- <div id="content" style="margin-left: auto; margin-right: auto; position:relative; width: 300px; height: 250px;"></div>
- <div id="confirmTextLeft"><h2>Left Door - Confirm</h2></div>
- <div id="confirmTextRight"><h2>Right Door - Confirm</h2></div>
- <div id="confirmBoxLeft"><div id="yesLeft" class="confirmButton">YES</div><div id="noLeft" class="confirmButton">NO</div></div>
- <div id="confirmBoxRight"><div id="yesRight" class="confirmButton">YES</div><div id="noRight" class="confirmButton">NO</div></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement