From 3da44b14eb04a3cbd5ab32e268157cf08e6536c3 Mon Sep 17 00:00:00 2001 From: jlord Date: Tue, 30 Jul 2013 12:21:39 -0700 Subject: [PATCH] add function to get latest, complete entry --- index.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index c4dc327..a3ee3ae 100644 --- a/index.html +++ b/index.html @@ -143,7 +143,20 @@ map.setView(selectedCoords, 13) }) - var theLatestSpot = gData.reverse()[0] + // so that the first map and info that loads + // is complete and doesn't show rows that are + // actively being edited by folk + function findLatestCompleteSpot(data) { + var latestCompleteSpot = [] + var startWithLatestRow = data.reverse() + startWithLatestRow.forEach(function(row){ + if (!row.lat || !row.long || !row.name || !row.address || !row.city || !row.state ) return + else latestCompleteSpot.push(row) + }) + return latestCompleteSpot[0] + } + + var theLatestSpot = findLatestCompleteSpot(gData) var latestSpot = ich.latestSpot({ rows: theLatestSpot })