Prevent duplicate E-mail Google Spreadsheets script - javascript

i'm currently able to send E-mail with Google Spreadsheets script. But my trigger and if condition didn't prevent E-mail sending as i wish :
Here is my code :
'''
function myFunction() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("MASTER");
const h3 = 'SPP Proyek JIS Tanggal xx dari xxx';
const headers = ws.getRange("A2:M2").getValues();
const item = headers[0][4];
const spec = headers[0][5];
const sat = headers[0][6];
const qty = headers[0][7];
const price = headers[0][8];
const total = headers[0][9];
const tujuan = headers[0][10];
const lr = ws.getLastRow();
const tableRangeValues = ws.getRange(3, 5,lr-2,7).getDisplayValues();
const trigger = ws.getRange(3, 1,lr-2).getValues();
const statusEmail = ws.getRange(3, 13,lr-2).getValues();
const htmlTemplate = HtmlService.createTemplateFromFile("Email");
htmlTemplate.h3 = h3;
htmlTemplate.headers = headers;
htmlTemplate.item = item;
htmlTemplate.spec = spec;
htmlTemplate.sat = sat;
htmlTemplate.qty = qty;
htmlTemplate.price = price;
htmlTemplate.total = total;
htmlTemplate.tujuan = tujuan;
htmlTemplate.tableRangeValues = tableRangeValues;
htmlTemplate.trigger = trigger;
htmlTemplate.statusEmail = statusEmail;
const htmlForEmail = htmlTemplate.evaluate().getContent();
if ((trigger != 'FALSE') && (statusEmail != 'EMAIL_SENT')); {
GmailApp.sendEmail(
"sistem.jis#gmail.com",
"Approval SPP Komersial",
"HTML Support",
{ htmlBody: htmlForEmail }
);
ws.getRange(3, 13,lr-2).setValue('EMAIL_SENT');
}
'''
and this is my sample file link :
https://docs.google.com/spreadsheets/d/13TKIhY7HmK3o-j98q45XXb2nwZzfYwyYn7EULhY_RJw/edit#gid=1216091331
it seems i have problem with the trigger and if condition code which i don't understand
Thank you!

Defining const trigger = ws.getRange(3, 1,lr-2).getValues(); returns you an array of type [[FALSE], [true], [FALSE], [true]]
To make your code work you need to define a loop that iterates through each row (and trigger) invidually
Also, remove the ; from if ((trigger != 'FALSE') && (statusEmail != 'EMAIL_SENT')); {
Sample:
function myFunction() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheetByName("MASTER");
const h3 = 'SPP Proyek JIS Tanggal xx dari xxx';
const headers = ws.getRange("A2:M2").getValues();
const item = headers[0][4];
const spec = headers[0][5];
const sat = headers[0][6];
const qty = headers[0][7];
const price = headers[0][8];
const total = headers[0][9];
const tujuan = headers[0][10];
const lr = ws.getLastRow();
const tableRangeValues = ws.getRange(3, 5,lr-2,7).getDisplayValues();
var data = ws.getRange(3, 1,lr-2,13).getDisplayValues();
for (var i = 0; i < data.length; i++){
const trigger = data[i][0];
const statusEmail = data[i][12];
const htmlTemplate = HtmlService.createTemplateFromFile("Email");
htmlTemplate.h3 = h3;
htmlTemplate.headers = headers;
htmlTemplate.item = item;
htmlTemplate.spec = spec;
htmlTemplate.sat = sat;
htmlTemplate.qty = qty;
htmlTemplate.price = price;
htmlTemplate.total = total;
htmlTemplate.tujuan = tujuan;
htmlTemplate.tableRangeValues = tableRangeValues;
htmlTemplate.trigger = trigger;
htmlTemplate.statusEmail = statusEmail;
const htmlForEmail = htmlTemplate.evaluate().getContent();
Logger.log(trigger);
if ((trigger != 'FALSE') && (statusEmail != 'EMAIL_SENT')) {
GmailApp.sendEmail(
"sistem.jis#gmail.com",
"Approval SPP Komersial",
"HTML Support",
{ htmlBody: htmlForEmail }
);
ws.getRange(3, 13,lr-2).setValue('EMAIL_SENT');
}
}
}
Note:
In this sample I did not modify tableRangeValues since those values are processed later on on your client-side. Depending on what you want them to be like, you might also want to iterate throguh tem.

