Added premium verification for the Reminders feature

This commit is contained in:
ION606
2022-08-12 14:18:33 -07:00
parent 489047b084
commit 3ab442002d
7 changed files with 186 additions and 117 deletions
+52 -28
View File
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<span id="IMPORTS">
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico?raw=true" type="image/x-icon">
<script src="https://kit.fontawesome.com/728e740903.js" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet">
@@ -370,6 +370,8 @@
calSpacing.cellSpacing = 1;
calSpacing.cellPadding = 1;
}
document.getElementById('calHeader').style.display = "block";
}
</script>
@@ -389,42 +391,58 @@
//Get serverId
const id = window.localStorage.getItem('Id').toString();
var xhr2 = new XMLHttpRequest();
xhr2.open('get', 'http://www.selmerbot.com/getCal/', true);
xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
//Check if the user has premium
var xhrverify = new XMLHttpRequest();
xhrverify.open('post', 'http://www.selmerbot.com/verifypremium/', true);
xhrverify.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
//Use the guild Id as the userId
xhr2.setRequestHeader('userId', id);
xhrverify.setRequestHeader('userId', id);
xhrverify.onloadend = (e) => {
if (xhrverify.response == "Unauthorized") {
document.getElementById("unauth").style.display = "block";
return;
}
xhr2.onloadend = (e) => {
const calList = new Map();
var xhr2 = new XMLHttpRequest();
xhr2.open('get', 'http://www.selmerbot.com/getCal/', true);
xhr2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
const res = JSON.parse(xhr2.response);
const times = res[0];
const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
document.getElementById('monthName').innerText = `Editing Reminders for the Month of ${monthNames[(new Date()).getMonth()]}`;
//Use the guild Id as the userId
xhr2.setRequestHeader('userId', id);
times.forEach((time, ind) => {
const fullDate = new Date(Number(time));
const month = fullDate.getMonth();
const day = fullDate.getDate();
xhr2.onloadend = (e) => {
const calList = new Map();
//Make sure it's the right month (old ones should be removed, this is just a catch)
if (month == (new Date()).getMonth()) {
if (calList.has(day)) {
var temp = calList.get(day);
temp.push(res[1][ind]);
calList.set(day, temp);
} else {
calList.set(day, [res[1][ind]]);
const res = JSON.parse(xhr2.response);
const times = res[0];
const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
document.getElementById('monthName').innerText = `Editing Reminders for the Month of ${monthNames[(new Date()).getMonth()]}`;
times.forEach((time, ind) => {
const fullDate = new Date(Number(time));
const month = fullDate.getMonth();
const day = fullDate.getDate();
//Make sure it's the right month (old ones should be removed, this is just a catch)
if (month == (new Date()).getMonth()) {
if (calList.has(day)) {
var temp = calList.get(day);
temp.push(res[1][ind]);
calList.set(day, temp);
} else {
calList.set(day, [res[1][ind]]);
}
}
}
});
});
calSetup(calList);
calSetup(calList);
}
xhr2.send();
}
xhr2.send();
xhrverify.send();
}
</script>
</head>
@@ -473,8 +491,14 @@
<caption style="caption-side: top;"></caption>
<div id="unauth" style="display: none;" class="text-center">
<h1 style="margin-bottom: 20px;">You have to be a premium subscriber to use this feature!</h1>
<h3 style="margin-bottom: 50px;">vvv GET PREMIUM NOW vvv</h3>
<a href="premium.html"><i class="fa-solid fa-crown" style="scale: 4; color: gold;" alt="PREMIUM"></i></a>
</div>
<thead>
<tr>
<tr id="calHeader" style="display: none;">
<th style="color: white; background: purple;">
Sun</th>
<th style="color: white; background: purple;">