-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
57 lines (51 loc) · 1.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<html>
<head>
<title>Volume</title>
<meta name="description" content="Troll Rover by changing his computer's volume!">
</head>
<body>
<h1> Control Rover's computer's volume.</h1>
<br>
<p>Control it via the slider below</p>
<form action="/volume" method="post">
<p id="text"> </p>
<input type="range" name="volume" id="volume" min="0" max="100" onChange="currentvolume()" value=currentvolume() required>
<br>
<!--Lets add a optional textbox to attach a message -->
<label for="message">Message to send:</label>
<input type="text" name="message" id="message" placeholder="Optional">
<br>
<input type="submit" value="Submit">
</form>
</body>
<style>
body {
background-color: #f2f2f2;
}
form {
background-color: #f2f2f2;
border: 1px solid black;
padding: 20px;
margin: 20px;
}
input {
margin: 10px;
}
</style>
<script>
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
function currentvolume() {
var current = httpGet(window.location.href + "currentvolume");
console.log("current volume is " + current);
// set the current volume to the current volume
document.getElementById("text").innerHTML = "Current volume is: "+current+"%"+ "\n This is the current volume of the computer and not the current value of the slider.";
}
currentvolume()
</script>
</html>