Related

Adding data to table from local storage

Good day,
This is some sort of a journal I'm trying to make, the localStorage setItem part is fine, it's the getItem I'm having trouble with, after adding the entries to the table, when I refresh, all of the entries are gone and I'm only left with 1 row with the default input values, ("state?" and "").
JS code:
const state = document.querySelector("#state");
const why = document.querySelector(".why");
const button = document.querySelector(".button");
const table = document.querySelector(".table");
var currentDate = new Date();
let cDay = currentDate.getDate();
let cMonth = currentDate.getMonth() + 1;
let cYear = currentDate.getFullYear();
let cDate = cMonth + "-" + cDay;
var sArray = [];
// Check if there's data in local storage
if (localStorage.getItem("states")) {
sArray = JSON.parse(localStorage.getItem("states"));
}
getDataFromLocalStorage();
button.addEventListener("click", () => {
if (state.value !== "state?") {
addToArray();
why.value = "";
state.value = "state?";
}
});
function addToArray() {
addToTable();
addDataToLocalStorage();
}
function addDataToLocalStorage() {
window.localStorage.setItem("states", JSON.stringify(sArray));
}
function addToTable() {
// Object
let dataObject = {
state: state.value,
reason: why.value,
};
// Add to array
sArray.push(dataObject);
const tr = document.createElement("tr");
const tdstate = document.createElement("td");
const tdWhy = document.createElement("td");
const tdDate = document.createElement("td");
tr.appendChild(tdstate);
tr.appendChild(tdWhy);
tr.appendChild(tdDate);
table.appendChild(tr);
tdstate.innerText = dataObject.state;
tdWhy.innerText = dataObject.reason;
tdDate.innerText = cDate;
}
function getDataFromLocalStorage() {
let data = window.localStorage.getItem("states");
if (data) {
let states = JSON.parse(data);
addToTable(states);
}
}
And this is the HTML code
<body>
<h1>How are you feeling today?</h1>
<div class="content">
<div class="form">
<select name="state" id="state">
<option>State?</option>
<option value="very happy">Very happy</option>
<option value="happy">Happy</option>
<option value="okay">Okay</option>
<option value="sad">Sad</option>
<option value="terrible">Terrible</option>
</select>
<input class="why" type="text" placeholder="Why?" />
<input class="button" type="button" value="Add" />
</div>
<table class="table">
<th>State</th>
<th>Reason</th>
<th>Date</th>
</table>
</div>
<script src="script.js"></script>
</body>
you call addToTable(states); but this function doesn't accept any parameters function addToTable() {.
and it seams like a problem in your logic.
you write it to sArray but never use this values.
here a blind try, not tested it:
const state = document.querySelector("#state");
const why = document.querySelector(".why");
const button = document.querySelector(".button");
const table = document.querySelector(".table");
// Date
var currentDate = new Date();
let cDay = currentDate.getDate();
let cMonth = currentDate.getMonth() + 1;
let cYear = currentDate.getFullYear();
let cDate = cMonth + "-" + cDay;
var sArray = [];
getDataFromLocalStorage();
button.addEventListener("click", () => {
if (state.value !== "state?") {
addToArray({
state: state.value,
reason: why.value,
});
why.value = "";
state.value = "state?";
}
});
function addToArray(dataObject) {
sArray.push(dataObject);
addToTable(dataObject);
addDataToLocalStorage();
}
function addDataToLocalStorage() {
window.localStorage.setItem("states", JSON.stringify(sArray));
}
function addToTable(dataObject) {
const tr = document.createElement("tr");
const tdstate = document.createElement("td");
const tdWhy = document.createElement("td");
const tdDate = document.createElement("td");
tr.appendChild(tdstate);
tr.appendChild(tdWhy);
tr.appendChild(tdDate);
table.appendChild(tr);
tdstate.innerText = dataObject.state;
tdWhy.innerText = dataObject.reason;
tdDate.innerText = cDate;
}
function getDataFromLocalStorage() {
let data = window.localStorage.getItem("states");
if (data) {
sArray = JSON.parse(data);
for(const row of sArray) {
addToTable(row);
}
}
}
There are multiple issues. I would suggest, you should follow the SOLID principle and divide function according to its work. Same time, Instead of creating variables and syncing with storage could be an issue. So directly modifying the localStorage is a good choice.
const stateBtn = document.querySelector("#state");
const whyBtn = document.querySelector(".why");
const addBtn = document.querySelector(".button");
const table = document.querySelector(".table");
// Date
var currentDate = new Date();
let cDay = currentDate.getDate();
let cMonth = currentDate.getMonth() + 1;
let cYear = currentDate.getFullYear();
let cDate = cMonth + "-" + cDay;
addBtn.addEventListener("click", () => {
if (stateBtn.value !== "state?") {
const row = { reason: whyBtn.value, state: stateBtn.value };
addDataToLocalStorage(row);
addToTable(row);
whyBtn.value = "";
stateBtn.value = "state?";
}
});
function addDataToLocalStorage(row) {
const states = [...getDataFromLocalStorage(), row];
localStorage.setItem("states", JSON.stringify(states));
}
function renderTable() {
const states = getDataFromLocalStorage();
for (let row of states) {
addToTable(row);
}
}
function addToTable(row) {
const tr = document.createElement("tr");
const tdstate = document.createElement("td");
const tdWhy = document.createElement("td");
const tdDate = document.createElement("td");
tr.appendChild(tdstate);
tr.appendChild(tdWhy);
tr.appendChild(tdDate);
table.appendChild(tr);
tdstate.innerText = row.state;
tdWhy.innerText = row.reason;
tdDate.innerText = cDate;
}
function getDataFromLocalStorage() {
let data = localStorage.getItem("states") || "[]";
return JSON.parse(data);
}
renderTable();

