mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 17:02:41 +01:00
8166f25c0d
Summary: Ref T8300, First step towards a Javelin behavior for Calendar day view Test Plan: No user facing changes. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8300 Differential Revision: https://secure.phabricator.com/D12978
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-day-view
|
|
*/
|
|
|
|
|
|
JX.behavior('day-view', function(config) {
|
|
var hourly_events = config.hourlyEvents;
|
|
var today_events = config.todayEvents;
|
|
|
|
function findTodayClusters() {
|
|
var events = today_events.sort(function(x, y){
|
|
return (x.eventStartEpoch - y.eventStartEpoch);
|
|
});
|
|
|
|
var clusters = [];
|
|
|
|
events.forEach(function(e){
|
|
var destination_cluster_index = null;
|
|
var event_start = e.eventStartEpoch - (30*60);
|
|
var event_end = e.eventEndEpoch + (30*60);
|
|
|
|
clusters.forEach(function(cluster, index){
|
|
for(var i=0; i < cluster.length; i++) {
|
|
var clustered_event = cluster[i];
|
|
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) {
|
|
destination_cluster_index = index;
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
if (destination_cluster_index !== null) {
|
|
clusters[destination_cluster_index].push(e);
|
|
destination_cluster_index = null;
|
|
} else {
|
|
var next_cluster = [];
|
|
next_cluster.push(e);
|
|
clusters.push(next_cluster);
|
|
}
|
|
});
|
|
|
|
return clusters;
|
|
}
|
|
|
|
var today_clusters = findTodayClusters();
|
|
});
|