I have this script to get the historical data from last year to today. The script is running good with one stock (in this example "mo"). I build an array because I want 6 stocks and the loop needs to build 6 tables. If I replace the stock name "mo" with my array name I get error.
var yyyy = new Date().getFullYear();
var mm = new Date().getMonth() + 1;
if (mm < 10) {
mm = "0" + mm;
}
var dd = new Date().getDate();
var endDate = yyyy + "-" + mm + "-" + dd;
var startDate = (yyyy - 1) + "-" + mm + "-" + dd;
$.ajax({
url: "https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.historicaldata where symbol = 'mo' and startDate = '" + startDate + "' and endDate = '" + endDate + "'&format=json&diagnostics=true&env=store://datatables.org/alltableswithkeys&callback=",
dataType: 'json',
success: function (data) {
var myTable = "";
myTable += "<br /><table border='1' cellpadding='0' cellspacing='0' width='500' bgcolor='green'>";
myTable += "<tr>";
myTable += "<td>Date</td><td>Open</td><td>Low</td><td>High</td><td>Volume</td><td>Close Price</td>";
myTable += "</tr>";
$.each(data.query.results.quote, function (index, item) {
myTable += "<tr><td>" + item.Date + "</td><td>" + item.Open + "</td><td>" + item.Low + "</td><td>" + item.High + "</td><td>" + item.Volume + "</td><td>" + item.Close + "</td></tr>";
});
myTable += "</table>";
$("#quotes").html(myTable);
},
error: function () {
$("#quotes").html('<p>Something has gone terribly wrong.</p>');
}
});
You don't need to build 6 table queries. You can use the "IN" keyword. Sample query if you want historical data for "YHOO", "GOOG" and "AAPL" stock
select * from yahoo.finance.historicaldata where symbol IN ("YHOO","GOOG","AAPL") and startDate = "2009-09-11" and endDate = "2010-03-10"
Test it out in YQL console here
Related
I have this table:
I'm trying to insert the events I have in my database in a certain way: basically what i would like is to let the code to check the name of the events in my database (blue square) and associate the cells (above the red line) where I add manually my events with the same name. And at that point add the hour difference (between startDate and endDate) in the corresponding day of the month.
This is the code that render the header of my table (where it takes the current month and add every days of that month):
function renderHead(div, start, end) {
var c_year = start.getFullYear();
var r_year = "<tr>";
var daysInYear = 0;
var c_month = start.getMonth();
var r_month = "<tr>";
var daysInMonth = 0;
var r_days = "<tr> <td id= 'event'> Eventi </td>";
for (start; start <= end; start.setDate(start.getDate() + 1)) {
if (start.getFullYear() !== c_year) {
r_year += '<td colspan="' + daysInYear + '">' + c_year + '</td>';
c_year = start.getFullYear();
daysInYear = 0;
}
daysInYear++;
if (start.getMonth() !== c_month) {
r_month += '<td colspan="' + daysInMonth + '">' + months[c_month] + '</td>';
c_month = start.getMonth();
daysInMonth = 0;
}
daysInMonth++;
r_days += '<td id="days">' + start.getDate() + '</td>';
}
r_days += " <td id='tot'> Totale </td> </tr>";
r_year += '<td colspan="' + (daysInYear) + '">' + months[c_month] + ' '+ c_year +'</td>';
r_year += "</tr>";
table = "<table id='tblData' border='1'>" + r_year + r_days + "</table>";
div.html(table);
}
var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);
renderHead($('div#table2'), new Date(firstDay), new Date(lastDay));
This is the function that get the events (blue square) and the difference between startDate and endDate from my database (and the tbody where i manually add the events):
function getEvents(year, month){
var currentEvents = $('#calendar').fullCalendar('clientEvents').filter(event =\> (new Date(event.start) \> firstDay && new Date(event.end) \<= lastDay));
for(i=0; i\<currentEvents.length; i++) {
if(currentEvents\[i\].nomeUtente == $("#nomeUtente").data('value')){
const start = new Date(currentEvents\[i\].start.\_i);
const end = new Date(currentEvents\[i\].end.\_i);
if (currentEvents\[i\].title == "Normali" || currentEvents\[i\].title == "Ferie"){
const milliseconds = Math.abs((end - start)-5400000);
var hours = milliseconds / 36e5;
}else{
const milliseconds = Math.abs(end - start);
var hours = milliseconds / 36e5;
}
if ($("#tblData tbody").length == 0) {
$("#tblData").append("\<tbody\>"+ "\<tr\>\<td id='norm'\>Normali\</td\>\</tr\>"+
"\<tr\>\<td id='stra'\>Straordinarie\</td\>\</tr\>"+
"\<tr\>\<td id='fer'\>Ferie\</td\>\</tr\>"+
"\<tr\>\<td id='mal'\>Malattia\</td\>\</tr\>"+
"\<tr\>\<td id='perm'\>Permesso\</td\>\</tr\>"+
"\<tr\>\<td id='sm'\>Smart Working\</td\>\</tr\>"+
"\<tr\>\<td id='tras'\>Trasferta\</td\>\</tr\>"+
"\<tr\>\<td id='anr'\>Assenze non retribuita\</td\>\</tr\>"+
"\<tr\>\<td id='alt'\>Altro\</td\>\</tr\>"+ "\</tbody\>");
}
$("#tblData tbody").append("\<tr\>" +
//"\<td\>" + currentEvents\[i\].title + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\<td\>" + hours + "\</td\>" +
"\</tr\>");
}
}
};
For reference, this is my database:
This is what I've been doing so far:
function getEvents(year, month){
var table = document.getElementById('tblData');
var currentEvents = $('#calendar').fullCalendar('clientEvents').filter(event => (new Date(event.start) > firstDay && new Date(event.end) <= lastDay));
for(i=0; i<currentEvents.length; i++) {
if(currentEvents[i].nomeUtente == $("#nomeUtente").data('value')){
const start = new Date(currentEvents[i].start._i);
const end = new Date(currentEvents[i].end._i);
if (currentEvents[i].title == "Normali" || currentEvents[i].title == "Ferie"){ //provato a mettere una condizione nel quale se Normali o Ferie togliere millisecondi se no no
const milliseconds = Math.abs((end - start)-5400000);
var hours = milliseconds / 36e5;
}else{
const milliseconds = Math.abs(end - start);
var hours = milliseconds / 36e5;
}
if ($("#tblData tbody").length == 0) {
$("#tblData").append("<tbody>"+ "<tr><td id='norm'>Normali</td></tr>"+
"<tr><td id='stra'>Straordinarie</td></tr>"+
"<tr><td id='fer'>Ferie</td></tr>"+
"<tr><td id='mal'>Malattia</td></tr>"+
"<tr><td id='perm'>Permesso</td></tr>"+
"<tr><td id='sm'>Smart Working</td></tr>"+
"<tr><td id='tras'>Trasferta</td></tr>"+
"<tr><td id='anr'>Assenze non retribuita</td></tr>"+
"<tr><td id='alt'>Altro</td></tr>"+ "</tbody>");
}
for (var r = 0, n = table.rows.length; r < n; r++) {
for (var c = 0, m = table.rows[r].cells.length; c < m; c++) {
if(table.rows[r].cells[c].innerHTML == currentEvents[i].title){ //controlla contenuto cella se รจ uguale ad evento
$("#tblData tbody #days").append("<tr> <td>" + hours + "</td></tr>");
}else{
alert (table.rows[r].cells[c].innerHTML);
}
}
}
}
}
};
But it doesnt work :(
I am trying to send an email based on expired items. I have read through a lot of blogs and found one that finally worked (link below). I had it working last night and now somehow I have broken it. I tried reverting but I am still having issues. I am very new at all this so I really appreciate any explanations you can give. For now I want it to just send an alert because there is a limit on the number of emails it will send daily.
function emailAlert() {
// Same variations.
// today's date information
var today = new Date();
var todayMonth = today.getMonth() + 1;
var todayDay = today.getDate();
var todayYear = today.getFullYear();
// 2 months from now
var oneMonthFromToday = new Date(todayYear, todayMonth, todayDay);
var oneMonthMonth = oneMonthFromToday.getMonth() + 2;
var oneMonthDay = oneMonthFromToday.getDate();
var oneMonthYear = oneMonthFromToday.getYear();
// getting data from spreadsheet
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Exp");
var startRow = 2; // First row of data to process
var numRows = 500; // Number of rows to process
var dataRange = sheet.getRange(startRow, 1, numRows, 999);
var data = dataRange.getValues();
//looping through all of the rows
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var expireDateFormat = Utilities.formatDate(new Date(row[5]),
'ET',
'MM/dd/yyyy'
);
//email Information
var subject = 'Pantry Item Needs Attention!';
var message1 =
row[6] + ' ' + row[3] + ' of ' + row[2] + ' ' + row[1] + ' will expire on ' + expireDateFormat + '. Item can be found in ' + row[7]
+ '. Please Remove and Replace Item.' +
'\n' + 'Thanks Steve!';
var message2 =
row[6] + ' ' + row[3] + ' of ' + row[2] + ' ' + row[1] + ' will expire on ' + expireDateFormat + '. Item can be found in ' + row[7] +
'. Please ensure item has been replaced, removed from the pantry, and deleted from inventory.' +
'\n' + 'Thanks Steve!'
//expiration date information
var expireDateMonth = new Date(row[5]).getMonth() + 1;
var expireDateDay = new Date(row[5]).getDate();
var expireDateYear = new Date(row[5]).getYear();
//checking for today
if (
expireDateMonth === todayMonth &&
expireDateDay === todayDay &&
expireDateYear === todayYear
) {
ui.alert(message1);
}
}
}
Does this work for you?
function emailAlert() {
var ss=SpreadsheetApp.getActive();
var sheet=ss.getSheetByName("Exp");
var startRow=2;
var rg=sheet.getRange(startRow,1,sheet.getLastRow()-startRow+1,sheet.getLastColumn());
var expireDateFormat=Utilities.formatDate(new Date(new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()),Session.getScriptTimeZone(),"MM/dd/yyyy")
var data=rg.getValues();
for(var i=0;i<data.length;++i) {
var row=data[i];
var subject='Pantry Item Needs Attention!';
var message1=row[6] + ' ' + row[3] + ' of ' + row[2] + ' ' + row[1] + ' will expire on ' + expireDateFormat + '. Item can be found in ' + row[7] + '. Please Remove and Replace Item.' + '\n' + 'Thanks Steve!';
var message2=row[6] + ' ' + row[3] + ' of ' + row[2] + ' ' + row[1] + ' will expire on ' + expireDateFormat + '. Item can be found in ' + row[7] + '. Please ensure item has been replaced, removed from the pantry, and deleted from inventory.' + '\n' + 'Thanks Steve!';
Logger.log(message1);
}
}
I solved the problem. I was using getYear, which has been replaced by getFullYear. Everything is functioning well now. Thank you guys!
expireDateYear = new Date(row[5]).getYear();
expireDateYear = new Date(row[5]).getFullYear();
I'm using railway API in my website and want the Train data in grid format. Please help me with the same.
I want all the variables (Train name, Train number, Departure Time, Arrival Time, Travel Time, Availability Status) in a table format. I'm calling two APIs to get the final result. How can I achieve this using AngularJs?
function between(trainData) {
var total = trainData.TotalTrains;
for (i = 0; i < total; i++) {
var source = trainData.Trains[i].Source;
var destination = trainData.Trains[i].Destination;
var name = trainData.Trains[i].TrainName;
var number = trainData.Trains[i].TrainNo;
var ttime = trainData.Trains[i].TravelTime;
var deptime = trainData.Trains[i].DepartureTime;
var arrtime = trainData.Trains[i].ArrivalTime;
$('.' + className + '').append("<br/>" + name + "(" + number + ")" + " " + ttime + " " + deptime + " " + arrtime + "<br/>");
}
}
}
you can append with the in the end like
$('.' + className + '').append("<table><tr><th>name</th><th>number </th><th>ttime </th><th>deptime </th><th>arrtime </th><th>classcode </th><th>status </th><th>jdate </th></tr><tr><td>" + name + "</td><td>" + number + "</td><td>" + ttime + "</td><td>" + deptime + " </td><td>" + arrtime + " </td><td>" + classcode + "</td><td>" + status + "</td><td>" + jdate + "</td></tr></table>");
I am trying to complete my code that dynamically produces a table using Jquery DataTables plugin.
The code works up to a point, it displays the data but above the data it also displays "No data available in table".
From what I have read it is something to do with the table initialisation, Can anyone see where I am going wrong.
$(document).ready(function(){
$('#userTable').DataTable( {
"ordering": false,
paging: false,
searching: false,
language: {
emptyTable: "No data available in table", //
loadingRecords: "Please wait .. ", // default Loading...
zeroRecords: "No matching records found"
},
"stripeClasses": [ 'odd-row', 'even-row' ]
});
$.ajax({
url: 'server_processing.php',
type: 'get',
dataType: 'JSON',
success: function(response){
var len = response.length;
for(var i=0; i<len; i++){
var recordid = response[i].RecordID;
var deviceid = response[i].DeviceID;
var mediatype = response[i].MediaType;
var screenlocation = response[i].ScreenLocation;
var promotionname = response[i].PromotionName;
var fromdate = response[i].FromDate;
var fromtime = response[i].FromTime;
var todate = response[i].ToDate;
var totime = response[i].ToTime;
var promotionimage = response[i].PromotionImage;
var orientation = response[i].Orientation;
var enddate = todate +' '+totime;
var startdate = fromdate +' '+fromtime;
var now = new Date();
var nowdate = fixDigit(now.getDay()) + '-' +fixDigit(now.getMonth() + 1) + '-' + now.getFullYear()+' ' +now.getHours() + ":" + now.getMinutes();
// Utility function to prepend zeros to single digits:
function fixDigit(val){
return val.toString().length === 1 ? "0" + val : val;
}
var tr_str = "<tr class='TableText'>" +
"<td style='color:#333;font-size:0.8em;'>" + promotionname + "</td>" +
"<td style='color:#333;font-size:0.8em;'>" + deviceid + " " + screenlocation + "</td>" +
"<td align='center' style='color:#333;font-size:0.8em;'>" + orientation + "</td>" +
"<td style='color:#333;font-size:0.8em;'>" + promotionimage + "</td>" +
"<td align='center' style='color:#333;font-size:0.8em;'>" + mediatype + "</td>" +
"<td style='color:#333;font-size:0.8em;'>" + fromdate + "</td>" +
"<td style='color:#333;font-size:0.8em;'>" + todate + "</td>"
if( (new Date(startdate).getTime() > new Date(nowdate).getTime())) {
tr_str += "<td align='center' style='color:#333;font-size:0.8em;' class='Active'>Active</td>";
} else {
tr_str += "<td align='center' style='color:#333;font-size:0.8em;' class='Scheduled'>Scheduled</td>";
}
tr_str += "<td align='center' style='color:#333;font-size:0.8em;'><input type='button' name='edit' value='Edit' id=" + (i+1) + " class='btn btn-info btn-xs btn-block edit_data'></td>" +
"</tr>";
$("#userTable tbody").append(tr_str);
}
}
});
});
Many thanks in advance for you help and time.
This is because you are appending content without deleting previous, "no data" massage is a row, so you should clear it before for loop:
success: function(response){
var len = response.length;
$("#userTable tbody").html("");
for(var i=0; i<len; i++){
var recordid = response[i].RecordID;
var deviceid = response[i].DeviceID;
...
One thing, this is not the best way to insert data in datatables.
I am trying to access all my data so that I can append it my html document.
I couldn't reach any of the nested arrays by using evt.locations[i].foo because it would only return the first record.
My goal is to be able to access the variables, I have declared and append them to main_info or secondary_info.
Note: I will obviously be restructuring the number of paragraphs used each time but it is just to see it on the page.
$.each(data.events, function(i, evt) {
//getting all nested records
evt.locations.forEach(function(locations, i, array) {
//location data
var city = evt.locations[i].city;
var state = evt.locations[i].state;
var timeZone = evt.locations[i].timezone;
var contactPhone = evt.locations[i].contactPhone;
var contactEmail = evt.locations[i].contactEmail;
var contactName = evt.locations[i].contactName;
var address1 = evt.locations[i].address1;
var address2 = evt.locations[i].address2;
var postalCode = evt.locations[i].postalCode;
//hosts
var host = evt.locations[i].tags.host;
var specialGuest = evt.locations[i].tags.specialGuest;
var cohost = evt.locations[i].tags.cohost;
//tiers
var tierTitle = evt.locations[i].tiers[i].title;
var tierDecription = evt.locations[i].tiers[i].decription;
var tierPrice = evt.locations[i].tiers[i].price;
var tierRaiser = evt.locations[i].tiers[i].raiser;
var tierMax = evt.locations[i].tiers[i].maxNum;
var tierQuantity = evt.locations[i].tiers[i].quantity;
var shiftStart = evt.locations[i].shifts[i].startDate;
var shiftEnd = evt.locations[i].shifts[i].endDate;
//Creating variables for schema found within locations
console.log(evt.locations[i].city)
//if equal to null/nan/undefined/""
});
var main_info = '<h1>' + evt.name + '</h1>';
main_info += '<p>' + evt.templateInfo.title + '</p>';
main_info += '<p>' + evt.description + '</p>';
main_info += '<p> Date: ' + dateString + " " + timeOfEvent + '</p>';
main_info += '<button class="eventsButton">View Event Details</button>';
// only counts first record
// main_info += '<p class="mainInfo">' + evt.locations[i].city + ','
+ evt.locations[i].state +'</p>';
var secondary_info = '<h1 class="">' + 'hello' + '</h1>';
secondary_info += '<p class="">' + evt.description + '</p>';
secondary_info += '<p class="">' + evt.createdDate + '</p>';
secondary_info += '<p class="">' + evt.createdDate + '</p>';
secondary_info += '<p class="">' + evt.guestsCanInviteOthers + '</p>';
code in JsBin
you already ve a ready to be used object from the http call, why parse it again
$(document).ready(function() {
// Getting all the data from AWS link
$.ajax({
url: 'https://s3.amazonaws.com/interview-api-samples/events-results.json',
cache: false,
dataType: 'json',
type: 'GET',
data: ({
'events': []
}),
success: printEvents,
error: function(e, xhr) {
console.log(e);
}
});
function printEvents(events) {
$.each(events.events, function(i, event) {
//console.log(i, event);
var eventStart = event.startDate;
var myDate = new Date(eventStart);
var dateString = myDate.getUTCMonth() + "/" + ("0" + (myDate.getUTCDate() + 1)).slice(-2) + "/" + ("0" + myDate.getUTCFullYear()).slice(-2);
// Converting time from military to standaerd and checking if it is am/pm
var hours = myDate.getUTCHours();
var minutes = myDate.getUTCMinutes();
var timeOfEvent = "" + ((hours > 12) ? hours - 12 : hours);
timeOfEvent += (minutes < 10) ? ":0" + minutes : ":" + minutes;
timeOfEvent += (hours >= 12) ? " P.M." : " A.M.";
var main_info = '<h1>' + event.name + '</h1>';
main_info += '<p>' + /*event.templateInfo.title*/ "" + '</p>'; //<--- empty
main_info += '<p>' + event.description + '</p>';
main_info += '<p> Date: ' + dateString + " " + timeOfEvent + '</p>';
main_info += '<button class="eventsButton">View Event Details</button>';
console.log(event.locations);
$.each(event.locations, function(i, location) {
// here take what you need es: location.city, location.contactGivenName ....
$.each(Object.keys(location), function(i, loc) {
main_info += '<p class="mainInfo">' + loc + ' , ' + location[loc] + '</p>';
})
$.each(location.tiers, function(i, tier) {
// here take what you need es: tier.id, tier.quantity ....
$.each(Object.keys(tier), function(i, t) {
main_info += '<p class="mainInfo">' + t + ' , ' + tier[t] + '</p>';
})
});
//same here for others nested array elements
});
var secondary_info = '<h1 class="">' + 'hello' + '</h1>';
secondary_info += '<p class="">' + event.description + '</p>';
secondary_info += '<p class="">' + event.createdDate + '</p>';
secondary_info += '<p class="">' + event.createdDate + '</p>';
secondary_info += '<p class="">' + event.guestsCanInviteOthers + '</p>';
$("div.content").append("<div class=event><div class=main_info>" + main_info + "<div class=secondary_info>" + secondary_info + "<input class=attending type=checkbox>" + "I will attend this event" + "</>" + "</div></div></div>");
});
}
console.log("done");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class=content></div>
try:
$(document).ready(function(){
// Getting all the data from AWS link
$.ajax(
{
url: 'https://s3.amazonaws.com/interview-api-samples/events-results.json',
cache: false,
dataType: 'json',
type: 'GET',
data: ({ 'events' : [] }),
success: hillEvents,
error: function(e, xhr)
{
console.log(e);
}
});
function hillEvents(data)
{
$('#hillEvents').html(data.Date);
$.each(data.events, function(i, evt){
// converting date and time.
var eventStart= evt.startDate;
var myDate = new Date(eventStart);
// changing myDate to a date string
var dateString =
myDate.getUTCMonth() +"/"+
("0" + (myDate.getUTCDate()+1)).slice(-2) +"/"+
("0" + myDate.getUTCFullYear()).slice(-2);
// Converting time from military to standaerd and checking if it is am/pm
var hours = myDate.getUTCHours();
var minutes =myDate.getUTCMinutes();
var timeOfEvent = "" + ((hours >12) ? hours - 12 : hours);
timeOfEvent += (minutes < 10) ? ":0" + minutes : ":" + minutes;
timeOfEvent += (hours >= 12) ? " P.M." : " A.M.";
//getting all nested records
$.each(evt.locations,function(i,locations) {
//location data
var city= locations.city;
var state= locations.state;
var timeZone= locations.timezone;
var contactPhone= locations.contactPhone;
var contactEmail= locations.contactEmail;
var contactName= locations.contactName;
var address1= locations.address1;
var address2= locations.address2;
var postalCode= locations.postalCode;
//hosts
var host= locations.tags.host;
var specialGuest=locations.tags.specialGuest;
var cohost=locations.tags.cohost;
$.each(locations.tiers,function(i,v){
var tierTitle= v.title;
var tierDecription= v.decription;
var tierPrice=locations.price;
var tierRaiser=v.raiser;
var tierMax=v.maxNum;
var tierQuantity=v.quantity;
});
$.each(locations.shifts,function(i,v){
var shiftStart= v.startDate;
var shiftEnd= v.endDate;
});
});
var main_info ='<h1>' + evt.name + '</h1>';
main_info += '<p>' + evt.templateInfo.title + '</p>';
main_info += '<p>' + evt.description + '</p>';
main_info += '<p> Date: ' + dateString + " "+ timeOfEvent+ '</p>';
main_info += '<button class="eventsButton">View Event Details</button>';
// only counts first record
// main_info += '<p class="mainInfo">' + locations.city + ','+ locations.state +'</p>';
var secondary_info = '<h1 class="">' + 'hello'+ '</h1>';
secondary_info += '<p class="">' + evt.description + '</p>';
secondary_info += '<p class="">' + evt.createdDate + '</p>';
secondary_info += '<p class="">' + evt.createdDate + '</p>';
secondary_info += '<p class="">' + evt.guestsCanInviteOthers + '</p>';
$("div.content").append("<div class=event><div class=main_info>"+ main_info +"<div class='secondary_info>'"+ secondary_info +"<input class=attending type=checkbox>"+"I will attend this event"+"</>"+"</div></div></div>");
});
}
console.log("done");
});
just declare it out of function and you are able to use that variable in your main_info and secondary_info i.e.:
var city;
var state;
var timeZone;
var contactPhone;
var contactEmail;
var contactName;
var address1;
var address2;
var postalCode;
//hosts
var host;
var specialGuest;
var cohost;
//tiers
var tierTitle;
var tierDecription;
var tierPrice;
var tierRaiser;
var tierMax;
var tierQuantity;
var shiftStart;
var shiftEnd; //getting all nested records
evt.locations.forEach(function(locations, i, array) {
//location data
city= evt.locations[i].city;
state= evt.locations[i].state;
timeZone= evt.locations[i].timezone;
contactPhone= evt.locations[i].contactPhone;
contactEmail= evt.locations[i].contactEmail;
contactName= evt.locations[i].contactName;
address1= evt.locations[i].address1;
address2= evt.locations[i].address2;
postalCode= evt.locations[i].postalCode;
//hosts
host= evt.locations[i].tags.host;
specialGuest=evt.locations[i].tags.specialGuest;
cohost=evt.locations[i].tags.cohost;
//tiers
tierTitle= evt.locations[i].tiers[i].title;
tierDecription= evt.locations[i].tiers[i].decription;
tierPrice=evt.locations[i].tiers[i].price;
tierRaiser=evt.locations[i].tiers[i].raiser;
tierMax=evt.locations[i].tiers[i].maxNum;
tierQuantity=evt.locations[i].tiers[i].quantity;
shiftStart= evt.locations[i].shifts[i].startDate;
shiftEnd= evt.locations[i].shifts[i].endDate;
console.log(evt.locations[i].city)
});