This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Move on the map and add marker to a chosen position | |
function moveOnTheMap(map, chosenPositionMarker) { | |
map.on("click", function (e) { | |
lat = e.latlng.lat; | |
lon = e.latlng.lng; | |
document.getElementById("shop-location").value = lat + " " + lon; | |
let redIcon = new L.Icon({ | |
iconUrl: "https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png", | |
shadowUrl: "https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uploading picture | |
function uploadImageToFirebaseStorage(elementName, fileName, img, edit) { | |
// // Create a reference for the storage, the folder and the filename | |
const storageRef = firebase.storage().ref('products/' + fileName); | |
// Upload the file and metadata | |
const uploadTask = storageRef.putString(img, 'base64'); | |
// Register three observers: | |
// 1. 'state_changed' observer, called any time the state changes | |
// 2. Error observer, called on failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Real time update with Firebase for the Products | |
const getRealTimeUpdatesForProducts = (elementName, pageName) => { | |
... | |
db.collection('products').onSnapshot((doc) => { | |
let result = ''; | |
doc.docs.forEach((doc) => { | |
... | |
const data = doc.data(); | |
result += ` | |
<div class="card-bg block block-strong inset"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Listen for Auth Status Changes | |
auth.onAuthStateChanged(user => setUpUI(user)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Logout | |
const logoutBtn = document.querySelector('#logout'); | |
logoutBtn.addEventListener('click', () => auth.signOut()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get Threads Data | |
const getThreads = () => { | |
db.collection('threads') | |
.orderBy('created', 'desc') | |
.get().then(snapshot => setUpThreads(snapshot.docs)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
getThreads(); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
return { | |
on: { | |
pageInit: function (e, page) { | |
signUp(); | |
} | |
} | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
return { | |
on: { | |
pageInit: function (e, page) { | |
const newCommentBtn = document.querySelector('#new-comment'); | |
// Toggle UI Element | |
auth.onAuthStateChanged(user => { | |
(user) | |
? newCommentBtn.classList.remove('display') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Delete Thread/Comment Image | |
const deleteImage = (folder, id) => { | |
const ref = firebase.storage().ref(folder).child(id + '.jpg'); | |
// Delete the file | |
ref.delete(); | |
} |