EVOLUTION-MANAGER
Edit File: crear-resoluciones.js
function agregar_anio() { const select = document.getElementById('sel1'); const anio = select.value; document.getElementById('anio').value = anio; } document.getElementById('formulario-creacion-resolucion').addEventListener('submit', function (e) { e.preventDefault(); var formulario = document.getElementById('formulario-creacion-resolucion'); var fecha = document.getElementById('anio').value; var titulo = document.getElementById('titulo').value; var documento = document.getElementById('cargar'); if (fecha != "" && titulo != "" && documento.files.length > 0) { formulario.submit(); const loadingModal = document.getElementById('loadingModal'); loadingModal.style.display = 'block'; } else { mensaje_de_alerta("error", "Llene todos los campos solicitados"); } }); const anio = document.getElementById('anio'); anio.addEventListener('input', function () { anio.value = ""; }); // Función para actualizar el contador de caracteres function actualizarContador() { var maximo = 260; var textarea = document.getElementById('titulo'); if (textarea.value.length >= maximo) { textarea.value = textarea.value.substring(0, maximo); } var caracteresRestantes = maximo - textarea.value.length; document.getElementById('caracteres-restantes').textContent = caracteresRestantes; } // Llama a la función al cargar la página para establecer el contador inicial window.onload = function() { actualizarContador(); }; var input = document.getElementById("cargar"); var show_archivos = document.getElementById("documentos-cargados"); input.addEventListener("change", (e) => { const fileshow = (filename, filetype) => { let container = document.createElement('div'); container.className = 'mostrar-archivos'; let leftdiv = document.createElement('div'); leftdiv.className = 'left'; let filespan = document.createElement('span'); filespan.className = 'tipo-archivo'; filespan.textContent = filetype; let fileh3 = document.createElement('h3'); fileh3.textContent = filename; leftdiv.appendChild(filespan); leftdiv.appendChild(fileh3); let rightdiv = document.createElement('div'); rightdiv.className = 'right'; rightdiv.id = 'borrar'; let filespan2 = document.createElement('span'); filespan2.innerHTML = '×'; rightdiv.appendChild(filespan2); container.appendChild(leftdiv); container.appendChild(rightdiv); show_archivos.innerHTML = ''; show_archivos.appendChild(container); var borrar = document.getElementById("borrar") borrar.addEventListener("click", () => { show_archivos.innerHTML = `<h3 class="subidos-exito">Documentos subidos</h3>`; e.target.value = ""; }); } if (e.target.files[0]) { let filename = e.target.files[0].name; let filetype = e.target.value.split(".").pop(); // const file = input.files[0]; const reader = new FileReader(); reader.readAsArrayBuffer(file); var porcentaje; const progressBar = document.getElementById('progressBar'); progressBar.classList.add('progressBarshow'); reader.onprogress = (e) => { porcentaje = Math.round((e.loaded / e.total) * 100); progressBar.style.width = porcentaje + '%'; progressBar.innerHTML = porcentaje + "%" } reader.onload = (e) => { progressBar.classList.remove('progressBarshow'); progressBar.style.width = '0%'; fileshow(filename, filetype); } } else { show_archivos.innerHTML = `<h3 class="subidos-exito">Documentos subidos</h3>`; input.value = ""; } }); function mensaje_de_alerta(icon, title) { Swal.fire({ icon: icon, title: title, showConfirmButton: true }); }