horarios-v1/process.min.js

1 line
8.8 KiB
JavaScript
Raw Permalink Normal View History

2018-10-12 15:50:46 +00:00
let laData,datosUsuario={ocultarCursosSolapan:!0,escribirCursosSeleccionados:!0},ajax=new XMLHttpRequest,miHorario={};function crearDatos(e,t,...a){if(void 0===e&&(e=laData),void 0!==a)for(const e in a)limpiarTabla(e),limpiarDescripciones(e);for(let a in e){let r=e[a];for(let e in r){let o=r[e];if(void 0!==o.oculto&&!0===o.oculto)continue;let n=document.createElement("div");n.className="cursoDataDiv descrCurso--Light--On",n.setAttribute("req","");let i=document.createElement("span");i.style.fontWeight="bold",i.appendChild(document.createTextNode(e.substring(0,e.search("->"))+" - "+e.substring(e.search("->")+2)+" ")),n.appendChild(i);let l=document.createElement("input");l.type="checkbox",l.checked="checked",l.addEventListener("click",()=>{ocultarCurso(l.checked,n,e.substring(e.search("->")+2),a)}),n.appendChild(l);for(let r in o){if("oculto"===r)continue;n.appendChild(document.createElement("br"));let i=document.createElement("span");i.innerText=r+" = ",n.appendChild(i);let l={},c=o[r];for(let o in c){let i=c[o];void 0===l[i.Docente]?l[i.Docente]=o.substring(o.indexOf(" ")+1):l[i.Docente]+=","+o.substring(o.indexOf(" ")+1);for(let l in i.Horas){let c=i.Horas[l],s=document.getElementById(c+a),d=e.substring(e.search("->")+2)+r+o.substring(o.indexOf(" ")+1)+a,u=e.substring(e.search("->")+2)+a;n.id=`descr${u}`;let m=e.substring(e.search("->")+2)+r+a,p=document.createElement("div");p.className="nombreCursoTeoriaLight dropdown "+d+" "+u+" "+m,p.addEventListener("mouseover",()=>{cambiarBack(d,!0)}),p.addEventListener("mouseout",()=>{cambiarBack(d,!1)});let b=document.createElement("div");b.className="dropdown-content";let h=document.createElement("span");if(h.style.fontWeight="bold",b.appendChild(h),b.appendChild(document.createElement("hr")),"Laboratorio"===r){if(n.setAttribute("req",n.getAttribute("req")+"L"),t){let t=document.createElement("span");p.className=p.className.replace(/Teoria/,"Lab"),t.appendChild(document.createTextNode(e.substring(0,e.search("->"))+o.substring(o.search(" "))+" (L)")),p.appendChild(t),h.innerText=e.substring(0,e.search("->"))}else{let t=document.createElement("span");p.className=p.className.replace(/Teoria/,"Lab"),t.appendChild(document.createTextNode(e.substring(e.search("->")+2)+o.substring(o.search(" "))+" (L)")),p.appendChild(t),h.innerText=e.substring(0,e.search("->"))}b.appendChild(document.createTextNode(o+" (Lab)"))}else n.setAttribute("req",n.getAttribute("req")+"T"),t?(p.appendChild(document.createTextNode(e.substring(0,e.search("->"))+o.substring(o.search(" ")))),h.innerText=e.substring(0,e.search("->"))):(p.appendChild(document.createTextNode(e.substring(e.search("->")+2)+o.substring(o.search(" ")))),h.innerText=e.substring(0,e.search("->"))),b.appendChild(document.createTextNode(o));if(b.appendChild(document.createElement("br")),b.appendChild(document.createTextNode(i.Docente)),"0"!==a.substring(0,1)){b.appendChild(document.createElement("hr"));let t=document.createElement("span");t.style.textDecoration="underline",t.style.color="blue",t.style.cursor="pointer",t.appendChild(document.createTextNode("Añadir a mi Horario")),t.addEventListener("click",()=>{anadirAMiHorario(a,e,r,o)}),b.appendChild(t)}p.appendChild(b);let g=document.createTextNode(" | ");try{s.appendChild(p),s.appendChild(g)}catch(t){console.log("El Div "+c+a+" no existe | "+e+" "+r+" "+o+"\n\n"+t.stack)}}}for(let e in l){let t=" ("+l[e]+") ",a=document.createElement("span");a.innerText=t+e+",",i.appendChild(a)}}document.getElementById("Horario"+a.substring(0,1)+"anio").appendChild(n)}}}function limpiarTabla(e){let t=document.querySelector("#tablaHorario"+e+"anio").rows;for(let e of t)for(let t of e.cells)""!==t.id&&(t.innerHTML="")}function limpiarDescripciones(e){let t=document.getElementById("Horario"+e+"anio"),a=t.children;for(let e=0;e<a.length;e++){let r=a[e];/cursoDataDiv/.test(r.className)&&(t.removeChild(r),e--)}}function ocultarTabla(e){let t=document.getElementById("Horario"+e+"anio");"true"===t.getAttribute("data-collapsed")?(expandSection(t),t.setAttribute("data-collapsed","false")):collapseSection(t)}funct