-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
script.js
77 lines (66 loc) · 2.11 KB
/
script.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
/* add event listeners here */
(function ($) {
"use strict";
$(function () {
var header = $(".start-style");
$(window).scroll(function () {
var scroll = $(window).scrollTop();
if (scroll >= 10) {
header.removeClass("start-style").addClass("scroll-on");
} else {
header.removeClass("scroll-on").addClass("start-style");
}
});
});
//Animation
$(document).ready(function () {
$("body.hero-anime").removeClass("hero-anime");
});
//Menu On Hover
$("body").on("mouseenter mouseleave", ".nav-item", function (e) {
if ($(window).width() > 750) {
var _d = $(e.target).closest(".nav-item");
_d.addClass("show");
setTimeout(function () {
_d[_d.is(":hover") ? "addClass" : "removeClass"]("show");
}, 1);
}
});
//Switch light/dark
$("#switch").on("click", function () {
if ($("body").hasClass("dark")) {
$("body").removeClass("dark");
$("#switch").removeClass("switched");
} else {
$("body").addClass("dark");
$("#switch").addClass("switched");
}
});
})(jQuery);
// form data sending to discord using webhooks
$("#contact-form").submit(function (e) {
e.preventDefault();
var data = {
name: $("#name").val(),
email: $("#email").val(),
message: $("#message").val(),
};
// console.log(data);
var msg = `Name: ${data.name}\nEmail: ${data.email}\nMessage: ${data.message}`;
console.log(msg);
var discordUrl =
"https://discord.com/api/webhooks/1164479973877354508/Q-wGZb34MkGodGbMsZaRIEgYK8BsJBotMhHVplF8n7z9I_4RxqAMB7Hk9aYUHD8pzuLF";
$.ajax({
type: "POST",
url: discordUrl,
data: JSON.stringify({ content: msg }),
contentType: "application/json",
success: function () {
alert("Message Sent");
$("#contact-form")[0].reset();
},
error: function () {
alert("Message Failed");
},
});
});