This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
let onSuccess = function (map, p) { | |
L.marker([p.coords.latitude, p.coords.longitude]) | |
.addTo(map) | |
.bindPopup("Your current location.") | |
.openPopup(); | |
map.setView([p.coords.latitude, p.coords.longitude], 14); | |
}; |
This file contains hidden or 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
let map = null; | |
//For the edit-shop page, the map needs a different name | |
if (!map) map = L.map('newShopMap', {doubleClickZoom: false}).locate({setView: true, maxZoom: 12}); | |
map.setView([35.40, 139.50], 12); | |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' | |
}).addTo(map); |
This file contains hidden or 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
const getProductInfoWithYahoo = (barcode) => { | |
try { | |
cordova.plugin.http.get('https://shopping.yahooapis.jp/ShoppingWebService/V3/itemSearch', { | |
appid: yahooApiKey, | |
jan_code: barcode | |
}, {}, function (response) { | |
const data = JSON.parse(response.data); | |
if (data && data.hits && data.hits.length) { | |
document.getElementById("product-name").value = data.hits[0].name; | |
document.getElementById("product-price").value = "¥" + data.hits[0].price; |