-
Notifications
You must be signed in to change notification settings - Fork 55
/
disco.html
108 lines (93 loc) · 2.33 KB
/
disco.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
97
98
99
100
101
102
103
104
105
106
107
108
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Getting data from a sensor</title>
<meta name="description" content="Simple Chat Room">
<meta name="author" content="Tomomi Imura @girlie_mac">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", "Roboto Light", "Segoe UI Web Light", "Segoe UI Light", "Segoe UI Web Regular", "Segoe UI", Helvetica, Arial, sans-serif;
margin: 1em;
}
header {
margin-bottom: 2em;
}
h1, h2, h3 {
margin: 0;
text-rendering: optimizeLegibility;
}
h1 {
font-size: 2.4em;
line-height: 1.4em;
text-transform: lowercase;
font-weight: normal;
text-shadow: 1px 2px 0 #fff;
}
h2 {
font-size: 1em;
text-transform: uppercase;
font-weight: normal;
text-shadow: 1px 1px 0 #fff;
}
footer {
position: absolute;
bottom: 2em;
}
#main {
margin: 4em auto;
text-align: center;
position: relative;
}
button {
display: block;
font-size: 2em;
border-radius: 10px;
padding: .3em 1em;
position: absolute;
top: 50%;
left: calc(50% - 100px);
}
</style>
</head>
<body>
<header>
<h1>Control LED from Web Interface</h1>
<h2>Publishing from web to control a LED</h2>
</header>
<section id="main" role="main">
<img src="images/disco-ball.png" width="400">
<button>Disco on!</button>
</section>
<footer>
Use this UI with <code>project-python/remote-led/remote-led.py</code>.
</footer>
<!-- including the latest PubNub JavaScript SDK -->
<script src="http://cdn.pubnub.com/pubnub-3.7.1.min.js"></script>
<script>
(function() {
// DOM
var button = document.querySelector('button');
// This is the channel name you are subscribing in remote-led.py
var channel = 'disco';
// Init - Get your own keys at admin.pubnub.com
var p = PUBNUB.init({
subscribe_key: 'sub-c-f762fb78-2724-11e4-a4df-02ee2ddab7fe',
publish_key: 'pub-c-156a6d5f-22bd-4a13-848d-b5b4d4b36695'
});
// Sending data
function disco() {
p.publish({
channel : channel,
message : {led: 1}
});
}
// Click event
button.addEventListener('click', disco);
})();
</script>
</body>
</html>