-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
125 lines (103 loc) · 5.09 KB
/
Copy pathindex.html
File metadata and controls
125 lines (103 loc) · 5.09 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<htm lang="en">
<head>
<meta charset="utf-8">
<title>Particle Connection</title>
</head>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
<body class="h-screen overflow-hidden flex items-center justify-center" style="background: #edf2f7;">
<!-- <h1 class="block text-gray-700 text-sm font-bold mb-2">Automatic Salt Spreader Controls<sup>TM</sup></h1> -->
<!-- <h2>Device #1</h2> -->
<!--
<form name="myForm" method="POST" id="myFormId" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
<p class="block text-gray-700 text-sm font-bold mb-2">Device ID:<input id="deviceId" name="myCoreID" size=50 value="480025000e504b464d323520"> <br> Get this from the core area when logged in<br></p>
<p>Access Token:<input id="access_token" name="myCoreID" type=password size=50 value="2914fec95e7f2ed423645e2d456604076901a3fd"> <br> Get this from the core area when logged in<br></p>
</form>
<button type="turnLedOnButton" onclick="getParticle('on', 'led')">Turn Led On</button>
<button type="turnLedOffButton" onclick="getParticle('off', 'led')">Turn Led Off</button>
<br><br>
<button type="dispenseButton" onclick="getParticle('true', 'dispense')">Dispense Salt</button>
<button type="updatePressureButton" onclick="getParticle('value', 'update')">Update Pressure Sensor Value</button>
<p id="Response">No actions have been taken</p>
<h2 id="Pressure Heading">Pressure Value<p id="Pressure Value"></p></h2> -->
<div class="bg-white shadow-md rounded px-24 pt-8 pb-8 mb-4 flex flex-col">
<div class="max-w-xs">
<div class="w-full">
<h1 class="text-3xl text-gray-darkest font-bold">Automatic Salt Spreader<sup>TM</sup></h1>
</div>
</div>
<br>
<form class="w-full max-w-sm">
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4" for="inline-full-name">
Device ID
</label>
</div>
<div class="md:w-2/3">
<input class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="deviceId" type="text" value="480025000e504b464d323520">
</div>
</div>
<div class="md:flex md:items-center mb-6">
<div class="md:w-1/3">
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4" for="inline-username">
Access Token
</label>
</div>
<div class="md:w-2/3">
<input class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="access_token" type="password" value="2914fec95e7f2ed423645e2d456604076901a3fd">
</div>
</div>
<div class="md:w-full"><label id='Response' class="block text-gray-500 font-bold md:text-center mb-1 md:mb-0" for="inline-full-name">No Response has been recieved</label></div>
<div class="md:w-full"><label id='Pressure Value' class="block text-gray-500 font-bold md:text-center mb-1 md:mb-0" for="inline-full-name">Pressure Value has not been updated</label></div>
<br>
<div class="items-center justify-between py-4 px-10">
<button class="bg-blue-700 hover:bg-purple-500 text-white font-bold py-2 px-6 rounded" type="button" onclick="getParticle('on', 'led')">
Turn Led On
</button>
<button class="bg-blue-700 hover:bg-purple-500 text-white font-bold py-2 px-6 rounded" type="button" onclick="getParticle('off', 'led')">
Turn Led Off
</button>
</div>
<div class="items-center justify-between">
<button class="bg-blue-700 hover:bg-purple-500 text-white font-bold py-2 px-6 rounded" type="button" onclick="getParticle('true', 'dispense')">
Dispense Salt
</button>
<button class="bg-blue-700 hover:bg-purple-500 text-white font-bold py-2 px-6 rounded" type="button" onclick="getParticle('value', 'update')">
Update Pressure Value
</button>
</div>
</form>
</div>
</body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
function getParticle(input, func){
var coreID = document.all.deviceId.value;
var accessToken = document.all.access_token.value;
var url = "https://api.spark.io/v1/devices/" + coreID + "/" + func;
$.ajax({
type: "POST",
url: url,
data: {
access_token: accessToken,
args: input
},
success: (data) => {
console.log(data);
if (func == 'led'){
if (data.return_value == 1)
document.getElementById("Response").innerHTML = "Led is On";
else
document.getElementById("Response").innerHTML = "Led is Off";
} else if (func == 'dispense'){
document.getElementById("Response").innerHTML = "Salt has been dispensed";
} else if (func == 'update'){
document.getElementById("Response").innerHTML = "Pressure Value has been updated";
document.getElementById("Pressure Value").innerHTML = data.return_value;
}
},
});
}
</script>
</html>