2015-05-22 23:30:15 +02:00
|
|
|
/**
|
|
|
|
* @provides javelin-behavior-day-view
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
JX.behavior('day-view', function(config) {
|
|
|
|
var hourly_events = config.hourlyEvents;
|
|
|
|
var today_events = config.todayEvents;
|
|
|
|
|
2015-05-22 23:46:48 +02:00
|
|
|
|
2015-05-22 23:30:15 +02:00
|
|
|
function findTodayClusters() {
|
|
|
|
var events = today_events.sort(function(x, y){
|
|
|
|
return (x.eventStartEpoch - y.eventStartEpoch);
|
|
|
|
});
|
|
|
|
|
|
|
|
var clusters = [];
|
|
|
|
|
2015-05-22 23:46:48 +02:00
|
|
|
for (var i=0; i < events.length; i++) {
|
|
|
|
var today_event = events[i];
|
|
|
|
|
2015-05-22 23:30:15 +02:00
|
|
|
var destination_cluster_index = null;
|
2015-05-22 23:46:48 +02:00
|
|
|
var event_start = today_event.eventStartEpoch - (30*60);
|
|
|
|
var event_end = today_event.eventEndEpoch + (30*60);
|
2015-05-22 23:30:15 +02:00
|
|
|
|
2015-05-22 23:46:48 +02:00
|
|
|
for (var j=0; j < clusters.length; j++) {
|
|
|
|
var cluster = clusters[j];
|
|
|
|
|
|
|
|
for(var k=0; k < cluster.length; k++) {
|
|
|
|
var clustered_event = cluster[k];
|
2015-05-22 23:30:15 +02:00
|
|
|
var compare_event_start = clustered_event.eventStartEpoch;
|
|
|
|
var compare_event_end = clustered_event.eventEndEpoch;
|
|
|
|
|
|
|
|
if (event_start < compare_event_end &&
|
|
|
|
event_end > compare_event_start) {
|
2015-05-22 23:46:48 +02:00
|
|
|
destination_cluster_index = j;
|
2015-05-22 23:30:15 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-05-22 23:46:48 +02:00
|
|
|
|
|
|
|
if (destination_cluster_index !== null) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-05-22 23:30:15 +02:00
|
|
|
|
|
|
|
if (destination_cluster_index !== null) {
|
2015-05-22 23:46:48 +02:00
|
|
|
clusters[destination_cluster_index].push(today_event);
|
2015-05-22 23:30:15 +02:00
|
|
|
destination_cluster_index = null;
|
|
|
|
} else {
|
|
|
|
var next_cluster = [];
|
2015-05-22 23:46:48 +02:00
|
|
|
next_cluster.push(today_event);
|
2015-05-22 23:30:15 +02:00
|
|
|
clusters.push(next_cluster);
|
|
|
|
}
|
2015-05-22 23:46:48 +02:00
|
|
|
}
|
2015-05-22 23:30:15 +02:00
|
|
|
|
|
|
|
return clusters;
|
|
|
|
}
|
|
|
|
|
|
|
|
var today_clusters = findTodayClusters();
|
|
|
|
});
|