This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
146 lines (112 loc) · 4.25 KB
/
main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// CONSTANTS ============================================================
const API_URL = `https://speedcubing-backend.herokuapp.com`
// Navbar ============================================================
document.addEventListener('DOMContentLoaded', function () {
// Get all "navbar-burger" elements
var $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
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
var target = $el.dataset.target;
var $target = document.getElementById(target);
var mobileDrop = document.getElementById("navMenu");
mobileDrop.classList.toggle("is-active");
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
});
// mobileNavDrop.classList.toggle("");
// document.querySelectorAll('.navbar-dropdown').forEach(function(navbarLink){
// navbarLink.addEventListener('click', function(){
// console.log(YEET);
// console.log(mobileNavDrop);
// navbarLink.nextElementSibling.classList.toggle('');
// })
// });
var mobileButton = document.querySelectorAll('.navbar-link') ;
// document.getElementsByClassName('navbar-dropdown')[0].classList.toggle("open");
console.log("plz work");
function hideFunction() {
console.log("plz workyeet");
$('.has-dropdown').click(function(){
var nextDiv = element.next().find('.navbar-dropdown')
console.log(nextDiv);
nextDiv.classList.toggle('');
});
};
Array.from(mobileButton).forEach(function(element) {
element.addEventListener('click', hideFunction);
});
// console.log(mobileNavDrop);
// mobileNavDrop.addEventListener("click", () => {
// // mobileDrop.classList.toggle("");
// // mobileNavDrop.classList.toggle("is-hidden");
// });
const burger = document.querySelector(".burger");
const nav = document.querySelector(`#${burger.dataset.target}`);
burger.addEventListener("click", () => {
burger.classList.toggle("is-active");
nav.classList.toggle("is-active");
});
// ============================================================
function modalSignup() {
document.getElementById("signupModal").className += " is-active";
}
function closeFunction() {
document.getElementById("signupModal").className += "modal";
}
// document.getElementById("register_form").onsubmit = e => {
// e.preventDefault();
// submitFunction();
// return false;
// };
// function submitFunction() {
// $.ajax({
// url: API_URL + "/emails",
// data: JSON.stringify({ email: document.getElementById("address").value }),
// dataType: "json",
// contentType: "application/json",
// type: "POST",
// success() {
// const btn = document.getElementById("submit-btn");
// btn.innerText = "Success!";
// btn.disabled = true;
// document.getElementById("address").disabled = true;
// // elem.addEventListener("keypress", enterfunction);
// }
// });
// }
// // ============================================================
function modalContact() {
document.getElementById("contactModal").className += " is-active";
}
function closeContact() {
document.getElementById("contactModal").className += "modal";
}
// document.getElementById("contact_form").onsubmit = e => {
// e.preventDefault();
// submitContact();
// return false;
// };
// function submitContact() {
// $.ajax({
// url: API_URL + "/contacts",
// data: JSON.stringify({ email: document.getElementById("addresscont").value, name: document.getElementById("namecont").value, message: document.getElementById("messagecont").value }),
// dataType: "json",
// contentType: "application/json",
// type: "POST",
// success() {
// const btn = document.getElementById("contact-btn");
// btn.innerText = "Success!";
// btn.disabled = true;
// elem.addEventListener("keypress", enterfunction);
// }
// });
// }
// ============================================================