I want to find Biggest Changerate in the prices of coins

i want to find biggests changerate in the prices in my coins data
like if SDT oldprice is 1.00 and
new price is 1.02 = 2%
and if it was the biggests changerate in the coins my script should printing it
but the script dont working
it only keep give me same coin
const math = require('mathjs');
const fetch = require('node-fetch');
get()
async function get() {
const response = await fetch("https://trade.kucoin.com/_api/currency/prices?base=USD&targets=&lang=en_US");
const coin1 = await response.json();
const olddata = coin1.data
const tokens = Object.keys(olddata)
const oldprice = Object.values(olddata)
get1()
async function get1() {
const response = await fetch("https://trade.kucoin.com/_api/currency/prices?base=USD&targets=&lang=en_US");
const coin2 = await response.json();
const newdata = coin2.data
const tokens = Object.keys(newdata)
const newprice = Object.values(newdata)
function findLargestDifference() {
var large = null;
var index = 0;
for (var i = 0; i < oldprice.length; i++) {
var change = tokens[i].newprice / oldprice[i].oldprice;
if (change > large) {
large = change;
index = i;
}
}
console.log(tokens[index])
return tokens[index];
}
findLargestDifference()
}
}
here how data looks https://prnt.sc/19syjjg

Updating the query data in cloud firestore nested map fields

