Funcionalidad Basica

This commit is contained in:
Fernando 2018-10-12 10:50:46 -05:00
commit e862fcb0c1
8 changed files with 1317 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/idea
/node_modules

278
data.json Normal file
View File

@ -0,0 +1,278 @@
{
"1er_anio": {
"Calculo 1->C1V": {
"Teoria": {
"Grupo A": {
"Docente": "Doris Tupacyupanqui", "Horas": ["Ma1130", "Ma1220", "Ma1310", "Mi0850", "Mi0940", "Vi0700", "Vi0750"]
}
,
"Grupo B": {
"Docente": "Pablo Quicaño", "Horas": ["Lu1640", "Ma1740", "Ma1830", "Ma1920", "Ju1740", "Ju1920", "Ju1830"]
}
}
}
,
"Estructuras Discretas 2->ED2": {
"Teoria": {
"Grupo A": {
"Docente": "Olha Sharhorodska", "Horas": ["Mi1220", "Mi1310", "Ju1220", "Ju1310"]
}
,
"Grupo B": {
"Docente": "Olha Sharhorodska", "Horas": ["Mi1400", "Mi1450", "Vi1550", "Vi1640"]
}
}
}
,
"Programacion Web 1->PW1": {
"Teoria": {
"Grupo A": {
"Docente": "Richart Escobedo", "Horas": ["Ma0940", "Ma1040"]
}
,
"Grupo B": {
"Docente": "Carlo Corrales", "Horas": ["Lu1220", "Lu1310"]
}
}
,
"Laboratorio": {
"Grupo A": {
"Docente": "Richart Escobedo", "Horas": ["Ma1130", "Ma1220", "Mi0850", "Mi0940"]
}
,
"Grupo B": {
"Docente": "Carlo Corrales", "Horas": ["Lu1400", "Lu1450", "Mi1550", "Mi1640"]
}
,
"Grupo C": {
"Docente": "Richart Escobedo", "Horas": ["Ma1550", "Ma1640", "Lu1740", "Lu1830"]
}
,
"Grupo D": {
"Docente": "Carlo Corrales", "Horas": ["Lu1740", "Lu1830", "Mi1740", "Mi1830"]
}
,
"Grupo E": {
"Docente": "Carlo Corrales", "Horas": ["Lu1550", "Lu1640", "Ma1740", "Ma1830"]
}
}
}
,
"Fundamentos de Programacion 2->FP2": {
"Teoria": {
"Grupo A": {
"Docente": "Marco Aedo", "Horas": ["Lu0850", "Lu0940", "Vi1220", "Vi1310"]
}
,
"Grupo B": {
"Docente": "Marco Aedo", "Horas": ["Ju1550", "Ju1640", "Vi1400", "Vi1450"]
}
}
,
"Laboratorio": {
"Grupo A": {
"Docente": "Marco Aedo", "Horas": ["Lu1040", "Lu1130", "Ju1040", "Ju1130"]
}
,
"Grupo B": {
"Docente": "Marco Aedo", "Horas": ["Ju1400", "Ju1450", "Vi1550", "Vi1640"]
}
,
"Grupo C": {
"Docente": "Marco Aedo", "Horas": ["Ju0850", "Ju0940", "Vi1040", "Vi1130"]
}
,
"Grupo D": {
"Docente": "Karim Guevara", "Horas": ["Vi0850", "Vi0940", "Ju0850", "Ju0940"]
}
,
"Grupo E": {
"Docente": "Ernesto Suarez", "Horas": ["Mi1040", "Mi1130", "Ju0700", "Ju0750"]
}
}
}
,
"Comunicacion Integral->CI": {
"Teoria": {
"Grupo A": {
"Docente": "?", "Horas": ["Lu0700", "Lu0750", "Mi0700", "Mi0750"]
}
,
"Grupo B": {
"Docente": "?", "Horas": ["Ma1400", "Ma1450", "Ju1400", "Ju1450"]
}
}
}
,
"Realidad Nacional->RN": {
"Teoria": {
"Grupo A": {
"Docente": "?", "Horas": ["Ma0700", "Ma0750", "Ma0850"]
}
,
"Grupo B": {
"Docente": "?", "Horas": ["Lu1400", "Lu1450", "Lu1550"]
}
}
}
},
"2do_anio" : {
"Ecologia y Medio Ambiente->ECA" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "?", "Horas" : ["Lu0700", "Lu0750", "Lu0850"]
},
"Grupo B" : {
"Docente" : "?", "Horas" : ["Mi1400", "Mi1450", "Mi1550"]
}
}
},
"Estadistica y Matematica->EMAT" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Antonia Quispe", "Horas" : ["Mi0700","Mi0750","Vi0850","Vi0940"]
},
"Grupo B" : {
"Docente" : "Esther Yanapa", "Horas" : ["Ma1550","Ma1640","Ju1830","Ju1920"]
}
},
"Laboratorio" : {
"Grupo A" : {
"Docente" : "Antonia Quispe", "Horas" : ["Mi0850","Mi0940"]
},
"Grupo B" : {
"Docente" : "Esther Yanapa", "Horas" : ["Ma1740","Ma1830"]
},
"Grupo C" : {
"Docente" : "Esther Yanapa", "Horas" : ["Ma0700","Ma0750"]
},
"Grupo D" : {
"Docente" : "Esther Yanapa", "Horas" : ["Ma0850","Ma0940"]
}
}
},
"Arquitectura de Computadoras->AC" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Pedro Rodriguez Gonzales", "Horas" : ["Ju0850","Ju0940","Vi1040"]
},
"Grupo B" : {
"Docente" : "Pedro Rodriguez Gonzales", "Horas" : ["Ju1550","Ju1640","Ju1740"]
}
},
"Laboratorio" : {
"Grupo A" : {
"Docente" : "Pedro Rodriguez Gonzales", "Horas" : ["Ju0700","Ju0750"]
},
"Grupo B" : {
"Docente" : "Pedro Rodriguez Gonzales", "Horas" : ["Vi1220","Vi1310"]
},
"Grupo C" : {
"Docente" : "Pedro Rodriguez Gonzales", "Horas" : ["Vi0700","Vi0750"]
},
"Grupo D" : {
"Docente" : "Pedro Rodriguez Gonzales", "Horas" : ["Vi0850","Vi0940"]
}
}
},
"Metodos de Investigacion y Redaccion->MIR" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Jesus Zuniga Cueva", "Horas" : ["Mi1040","Mi1130","Mi1220"]
},
"Grupo B" : {
"Docente" : "Jesus Zuniga Cueva", "Horas" : ["Lu1220","Lu1310","Mi1310"]
},
"Grupo C" : {
"Docente" : "Jesus Zuniga Cueva", "Horas" : ["Ma1040","Ma1130","Ma1220"]
}
}
},
"Interaccion Humano Computador->IHC" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Olha Sharhorodska", "Horas" : ["Ju1040","Ju1130","Vi1220","Vi1310"]
},
"Grupo B" : {
"Docente" : "Olha Sharhorodska", "Horas" : ["Ju1400","Ju1450","Vi1400","Vi1450"]
}
},
"Laboratorio" : {
"Grupo A" : {
"Docente" : "Richart Escobedo", "Horas" : ["Lu1040","Lu1130"]
},
"Grupo B" : {
"Docente" : "Richart Escobedo", "Horas" : ["Lu1550","Lu1640"]
},
"Grupo C" : {
"Docente" : "Richart Escobedo", "Horas" : ["Ma1740","Ma1830"]
},
"Grupo D" : {
"Docente" : "Juan Ramirez Ticona", "Horas" : ["Lu1550","Lu1640"]
}
}
},
"Enfoque Empresarial->EE" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Juan C. Juarez Bueno", "Horas" : ["Lu0940","Ma0850","Ma0940","Ju1220","Ju1310"]
},
"Grupo B" : {
"Docente" : "Juan C. Juarez Bueno", "Horas" : ["Ma1310","Ma1400","Ma1450","Vi1550","Vi1640"]
}
}
},
"Analisis y Disenio de Algoritmos->ADA" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Atencio Torres Carlos", "Horas" : ["Lu1400","Lu1450","Vi0700","Vi0750"]
} ,
"Grupo B" : {
"Docente" : "Atencio Torres Carlos", "Horas" : ["Lu1740","Lu1830","Vi1740","Vi1830"]
}
},
"Laboratorio" : {
"Grupo A" : {
"Docente" : "Christian Portugal", "Horas" : ["Lu1400","Lu1450"]
},
"Grupo B" : {
"Docente" : "Christian Portugal", "Horas" : ["Mi1550","Mi1640"]
},
"Grupo C" : {
"Docente" : "Christian Portugal", "Horas" : ["Mi1740","Mi1830"]
}
}
}
},
"3er_anio" : {
"Construccion de Software->CS" : {
},
"Redes y Comunicacion de Datos-> RCD" : {
},
"Tecnologia de Objetos->TO":{
}
},
"4to_anio" : {
"Aspectos Formales de Verif. y Esp.->AFVE" : {
},
"Gestion de Proyectos de Software->GPS" : {
}
},
"5to_anio" : {
"Topicos Avanzados en Ing. de Software->TAIS" : {
},
"Practicas Pre-Profesionales->PPP" : {
"Teoria" : {
"Grupo A" : {
"Docente" : "Ernesto Suarez", "Horas" : ["Ma1550","Ma1640","Mi0700","Mi0750","Ju0850","Ju0940"]
}
}
}
}
}

