-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (63 loc) · 2.55 KB
/
script.js
File metadata and controls
76 lines (63 loc) · 2.55 KB
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
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm';
const supabase = createClient('https://hlapzydzkeyttgmughiu.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhsYXB6eWR6a2V5dHRnbXVnaGl1Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MjkxNDc4NzAsImV4cCI6MjA0NDcyMzg3MH0.fNlhkzfU5RZURQpfu1sTz4EjWL-ImWRvGNx0mMBwuE8');
function setCookie(name, value, options = {}) {
options = {
path: '/',
expires: 'Tue, 19 Jan 2038 03:14:07 GMT',
...options
};
if (options.expires instanceof Date) {
options.expires = options.expires.toUTCString();
}
let updatedCookie = encodeURIComponent(name) + "=" + encodeURIComponent(value);
for (let optionKey in options) {
updatedCookie += "; " + optionKey;
let optionValue = options[optionKey];
if (optionValue !== true) {
updatedCookie += "=" + optionValue;
}
}
document.cookie = updatedCookie;
}
function getCookie(name) {
let matches = document.cookie.match(new RegExp(
"(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
));
return matches ? decodeURIComponent(matches[1]) : undefined;
}
window.onload = function() {
if (getCookie('signInStatus') == 'signed') {
window.open("/database/calendar.html", "_self");
} else {
setCookie('signInStatus', 'unsigned', {});
}
let inputLogin = document.getElementById("inputLogin");
let inputPassword = document.getElementById("inputPassword");
let buttonLogin = document.getElementById("buttonLogin");
buttonLogin.onclick = async function() {
const { data, error } = await supabase
.from('users')
.select('password')
.eq('login', `${inputLogin.value}`);
if (JSON.parse(JSON.stringify(data[0]) != null)) {
if(inputPassword.value == JSON.parse(JSON.stringify(data[0])).password) {
setCookie('signInStatus', 'signed', {});
window.open("/database/calendar.html", "_self");
}
else {
setCookie('signInStatus', 'unsigned', {});
}
}
}
let descriptionsContainer = document.getElementById("descriptionsContainer");
let descriptionsContainerClickCounter = 0;
let menuInner = document.getElementById("menuInner");
let websiteInfo = document.getElementById("websiteInfo");
descriptionsContainer.onclick = function() {
descriptionsContainerClickCounter++;
if(descriptionsContainerClickCounter == 10) {
menuInner.classList.add("menu-inner-animation");
websiteInfo.classList.add("website-info-animation");
}
}
}