blob: 0697b5166af8cdb45897dba2727dcb83c3056213 (
plain) (
blame)
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
|
/*
* Adds an event listener to all burgers to toggle navbar menu on click.
*/
document.addEventListener('DOMContentLoaded', function () {
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
if ($navbarBurgers.length > 0) {
// add a click event on each of them
$navbarBurgers.forEach(function(el) {
el.addEventListener('click', function () {
// get the target from the 'data-target' attribute
const target = el.dataset.target;
const $target = document.getElementById(target);
// toggle the 'is-active' class on both the 'navbar-burger' and the 'navbar-menu'
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
const disableErrorBox = function() {
document.getElementById("errorBox").style.display = "none";
}
const disableSuccessBox = function() {
document.getElementById("successBox").style.display = "none";
}
const enableErrorBox = function(message) {
let errorBox = document.getElementById("errorBox");
let aTag = document.createElement('a');
aTag.setAttribute("href", "mailto:amy@carpentertutoring.com");
aTag.innerText = message + " Click here to send through your mail client.";
while (errorBox.hasChildNodes()) { errorBox.removeChild(errorBox.lastChild); }
errorBox.appendChild(aTag);
errorBox.style.display = "block";
}
const enableSuccessBox = function() {
document.getElementById("successBox").style.display = "block";
}
/*
* Adds mail sender to form submit.
*/
document.forms.inquiry.onsubmit = function() {
disableErrorBox();
disableSuccessBox();
let form = document.forms.inquiry;
let name = form.elements.name.value;
let fromEmail = form.elements.from.value;
let body = form.elements.body.value;
Email.send({
SecureToken : "cec9bc04-de48-48fd-b1ad-a95cffb41468",
To : "atc@53hor.net",
From : fromEmail,
Subject : "Inquiry: " + name,
Body : body,
}).then( message => {
if (message == "OK") {
form.reset();
enableSuccessBox();
}
else {
enableErrorBox(message);
}
}
);
return false;
}
|