-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
79 lines (73 loc) · 1.82 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
<!DOCTYPE html>
<html>
<head>
<title>Whatsapp API by Lucas H.</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- This parts is optional, just for improve the styles -->
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Montserrat', sans-serif;
padding: 20px;
}
#app {
max-width: 500px;
margin: 20px auto;
}
#qrcode {
display: none; /* Showed when qr code received */
width: 100%;
margin: 10px 0;
border: 1px solid #efefef;
border-radius: 4px;
}
ul.logs {
max-height: 150px;
padding: 15px 15px 15px 30px;
margin-top: 5px;
border-radius: 4px;
overflow-y: auto;
background: #efefef;
color: #666;
font-size: 14px;
}
ul.logs li:first-child {
color: green;
}
</style>
</head>
<body>
<div id="app">
<h1>Whatsapp API</h1>
<p>Lucas Henrique</p>
<img src="" alt="QR Code" id="qrcode">
<h3>Logs:</h3>
<ul class="logs"></ul>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js" crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
var socket = io();
socket.on('message', function(msg) {
$('.logs').prepend($('<li>').text(msg));
});
socket.on('qr', function(src) {
$('#qrcode').attr('src', src);
$('#qrcode').show();
});
socket.on('ready', function(data) {
$('#qrcode').hide();
});
socket.on('authenticated', function(data) {
$('#qrcode').hide();
});
});
</script>
</body>
</html>