From 93979842f772863c4b23d3661b4b73c29642e3aa Mon Sep 17 00:00:00 2001 From: roeibi88 Date: Thu, 25 Nov 2021 14:04:08 +0200 Subject: [PATCH 1/6] Create hi.txt --- RoeiBi/hi.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 RoeiBi/hi.txt diff --git a/RoeiBi/hi.txt b/RoeiBi/hi.txt new file mode 100644 index 0000000..e69de29 From 283eaa581c720220c4bedbbb9ea9771bc6cb5e94 Mon Sep 17 00:00:00 2001 From: roeibi88 <94899806+roeibi88@users.noreply.github.com> Date: Thu, 25 Nov 2021 17:33:56 +0200 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c7953c..4a4a716 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Lets start with GitHub !! - +test change From 395413fee83305c67087fa0d06c9f220919e87ac Mon Sep 17 00:00:00 2001 From: roeibi88 Date: Thu, 25 Nov 2021 17:34:34 +0200 Subject: [PATCH 3/6] Create hi2.txt --- RoeiBi/hi2.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 RoeiBi/hi2.txt diff --git a/RoeiBi/hi2.txt b/RoeiBi/hi2.txt new file mode 100644 index 0000000..9a2c773 --- /dev/null +++ b/RoeiBi/hi2.txt @@ -0,0 +1 @@ +testing \ No newline at end of file From 3b489c023eb171c07b778aa277cda7301e20a64b Mon Sep 17 00:00:00 2001 From: roeibi88 Date: Thu, 25 Nov 2021 17:36:30 +0200 Subject: [PATCH 4/6] Delete hi2.txt --- RoeiBi/hi2.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 RoeiBi/hi2.txt diff --git a/RoeiBi/hi2.txt b/RoeiBi/hi2.txt deleted file mode 100644 index 9a2c773..0000000 --- a/RoeiBi/hi2.txt +++ /dev/null @@ -1 +0,0 @@ -testing \ No newline at end of file From 6a1f16c40ff8c8c2b7af979411b73f42b60b7b01 Mon Sep 17 00:00:00 2001 From: roeibi88 Date: Mon, 29 Nov 2021 21:17:04 +0200 Subject: [PATCH 5/6] first students form --- RoeiBi/form/index.html | 62 +++++++++++++++++++++++++ RoeiBi/form/js/script.js | 85 +++++++++++++++++++++++++++++++++++ RoeiBi/form/styles/styles.css | 18 ++++++++ 3 files changed, 165 insertions(+) create mode 100644 RoeiBi/form/index.html create mode 100644 RoeiBi/form/js/script.js create mode 100644 RoeiBi/form/styles/styles.css diff --git a/RoeiBi/form/index.html b/RoeiBi/form/index.html new file mode 100644 index 0000000..6fdbcd0 --- /dev/null +++ b/RoeiBi/form/index.html @@ -0,0 +1,62 @@ + + + + + + + + Student details + + + +
+
+

Please fill-in student detials

+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+ + + + + + + + + +
First NameLast NameEmailStatus
+
+
+ + + + \ No newline at end of file diff --git a/RoeiBi/form/js/script.js b/RoeiBi/form/js/script.js new file mode 100644 index 0000000..405d1f1 --- /dev/null +++ b/RoeiBi/form/js/script.js @@ -0,0 +1,85 @@ +let studentsStr = [] +window.onload = checkLocalStorage() + +class saveStudent { + constructor(fname, lname, email, sstatus) { + this.fname = fname, + this.lname = lname, + this.email = email, + this.sstatus = sstatus + } +} + +function checkLocalStorage() { + if (window.localStorage.getItem("student")) { + studentsStr = JSON.parse(localStorage.getItem("student")); + console.log(studentsStr) + for (i = 0; i < studentsStr.length; i++) { + loopStudent = studentsStr[i] + addToTable(loopStudent.fname, loopStudent.lname, loopStudent.email, loopStudent.sstatus) + } + } + else { + console.log("no students on local storage yet") + } +} + +function saveBtn() { + fname = document.getElementById("fname").value; + lname = document.getElementById("lname").value; + email = document.getElementById("email").value; + sstatus = document.getElementById("sstatus").value; + if (window.localStorage.getItem("student")) { + studentsStr = JSON.parse(localStorage.getItem("student")); + for (i = 0; i < studentsStr.length; i++) { + if (studentsStr[i].fname == fname){ + console.log("name already exists") + return; + } + else continue; + } + } + let student = new saveStudent(fname, lname, email, sstatus); + studentsStr.push(student); + window.localStorage.setItem("student", JSON.stringify(studentsStr)); + // console.log("student saved in local storage: " + window.localStorage.getItem("student")); + addToTable(fname, lname, email, sstatus) +} + +function addToTable(fname, lname, email, sstatus) { + let table = document.getElementById("sTable"); + let newRow = table.insertRow(); + newRow.insertCell().innerHTML = fname + newRow.insertCell().innerHTML = lname + newRow.insertCell().innerHTML = email + newRow.insertCell().innerHTML = sstatus +} + +// No need for this function +// function getStudents() { +// if (window.localStorage.getItem("student")) { +// let studentsStr = JSON.parse(window.localStorage.getItem("student")); +// console.log(studentsStr); +// for (let i = 0; i < studentsStr.length; i++) { +// console.log(studentsStr[i].index) +// //innerHTML here +// } +// } +// else console.log("no students registered"); +// } + +function clearStudents() { + if (!window.localStorage.getItem("student")) { + console.log("ls is empty"); + } + else { + let table = document.getElementById("sTable"); + let rowCount = table.rows.length + console.log(rowCount) + for (let i = rowCount; i > 1; i--) { + table.deleteRow(i - 1); + console.log("row: ", i); + } + window.localStorage.removeItem("student") + } +} \ No newline at end of file diff --git a/RoeiBi/form/styles/styles.css b/RoeiBi/form/styles/styles.css new file mode 100644 index 0000000..9de2c9f --- /dev/null +++ b/RoeiBi/form/styles/styles.css @@ -0,0 +1,18 @@ +.container { + margin: 0 auto; + width: 800px; +} +label { + width: 80px; + display: inline-block; +} +input { + padding: 2px; +} +textarea { + max-width: 170px; + max-height:160px; +} +ul li { + margin-top: 10px; +} \ No newline at end of file From 7ee4f97ad05ec715f6c31eba926c584903b86e7f Mon Sep 17 00:00:00 2001 From: roeibi88 Date: Mon, 29 Nov 2021 21:17:43 +0200 Subject: [PATCH 6/6] Delete hi.txt --- RoeiBi/hi.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 RoeiBi/hi.txt diff --git a/RoeiBi/hi.txt b/RoeiBi/hi.txt deleted file mode 100644 index e69de29..0000000