-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
57 lines (47 loc) · 1.41 KB
/
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Telegram Push Notification JS */
window.onload = function () {
setTimeout(showPopupIfNotHidden, 60000);
};
function showPopupIfNotHidden() {
if (!isPopupHidden()) {
showPopup();
setupPopupButtons();
}
}
function isPopupHidden() {
return document.cookie.includes("hidePopup=true");
}
function showPopup() {
var popup = document.getElementById("popup-container");
popup.style.display = "block";
}
function setupPopupButtons() {
var yesButton = document.getElementById("yes");
yesButton.onclick = onYesButtonClick;
var noButton = document.getElementById("no");
noButton.onclick = onNoButtonClick;
}
function onYesButtonClick() {
openTelegramChannel();
hidePopupForOneDay();
hidePopup();
}
function openTelegramChannel() {
window.open('https://telegram.me/username', '_blank'); //Enter your telegram channel url in place of https://telegram.me/username
}
function onNoButtonClick() {
hidePopupForOneDay();
hidePopup();
}
function hidePopupForOneDay() {
var date = new Date();
date.setDate(date.getDate() + 1);
document.cookie = "hidePopup=true; expires=" + date.toUTCString() + "; path=/";
}
function hidePopup() {
var popup = document.getElementById('popup-container');
popup.classList.add('closePopup');
setTimeout(function() {
popup.style.display = 'none';
}, 400);
}