I'm trying to update the data in nested map fields in firestore, my form is a window form that has 4 sides (wSide1,wSide2,wSide3,wSide4), what my form is doing is if customer select 1 field which is wSide1 and it needs to be updated then only this field only be updated but in my case it is updating all 4 sides, the one which is selected for example side 1 only that has the correct updated values other 3 sides updates with the false values. as my form is dynamic it only shows the field which is selected.
I only want to update the field which is selected, all other has to be null.
js & firestore query
function updateWindowForm(form, type){
var name = $('#name_'+type).val();
var type = $('#type_'+type).val();
const taskformWindow = document.getElementById("taskformWindow");
let editStatus = false;
let id = '';
const updateTask = (id, updatedTask) => db.collection('Buildings').doc(buildingID).collection('rooms').doc(roomID).collection('objects').doc(objectID).update(updatedTask);
window.addEventListener("DOMContentLoaded", async (e) => {
id = doc.id;
editStatus = true;
btnsEdit.forEach((btn) => {
btn.addEventListener("click", async (e) => {
try {
const doc = await getTask(e.target.dataset.id);
const task = doc.data();
editStatus = true;
id = doc.id;
taskformWindow["btn-update-data"].innerText = "Update";
} catch (error) {
console.log(error);
}
});
});
});
taskformWindow.addEventListener("click", async (e) => {
e.preventDefault();
var name_Window = document.getElementById('name_Window').value;
var wAluminium = document.getElementById('wAluminium').checked;
var wColorMeasurement = document.getElementById('wColorMeasurement').value;
var wComments = document.getElementById('wComments').value;
var wForEnd1 = document.getElementById('wForEnd1').checked;
var wForEnd2 = document.getElementById('wForEnd2').checked;
var wSideOfWindows = document.getElementById('wSideOfWindows').value;
var wHardwareManufacturer = document.getElementById('wHardwareManufacturer').value;
var wPlastic = document.getElementById('wPlastic').checked;
//Side 1
var wAxis1_1 = document.getElementById('wAxis1_1').checked;
var wAxis1_2 = document.getElementById('wAxis1_2').checked;
var wBackSet1 = document.getElementById('wBackSet1').value;
var wDirectionLR1_1 = document.getElementById('wDirectionLR1_1').checked;
var wDirectionLR1_2 = document.getElementById('wDirectionLR1_2').checked;
var wHandleHeight1 = document.getElementById('wHandleHeight1').value;
var wOverlapWidth1 = document.getElementById('wOverlapWidth1').value;
var wSashRebateHeight1 = document.getElementById('wSashRebateHeight1').value;
var wSashRebateWidth1 = document.getElementById('wSashRebateWidth1').value;
//Side 2
var wAxis2_1 = document.getElementById('wAxis2_1').checked;
var wAxis2_2 = document.getElementById('wAxis2_2').checked;
var wBackSet2 = document.getElementById('wBackSet2').value;
var wDirectionLR2_1 = document.getElementById('wDirectionLR2_1').checked;
var wDirectionLR2_2 = document.getElementById('wDirectionLR2_2').checked;
var wHandleHeight2 = document.getElementById('wHandleHeight2').value;
var wOverlapWidth2 = document.getElementById('wOverlapWidth2').value;
var wSashRebateHeight2 = document.getElementById('wSashRebateHeight2').value;
var wSashRebateWidth2 = document.getElementById('wSashRebateWidth2').value;
//Side 3
var wAxis3_1 = document.getElementById('wAxis3_1').checked;
var wAxis3_2 = document.getElementById('wAxis3_2').checked;
var wBackSet3 = document.getElementById('wBackSet3').value;
var wDirectionLR3_1 = document.getElementById('wDirectionLR3_1').checked;
var wDirectionLR3_2 = document.getElementById('wDirectionLR3_2').checked;
var wHandleHeight3 = document.getElementById('wHandleHeight3').value;
var wOverlapWidth3 = document.getElementById('wOverlapWidth3').value;
var wSashRebateHeight3 = document.getElementById('wSashRebateHeight3').value;
var wSashRebateWidth3 = document.getElementById('wSashRebateWidth3').value;
//Side 4
var wAxis4_1 = document.getElementById('wAxis4_1').checked;
var wAxis4_2 = document.getElementById('wAxis4_2').checked;
var wBackSet4 = document.getElementById('wBackSet4').value;
var wDirectionLR4_1 = document.getElementById('wDirectionLR4_1').checked;
var wDirectionLR4_2 = document.getElementById('wDirectionLR4_2').checked;
var wHandleHeight4 = document.getElementById('wHandleHeight4').value;
var wOverlapWidth4 = document.getElementById('wOverlapWidth4').value;
var wSashRebateHeight4 = document.getElementById('wSashRebateHeight4').value;
var wSashRebateWidth4 = document.getElementById('wSashRebateWidth4').value;
try {
if (!editStatus) {
await updateTask(id, {
name:name_Window,
Form:{
wAluminium: wAluminium,
wColorMeasurement: wColorMeasurement,
wComments: wComments,
wForEnd1: wForEnd1,
wForEnd2: wForEnd2,
wHardwareManufacturer: wHardwareManufacturer,
wPlastic: wPlastic,
wSide1:{
wAxis1_1: wAxis1_1,
wAxis1_2: wAxis1_2,
wBackSet1: wBackSet1,
wDirectionLR1_1: wDirectionLR1_1,
wDirectionLR1_2: wDirectionLR1_2,
wHandleHeight1: wHandleHeight1,
wOverlapWidth1: wOverlapWidth1,
wSashRebateHeight1: wSashRebateHeight1,
wSashRebateWidth1: wSashRebateWidth1,
},
wSide2:{
wAxis2_1: wAxis2_1,
wAxis2_2: wAxis2_2,
wBackSet1: wBackSet2,
wDirectionLR2_1: wDirectionLR2_1,
wDirectionLR2_2: wDirectionLR2_2,
wHandleHeight2: wHandleHeight2,
wOverlapWidth2: wOverlapWidth2,
wSashRebateHeight2: wSashRebateHeight2,
wSashRebateWidth2: wSashRebateWidth2,
},
wSide3:{
wAxis3_1: wAxis3_1,
wAxis3_2: wAxis3_2,
wBackSet1: wBackSet3,
wDirectionLR3_1: wDirectionLR3_1,
wDirectionLR3_2: wDirectionLR3_2,
wHandleHeight3: wHandleHeight3,
wOverlapWidth3: wOverlapWidth3,
wSashRebateHeight3: wSashRebateHeight3,
wSashRebateWidth3: wSashRebateWidth3,
},
wSide4:{
wAxis4_1: wAxis4_1,
wAxis4_2: wAxis4_2,
wBackSet4: wBackSet4,
wDirectionLR4_1: wDirectionLR4_1,
wDirectionLR4_2: wDirectionLR4_2,
wHandleHeight4: wHandleHeight4,
wOverlapWidth4: wOverlapWidth4,
wSashRebateHeight4: wSashRebateHeight4,
wSashRebateWidth4: wSashRebateWidth4,
},
wSideOfWindows: wSideOfWindows,
}
})
editStatus = false;
id = '';
taskformWindow['btn-update-window-data'].innerText = 'Daten aktualisiert';
swal("", "Daten wurden aktualisert!", "success");
}
taskformWindow.reset();
} catch (error) {
console.log(error);
}
});
}
I can't see the code you use for updating your data but I can ausme that you probably did not set the merge to true while saving the data.
Take a look at this code snipped:
var cityRef = db.collection('cities').doc('BJ');
var setWithMerge = cityRef.set({
capital: true
}, { merge: true });
By setting that we ensure to udate only the fields we want to and leave the rest as it is. Still make sure not to send fields with a null value because that is a valid value for firestore and it doesn't mean that those fields will by skipped in the update process. You can find more about it here.

