').prop('id', 'calendar_' + room.id).addClass('calendar');
- if (room.config.vertical && room.config.mode === 1) {
- width = 100 + "%";
+ function generateCalendarDiv(room) {
+ var width = 100;
+ if (room.config.mode === 1 && !room.config.vertical) {
+ width = room.config.scale;
+ }
+ var $cal = $('
').addClass('calendar');
+ if (room.config.mode === 1 && room.config.vertical) {
$cal.css('float', "none");
}
- $cal.width(width);
+ $cal.width(width + '%');
room.$.container.append($cal);
room.$.calendar = $cal;
}
@@ -785,12 +782,12 @@ optional:
close = 24;
}
room.openTimes = close - opening;
+ scaleCalendar(room);
room.$.calendar.weekCalendar("option", "businessHours", {
start: opening,
end: close,
limitDisplay: true
});
- scaleCalendar(room);
}
/**
@@ -879,8 +876,12 @@ optional:
var cal = room.$.calendar;
cal.weekCalendar('option', 'data', {events: json});
cal.weekCalendar("refresh");
- cal.weekCalendar("option", "defaultFreeBusy", {free: false});
+ cal.weekCalendar("option", "defaultFreeBusy", {free: !room.openingTimesCalendar});
cal.weekCalendar("updateFreeBusy", room.openingTimesCalendar);
+ cal.weekCalendar("resizeCalendar");
+ setTimeout(function() {
+ scaleRoom(room);
+ }, 550);
}
room.state = null;
UpdateRoomHeader(room);
@@ -955,12 +956,12 @@ optional:
$cal.weekCalendar("option", "data", {events: room.timetable});
$cal.weekCalendar('refresh');
}
+ $cal.weekCalendar("option", "defaultFreeBusy", {free: !room.openingTimesCalendar});
if (room.openingTimesCalendar) {
$cal.weekCalendar("updateFreeBusy", room.openingTimesCalendar);
}
$cal.weekCalendar("resizeCalendar");
- $cal.weekCalendar("scrollToHour");
-
+ $cal.weekCalendar("option", "hourLine", true);
}
/**
@@ -969,7 +970,7 @@ optional:
* @param {Date} a
* @param {Date} b
* @param room Room Object
- * @returns time string
+ * @returns {string} printable time
*/
function GetTimeDiferenceAsString(a, b, room) {
if (!a || !b) {
@@ -990,10 +991,10 @@ optional:
minutes = "0" + minutes;
}
if (days !== 0) {
- // dont show?
+ // don't show?
return "";
}
- if (room.config.eco) {
+ if (globalConfig.eco) {
return hours + ":" + minutes;
}
return hours + ":" + minutes + ":" + seconds;
@@ -1002,12 +1003,13 @@ optional:
/**
* returns next closing time of a given room
* @param room
- * @returns Date Object of next closing
+ * @returns {Date} Object of next closing
*/
function GetNextClosing(room) {
+ if (!room.openingTimes || room.openingTimes.length === 0) return null;
var now = MyDate();
var day = now.getDay();
- var bestdate = false;
+ var bestdate = null;
for (var a = 0; a < 7; a++) {
var tmp = room.openingTimes[(day + a) % 7];
if (!tmp) continue;
@@ -1034,10 +1036,10 @@ optional:
* checks if a room is on a given date/time open
* @param date Date Object
* @param room Room object
- * @returns bool for open or not
+ * @returns {Boolean} for open or not
*/
function IsOpen(date, room) {
- if (!room.openingTimes) return false;
+ if (!room.openingTimes || room.openingTimes.length === 0) return true;
var tmp = room.openingTimes[date.getDay()];
if (!tmp) return false;
var openDate = new Date(date.getTime());
@@ -1056,15 +1058,15 @@ optional:
/**
- * Retruns next Opening
+ * Returns next Opening
* @param room Room Object
- * @returns bestdate Date Object of next opening
+ * @returns {Date} Object of next opening
*/
function GetNextOpening(room) {
if (!room.openingTimes) return null;
var now = MyDate();
var day = now.getDay();
- var bestdate = false;
+ var bestdate = null;
for (var dow = 0; dow < 7; dow++) {
var tmp = room.openingTimes[(day + dow) % 7];
if (!tmp) continue;
@@ -1087,7 +1089,7 @@ optional:
/**
- * Sets the free PCs number in the right corner and updates the sqare color acordingly
+ * Sets the free PCs number in the right corner and updates the square color accordingly
* @param room Room
* @param seats Number of free PC's in the room
*/
@@ -1198,7 +1200,7 @@ optional:
/**
* returns next event from a given json of events
* @param calEvents Json which contains the calendar data.
- * @returns event next Carlendar Event
+ * @returns event next Calendar Event
*/
function getNextEvent(calEvents) {
if (!calEvents) return null;
@@ -1227,6 +1229,7 @@ optional:
/**
* Skip to next upcoming day matching the given day of week.
+ * @return {Date}
*/
function getNextDayOfWeek(date, dayOfWeek) {
var resultDate = new Date(date.getTime());
@@ -1238,8 +1241,8 @@ optional:
*/
- var picSizeX = 3.8;
- var picSizeY = 3;
+ const picSizeX = 3.8;
+ const picSizeY = 3;
/**
* Generates the RoomLayout Div
@@ -1316,19 +1319,12 @@ optional:
* @param room Room Object
*/
function generateOffsetAndScale(room) {
+ var clientHeight;
- var clientHeight = $(window).height();
- if (roomIds.length === 4) {
- clientHeight /= 2;
- }
-
- clientHeight -= room.$.header.height() - 5;
-
- if (roomIds.length > 1) {
- clientHeight -= 5;
- }
if (room.config.vertical && room.config.mode === 1) {
- clientHeight *= (1 - (room.config.scale / 100));
+ clientHeight = room.$.container.height() - (room.$.calendar.position().top + room.$.calendar.height());
+ } else {
+ clientHeight = room.$.container.height() - (room.$.header.height() + 5);
}
var clientWidth = room.$.layout.width();
@@ -1641,7 +1637,7 @@ optional:
*/
function generateProgressBar() {
if ($pbar) return;
- $pbar = $('
');
+ $pbar = $('
');
$('body').append($pbar);
SetProgressBarSpeed();
}
@@ -1665,6 +1661,14 @@ optional:
}, interval);
}
+ /**
+ * Convert passed argument to integer if possible, return NaN otherwise.
+ * The difference to parseInt() is that leading zeros are ignored and not
+ * interpreted as octal representation.
+ *
+ * @param str string or already a number
+ * @return {number} str converted to number, or NaN
+ */
function toInt(str) {
var t = typeof str;
if (t === 'number') return str | 0;
--
cgit v1.2.3-55-g7522