Skip to content

Instantly share code, notes, and snippets.

// Go to a folder where you want to create your project
// Then enter the following command:
monaca create projectname
// Choose JavaScript from the list and press Enter
// After that, choose the Framework7 Core Tab View from the list and press Enter again
// If the installation process is finished, your project is ready to go
#panel-header {
text-align: left !important;
width: 100%;
}
.card-bg {
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
// Add new items to the Shop List
function addNewShopToFirebase(jsonObject) {
db.collection('shops').add({
'name': jsonObject.name,
'telephone': jsonObject.telephone,
'address': jsonObject.address,
'location': jsonObject.location
});
}
// Gives back the current location & adds a marker to the map
// onSuccess callback accepts a Position object, which contains the current coordinates
// onError callback receives a PositionError object
function currentLocation(map) {
navigator.geolocation.getCurrentPosition(function (position) {
onSuccess(map, position);
document.getElementById("shop-location").value = position.coords.latitude + " " + position.coords.longitude;
}, onError);
}
// Set options for camera
function setOptions(srcType) {
const options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: srcType,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
allowEdit: false,
correctOrientation: true,
function scanBarcode() {
cordova.plugins.barcodeScanner.scan(
function (result) {
document.getElementById("product-code").value = result.text;
getProductInfoWithYahoo(result.text);
},
function (error) {
alert("Scanning failed: " + error);
},
{
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);
};
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: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// 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",
// 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