From 1c8e8c493e14203045335e429049835257f0fd3d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 23 Nov 2020 10:28:36 +0100 Subject: [PATCH 1/5] ajout interaction sur la page marks --- public/javascripts/marks.js | 11 +++++++++ sass/style.sass | 8 ++++++- views/pages/marks.pug | 46 ++++++++++++++++++------------------- views/template/layout.pug | 5 ++-- 4 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 public/javascripts/marks.js diff --git a/public/javascripts/marks.js b/public/javascripts/marks.js new file mode 100644 index 0000000..0cd6cae --- /dev/null +++ b/public/javascripts/marks.js @@ -0,0 +1,11 @@ +function setVisible(targetId) { + document.getElementById("notvisible").id = "visible"; +} + +function setNotVisible(targetId) { + document.getElementById(targetId).id = "notvisible"; +} + +function marksformChange(targetId) { + document.getElementById("marksform").style.display = "block"; +} diff --git a/sass/style.sass b/sass/style.sass index 4ff8617..7ac9c7b 100644 --- a/sass/style.sass +++ b/sass/style.sass @@ -387,4 +387,10 @@ div#visible + div font-size: 22px padding: 15px cursor: pointer - margin-bottom: 50px \ No newline at end of file + margin-bottom: 50px + +#notvisible + display: none + +#marksform + display: none \ No newline at end of file diff --git a/views/pages/marks.pug b/views/pages/marks.pug index 592674b..4895981 100644 --- a/views/pages/marks.pug +++ b/views/pages/marks.pug @@ -2,7 +2,7 @@ extends ../template/navbar block content if student === true - div(class="marksdetails" id="visibl") + div(class="marksdetails" id="notvisible" onclick="setNotVisible(this.getAttribute('id'))") table tr th(colspan="2") Details @@ -22,24 +22,24 @@ block content th(colspan="2") Maths tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -50,17 +50,17 @@ block content th(colspan="2") TP SE tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -71,17 +71,17 @@ block content th(colspan="2") PHP tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -92,17 +92,17 @@ block content th(colspan="2") Anglais tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -111,11 +111,11 @@ block content div(class="col s12 m10 offset-m1 marksgroup") h3 Selectionnez un groupe div(id="flexgroup") - p G1S1 - p G2S2 - p G3S3 + p(onclick="marksformChange(this.getAttribute('id'))") G1S1 + p(onclick="marksformChange(this.getAttribute('id'))") G2S2 + p(onclick="marksformChange(this.getAttribute('id'))") G3S3 - form + form(id="marksform") table(id="markstable") thead tr diff --git a/views/template/layout.pug b/views/template/layout.pug index 165f7ee..7abe3e1 100644 --- a/views/template/layout.pug +++ b/views/template/layout.pug @@ -7,8 +7,8 @@ html link(rel="stylesheet", href="/stylesheets/style.css") script(src="/socket.io/socket.io.js") body - - var student = true - - var teacher = false + - var student = false + - var teacher = true - var admin = false div(class="row" id="page") div(class="col s2" id="panel") @@ -16,4 +16,5 @@ html div(class="col s10" id="main") block content script(src="/javascripts/main.js") + script(src="/javascripts/marks.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js") From 9703f42d3292abb4524e801670ea74cfc6c7276c Mon Sep 17 00:00:00 2001 From: p1905074 Date: Mon, 23 Nov 2020 21:24:43 +0100 Subject: [PATCH 2/5] =?UTF-8?q?mise=20=C3=A0=20jour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/marks.js | 11 +++++++++ sass/style.sass | 7 +++++- views/pages/marks.pug | 46 ++++++++++++++++++------------------- views/template/layout.pug | 1 + 4 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 public/javascripts/marks.js diff --git a/public/javascripts/marks.js b/public/javascripts/marks.js new file mode 100644 index 0000000..0cd6cae --- /dev/null +++ b/public/javascripts/marks.js @@ -0,0 +1,11 @@ +function setVisible(targetId) { + document.getElementById("notvisible").id = "visible"; +} + +function setNotVisible(targetId) { + document.getElementById(targetId).id = "notvisible"; +} + +function marksformChange(targetId) { + document.getElementById("marksform").style.display = "block"; +} diff --git a/sass/style.sass b/sass/style.sass index c0593fc..f3a230b 100644 --- a/sass/style.sass +++ b/sass/style.sass @@ -487,4 +487,9 @@ div#visible + div border-radius: 2px display: block margin: auto - cursor: pointer \ No newline at end of file + cursor: pointer +#notvisible + display: none + +#marksform + display: none diff --git a/views/pages/marks.pug b/views/pages/marks.pug index d6cc47a..9066d95 100644 --- a/views/pages/marks.pug +++ b/views/pages/marks.pug @@ -2,7 +2,7 @@ extends ../template/navbar block content if student === true - div(class="marksdetails" id="visibl") + div(class="marksdetails" id="notvisible" onclick="setNotVisible(this.getAttribute('id'))") table tr th(colspan="2") Details @@ -22,24 +22,24 @@ block content th(colspan="2") Maths tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -50,17 +50,17 @@ block content th(colspan="2") TP SE tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -71,17 +71,17 @@ block content th(colspan="2") PHP tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -92,17 +92,17 @@ block content th(colspan="2") Anglais tbody tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 tr - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 1 p 18/20 - td + td(onclick="setVisible(this.getAttribute('id'))") p DS 2 p 16/20 @@ -111,11 +111,11 @@ block content div(class="col s12 m10 offset-m1 marksgroup") h3 Select a group div(id="flexgroup") - p G1S1 - p G2S2 - p G3S3 + p(onclick="marksformChange(this.getAttribute('id'))") G1S1 + p(onclick="marksformChange(this.getAttribute('id'))") G2S2 + p(onclick="marksformChange(this.getAttribute('id'))") G3S3 - form + form(id="marksform") table(id="markstable") thead tr diff --git a/views/template/layout.pug b/views/template/layout.pug index 5fa9957..7abe3e1 100644 --- a/views/template/layout.pug +++ b/views/template/layout.pug @@ -16,4 +16,5 @@ html div(class="col s10" id="main") block content script(src="/javascripts/main.js") + script(src="/javascripts/marks.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js") From 5a39d169b3e6046936a5ec5d5f09bb872b5489e0 Mon Sep 17 00:00:00 2001 From: p1905074 Date: Mon, 23 Nov 2020 21:28:17 +0100 Subject: [PATCH 3/5] add profil redirect --- public/javascripts/main.js | 7 ++++++- views/template/navbar.pug | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/public/javascripts/main.js b/public/javascripts/main.js index 1a1fcda..20b1d66 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -18,4 +18,9 @@ socket.on("logout", data=>{ }else{ window.location.href = "/"; } -}) \ No newline at end of file +}) + + +function profilRedirect(){ + document.location.href="/profil"; +} \ No newline at end of file diff --git a/views/template/navbar.pug b/views/template/navbar.pug index d738661..2da3620 100644 --- a/views/template/navbar.pug +++ b/views/template/navbar.pug @@ -2,16 +2,16 @@ extends layout block navbar if student === true - div(id="navprofile" class="student") + div(id="navprofile" class="student" onclick="profilRedirect()") p Kezel Benoit p G4S3 a(id="logout") Logout if teacher === true - div(id="navprofile" class="teacher") + div(id="navprofile" class="teacher" onclick="profilRedirect()") p Kezel Benoit a(id="logout") Logout if admin === true - div(id="navprofile" class="admin") + div(id="navprofile" class="admin" onclick="profilRedirect()") p Kezel Benoit a(id="logout") Logout From 768c982293b6e252cdf4823740d9c2f32afa9910 Mon Sep 17 00:00:00 2001 From: p1905074 Date: Thu, 26 Nov 2020 19:26:54 +0100 Subject: [PATCH 4/5] =?UTF-8?q?d=C3=A9placement=20de=20l'appel=20marks.js?= =?UTF-8?q?=20dans=20marks.pug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/pages/marks.pug | 4 +++- views/template/layout.pug | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/views/pages/marks.pug b/views/pages/marks.pug index 9066d95..6baa24c 100644 --- a/views/pages/marks.pug +++ b/views/pages/marks.pug @@ -185,4 +185,6 @@ block content input(type="number" value="16") td input(type="number") - input(id="marksubmit" type="submit" value="Enregistrer") \ No newline at end of file + input(id="marksubmit" type="submit" value="Enregistrer") + + script(src="/javascripts/marks.js") \ No newline at end of file diff --git a/views/template/layout.pug b/views/template/layout.pug index 7abe3e1..5fa9957 100644 --- a/views/template/layout.pug +++ b/views/template/layout.pug @@ -16,5 +16,4 @@ html div(class="col s10" id="main") block content script(src="/javascripts/main.js") - script(src="/javascripts/marks.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js") From eadfd0064d76f893be7b7186d90ee6cf34c257f5 Mon Sep 17 00:00:00 2001 From: p1905074 Date: Fri, 27 Nov 2020 08:35:19 +0100 Subject: [PATCH 5/5] =?UTF-8?q?envoie=20du=20formulaire=20=C3=A9dition=20d?= =?UTF-8?q?e=20profil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/profil.js | 21 +++++++++++++++++++++ sockets/profile/edit.js | 1 + 2 files changed, 22 insertions(+) create mode 100644 public/javascripts/profil.js diff --git a/public/javascripts/profil.js b/public/javascripts/profil.js new file mode 100644 index 0000000..c2c044b --- /dev/null +++ b/public/javascripts/profil.js @@ -0,0 +1,21 @@ +let socket = io.connect(); + +document.getElementById("editprofil").addEventListener("submit", e=>{ + e.preventDefault(); + socket.emit("profileEdit", { + "email": mail, + "firstName": document.getElementById("firstname-input").value, + "lastName": document.getElementById("lastname-input").value, + "newPassword": document.getElementById("new-password").value, + "password": document.getElementById("password").value + }); +}); + + +socket.on("profileEdit", data=>{ + if(data.error){ + alert(data.error.message); + }else{ + window.location.href = "/"; + } +}) \ No newline at end of file diff --git a/sockets/profile/edit.js b/sockets/profile/edit.js index 2fcaff5..99565a4 100644 --- a/sockets/profile/edit.js +++ b/sockets/profile/edit.js @@ -12,6 +12,7 @@ module.exports = socket => { user.firstName = data.firstName; if (data.lastName !== user.lastName) user.lastName = data.lastName; + user.newPassword = data.newPassword; if (data.password && !user.checkPassword(data.password)) user.passwordHash = data.password socket.request.session.user = user;