Added updating of datamaps with new bubbles

pull/174/head
Jordan Wright 2016-02-23 18:50:07 -06:00
parent 95fb02bade
commit 0c72e8b69a
1 changed files with 42 additions and 10 deletions

View File

@ -63,6 +63,7 @@ var statuses = {
}
var campaign = {}
var bubbles = []
function dismiss() {
$("#modal\\.flashes").empty()
@ -169,6 +170,15 @@ function renderTimeline(data) {
return results
}
/* poll - Queries the API and updates the UI with the results
*
* Updates:
* * Timeline Chart
* * Email (Donut) Chart
* * Map Bubbles
* * Datatables
*/
function poll() {
api.campaignId.get(campaign.id)
.success(function(c) {
@ -233,8 +243,31 @@ function poll() {
}
})
})
/* Update the map information */
$.each(campaign.results, function(i, result) {
// Check that it wasn't an internal IP
if (result.latitude == 0 && result.longitude == 0) {
return true;
}
newIP = true
$.each(bubbles, function(i, bubble) {
if (bubble.ip == result.ip) {
bubbles[i].radius += 1
newIP = false
return false
}
})
if (newIP) {
bubbles.push({
latitude: result.latitude,
longitude: result.longitude,
name: result.ip,
fillKey: "point",
radius: 2
})
}
})
map.bubbles(bubbles)
})
}
@ -440,7 +473,6 @@ function load() {
}
});
}
bubbles = []
$.each(campaign.results, function(i, result) {
// Check that it wasn't an internal IP
if (result.latitude == 0 && result.longitude == 0) {