JavaScript Problem with function with parameters

I have a little problem with my function.
When I try to run my function with parameter, it fails. I tried:
function(a4)
function('a4')
function("a4")
and nothing works :( I don't know where is my problem. I want to create a function because my code is repeating 10 times, so I would like to switch only a function parameter. Please, help!
This function works:
function zmien_dane() {
const silnik = document.querySelector('#dane');
var zawartosc = silnik.dataset.a4;
document.getElementById("dane").innerHTML = zawartosc;
const spalanie = document.querySelector('#dane2');
var zawartosc = spalanie.dataset.a4;
document.getElementById("dane2").innerHTML = zawartosc;
const skrzynia = document.querySelector('#dane3');
var zawartosc = skrzynia.dataset.a4;
document.getElementById("dane3").innerHTML = zawartosc;
const nadwozie = document.querySelector('#dane4');
var zawartosc = nadwozie.dataset.a4;
document.getElementById("dane4").innerHTML = zawartosc;
}
This function doesn't work:
function zmien_dane(parameter) {
const silnik = document.querySelector('#dane');
var zawartosc = silnik.dataset.parameter;
document.getElementById("dane").innerHTML = zawartosc;
const spalanie = document.querySelector('#dane2');
var zawartosc = spalanie.dataset.parameter;
document.getElementById("dane2").innerHTML = zawartosc;
const skrzynia = document.querySelector('#dane3');
var zawartosc = skrzynia.dataset.parameter;
document.getElementById("dane3").innerHTML = zawartosc;
const nadwozie = document.querySelector('#dane4');
var zawartosc = nadwozie.dataset.parameter;
document.getElementById("dane4").innerHTML = zawartosc;
}
You may need to use square bracket like this
silnik.dataset[parameter];
Check this link

How to ignore empty fields in Ionic / Firebase?

I have a function for the user to be able to change his own details in his account like his description or social links etc...
However, when I submit the form, it replaces everything and the empty values just erase the field in the database.
Any way to submit the form and replace ONLY the values that have been entered in the field and ignore the empty ones ?
Here is my controller :
var database = firebase.database();
var userId = firebase.auth().currentUser.uid;
var nameInput = document.querySelector('#name');
var descriptionInput = document.querySelector('#description');
var cityInput = document.querySelector('#city');
var ageInput = document.querySelector('#age');
var hobbiesInput = document.querySelector('#hobbies');
var facebookInput = document.querySelector('#facebook');
var twitterInput = document.querySelector('#twitter');
var instagramInput = document.querySelector('#instagram');
var youtubeInput = document.querySelector('#youtube');
var snapchatInput = document.querySelector('#snapchat');
var linkedinInput = document.querySelector('#linkedin');
var emailInput = document.querySelector('#email');
var passwordInput = document.querySelector('#password');
var saveButton = document.querySelector('#save');
saveButton.addEventListener("click", function() {
var name = nameInput.value;
var description = descriptionInput.value;
var city = cityInput.value;
var age = ageInput.value;
var hobbies = hobbiesInput.value;
var facebook = facebookInput.value;
var twitter = twitterInput.value;
var instagram = instagramInput.value;
var youtube = youtubeInput.value;
var snapchat = snapchatInput.value;
var linkedin = linkedinInput.value;
var email = emailInput.value;
var password = passwordInput.value;
firebase.database().ref('accounts/' + userId).set({
name: name,
description: description,
city: city,
age: age,
hobbies: hobbies,
facebook: facebook,
twitter: twitter,
instagram: instagram,
youtube: youtube,
snapchat: snapchat,
linkedin: linkedin,
email: email,
password: password,
});
receiveNewData();
function receiveNewData() {
// check if there's new data added
firebase.database().ref('accounts/' + userId).on('child_added', function(msg) {
var data = msg.val();
// your new data
console.log(data);
$state.go("tab.account");
});
}
});
var firebase_data = {};
var userID = firebase.auth().currentUser.uid;
var input_data = {
nameInput: document.querySelector('#name'),
descriptionInput: document.querySelector('#description'),
cityInput: document.querySelector('#city'),
ageInput: document.querySelector('#age'),
hobbiesInput: document.querySelector('#hobbies'),
facebookInput: document.querySelector('#facebook'),
twitterInput: document.querySelector('#twitter'),
instagramInput: document.querySelector('#instagram'),
youtubeInput: document.querySelector('#youtube'),
snapchatInput: document.querySelector('#snapchat'),
linkedinInput: document.querySelector('#linkedin'),
emailInput: document.querySelector('#email'),
passwordInput: document.querySelector('#password'),
saveButton: document.querySelector('#save')
}
for(var key in input_data) {
if(input_data.hasOwnProperty(key) && input_data[key].value.length) {
firebase_data[key] = input_data[key].value
}
}
firebase.database().ref('accounts/' + userId).set(firebase_data)
For the people, like me, that are new to this, here is the solution I found : Autocomplete the fields that have a value already so when I submit the form it is saved again with the same value.
The code :
var database = firebase.database();
var userId = firebase.auth().currentUser.uid;
var nameInput = document.querySelector('#name');
var descriptionInput = document.querySelector('#description');
var cityInput = document.querySelector('#city');
var ageInput = document.querySelector('#age');
var hobbiesInput = document.querySelector('#hobbies');
var facebookInput = document.querySelector('#facebook');
var twitterInput = document.querySelector('#twitter');
var instagramInput = document.querySelector('#instagram');
var youtubeInput = document.querySelector('#youtube');
var snapchatInput = document.querySelector('#snapchat');
var linkedinInput = document.querySelector('#linkedin');
var emailInput = document.querySelector('#email');
var passwordInput = document.querySelector('#password');
var saveButton = document.querySelector('#save');
var database = firebase.database().ref('/accounts/' + userId);
// Retrieve information into the fields already filled in Database
database.on('value', function(snapshot) {
var displayName = snapshot.val().name;
var description = snapshot.val().description;
var displayCity = snapshot.val().city;
var displayAge = snapshot.val().age;
var displayHobbies = snapshot.val().hobbies;
var displayFacebook = snapshot.val().facebook;
var displayTwitter = snapshot.val().twitter;
var displayInstagram = snapshot.val().instagram;
var displayYoutube = snapshot.val().youtube;
var displaySnapchat = snapshot.val().snapchat;
var displayLinkedin = snapshot.val().linkedin;
var displayEmail = snapshot.val().email;
var displayPassword = snapshot.val().password;
$scope.$apply(function() {
$scope.displayName = displayName;
$scope.description = description;
$scope.displayCity = displayCity;
$scope.displayAge = displayAge;
$scope.displayHobbies = displayHobbies;
$scope.displayFacebook = displayFacebook;
$scope.displayTwitter = displayTwitter;
$scope.displayInstagram = displayInstagram;
$scope.displayYoutube = displayYoutube;
$scope.displaySnapchat = displaySnapchat;
$scope.displayLinkedin = displayLinkedin;
$scope.displayEmail = displayEmail;
$scope.displayPassword = displayPassword;
});
document.getElementById("name").value = displayName;
document.getElementById("description").value = description;
document.getElementById("city").value = displayCity;
document.getElementById("age").value = displayAge;
document.getElementById("hobbies").value = displayHobbies;
document.getElementById("facebook").value = displayFacebook;
document.getElementById("twitter").value = displayTwitter;
document.getElementById("instagram").value = displayInstagram;
document.getElementById("youtube").value = displayYoutube;
document.getElementById("snapchat").value = displaySnapchat;
document.getElementById("linkedin").value = displayLinkedin;
document.getElementById("email").value = displayEmail;
document.getElementById("password").value = displayPassword;
});;

Categories

Resources