-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
104 lines (96 loc) · 2.85 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
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
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.7.0/firebase-app.js";
const firebaseConfig = {
apiKey: "API_KEY",
authDomain: "bncc-final-project.firebaseapp.com",
projectId: "bncc-final-project",
storageBucket: "bncc-final-project.appspot.com",
messagingSenderId: "956930442347",
appId: "1:956930442347:web:5c27863e2bd21b22b2dd2e",
measurementId: "G-8002ZWCSBH"
};
firebase.initializeApp(firebaseConfig);
const db = firebase.firestore();
const app = initializeApp(firebaseConfig);
$(document).ready(function () {
$("#regform").validate({
rules: {
mail: {
required: true,
email: true
},
names: {
required: true,
minlength: 3
},
phonum: {
required: true,
maxlength: 14,
pattern: "^[0][8][0-9]*$"
},
list: {
required: true
}
}
});
$("#regform").submit((e) => {
const valid = $("#regform").valid();
if (valid) {
e.preventDefault();
const inputmail = $("#inputmail").val();
const inputnama = $("#inputname").val();
const inputnum = $("#inputphonum").val();
const events = $("#dropdown").find(":selected").text();
db.collection("peserta")
.add({
Nama: inputmail,
Email: inputnama,
Telp: inputnum,
event: events
})
.then((docRef) => {
console.log("Document written with ID: ", docRef.id);
alert("Registration Success");
$("#inputmail").val("");
$("#inputname").val("");
$("#inputphonum").val("");
$("#dropdown").prop("selectedIndex", 0);
})
.catch((error) => {
console.error("Error adding document: ", error);
});
} else {
e.preventDefault();
alert("Please fill every box correctly!");
}
});
function pos() {
return Math.floor($(window).width() / 100 + $(window).scrollTop() / 10);
}
function opac() {
return 2 + ($(window).scrollTop() / 125) * -1;
}
function scl() {
return 1 + $(window).scrollTop() / 500;
}
$(window).scroll(() => {
if ($(window).scrollTop()) {
//scroll ke bawah
$("nav").removeClass("bg-transparent");
$("nav").addClass("bg-light", 400);
$(".navbar-toggler-icon").removeClass("whiteicon");
$(".nav-link").addClass("text-black");
$(".nav-link").removeClass("text-white");
$(".judul").css("letter-spacing", pos());
$(".judul").css("opacity", opac());
$(".judul2").css("opacity", opac());
$(".carousel-caption").css({ scale: scl() });
} else {
//sampai di atas lagi
$("nav").addClass("bg-transparent", 200);
$("nav").removeClass("bg-light");
$(".navbar-toggler-icon").addClass("whiteicon");
$(".nav-link").addClass("text-white");
$(".nav-link").removeClass("text-black");
}
});
});