From c34dc6774ab7ff5aea7532bf7786885f5ca0f741 Mon Sep 17 00:00:00 2001 From: Marcin Kowalicki Date: Sun, 10 Jan 2021 22:50:36 +0100 Subject: [PATCH] Add messages in menu and improve grades --- README.md | 4 ++++ files/css/start.css | 18 +++++++++-------- files/js/grades.js | 46 ++++++++++++++++++++++++++++++------------ templates/content.html | 14 ++++++++++++- 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 01b44a2..ae6ada2 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,7 @@ and modify the .envsample file. ```shell python manage.py runserver ``` +or if you run Windows you can run: +```shell +runserver.bat +``` diff --git a/files/css/start.css b/files/css/start.css index d560964..c43e731 100644 --- a/files/css/start.css +++ b/files/css/start.css @@ -40,12 +40,14 @@ body { } .grade { - font-size: 20px; - width: 25px; - height: 30px; - background: #ff0000; - text-align: center; - margin-left: auto; - margin-right: auto; - margin-top: 5px; + display: block; + border-radius: 5px; + cursor: pointer !important; + font-size: 20px !important; + width: 25px !important; + height: 30px !important; + text-align: center !important; + margin-left: auto !important; + margin-right: auto !important; + margin-top: 5px !important; } \ No newline at end of file diff --git a/files/js/grades.js b/files/js/grades.js index c818936..031a41f 100644 --- a/files/js/grades.js +++ b/files/js/grades.js @@ -15,24 +15,44 @@ const getGrades = () => { body: cookies_data }).then(response => response.json()).then(data => { allGrades = data.data.Oceny + const content = document.getElementById("content") allGrades.forEach((grade) => { - content = document.getElementById("content") - czastkowe = grade.OcenyCzastkowe - //console.log(grade) + const czastkowe = grade.OcenyCzastkowe + czastkowe.forEach((czastkowa) => { const gradeDiv = document.createElement("div") - gradeDiv.className = "grade" + gradeDiv.classList = "grade modal-trigger" + gradeDiv.href = "#modal1" gradeDiv.innerHTML = `${czastkowa.Wpis}` - if (czastkowa.Wpis == "6" || czastkowa.Wpis == "6-") gradeDiv.style.background = "#3dbbf5" - else if (czastkowa.Wpis == "5" || czastkowa.Wpis == "5-" || czastkowa.Wpis == "5+") gradeDiv.style.background = "#4caf50" - else if (czastkowa.Wpis == "4" || czastkowa.Wpis == "4-" || czastkowa.Wpis == "4+") gradeDiv.style.background = "#a0c431" - else if (czastkowa.Wpis == "3" || czastkowa.Wpis == "3-" || czastkowa.Wpis == "3+") gradeDiv.style.background = "#ffb940" - else if (czastkowa.Wpis == "2" || czastkowa.Wpis == "2-" || czastkowa.Wpis == "2+") gradeDiv.style.background = "#ff774d" - else if (czastkowa.Wpis == "1" || czastkowa.Wpis == "1-") gradeDiv.style.background = "#d43f3f" - else gradeDiv.style.background = "#607d8b" - console.log(czastkowa) - content.appendChild(gradeDiv) + + switch (czastkowa.Wpis) { + case "6" || "6-": + gradeDiv.style.background = "#3dbbf5" + break; + case "5" || "5-" || "5+": + gradeDiv.style.background = "#4caf50" + break; + case "4" || "4-" || "4+": + gradeDiv.style.background = "#a0c431" + break; + case "3" || "3-" || "3+": + gradeDiv.style.background = "#ffb940" + break; + case "2" || "2-" || "2+": + gradeDiv.style.background = "#ff774d" + break; + case "1" || "1+": + gradeDiv.style.background = "#d43f3f" + break; + default: + gradeDiv.style.background = "#607d8b" + } + gradeDiv.addEventListener('click', () => { + console.log(`Nauczyciel: ${czastkowa.Nauczyciel}, Waga: ${czastkowa.Waga}, Data: ${czastkowa.DataOceny}, Przedmiot: ${grade.Przedmiot}`) + }) + + content.append(gradeDiv) }) }) }) diff --git a/templates/content.html b/templates/content.html index 930e379..15d7ae3 100644 --- a/templates/content.html +++ b/templates/content.html @@ -46,7 +46,13 @@
  • Sprawdziany
  • Zadania Domowe
  • Frekwencjaa
  • -
  • Wiadomości
  • +
  • emailWiadomości
  • +
  • Uwagi
  • menu @@ -71,6 +77,12 @@ var elems = document.querySelectorAll('.modal'); var instances = M.Modal.init(elems, options); }); + + var dropdowns = document.querySelectorAll('.dropdown-trigger') + for (var i = 0; i < dropdowns.length; i++){ + M.Dropdown.init(dropdowns[i]); + } + \ No newline at end of file