Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementação do alerta de resub #10

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions assets/alerts.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,47 @@
</script>
</head>
<body>
<div id="alertbox">
<div id="subscriptionBox">
<b class="username"></b> acabou de se inscrever!<br />
Seja bem vindo(a) 😎
</div>

<div id="resubBox">
Obrigado pelo resub de <b class="months"></b> mes(es) <b class="username"></b>
jlcarvalho marked this conversation as resolved.
Show resolved Hide resolved
</div>


<script src="/socket.io/socket.io.js"></script>
<script>
var alertbox = document.querySelector("#alertbox");
var subscriptionBox = document.querySelector("#subscriptionBox");
var resubBox = document.querySelector("#resubBox");
var usernameEl = document.querySelector(".username");
var monthEl = document.querySelector(".months");
jlcarvalho marked this conversation as resolved.
Show resolved Hide resolved

var socket = io();

socket.on('subscription', function(msg) {
usernameEl.innerText = msg.username;

monthEl.innerText = msg.months
jlcarvalho marked this conversation as resolved.
Show resolved Hide resolved
window.requestAnimationFrame(function() {
alertbox.style.opacity = '1';
subscriptionBox.style.opacity = '1';

setTimeout(() => {
alertbox.style.opacity = '0';
subscriptionBox.style.opacity = '0';
}, 8000);
});
});

socket.on('resub', function(msg) {
console.log(msg);
usernameEl.innerText = msg.username;
jlcarvalho marked this conversation as resolved.
Show resolved Hide resolved

window.requestAnimationFrame(function() {
resubBox.style.opacity = '1';

setTimeout(() => {
resubBox.style.opacity = '0';
}, 8000);
});
jlcarvalho marked this conversation as resolved.
Show resolved Hide resolved
});
</script>
</body>
Expand Down