149
index.html Normal file
View File

@ -0,0 +1,149 @@
<!DOCTYPE html>
<html lang="es">
<head>
<title>Sistema de Horarios</title>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="./style.css?v=2">
</head>
<body style="margin: 0; background-color: #FAFAFA">
<nav>
<div id="nav-bar">
Sistema de horarios
</div>
</nav>
<br />
<div id="mainDiv" class="container">
Un sistema para la creación de horarios básico. La propia UNSA debería tener uno de estos...
<br />
Puedes <a onclick="crearDatos(undefined,true,1,2,3,4,5)">usar nombres completos</a> de los cursos (no lo recomiendo)
o <a onclick="modoNocturno()">activar el modo nocturno</a>.<br />
<br />
Parametros:<br />
<br />
<div>
<div style="display: inline-block">
<label>
<input type="checkbox" checked/>
<span>Ocultar los cursos que se solapan.</span>
</label>
</div>
<div style="display: inline-block">
<label>
<input type="checkbox" checked/>
<span>Escribir los cursos seleccionados en todas las tablas.</span>
</label>
</div>
<div style="display: inline-block">
<label>
<input type="checkbox" checked/>
<span>Ocultar otros grupos al seleccionar uno.</span>
</label>
</div>
</div>
<br />
<br />
<div style="padding: 3px; border: solid 1px lightgray; border-radius: 2px">
Mi horario:
<div onclick="ocultarTabla(0)" class="expandOccultButton">
<i class="material-icons" style="font-size: 30px;">keyboard_arrow_down</i>
</div>
<div id="Horario0anio" class="tablasHorarios">
</div>
<br />
</div>
<div style="padding: 3px; border: solid 1px lightgray; border-radius: 2px">
Primer Año
<div onclick="ocultarTabla(1)" class="expandOccultButton">
<i class="material-icons" style="font-size: 30px;">keyboard_arrow_down</i>
</div>
<div id="Horario1anio" class="tablasHorarios">
</div>
<br />
</div>
<div style="padding: 3px; border: solid 1px lightgray; border-radius: 2px">
Segundo Año
<div onclick="ocultarTabla(2)" class="expandOccultButton">
<i class="material-icons" style="font-size: 30px;">keyboard_arrow_down</i>
</div>
<div id="Horario2anio" class="tablasHorarios">
</div>
<br />
</div>
<div style="padding: 3px; border: solid 1px lightgray; border-radius: 2px">
Tercer Año
<div onclick="ocultarTabla(3)" class="expandOccultButton">
<i class="material-icons" style="font-size: 30px;">keyboard_arrow_down</i>
</div>
<div id="Horario3anio" class="tablasHorarios">
</div>
<br />
</div>
<div style="padding: 3px; border: solid 1px lightgray; border-radius: 2px">
Cuarto Año
<div onclick="ocultarTabla(4)" class="expandOccultButton">
<i class="material-icons" style="font-size: 30px;">keyboard_arrow_down</i>
</div>
<div id="Horario4anio" class="tablasHorarios">
</div>
<br />
</div>
<div style="padding: 3px; border: solid 1px lightgray; border-radius: 2px">
Quinto Año
<div onclick="ocultarTabla(5)" class="expandOccultButton">
<i class="material-icons" style="font-size: 30px;">keyboard_arrow_down</i>
</div>
<div id="Horario5anio" class="tablasHorarios">
</div>
<br />
</div>
</div>
<br />
<br />
<br />
<br />
<br />
<script src="./process.js?v=2"></script>
<script>
const modoNocturno = () => {
const cambiarClase = (nombre,reemplazo) => {
const lista = document.querySelectorAll(`.${nombre}`);
for (let i = 0; i<lista.length; i++){
const elem = lista[i];
elem.className = elem.className.replace(nombre,reemplazo);
}
};
document.body.style.backgroundColor = "#111111";
document.getElementById("mainDiv").style.backgroundColor = "#282c34";
document.getElementById("mainDiv").style.color = "#bbbbbb";
cambiarClase("striped","stripedD");
cambiarClase("trDescansoLight","trDescansoDark");
cambiarClase("nombreCursoTeoriaLight","nombreCursoTeoriaDark");
cambiarClase("nombreCursoLabLight","nombreCursoLabDark");
cambiarClase("descrCurso--Light--On","descrCurso--Dark--On");
cambiarClase("descrCurso--Light--Off","descrCurso--Dark--Off");
};
//modoNocturno();
</script>
</body>
</html>

