-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (60 loc) · 2.26 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
var request = require('request');
window.onload = function(){
console.log("loaded")
let quotep = document.querySelector("#quote")
let quoteauthor = document.querySelector("#quoteauthor");
request('https://quotes.rest/qod.json', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
var quote = JSON.parse(body).contents.quotes[0]
quotep.innerHTML = quote.quote;
quoteauthor.innerHTML = quote.author
});
}
let emailbtn = document.querySelector("#emailbtn")
emailbtn.addEventListener("click", function(){
console.log("email");
})
let sendbtn = document.querySelector("#sendbtn");
let emailfield = document.querySelector("#emailfield");
let textfield = document.querySelector("#textfield")
let dialogsuccess = document.querySelector("#dialog-success");
let subjectfield = document.querySelector("#subjectfield");
sendbtn.addEventListener('click', () => {
let body = {
data: {
from: emailfield.value,
to: "lucerodavid1010@gmail.com",
subject: subjectfield.value,
text: textfield.value
}
}
console.log("data: " + body);
let options = {
uri: 'https://mrhhkswrhd.execute-api.us-west-2.amazonaws.com/dev/sendEmail',
method: 'POST',
body:body,
json:true
}
request(options, function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log(body);
if(body === 'success'){
dialogsuccess.showModal();
}
})
})
$("#myBtn").click(function () {
$([document.documentElement, document.body]).animate({
scrollTop: 0
}, 1000);
});
window.onscroll = function () { scrollFunction() };
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.getElementById("myBtn").style.display = "block";
} else {
document.getElementById("myBtn").style.display = "none";
}
}