-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlockness.js
39 lines (34 loc) · 890 Bytes
/
lockness.js
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
var UI = require('ui');
var method = 'POST';
// Construct URL
var url = "https://agent.electricimp.com/B_odmEQnlMF2?LockState=";
// Create the request
var request = new XMLHttpRequest();
var main = new UI.Card({
title: 'Bike Lock',
subtitle: 'Control your bike lock remotely!',
body: 'Press Select Button to Start.',
subtitleColor: 'indigo', // Named colors
bodyColor: '#9a0036' // Hex colors
});
main.show();
main.on('click', 'select', function(e) {
var menu = new UI.Menu({
sections: [{
items: [{
title: 'Lock',
subtitle: 'Click here to lock your bike'
}, {
title: 'Unlock',
subtitle: 'Click here to unlock your bike'
}]
}]
});
menu.on('select', function(e) {
var urlNew = url + e.itemIndex;
console.log(urlNew);
request.open(method, urlNew);
request.send();
});
menu.show();
});