My question was the same as title. Below was my code how to detective collision resources:
scheduler.getConllisionOnEvents = function(id){
var startDate = [];
var endDate = [];
var resources = [];
var descriptions = [];
var oganizer = [];
var isContention = false;
var currentEv = scheduler.getEvent(id);
var contentionIndex = 0;
for (var index in scheduler._events){
var ev = scheduler._events[index];
if (ev && ev.id != id){
if ((ev.start_date<=currentEv.start_date && ev.end_date>currentEv.start_date) || (ev.start_date<currentEv.end_date && ev.end_date>=currentEv.end_date)){
var currentRes = “”;
if (currentEv.resources[0] == undefined)
{
currentRes = currentEv.resources.split(",");
} else {
currentRes = currentEv.resources;
}
for (var curIndex in currentRes){
var res = ev.resources.split(",");
for (var evIndex in res){
if (currentRes[curIndex] == res[evIndex]){
resources[contentionIndex] = res[evIndex];
startDate[contentionIndex] = ev.start_date;
endDate[contentionIndex] = ev.end_date;
descriptions[contentionIndex] = ev.text;
oganizer[contentionIndex] = ev.organizer;
contentionIndex++;
isContention = true;
}
}
}
}
}
}
if (isContention){
var alertStr = "Conllision Resources: ";
var list = “”;
for (var index in resources){
//if (resources[index + 1] != undefined && resources[index + 1] != resources[index]){
list = list + “\n”+ "Resource: " + resources[index] + ", Time Period: " + scheduler.convertDate(startDate[index]) + “~” + scheduler.convertDate(endDate[index]);
//}
}
alert(alertStr + list);
}
return isContention;
}
scheduler.convertDate=function(date){
var dat =date.getDate();
var mon =date.getMonth();
var yea = date.getYear();
var hor = date.getHours();
return yea+"-"+mon+"-"+dat+" “+hor+”:00:00";
}
But it seems that it doesn’t work all the time.
So how can I do make it work smoothly?
Best wishes,