1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="garage_door_opener.css">
- <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
- <meta charset="UTF-8">
- <title>Garage Remote</title>
- </head>
- <script>
- var xmlHttp = null;
- function pushTheButton(door)
- {
- var url = "/garage_door_opener.lua?door=" + door;
- xmlHttp = new XMLHttpRequest();
- xmlHttp.onreadystatechange = processRequest;
- xmlHttp.open("GET", url, true);
- xmlHttp.send( null );
- }
- function processRequest()
- {
- if(xmlHttp.readyState == 0)
- {
- document.getElementById('label').innerHTML = 'Initalizing...';
- }
- else if(xmlHttp.readyState == 1)
- {
- document.getElementById('label').innerHTML = 'Server connection established.';
- }
- else if(xmlHttp.readyState == 2)
- {
- document.getElementById('label').innerHTML = 'Request received.';
- }
- else if(xmlHttp.readyState == 3)
- {
- document.getElementById('label').innerHTML = 'Processing request.';
- }
- else if(xmlHttp.readyState == 4)
- {
- if(xmlHttp.status == 200)
- {
- document.getElementById('label').innerHTML = xmlHttp.responseText;
- }
- else if(xmlHttp.status == 400)
- {
- document.getElementById('label').innerHTML = 'Bad request.';
- }
- }
- }
- </script>
- <body bgcolor="#777777">
- <link href='http://fonts.googleapis.com/css?family=Khand:700' rel='stylesheet' type='text/css'>
- <a href="#" onclick="pushTheButton(1); " class="button"">
- <span>Door 1</span>
- </a>
- <a href="#" onclick="pushTheButton(2); " class="button"">
- <span>Door 2</span>
- </a>
- <div id="label">Text goes here</div>
- </body>
- </html>
|