513
process.js Normal file
View File

@ -0,0 +1,513 @@
let laData;
let datosUsuario = {
ocultarCursosSolapan: true,
escribirCursosSeleccionados: true
};
let ajax = new XMLHttpRequest();
let miHorario = {};
ajax.onreadystatechange = () => {
if (ajax.status === 200 && ajax.readyState === 4) {
laData = JSON.parse(ajax.responseText);
crearTablas(0, document.getElementById("Horario0anio"));
crearTablas(1, document.getElementById("Horario1anio"));
crearTablas(2, document.getElementById("Horario2anio"));
crearTablas(3, document.getElementById("Horario3anio"));
crearTablas(4, document.getElementById("Horario4anio"));
crearTablas(5, document.getElementById("Horario5anio"));
ocultarTabla(0);
/*ocultarTabla(1);*/
ocultarTabla(2);
ocultarTabla(3);
ocultarTabla(4);
ocultarTabla(5);
crearDatos(laData, false);
}
};
ajax.open("GET", "./data.json", true);
ajax.send();
function crearDatos(data, nombreCompleto, ...limpiar) {
if (data === undefined) {
data = laData;
}
if (limpiar !== undefined) {
for (const a in limpiar) {
limpiarTabla(a);
limpiarDescripciones(a);
}
}
for (let anio in data) {
let anioData = data[anio];
for (let curso in anioData) {
let cursoData = anioData[curso];
if (cursoData["oculto"] !== undefined && cursoData["oculto"] === true) continue;
let cursoDataDiv = document.createElement("div");
cursoDataDiv.className = "cursoDataDiv descrCurso--Light--On";
cursoDataDiv.setAttribute("req","");
let nombreCurso = document.createElement("span");
nombreCurso.style.fontWeight = "bold";
nombreCurso.appendChild(document.createTextNode(curso.substring(0, curso.search("->")) + " - " + curso.substring(curso.search("->") + 2) + " "));
cursoDataDiv.appendChild(nombreCurso);
let input = document.createElement("input");
input.type = "checkbox";
input.checked = "checked";
input.addEventListener("click", () => {
ocultarCurso(input.checked, cursoDataDiv, (curso.substring(curso.search("->") + 2)), anio)
});
cursoDataDiv.appendChild(input);
for (let variante in cursoData) {
if (variante === "oculto") continue;
cursoDataDiv.appendChild(document.createElement("br"));
let span = document.createElement("span");
span.innerText = variante + " = ";
cursoDataDiv.appendChild(span);
/* Crea temporalmente un objeto para manejar los Grupos y Profesores */
let gruposYProf = {};
let varianteData = cursoData[variante];
for (let grupo in varianteData) {
let grupoData = varianteData[grupo];
/* Inicializa el objeto */
if (gruposYProf[grupoData["Docente"]] === undefined) {
gruposYProf[grupoData["Docente"]] = grupo.substring(grupo.indexOf(" ") + 1);
} else {
gruposYProf[grupoData["Docente"]] += "," + grupo.substring(grupo.indexOf(" ") + 1);
}
/* NUEVO ESTANDAR PARA LOS DIV:
* En vez de que el DIV tenga ID 1er_anioLu0700
* se reemplazará por Lu07001er_anio
* basicamente para evitar problemas con el DOM.*/
for (let horaIndex in grupoData["Horas"]) {
let hora = grupoData["Horas"][horaIndex];
let elDiv = document.getElementById(hora + anio);
/* <codigo><variante><grupo><anio> -> C1VTeoriaA1er_anio */
let className = (curso.substring(curso.search("->") + 2)) + variante + (grupo.substring(grupo.indexOf(" ") + 1)) + anio;
/* <codigo><anio> -> C1V1er_anio */
let classGenerica = (curso.substring(curso.search("->") + 2)) + anio;
cursoDataDiv.id = `descr${classGenerica}`;
/* <codigo><variante><anio> -> C1V1er_anio */
let classNV = (curso.substring(curso.search("->") + 2)) + variante + anio;
let laData = document.createElement("div");
laData.className = "nombreCursoTeoriaLight dropdown " + className + " " + classGenerica + " " + classNV;
laData.addEventListener("mouseover", () => {
cambiarBack(className, true)
});
laData.addEventListener("mouseout", () => {
cambiarBack(className, false)
});
let laInnerData = document.createElement("div");
laInnerData.className = "dropdown-content";
let nombreCurso = document.createElement("span");
nombreCurso.style.fontWeight = "bold";
laInnerData.appendChild(nombreCurso);
laInnerData.appendChild(document.createElement("hr"));
if (variante === "Laboratorio") {
cursoDataDiv.setAttribute("req",cursoDataDiv.getAttribute("req") + "L");
if (nombreCompleto) {
let labI = document.createElement("span");
laData.className = laData.className.replace(/Teoria/,"Lab");
labI.appendChild(document.createTextNode(curso.substring(0, curso.search("->")) +
grupo.substring(grupo.search(" ")) + " (L)"));
laData.appendChild(labI);
nombreCurso.innerText = curso.substring(0, curso.search("->"));
} else {
let labI = document.createElement("span");
laData.className = laData.className.replace(/Teoria/,"Lab");
labI.appendChild(document.createTextNode(curso.substring(curso.search("->") + 2) +
grupo.substring(grupo.search(" ")) + " (L)"));
laData.appendChild(labI);
nombreCurso.innerText = curso.substring(0, curso.search("->"));
}
laInnerData.appendChild(document.createTextNode(grupo + " (Lab)"));
}
else {
cursoDataDiv.setAttribute("req",cursoDataDiv.getAttribute("req") + "T");
if (nombreCompleto) {
laData.appendChild(document.createTextNode(curso.substring(0, curso.search("->")) +
grupo.substring(grupo.search(" "))));
nombreCurso.innerText = curso.substring(0, curso.search("->"));
} else {
laData.appendChild(document.createTextNode(curso.substring(curso.search("->") + 2) +
grupo.substring(grupo.search(" "))));
nombreCurso.innerText = curso.substring(0, curso.search("->"));
}
laInnerData.appendChild(document.createTextNode(grupo));
}
laInnerData.appendChild(document.createElement("br"));
laInnerData.appendChild(document.createTextNode(grupoData["Docente"]));
if (anio.substring(0, 1) !== "0") {
laInnerData.appendChild(document.createElement("hr"));
let linkParaAnadir = document.createElement("span");
linkParaAnadir.style.textDecoration = "underline";
linkParaAnadir.style.color = "blue";
linkParaAnadir.style.cursor = "pointer";
linkParaAnadir.appendChild(document.createTextNode("Añadir a mi Horario"));
linkParaAnadir.addEventListener("click", () => {
anadirAMiHorario(anio, curso, variante, grupo)
});
laInnerData.appendChild(linkParaAnadir);
}
laData.appendChild(laInnerData);
let texto = document.createTextNode(" | ");
try {
elDiv.appendChild(laData);
elDiv.appendChild(texto);
} catch (e) {
console.log("El Div " + hora + anio + " no existe | " + curso + " " + variante + " "
+ grupo + "\n\n" + e.stack);
}
}
}
for (let prof in gruposYProf) {
let data = gruposYProf[prof];
let datos = " (" + data + ") ";
let span2 = document.createElement("span");
span2.innerText = datos + prof + ",";
span.appendChild(span2);
}
}
document.getElementById("Horario" + anio.substring(0, 1) + "anio").appendChild(cursoDataDiv);
}
}
//modoNocturno();
}
function limpiarTabla(num) {
let rows = document.querySelector("#tablaHorario" + num + "anio").rows;
for (let row of rows) {
for (let cell of row.cells) {
if (cell.id !== "") {
cell.innerHTML = "";
}
}
}
}
function limpiarDescripciones(num) {
let mayorDiv = document.getElementById("Horario" + num + "anio");
let valores = mayorDiv.children;
for (let a = 0; a < valores.length; a++) {
let node = valores[a];
if (/cursoDataDiv/.test(node.className)) {
mayorDiv.removeChild(node);
a--;
}
}
}
function ocultarTabla(num) {
let section = document.getElementById("Horario" + num + "anio");
let isCollapsed = section.getAttribute('data-collapsed') === 'true';
if (isCollapsed) {
expandSection(section);
section.setAttribute('data-collapsed', 'false');
} else {
collapseSection(section);
}
}
function cambiarBack(nombreClase, paraAplicar) {
let data = document.querySelectorAll("." + nombreClase);
if (paraAplicar) {
for (let a = 0; a < data.length; a++) {
data[a].style.color = "black";
let temp = data[a].parentNode;
chechAttribute(temp, false, 0);
}
} else {
for (let a = 0; a < data.length; a++) {
data[a].style = "";
let temp = data[a].parentNode;
chechAttribute(temp, false, -1, true)
}
}
}
function collapseSection(element) {
/* get the height of the element's inner content, regardless of its actual size*/
let sectionHeight = element.scrollHeight;
/* temporarily disable all css transitions*/
let elementTransition = element.style.transition;
element.style.transition = '';
/* on the next frame (as soon as the previous style change has taken effect),
// explicitly set the element's height to its current pixel height, so we
// aren't transitioning out of 'auto'*/
requestAnimationFrame(function () {
element.style.height = sectionHeight + 'px';
element.style.transition = elementTransition;
/* on the next frame (as soon as the previous style change has taken effect),
have the element transition to height: 0*/
requestAnimationFrame(function () {
element.style.height = 0 + 'px';
});
});
/* mark the section as "currently collapsed"*/
element.setAttribute('data-collapsed', 'true');
}
function expandSection(element) {
/* get the height of the element's inner content, regardless of its actual size*/
let sectionHeight = element.scrollHeight;
/* have the element transition to the height of its inner content*/
element.style.height = sectionHeight + 'px';
/* when the next css transition finishes (which should be the one we just triggered)*/
element.addEventListener('transitionend', function (e) {
// remove this event listener so it only gets triggered once
element.removeEventListener('transitionend', arguments.callee);
/* remove "height" from the element's inline styles, so it can return to its initial value*/
element.style.height = null;
});
/* mark the section as "currently not collapsed"*/
element.setAttribute('data-collapsed', 'false');
}
function anadirAMiHorario(anio, curso, variante, grupo) {
const idCurso = "descr" + (curso.substring(curso.search("->") + 2)) + anio;
/* Si aun no se creo el horario */
if (miHorario["0_anio"] === undefined) {
miHorario["0_anio"] = {};
}
/* Si el curso a añadir no existe */
if (miHorario["0_anio"][curso] === undefined) {
miHorario["0_anio"][curso] = JSON.parse("{\"" + variante + "\" : { \"" + grupo + "\" : {}}}");
miHorario["0_anio"][curso][variante][grupo] = laData[anio][curso][variante][grupo];
reservarCeldas(variante, idCurso, ...(miHorario["0_anio"][curso][variante][grupo]["Horas"]));
}
/* El curso a añadir si existe */
else {
/* El curso a añadir existe, pero no la variante(Teoria/Lab) */
if (miHorario["0_anio"][curso][variante] === undefined) {
miHorario["0_anio"][curso][variante] = JSON.parse("{ \"" + grupo + "\" : {}}");
miHorario["0_anio"][curso][variante][grupo] = laData[anio][curso][variante][grupo];
reservarCeldas(variante, idCurso, ...(miHorario["0_anio"][curso][variante][grupo]["Horas"]));
}
/* El curso y la variante existen. Sospechoso...*/
else {
/* El curso y la variante existen, pero no el grupo. ¿Quieres añadir otro grupo? Que extraño...*/
if (miHorario["0_anio"][curso][variante][grupo] === undefined && confirm("¿Quieres añadir otro grupo de este curso?")) {
miHorario["0_anio"][curso][variante][grupo] = laData[anio][curso][variante][grupo];
reservarCeldas(undefined, undefined, ...(miHorario["0_anio"][curso][variante][grupo]["Horas"]));
}
/*El curso, la variante y el grupo existen. ¿Quieres añadir un curso duplicado? Nope*/
else {
alert("Este curso ya existe.");
}
}
}
crearDatos(miHorario, false, 0);
}
function reservarCeldas(variante, idCurso, ...id) {
if (variante !== undefined && idCurso !== undefined) {
console.log(idCurso);
const elem = document.getElementById(idCurso);
elem.setAttribute(variante,"true");
let condicion = false;
if (/T/.test(elem.getAttribute("req"))){
if (/L/.test(elem.getAttribute("req"))){
condicion = elem.getAttribute("Teoria") === "true" && elem.getAttribute("Laboratorio") === "true";
} else {
condicion = elem.getAttribute("Teoria") === "true";
}
} else if (/L/.test(elem.getAttribute("req"))){
condicion = elem.getAttribute("Laboratorio") === "true";
}
if (condicion){
elem.className = elem.className.replace(/On/,"OK");
elem.className = elem.className.replace(/Off/,"OK");
}
}
for (let index in id) {
let valor = id[index];
let divs = document.querySelectorAll("." + valor);
let div;
for (let i = 0; i < divs.length, div = divs[i]; i++) {
chechAttribute(div, true);
}
}
}
function chechAttribute(div, set = false, offset = 0, isOnMouseUp = false) {
const COLORES = ["#ABE77E", "#ffcb6b", "#b74d33", "#ff002f", "#454545", "#454545"];
if (div.getAttribute("hora-ocupada") === "1") {
if (set)
div.setAttribute("hora-ocupada", "2");
div.style.backgroundColor = COLORES[1 + offset];
} else if (div.getAttribute("hora-ocupada") === "2") {
if (set)
div.setAttribute("hora-ocupada", "3");
div.style.backgroundColor = COLORES[2 + offset];
} else if (div.getAttribute("hora-ocupada") === "3") {
if (set)
div.setAttribute("hora-ocupada", "4");
div.style.backgroundColor = COLORES[3 + offset];
} else if (!isNaN(parseInt(div.getAttribute("hora-ocupada"))) && parseInt(div.getAttribute("hora-ocupada")) > 3) {
if (set)
div.setAttribute("hora-ocupada", "5");
div.style.backgroundColor = COLORES[4 + offset];
} else {
if (set)
div.setAttribute("hora-ocupada", "1");
if (isOnMouseUp)
div.style.backgroundColor = "transparent";
else
div.style.backgroundColor = COLORES[0];
}
}
function crearTablas(anio, divDestino,
indiceArray = ["Hora", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes"],
patronHoras = ["07:00", "07:50", ["08:40"], "08:50", "09:40", ["10:30"], "10:40",
"11:30", "12:20", "13:10", "14:00", "14:50", ["15:40"], "15:50",
"16:40", ["17:30"], "17:40", "18:30", "19:20"]) {
const nomenclaturaAnios = ["0_anio", "1er_anio", "2do_anio", "3er_anio", "4to_anio", "5to_anio"];
const nombreAnio = nomenclaturaAnios[anio];
let tabla = document.createElement("table");
tabla.id = "tablaHorario" + anio + "anio";
tabla.className = "striped";
let thead = document.createElement("thead");
let tr = document.createElement("tr");
for (let index in indiceArray) {
let valor = indiceArray[index];
let td = document.createElement("td");
td.innerText = valor;
tr.appendChild(td);
}
thead.appendChild(tr);
tabla.appendChild(thead);
let tbody = document.createElement("tbody");
for (let index in patronHoras) {
let valor = patronHoras[index];
let tr = document.createElement("tr");
let isHoraDescanso = false;
if (typeof valor === "object") {
valor = valor[0];
tr.className = "trDescansoLight";
isHoraDescanso = true;
}
for (let i in indiceArray) {
let td = document.createElement("td");
if (i === "0") {
td.innerText = valor;
} else if (!isHoraDescanso) {
td.id = indiceArray[i].substring(0, 2) + valor.replace(":", "") + nombreAnio;
td.className = indiceArray[i].substring(0, 2) + valor.replace(":", "");
}
tr.appendChild(td);
}
tbody.appendChild(tr);
}
tabla.appendChild(tbody);
divDestino.appendChild(tabla);
}
function ocultarCurso(ocultar, div, curso, anio) {
if (ocultar) {
div.className = div.className.replace(/Off/,"On");
let lista = document.querySelectorAll("." + curso + anio);
let iDiv;
for (let i = 0; i < lista.length, iDiv = lista[i]; i++) {
iDiv.style.display = "inline-block";
}
} else {
div.className = div.className.replace(/On/,"Off");
let lista = document.querySelectorAll("." + curso + anio);
console.log("Query: " + "." + curso + anio);
let iDiv;
for (let i = 0; i < lista.length; i++) {
iDiv = lista[i];
iDiv.style.display = "none";
}
}
}
function ocultarVariante(ocultar, div, anio, curso, variante) {
}
function ocultarGrupo(ocultar, div, anio, curso, variante, grupo) {
}

1
process.min.js vendored Normal file

File diff suppressed because one or more lines are too long

147
raw3anioData.json Normal file
View File

@ -0,0 +1,147 @@
{
"Hoja1": [
[
"SEMESTRE: TERCER AÑO AULA 302"
],
[
"HORA",
"LUNES",
"MARTES",
"MIERCOLES",
"JUEVES",
"VIERNES"
],
[
"07:00-07:50",
"CS-A(P.HUERTAS)",
"SO-A(K.GUEVARA)",
"RCA-A(L.DELGADO)",
"SO-A(K.GUEVARA)",
"SO-A(K.GUEVARA)"
],
[
"07:50-08:40",
"CS-A(P.HUERTAS)",
"SO-A(K.GUEVARA)",
"RCA-A(L.DELGADO)",
"SO-A(K.GUEVARA)",
"SO-A(K.GUEVARA)"
],
[],
[
"08:50-09:40",
"CS-C(JORGE R,)",
"CS-A(T)(P.HUERTAS)",
"RCD-A(L.DELGADO)",
"FSI-A(V.CORNEJO)",
"CS-C(JORGE R)-PROY"
],
[
"09:40 -10:30",
"CS-C(JORGE R,)",
"CS-A(T)(P.HUERTAS)",
"RCD-A(L.DELGADO)",
"FSI-A(V.CORNEJO)",
"CS-C(JORGE R)-PROY"
],
[],
[
"10:40-11:30",
"RCD-A(L.DELGADO)",
"FSI-A(V.CORNEJO)",
"RCD-C(L.DELGADO)",
"MIR-A(J.ZUÑIGA)"
],
[
"11:30-12:20",
"RCD-A(L.DELGADO)",
"FSI-A(V.CORNEJO)",
"RCD-C(L.DELGADO)",
"MIR-A(J.ZUÑIGA)"
],
[
"12:20-13:10",
"RCD-C(L.DELGADO)",
"FSI-A(V.CORNEJO)",
null,
"MIR-A(J.ZUÑIGA)",
"TO(V.MACHACA)"
],
[
"13:10-14:00",
"RCD-C(L.DELGADO)",
null,
null,
null,
"TO(V.MACHACA)"
],
[
"14:00-14:50",
"RCD-B(L.DELGADO)",
"SO-B(K.GUEVARA)",
"TO-A(CH.PORTUGAL)",
"SO-C(K.GUEVARA)",
"CS-A(P.HUERTAS)"
],
[
"14:50-15:40",
"RCD-B(L.DELGADO)",
"SO-B(K.GUEVARA)",
"TO-A(CH.PORTUGAL)",
"SO-C(K.GUEVARA)",
"CS-A(P.HUERTAS)"
],
[],
[
"15:50-16:40",
"FSI-B(JC.JUAREZ)",
"TO-B(CH.PORTUGAL)",
null,
"FSI-B(JC.JUAREZ)"
],
[
"16:40-17:30",
"FSI-B(JC.JUAREZ)",
"TO-B(CH.PORTUGAL)",
null,
"FSI-B(JC.JUAREZ)"
],
[],
[
"17:40-18:30",
"FSI-B(JC.JUAREZ)",
"TO-C(CH.PORTUGAL)",
"TO(V.MACHACA)"
],
[
"18:30-19:20",
null,
"TO-C(CH.PORTUGAL)",
"TO(V.MACHACA)"
],
[
"19:20-20:10"
],
[
"20:10-21:00"
],
[
"CS= Construcción de Software (A)(T)(L)(A) Percy Huertas (B)Giovani Cabrera ( C ) Jorge Ramirez "
],
[
"RCD=Redes y Comunicación de Datos (A,B)(T)(A,C)(L) Lucy Delgado (B,D)(L) Juan Ramirez Ticona"
],
[
"TO=Tecnologías de Objetos(A)(T) Vicente Machaca (L)(A,B,C) Christian Portugal"
],
[
"SO=Sistemas Operativos (A) Karim Guevara P. de la Vega"
],
[
"FSI=Fundamentos de Sistemas de Informacion (A) Victor Cornejo Aparicio (B) Juan C. Juarez Bueno"
],
[
"MIR=Métodos de Investigación y Redacción (A) Jesús Zuñiga Cueva"
]
]
}

66
rawJsonCreator.js Normal file
View File

@ -0,0 +1,66 @@
let fs = require('fs');
const tabla = {};
fs.readFile('./raw3anioData.json',(err, data) => {
const miData = JSON.parse(data);
crearData(miData);
});
function crearData(data) {
let datos = data["Hoja1"];
let indiceAnios = [];
let indiceDatos = [undefined,undefined];
let cursosMap = {};
let anioActual = -1;
/* datos contiene un Array con las filas, cada una de estas filas es un array con las posiciones. */
const DIAS = ["Lunes","Martes","Miercoles","Jueves","Viernes"];
const NOMBRES_ANIOS = "(primer | segundo | tercer | cuarto | quinto)";
const regexNombresAnios = new RegExp(NOMBRES_ANIOS,"i");
const regexHoras = new RegExp("\d\d\s*[:]\s*\d\d\s*[-]\s*\d\d\s*[:]\s*\d\d","i");
for (let index in datos) {
let fila = datos[index];
for (let indexF in fila) {
let celda = fila[indexF];
let horaActual = "";
let diaActual = 0;
/* Revisa si es un inicio de anio */
if ((/semestre/i).test(celda) === true) {
console.log("Celda semestre: " + celda);
let nombreAnio = (regexNombresAnios.exec(celda))[0].trim();
console.log("Datos tras regex: '" + nombreAnio + "'");
anioActual++;
indiceAnios.push(nombreAnio);
tabla[nombreAnio] = {};
}
/* Revisa la hora actual */
else if (regexHoras.test(celda)) {
}
else if ((/\w+\s?=\s?\w+/i).test(celda) === false) {
if (indiceDatos[0] === undefined) indiceDatos[0] = index;
}
/* Mapea los cursos y sus abreviaturas en cursosMap para poder acceder a ellos facilmente */
else {
if (indiceDatos[1] === undefined) indiceDatos[1] = index-1;
let regex = /(\w+)(\s*=\s*)(\w+\s*)+(([(]\s?\w(,\w)*\s?[)]\s*)+(\w+\.?\s*)+)+/g;
let datosRegex = regex.exec(celda);
console.log("Datos tras regex\n" + celda + "\n" + datosRegex);
}
}
}
console.log(`Al final el obj es:\n\n${JSON.stringify(tabla)}\n\n`);
}

161
style.css Normal file
View File

@ -0,0 +1,161 @@
body {
font-family: Roboto, sans-serif;
}
a {
text-decoration: underline;
color: #545bff;
cursor: pointer;
}
.tablasHorarios {
overflow-y: hidden;
transition: height 300ms ease-out;
height: auto;
padding: 5px;
}
#nav-bar {
padding: 20px;
font-size: x-large;
text-transform: uppercase;
font-family: Roboto, sans-serif;
text-align: center;
background: #64001d;
color: #FFFFFF;
margin: 0;
box-shadow: 0 3px 5px gray;
}
.container {
margin: 0 auto;
max-width: 1280px;
width: 90%;
border-radius: 2px;
box-shadow: 2px 2px 2px lightgray;
padding: 15px;
background-color: #FFFFFF;
}
.expandOccultButton {
display: inline-block;
cursor: pointer;
float: right
}
.descanso {
background-color: lightgreen;
}
table {
width: 100%;
}
table tr, table tr td {
text-align: center;
padding: 3px;
}
table.striped > tbody > tr:nth-child(odd) {
background-color: #f2f2f2;
}
table.stripedD > tbody > tr:nth-child(odd) {
background-color: #353c44;
}
table.striped > tbody > tr > td {
transition: background-color 150ms, color 150ms;
border-radius: 0;
}
.dropdown {
position: relative;
display: inline-block;
cursor: pointer;
}
.dropdown-content {
right: 0;
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 150px;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
padding: 10px;
z-index: 1;
cursor: default;
text-align: left;
color: black;
}
.dropdown:hover {
text-decoration: underline;
}
.dropdown:hover .dropdown-content {
display: block;
}
.botonAdd {
cursor: pointer;
display: inline-block;
color: #33F;
}
.botonAdd:hover {
text-decoration: underline;
}
.cursoDataDiv {
padding: 10px;
display: inline-block
}
table > tbody > tr.trDescansoLight > td {
background-color: #e4ffed
}
table > tbody > tr.trDescansoDark > td {
background-color: #48544c
}
.nombreCursoTeoriaLight {
color: blue;
}
.nombreCursoTeoriaDark {
color: #82aaff;
}
.nombreCursoLabLight {
color: #ff563c
}
.nombreCursoLabDark {
color: #f07178
}
.descrCurso--Light--On {
color: black;
}
.descrCurso--Light--Off {
color: #ababab;
}
.descrCurso--Dark--On {
color: #ababab;
}
.descrCurso--Dark--Off {
color: #656d78;
}
.descrCurso--Light--OK {
}
.descrCurso--Dark--OK {
color: #93e78c;
}