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) {
return content;
}
function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, className) {
function createWeekViewVerticalRaw(dataObj, now, className, offset, addDayOfWeek) {
var data = dataObj.intervals;
var holidays = dataObj.holidays;
noOfDays = noOfDays || 7;
var noOfDays = 7;
var offset;
if(flexibleLayout) {
offset = 3;
}
else {
if(!offset) {
offset = now.getDay() - 1;
if(offset < 0) offset += 7;
}
......@@ -73,11 +69,7 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam
var startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() - offset);
var endDate = new Date(now.getFullYear(), now.getMonth(), now.getDate() + noOfDays - offset);
var oHours = transformData(data, startDate, endDate);
var maxNumber = getMaxNoOfItemsPerDay(oHours);
var tableWidth = maxNumber;
var content = '<div class="' + className + '-container"><table class="' + className + '-table">';
content += '<tbody>';
var maxItems = getMaxNoOfItemsPerDay(oHours);
var columns = [];
......@@ -101,21 +93,46 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam
}
var datString = formatDate(day.date);
column.push('<td class="' + className + '-td-first' + cls + '">' + datString[0] + '</td>');
column.push('<td class="' + className + '-td-date' + cls + '">' + datString[1] + '</td>');
if(addDayOfWeek) {
column.push('<td class="' + className + '-td-first' + cls + '">' + datString[0] + '</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++) {
var oHour = day.oHours[j];
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>');
}
}
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]);
}
for (var j = 0; j < tableWidth + 2; j++) {
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 < noOfDays; i++) {
for (var i = 0; i < iLim; i++) {
content += columns[i][j];
}
content += '</tr>';
......@@ -125,6 +142,29 @@ function createWeekViewVertical(dataObj, now, noOfDays, flexibleLayout, classNam
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">';
for (var i = 0; i < iLim; i++) {
content += columns[i][j];
}
content += '</tr>';
}
content += '</tbody>';
content += '</table></div>';
return content;
}
function dayInHolidays(day, holidays) {
for (var i = 0; i < holidays.length; i++) {
......@@ -342,12 +382,8 @@ function asString(data, now) {
module.exports.asString = asString;
module.exports.weekView = createWeekView;
module.exports.weekViewV = function(dataObj, now) {
return createWeekViewVertical(dataObj, now, 7, false, 'weekview-v');
};
module.exports.twoWeekViewV = function(dataObj, now) {
return createWeekViewVertical(dataObj, now, 14, true, 'two-weekview-v');
};
module.exports.weekViewV = createWeekViewVertical;
module.exports.twoWeekViewV = createTwoWeekViewVertical;
module.exports.monthView = create3MonthView;
module.exports.getView = getView;
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