function ReservationsTable(){this.dayStartHour=5;this.dayEndHour=20;this.compare=function(d,c){var a=d.starthour*4+d.startmin/15;var e=c.starthour*4+c.startmin/15;var b=a-e;if(b<0){return -1}else{if(b>0){return 1}else{return 0}}};this.generateTableHeader=function(){var a="
";for(var b=this.dayStartHour;b"+b+"15 | 30 | 45"}a+=" | |
";return a};this.getSlotsCount=function(a){return this.getSlotsInPeriodByHour(a.starthour,a.startmin,a.endhour,a.endmin)};this.getSlotsInPeriod=function(a,c,b){return this.getSlotsInPeriodByHour(a,c,b.starthour,b.startmin)};this.getSlotsInPeriodByHour=function(c,d,b,a){if(cthis.dayEndHour){b=this.dayEndHour;a=0}var e=(b*4+a/15)-(c*4+d/15);return e};this.getRealEndHour=function(a){var b=this.getSlotsInPeriodByHour(a.starthour,a.startmin,a.endhour,a.endmin);if(b>=0){return a.endhour}else{return 24+a.endhour}};this.genCell=function(d,c,f,e){var a="";var b="";if(e!=null){a=" id='resitem_"+e+"' ";b=" resitem "}if(c>0){return""+d+" | "}else{return""}};this.cellContent=function(e){var d=this.reservationitem.split("\n");var a=[];for(var c=0;c")};this.distributeTable=function(e){var n=e.sort(this.compare);var o=[];var k=[];var a=true;while(a){a=false;var p=0;var c=0;var f=0;var h="";for(var g=0;g=q){var d=this.getSlotsInPeriod(c,f,j);if(this.dayStartHour>j.starthour){d=0}var l=this.getSlotsCount(j);var b=this.genCell("",d,"fillcell",null);if(j.starthour0){var a=""+c;var d=true;b.forEach(function(h){if(!d){a+=" |
"}else{d=false}a+=h+"
"});return a}else{return""}};this.layoutTable=function(d,c,b,f){this.dayStartHour=parseInt(d);this.dayEndHour=parseInt(c);this.reservationitem=f;var a="";a+=this.generateTableHeader();for(var e=0;e | "}a+="
";return a}};