From 8d1c75cede9431fee19065f74a5bd5845f52afb7 Mon Sep 17 00:00:00 2001 From: eastanganelli Date: Tue, 5 Sep 2023 10:05:06 -0300 Subject: [PATCH] Auto subject selection --- public/javascripts/addmember.js | 32 +++++++++++++------------- public/javascripts/index.js | 40 +++++++++++++++++---------------- routes/index.route.js | 17 ++++++++++++-- views/pages/index.ejs | 9 ++------ 4 files changed, 55 insertions(+), 43 deletions(-) diff --git a/public/javascripts/addmember.js b/public/javascripts/addmember.js index fc29993..87f04f1 100644 --- a/public/javascripts/addmember.js +++ b/public/javascripts/addmember.js @@ -1,16 +1,18 @@ // Event handler for submit button click -$(`#sendData`).click(() => { - const mail_ = $(`#mailInput`).val(); - const subject_ = $(`#subject`).text() == 'IRI' ? 1 : 2; - - if (mail_.length == 0) { - appendAlert(`No se ingreso Mail`, `danger`); - } else { - $.get(`/sendinvite`, { mail: mail_, subject: subject_ }).done((data) => { - appendAlert(`Invitación enviada, revisa el SPAM!`, `success`); - return; - }).fail((err) => { - appendAlert(err.responseText, `danger`); - }); - } -}); \ No newline at end of file +(() => { + $(`#sendData`).click(() => { + const mail_ = $(`#mailInput`).val(); + const subject_ = $(`#subject`).text() == 'IRI' ? 1 : 2; + + if (mail_.length == 0) { + appendAlert(`No se ingreso Mail`, `danger`); + } else { + $.get(`/sendinvite`, { mail: mail_, subject: subject_ }).done((data) => { + appendAlert(`Invitación enviada, revisa el SPAM!`, `success`); + return; + }).fail((err) => { + appendAlert(err.responseText, `danger`); + }); + } + }); +})(); \ No newline at end of file diff --git a/public/javascripts/index.js b/public/javascripts/index.js index e7f990a..5c4e1b8 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -1,20 +1,22 @@ // Event handler for submit button click -$(`#sendData`).click(() => { - const student_ = $(`#studentInput`).val(); - const subject_ = $(`#studentSubject option:selected`).val(); - - if (student_ == `` || subject_ == `Materia:`) { - if (student_ == `` && subject_ == `Materia:`) - appendAlert(`No se ingreso DNI/Mail ni seleccionó la materia`, `danger`); - else if (student_ == ``) - appendAlert(`No se ingreso DNI/Mail`, `danger`); - else - appendAlert(`No se seleccionó la materia`, `danger`); - } else { - $.get(`/studentstatus`, { student: student_, subject: subject_ }).done((data) => { - $(`#statusResponse`).html(data); - }).fail((err) => { - appendAlert(err.responseText, `danger`); - }); - } -}); \ No newline at end of file +(() => { + $(`#sendData`).click(() => { + const student_ = $(`#studentInput`).val(); + const subject_ = $(`#studentSubject option:selected`).val(); + + if (student_ == `` || subject_ == `Materia:`) { + if (student_ == `` && subject_ == `Materia:`) + appendAlert(`No se ingreso DNI/Mail ni seleccionó la materia`, `danger`); + else if (student_ == ``) + appendAlert(`No se ingreso DNI/Mail`, `danger`); + else + appendAlert(`No se seleccionó la materia`, `danger`); + } else { + $.get(`/studentstatus`, { student: student_, subject: subject_ }).done((data) => { + $(`#statusResponse`).html(data); + }).fail((err) => { + appendAlert(err.responseText, `danger`); + }); + } + }); +})(); \ No newline at end of file diff --git a/routes/index.route.js b/routes/index.route.js index ad5486c..e41b5d5 100644 --- a/routes/index.route.js +++ b/routes/index.route.js @@ -2,8 +2,21 @@ const express = require('express'); const IndexRoute = express.Router(); /* GET home page. */ -IndexRoute.get('/', function(req, res, next) { - res.render('pages/index', { title: 'Estado Materias', year: new Date().getUTCFullYear() }); +IndexRoute.get('/', (req, res, next) => { + const selSubject = req.query.subject || null; + const subjects = ` + `; + +console.log(selSubject,subjects); + + res.render('pages/index', { title: 'Estado Materias', + year: new Date().getUTCFullYear(), + subjectSelected: subjects + }); }); module.exports = IndexRoute; \ No newline at end of file diff --git a/views/pages/index.ejs b/views/pages/index.ejs index a71092a..c4f3a81 100644 --- a/views/pages/index.ejs +++ b/views/pages/index.ejs @@ -3,13 +3,8 @@
- - + + <%- subjectSelected %>