/* * Funciones generales de horario * Necesita variables globales: _w, _h, _hora_min, _frac */ function getX(dia){//lunes = 1 devuelve pos en X return (parseInt(dia)-1) * _w; } function getY(hora){//recibe hh:mm devuelve pos en Y var horaNuevaArr = hora.split(':'); return ((parseInt(horaNuevaArr[0]) - _hora_min) * (_h * _frac)) + (parseInt(horaNuevaArr[1]) / (60/_frac) * _h); } function getDia(x){//recibe coordenada y devuelve día return parseInt(x / _w)+1; } function getHora(y){//recibe coordenada y devuelve hora var hora = parseInt(y / (_h * _frac)) + _hora_min; if(hora < 10) return "0"+hora; return hora; } function getMinutos(y){//recibe coordenada y devuelve minutos de la hora var base = parseInt(y / (_h * _frac)); var min = (y - (base * _h * _frac)) * 60 / (_h * _frac); if(min < 10) return "0"+min; return min; } function getAlto(alto){//calcula alto del bloque html return alto * _h / (60/_frac); } $(document).on( "mouseenter", ".menu-wrapper", function(){ $(this).find('.menu-flotante').removeClass('d-none'); }); $(document).on( "mouseleave", ".menu-wrapper", function(){ $(this).find('.menu-flotante').addClass('d-none'); }); function getIndexClase(idobj){//busca en qué posición del arreglo está el id del horario for(var i=0; i < clasesObj.length; i++){ if(clasesObj[i].id_obj == idobj){ return i; } } return -1; } //devuelve arreglo de pos de colisiones, necesita arreglo global clasesObj function colisionHorario(max, posX, posY, alto){ var colArr = []; for(var i=0; i < max; i++){ if(posX == getX(clasesObj[i].dia)){//mismo día if((posY >= getY(clasesObj[i].hora) && posY < (getY(clasesObj[i].hora)+getAlto(clasesObj[i].duracion)) ) || ((posY+alto) >= getY(clasesObj[i].hora) && (posY+alto) <= (getY(clasesObj[i].hora)+getAlto(clasesObj[i].duracion))) ){ //console.log("["+clasesObj.length+" vs i= "+i+"]( ["+clasesObj[i].dia+"]"+posX+" == "+getX(clasesObj[i].dia)+")("+posY +" >= "+getY(clasesObj[i].hora)+" && <"+(getY(clasesObj[i].hora)+getAlto(clasesObj[i].duracion))+") || ("+(posY+alto)+" >= "+getY(clasesObj[i].hora)+" && <= "+(getY(clasesObj[i].hora)+getAlto(clasesObj[i].duracion))+")"); colArr.push(clasesObj[i].id_obj); } } } return colArr; } function getColisionAll(colArr, total){//revisa todas las colisiones for(var i=0; i ["+_tab_size+"] mL ["+((index * _tab_size)%_w)+"]"); } $("#bloque_"+colArr[i]).addClass("pointer"); index++; index = cambiaAnchoAll(clasesObj[colArr[i]].colision, offset, index); } return index; } //recibe arreglo de ids de colisiones de colisionHorario function cambiaAncho(idCurr, colArr){ var id; var offset = getColisionAll(colArr, 0); var index = cambiaAnchoAll(colArr, offset, 0); if(offset > 0){//había otros //console.log("("+idCurr+") Cambia ancho Last ["+i+"] de ["+offset+"] -> width["+(_w - (offset * _tab_size))+"] mL["+i* _tab_size+"]"); //$("#bloque_"+idCurr).css({width: _w - (offset * _tab_size), marginLeft: index*_tab_size}); if((offset * _tab_size) < _w) { $("#bloque_"+idCurr).css({width: (_w - (offset * _tab_size))+"px", marginLeft: ((index * _tab_size)%_w)+"px"}); console.log("* w< ["+(_w - (offset * _tab_size))+"] mL ["+((index * _tab_size)%_w)+"]"); }else{ $("#bloque_"+idCurr).css({width: _tab_size+"px", marginLeft: (((index +1) * _tab_size)%_w)+"px"}); console.log("w> ["+_tab_size+"] mL ["+((index * _tab_size)%_w)+"]"); } $("#bloque_"+idCurr).addClass("pointer"); } }