mirror of
https://github.com/marcogll/soul23_placeholder_site_server.git
synced 2026-01-13 13:25:18 +00:00
feat: Add initial project structure with HTML, CSS, JavaScript libraries, and image assets.
This commit is contained in:
54
js/firebase_configuration.js
Normal file
54
js/firebase_configuration.js
Normal file
@@ -0,0 +1,54 @@
|
||||
// Initialize Firebase
|
||||
function validateEmail(email) {
|
||||
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return re.test(String(email).toLowerCase());
|
||||
}
|
||||
|
||||
var config = {
|
||||
apiKey: "<YOUR FIREBASE API KEY>",
|
||||
authDomain: "<FIREBASE AUTH DOMAIN>",
|
||||
databaseURL: "<DB URL>",
|
||||
projectId: "<PROJECT ID>",
|
||||
storageBucket: "<STRORAGE BUKCET>",
|
||||
messagingSenderId: "<MESSAGE SENDER ID>"
|
||||
};
|
||||
firebase.initializeApp(config);
|
||||
var db = firebase.firestore();
|
||||
db.settings({
|
||||
timestampsInSnapshots: true
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('#notifs-form-btn').click(function (e) {
|
||||
var is_present = false;
|
||||
email = $('#notifs-form-input').val();
|
||||
if (validateEmail(email)) {
|
||||
db.collection('Emails').get().then(function (qs) {
|
||||
qs.forEach(function (element) {
|
||||
if (element.data()['ID'] == email) {
|
||||
is_present = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (is_present == false) {
|
||||
db.collection("Emails").add({
|
||||
'ID': email,
|
||||
})
|
||||
.then(function (docRef) {
|
||||
console.log("Document written with ID: ", docRef.id);
|
||||
$("#notifs-form-btn").text("Notified!");
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error("Error adding document: ", error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
alert('Invalid Email');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user