2015 年 07 月

浏览模式: 标准 | 列表 | 图文
fullcalendar 判断时间冲突

fullcalendar 判断时间冲突

其实在fullcalendar2中已经有现成的代码了,但是因为我用的是1,所以借鉴网上的一些代码加了自己的处理。可能写的比较恶心!

function isOverlapping(event){
var array=calendar.fullCalendar('clientEvents');
var start=Date.parse(event.start);
if(event.end==null){
var end=start+defaultEventMinutes*60*1000;
}else{
var end=Date.parse(event.end);
}
for(i in array){
if(array[i]._id!=event._id){
var currentStart=Date.parse(array[i].start);
if(array[i].end==null){
var currentEnd=currentStart+defaultEventMinutes*60*1000;
}else{
var currentEnd=Date.parse(array[i].end);
}
/**
* 对应的事件的起始时间>当前事件的结束时间
*/
//if(!(array[i].start >= event.end || array[i].end <= event.start )){
console.log("start :"+start);
console.log("current start :"+currentStart);
console.log("end :"+end);
console.log("current End :"+currentEnd);
if(start>currentStart&&start<currentEnd){//
console.log('开始时间在其他日程之间');
return true;
}
if(end>currentStart&&end<currentEnd){//
console.log('结束时间在其他日程之间');
return true;
}
if(start==currentStart||end==currentEnd){
console.log('//开始时间或者结束时间等于别人的时间');
return true;
}
if(start<currentStart&&end>currentStart){
console.log('其他日程在当前的日期中间');
return true;
}
}
}
return false;
}
其中:defaultEventMinutes 默认应该是等于fullcalendar中的120的,但由于不是每个人都将默认日程设置为120分钟,所以加了个变量自定义一下。

只要不是120,还需要设置一下:fullcalendar({defaultEventMinutes:defaultEventMinutes});

在使用的时候,有3个事件需要用到它,eventDrop,eventResize,drop。drop是指将外部的日程(或者颜色)拖放到日历上。eventDrop,eventResize都是针对指定日程的。

//用的时候就比较简单
if(isOverLapping(event)){
alert('日程安排有冲突');
revertFunc(); //这个方法只有在 eventDrop,eventResize中才有,
return ;
}
至此,处理日程安排重复算是搞定。折腾了一天,网上的那个是直接比较对象。不能用==,好尴尬,所以就采用时间戳了
aliyun的dotdeb源有BUG

aliyun的dotdeb源有BUG

纯笔记做个记录
1、http://mirrors.aliyun.com/ ,这是阿里的源

2、这是dotdeb的说明:http://mirrors.aliyun.com/help/dotdeb

3、阿里云的说明:

编辑/etc/apt/sources.list文件(需要使用sudo), 在文件最后面添加以下条目(操作前请做好相应备份)

deb http://mirrors.aliyun.com/dotdeb/packages.dotdeb.org wheezy all
deb-src http://mirrors.aliyun.com/dotdeb/packages.dotdeb.org wheezy all

其实上面的源的写法是错误的,不需要package.dotdeb.org,应该是这样


deb http://mirrors.aliyun.com/dotdeb wheezy all
deb-src http://mirrors.aliyun.com/dotdeb wheezy all

不过,如果是默认这样其实没有什么特别用,PHP还是5.4,所以如果要针对PHP,就需要再加上

deb http://mirrors.aliyun.com/dotdeb wheezy-php56 all
deb-src http://mirrors.aliyun.com/dotdeb wheezy-php56 all

其实说白了就是看:http://mirrors.aliyun.com/dotdeb/dists/,看这一页支持哪些,然后加在源里就OK了。就象官网说的,如果是阿里云服务器,请使用aliyuncs,流量直接从内网走~