Initial Commit
This commit is contained in:
59
source/static/script.js
Normal file
59
source/static/script.js
Normal file
@@ -0,0 +1,59 @@
|
||||
let token = "womwpomwp";
|
||||
let calendar_id = "wompwomp";
|
||||
let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
const client = google.accounts.oauth2.initTokenClient({
|
||||
client_id:
|
||||
"1000685713819-om0gq7bqr3e91f2rok224ooqgae6bojg.apps.googleusercontent.com",
|
||||
scope: "https://www.googleapis.com/auth/calendar",
|
||||
callback: (tokenResponse) => {
|
||||
if (tokenResponse && tokenResponse.access_token) {
|
||||
token = tokenResponse.access_token;
|
||||
fetch("/calendar/getCalendarId", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ token: token, timezone: timezone }),
|
||||
headers: { "Content-type": "application/json" },
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
calendar_id = json["calendar_id"];
|
||||
})
|
||||
.then(() => {
|
||||
send_request();
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function handle_form(event) {
|
||||
event.preventDefault();
|
||||
send_request();
|
||||
}
|
||||
|
||||
function send_request() {
|
||||
let input_value = document.forms["chatbox"]["msg-input"].value;
|
||||
|
||||
content_output = document.getElementById("content");
|
||||
|
||||
fetch("/calendar/execute", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
token: token,
|
||||
calendar_id: calendar_id,
|
||||
timezone: timezone,
|
||||
input: input_value,
|
||||
}),
|
||||
headers: { "Content-type": "application/json" },
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((json) => {
|
||||
if (json["output"] != "verify") {
|
||||
content_output.innerHTML += `>>> ${input_value}<br>>>> ${json["output"]}<br><br>`;
|
||||
document.forms["chatbox"]["msg-input"].value = "";
|
||||
} else {
|
||||
client.requestAccessToken();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.forms["chatbox"].addEventListener("submit", handle_form);
|
||||
99
source/static/style.css
Normal file
99
source/static/style.css
Normal file
@@ -0,0 +1,99 @@
|
||||
body{
|
||||
|
||||
margin: 0;
|
||||
|
||||
background-color: #DAC4F7;
|
||||
|
||||
font-family: 'Lexend';
|
||||
|
||||
}
|
||||
|
||||
.header{
|
||||
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
margin: 0;
|
||||
|
||||
color: #F0F3BD;
|
||||
background-color: #5D5F71;
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1{
|
||||
|
||||
margin: 15px;
|
||||
|
||||
}
|
||||
|
||||
.filler{
|
||||
|
||||
height: 60px;
|
||||
width: 100%;
|
||||
|
||||
}
|
||||
|
||||
#content{
|
||||
|
||||
width: 80%;
|
||||
margin-left: 10%;
|
||||
margin-right: 10%;
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
|
||||
}
|
||||
|
||||
form{
|
||||
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom:0;
|
||||
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
margin: 0;
|
||||
|
||||
background-color: #5D5F71;
|
||||
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
#msg-input{
|
||||
|
||||
width: 80%;
|
||||
height: 30px;
|
||||
margin: 15px;
|
||||
padding-left: 10px;
|
||||
|
||||
color: #F0F3BD;
|
||||
background-color: #5D5F71;
|
||||
|
||||
font-family: 'Lexend';
|
||||
|
||||
border: 2px solid #F0F3BD;
|
||||
border-radius: 20px;
|
||||
|
||||
outline: none;
|
||||
|
||||
}
|
||||
|
||||
#submit-btn{
|
||||
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
margin: 15px;
|
||||
margin-left: 0;
|
||||
|
||||
color: #5D5F71;
|
||||
background-color: #F0F3BD;
|
||||
font-family: 'Lexend';
|
||||
|
||||
border: 2px solid #F0F3BD;
|
||||
border-radius: 50%;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user