Skip to content

Commit

Permalink
fixed bug for issues/22
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanye committed Jan 7, 2015
1 parent 04b43ea commit 5056cc8
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 206 deletions.
136 changes: 68 additions & 68 deletions code/js/plugin/xgcalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,74 +229,74 @@
return { start: option.vstart, end: option.vend };
}
//添加到已获取数据的时间段内
function pushER(start, end) {
var ll = option.loadDateR.length;
if (!end) {
end = start;
}
if (ll == 0) {
option.loadDateR.push({ startdate: start, enddate: end });
}
else {
for (var i = 0; i < ll; i++) {
var dr = option.loadDateR[i];
var diff = DateDiff("d", start, dr.startdate);
if (diff == 0 || diff == 1) {
if (dr.enddate < end) {
dr.enddate = end;
}
break;
}
else if (diff > 1) {
var d2 = DateDiff("d", end, dr.startdate);
if (d2 > 1) {
option.loadDateR.splice(0, 0, { startdate: start, enddate: end });
}
else {
dr.startdate = start;
if (dr.enddate < end) {
dr.enddate = end;
}
}
break;
}
else {
var d3 = DateDiff("d", end, dr.startdate);

if (dr.enddate < end) {
if (d3 < 1) {
dr.enddate = end;
break;
}
else {
if (i == ll - 1) {
option.loadDateR.push({ startdate: start, enddate: end });
}
}
}
}
}
//end for
//clear
ll = option.loadDateR.length;
if (ll > 1) {
for (var i = 0; i < ll - 1; ) {
var d1 = option.loadDateR[i];
var d2 = option.loadDateR[i + 1];

var diff1 = DateDiff("d", d2.startdate, d1.enddate);
if (diff1 <= 1) {
d1.startdate = d2.startdate > d1.startdate ? d1.startdate : d2.startdate;
d1.enddate = d2.enddate > d1.enddate ? d2.enddate : d1.enddate;
option.loadDateR.splice(i + 1, 1);
ll--;
continue;
}
i++;
}
}
}
}
function pushER(start, end) {
var ll = option.loadDateR.length;
if (!end) {
end = start;
}
if (ll == 0) {
option.loadDateR.push({ startdate: start, enddate: end });
}
else {
for (var i = 0; i < ll; i++) {
var dr = option.loadDateR[i];
var diff = DateDiff("d", start, dr.startdate);
if (diff == 0 || diff == 1) {
if (dr.enddate < end) {
dr.enddate = end;
}
break;
}
else if (diff > 1) {
var d2 = DateDiff("d", end, dr.startdate);
if (d2 > 1) {
option.loadDateR.splice(i, 0, { startdate: start, enddate: end });
}
else {
dr.startdate = start;
if (dr.enddate < end) {
dr.enddate = end;
}
}
break;
}
else {
var d3 = DateDiff("d", start, dr.enddate);
if (dr.enddate < end) {
if (d3 >0) {
dr.enddate = end;
break;
}
else {
if (i == ll - 1) {
option.loadDateR.push({ startdate: start, enddate: end });
}
}
}
}
}
//end for
//clear
ll = option.loadDateR.length;
if (ll > 1) {
for (var i = 0; i < ll - 1; ) {
var d1 = option.loadDateR[i];
var d2 = option.loadDateR[i + 1];

var diff1 = DateDiff("d", d1.enddate, d2.startdate);
if (diff1 <= 1) {
d1.startdate = d2.startdate > d1.startdate ? d1.startdate : d2.startdate;
d1.enddate = d2.enddate > d1.enddate ? d2.enddate : d1.enddate;
option.loadDateR.splice(i + 1, 1);
ll--;
continue;
}
i++;
}
}
}
}
//输出
function render() {
//需要的参数
Expand Down
4 changes: 2 additions & 2 deletions example/nodejs/libs/calendardao.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function GetConnection(usecusformat)
{
var db = mysql.createConnection({
host : "localhost",
user : "root",
password : "cjchnws",
user : "xgcalendar",
password : "xgcalendar@123",
database : "xgcalendar"
})
if(usecusformat)
Expand Down
136 changes: 68 additions & 68 deletions example/nodejs/static/js/plugin/xgcalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,74 +229,74 @@
return { start: option.vstart, end: option.vend };
}
//添加到已获取数据的时间段内
function pushER(start, end) {
var ll = option.loadDateR.length;
if (!end) {
end = start;
}
if (ll == 0) {
option.loadDateR.push({ startdate: start, enddate: end });
}
else {
for (var i = 0; i < ll; i++) {
var dr = option.loadDateR[i];
var diff = DateDiff("d", start, dr.startdate);
if (diff == 0 || diff == 1) {
if (dr.enddate < end) {
dr.enddate = end;
}
break;
}
else if (diff > 1) {
var d2 = DateDiff("d", end, dr.startdate);
if (d2 > 1) {
option.loadDateR.splice(0, 0, { startdate: start, enddate: end });
}
else {
dr.startdate = start;
if (dr.enddate < end) {
dr.enddate = end;
}
}
break;
}
else {
var d3 = DateDiff("d", end, dr.startdate);

if (dr.enddate < end) {
if (d3 < 1) {
dr.enddate = end;
break;
}
else {
if (i == ll - 1) {
option.loadDateR.push({ startdate: start, enddate: end });
}
}
}
}
}
//end for
//clear
ll = option.loadDateR.length;
if (ll > 1) {
for (var i = 0; i < ll - 1; ) {
var d1 = option.loadDateR[i];
var d2 = option.loadDateR[i + 1];

var diff1 = DateDiff("d", d2.startdate, d1.enddate);
if (diff1 <= 1) {
d1.startdate = d2.startdate > d1.startdate ? d1.startdate : d2.startdate;
d1.enddate = d2.enddate > d1.enddate ? d2.enddate : d1.enddate;
option.loadDateR.splice(i + 1, 1);
ll--;
continue;
}
i++;
}
}
}
}
function pushER(start, end) {
var ll = option.loadDateR.length;
if (!end) {
end = start;
}
if (ll == 0) {
option.loadDateR.push({ startdate: start, enddate: end });
}
else {
for (var i = 0; i < ll; i++) {
var dr = option.loadDateR[i];
var diff = DateDiff("d", start, dr.startdate);
if (diff == 0 || diff == 1) {
if (dr.enddate < end) {
dr.enddate = end;
}
break;
}
else if (diff > 1) {
var d2 = DateDiff("d", end, dr.startdate);
if (d2 > 1) {
option.loadDateR.splice(i, 0, { startdate: start, enddate: end });
}
else {
dr.startdate = start;
if (dr.enddate < end) {
dr.enddate = end;
}
}
break;
}
else {
var d3 = DateDiff("d", start, dr.enddate);
if (dr.enddate < end) {
if (d3 >0) {
dr.enddate = end;
break;
}
else {
if (i == ll - 1) {
option.loadDateR.push({ startdate: start, enddate: end });
}
}
}
}
}
//end for
//clear
ll = option.loadDateR.length;
if (ll > 1) {
for (var i = 0; i < ll - 1; ) {
var d1 = option.loadDateR[i];
var d2 = option.loadDateR[i + 1];

var diff1 = DateDiff("d", d1.enddate, d2.startdate);
if (diff1 <= 1) {
d1.startdate = d2.startdate > d1.startdate ? d1.startdate : d2.startdate;
d1.enddate = d2.enddate > d1.enddate ? d2.enddate : d1.enddate;
option.loadDateR.splice(i + 1, 1);
ll--;
continue;
}
i++;
}
}
}
}
//输出
function render() {
//需要的参数
Expand Down
Loading

0 comments on commit 5056cc8

Please sign in to comment.