-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (91 loc) · 3.33 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
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Light My Stuff</title>
<!-- <link rel="icon" type="image/png" href="public/favicon.ico" /> -->
<link rel="icon" type="image/png" href="public/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="public/favicon-16x16.png" sizes="16x16" />
<link rel="stylesheet" type="text/css" href="public/index.css">
<script src="https://unpkg.com/[email protected]/dist/mqtt.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
var rainbowButton = document.getElementById('rainbowButton');
var rainButton = document.getElementById('rainButton');
var rainbowRainButton = document.getElementById('rainbowRainButton');
var sparkleButton = document.getElementById('sparkleButton');
var snakeButton = document.getElementById('snakeButton');
var client = mqtt.connect('wss://KEY:[email protected]', {
clientId: 'javascript'
})
function sendEvent(program) {
client.publish('lights', program)
}
client.on('connect', function () {
client.publish('lights', 'Hello mqtt')
client.on("error", function (error) {
console.log("ERROR: ", error);
});
client.on('offline', function () {
console.log("offline");
});
client.on('disconnect', function () {
console.log("disconnect");
});
client.on('reconnect', function () {
console.log("reconnect");
});
})
rainbowButton.addEventListener('click', () => sendEvent('rainbow'));
rainButton.addEventListener('click', () => sendEvent('rain'));
rainbowRainButton.addEventListener('click', () => sendEvent('rainbowRain'));
sparkleButton.addEventListener('click', () => sendEvent('sparkle'));
snakeButton.addEventListener('click', () => sendEvent('snake'));
});
</script>
</head>
<body class="wrapper">
<main class="content">
<h1 class="heading">Light My
<div class="slidingVertical">
<span>Clothes</span>
<span>Skirt</span>
<span>Necklace</span>
<span>Stuff</span>
<span>Umbrella</span>
</div>
</h1>
<div class="umbrella">
<img src="public/animated-pixel-umbrella.gif" alt="pixelated rainbow umbrella">
</div>
<div class="instructions">
<p>Click on a program below</p>
<p>& it will light my clothing!</p>
<div class="line" />
</div>
<section class="menu">
<button type="button" id="rainbowButton" name="rainbowButton">
<span id="rainbow">RAINBOWS</span>
</button>
<button type="button" id="snakeButton" name="snakeButton">
<span id="snake">Snake</span>
</button>
<button type="button" id="rainButton" name="rainButton">
<span id="rain">RAIN</span>
</button>
<button type="button" id="rainbowRainButton" name="rainbowRainButton">
<span id="rainbowRain">RAINBOW RAIN</span>
</button>
<button type="button" id="sparkleButton" name="sparkleButton">
<span id="sparkle">Sparkle</span>
</button>
</section>
</main>
<footer>
<p>Made & Worn with 💖 by
<a href="https://stephanie.lol">Stephanie</a>
</p>
</footer>
</body>
</html>