-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (82 loc) · 3.36 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RoboPava</title>
<link rel="stylesheet" href="style/bootstrap.min.css" />
<link rel="stylesheet" href="style/bootstrap-theme.min.css" />
<link rel="stylesheet" href="style/jquery-ui.min.css" />
<link rel="stylesheet" href="style/custom.css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script type="text/javascript" src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script type="text/javascript" src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container tc">
<h1>RoboPava</h1>
<div class="row">
<div class="col-md-6">
<form>
<div class="wrapper">
<button type="button" class="btn btn-primary btn-lg wdefault mleft" value="70" id="tempte">Te</button>
<button type="button" class="btn btn-primary btn-lg wdefault mleft" value="80" id="tempmate">Mate</button>
<button type="button" class="btn btn-primary btn-lg wdefault mleft" value="90" id="tempcafe">Cafe</button>
</div>
<div class="customTempDiv">
<input type="input " class="form-control" id="temp" placeholder="Temperatura">
</div>
<div style="margin: auto; width: 150px;">
<button style="width: 100px;" type="button" class="btn btn-primary btn-lg wdefault">Submit</button>
</div>
</form>
</div>
<div class="col-md-6">
<div class="wrapper">
<textarea class="form-control rounded-0" id="logEvent" rows="10" readonly></textarea>
</div>
</div>
</div>
</div>
<!-- /.container -->
<script type="text/javascript " src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript " src="js/jquery-ui.min.js "></script>
<script type="text/javascript " src="js/bootstrap.min.js "></script>
<script type="text/javascript " src="js/underscore-min.js "></script>
</body>
</html>
<script type="text/javascript ">
//set local reference to server
const urlPost = 'http://x.x.x.x/v1/pavas/calentar';
const urlGet = 'http://x.x.x.x/v1/pavas/temperatura';
function takeCurrentDateTime() {
let date = new Date();
return date.toISOString();
}
$(":button ").click(function(e) {
//set temperature from input or buttons
let temp = e.toElement.value != "" ? e.toElement.value : $("#temp").val();
//Post query
$.when(
$.post(urlPost, {
"temperatura": temp
}),
).done(function(result) {
//take response and log into textarea
$("#logEvent").append("\n" + takeCurrentDateTime + " : " + result);
//Set 1 second interval to take actual state of robopava
setInterval(function() {
$.get(urlGet).done(function(result) {
$("#logEvent").append("\n" + takeCurrentDateTime + " : " + result);
})
}, 1000);
}).fail(function(result) {
//take response and log into textarea
$("#logEvent").append("\n" + takeCurrentDateTime + " : " + result.statusText);
});
});
</script>