Commit 4a12c8cd authored by Johannes Bill's avatar Johannes Bill

fixed two week view, weeks are now arranged vertically

parent 78cadac7
...@@ -56,16 +56,12 @@ function createWeekView(dataObj, now) { ...@@ -56,16 +56,12 @@ function createWeekView(dataObj, now) {
return content; return content;
} }
function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, className) { function createWeekViewVerticalRaw(dataObj, now, className, offset, addDayOfWeek) {
var data = dataObj.intervals; var data = dataObj.intervals;
var holidays = dataObj.holidays; var holidays = dataObj.holidays;
noOfDays = noOfDays || 7; var noOfDays = 7;
var offset; if(!offset) {
if(flexibleLayout) {
offset = 3;
}
else {
offset = now.getDay() - 1; offset = now.getDay() - 1;
if(offset < 0) offset += 7; if(offset < 0) offset += 7;
} }
...@@ -73,11 +69,7 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam ...@@ -73,11 +69,7 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam
var startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() - offset); var startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() - offset);
var endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + noOfDays - offset); var endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + noOfDays - offset);
var oHours = transformData(data, startDate, endDate); var oHours = transformData(data, startDate, endDate);
var maxNumber = getMaxNoOfItemsPerDay(oHours); var maxItems = getMaxNoOfItemsPerDay(oHours);
var tableWidth = maxNumber;
var content = '<div class="' + className + '-container"><table class="' + className + '-table">';
content += '<tbody>';
var columns = []; var columns = [];
...@@ -101,21 +93,68 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam ...@@ -101,21 +93,68 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam
} }
var datString = formatDate(day.date); var datString = formatDate(day.date);
if(addDayOfWeek) {
column.push('<td class="' + className + '-td-first' + cls + '">' + datString[0] + '</td>'); column.push('<td class="' + className + '-td-first' + cls + '">' + datString[0] + '</td>');
column.push('<td class="' + className + '-td-date' + cls + '">' + datString[1] + '</td>'); column.push('<td class="' + className + '-td-date' + cls + '">' + datString[1] + '</td>');
}
else {
column.push('<td class="' + className + '-td-date2' + cls + '">' + datString[1] + '</td>');
}
for (var j = 0; j < day.oHours.length; j++) { for (var j = 0; j < day.oHours.length; j++) {
var oHour = day.oHours[j]; var oHour = day.oHours[j];
column.push('<td class="' + className + '-td ' + className + '-filled' + cls + '">' + formatTime(oHour[0]) + " – " + formatTime(oHour[1]) + '</td>'); column.push('<td class="' + className + '-td ' + className + '-filled' + cls + '">' + formatTime(oHour[0]) + " – " + formatTime(oHour[1]) + '</td>');
} }
for (var j = day.oHours.length; j < tableWidth; j++) { for (var j = day.oHours.length; j < maxItems; j++) {
column.push('<td class="' + className + '-td ' + className + '-empty' + cls + '"></td>'); column.push('<td class="' + className + '-td ' + className + '-empty' + cls + '"></td>');
} }
}
return columns;
}
function createTwoWeekViewVertical(dataObj, now) {
var className = 'two-weekview-v';
var columns = createWeekViewVerticalRaw(dataObj, now, className, 3, true);
var columns2 = createWeekViewVerticalRaw(dataObj, new Date(now.getFullYear(), now.getMonth(), now.getDate() + 7), className, 3, false);
for (var i = 0; i < columns.length; i++) {
columns[i] = columns[i].concat(columns2[i]);
}
var content = '<div class="' + className + '-container"><table class="' + className + '-table">';
content += '<tbody>';
var jLim = columns[0].length;
var iLim = columns.length;
for (var j = 0; j < jLim; j++) {
content += '<tr class="' + className + '-tr">';
for (var i = 0; i < iLim; i++) {
content += columns[i][j];
}
content += '</tr>';
} }
for (var j = 0; j < tableWidth + 2; j++) {
content += '</tbody>';
content += '</table></div>';
return content;
}
function createWeekViewVertical(dataObj, now) {
var className = 'weekview-v';
var columns = createWeekViewVerticalRaw(dataObj, now, className, null, true);
var content = '<div class="' + className + '-container"><table class="' + className + '-table">';
content += '<tbody>';
var jLim = columns[0].length;
var iLim = columns.length;
for (var j = 0; j < jLim; j++) {
content += '<tr class="' + className + '-tr">'; content += '<tr class="' + className + '-tr">';
for (var i = 0; i < noOfDays; i++) { for (var i = 0; i < iLim; i++) {
content += columns[i][j]; content += columns[i][j];
} }
content += '</tr>'; content += '</tr>';
...@@ -126,6 +165,7 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam ...@@ -126,6 +165,7 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam
return content; return content;
} }
function dayInHolidays(day, holidays) { function dayInHolidays(day, holidays) {
for (var i = 0; i < holidays.length; i++) { for (var i = 0; i < holidays.length; i++) {
if (compareDate(day, holidays[i]) == 0) { if (compareDate(day, holidays[i]) == 0) {
...@@ -342,12 +382,8 @@ function asString(data, now) { ...@@ -342,12 +382,8 @@ function asString(data, now) {
module.exports.asString = asString; module.exports.asString = asString;
module.exports.weekView = createWeekView; module.exports.weekView = createWeekView;
module.exports.weekViewV = function(dataObj, now) { module.exports.weekViewV = createWeekViewVertical;
return createWeekViewVertical(dataObj, now, 7, false, 'weekview-v'); module.exports.twoWeekViewV = createTwoWeekViewVertical;
};
module.exports.twoWeekViewV = function(dataObj, now) {
return createWeekViewVertical(dataObj, now, 14, true, 'two-weekview-v');
};
module.exports.monthView = create3MonthView; module.exports.monthView = create3MonthView;
module.exports.getView = getView; module.exports.getView = getView;
module.exports.getPropperEpochSpan = getPropperEpochSpan; module.exports.getPropperEpochSpan = getPropperEpochSpan;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment