diff --git a/.gitignore b/.gitignore
new file mode 100755
index 00000000..57195033
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.DS_Store
+node_modules/
+package-lock.json
diff --git a/.glitch-assets b/.glitch-assets
new file mode 100644
index 00000000..2b950f60
--- /dev/null
+++ b/.glitch-assets
@@ -0,0 +1,11 @@
+{"name":"image.png","date":"2019-09-09T03:21:27.676Z","url":"https://cdn.glitch.com/e0bc9286-a871-443e-a57f-2e27d07bd89e%2Fimage.png","type":"image/png","size":54851,"imageWidth":558,"imageHeight":601,"thumbnail":"https://cdn.glitch.com/e0bc9286-a871-443e-a57f-2e27d07bd89e%2Fthumbnails%2Fimage.png","thumbnailWidth":307,"thumbnailHeight":330,"uuid":"gyBKnc2D2mLyQ8up"}
+{"name":"favicon (2).ico","date":"2019-09-14T16:22:13.186Z","url":"https://cdn.glitch.com/5cd46ecf-8f21-44d2-941d-1799ff06883e%2Ffavicon%20(2).ico","type":"image/x-icon","size":318,"imageWidth":16,"imageHeight":16,"thumbnail":"https://cdn.glitch.com/5cd46ecf-8f21-44d2-941d-1799ff06883e%2Ffavicon%20(2).ico","thumbnailWidth":16,"thumbnailHeight":16,"uuid":"s1BVKqfyil2B9f2m"}
+{"uuid":"s1BVKqfyil2B9f2m","deleted":true}
+{"name":"favicon-a3.ico","date":"2019-09-14T16:26:08.998Z","url":"https://cdn.glitch.com/5cd46ecf-8f21-44d2-941d-1799ff06883e%2Ffavicon-a3.ico","type":"image/x-icon","size":318,"imageWidth":16,"imageHeight":16,"thumbnail":"https://cdn.glitch.com/5cd46ecf-8f21-44d2-941d-1799ff06883e%2Ffavicon-a3.ico","thumbnailWidth":16,"thumbnailHeight":16,"uuid":"2XFISO0ezBjOTcjZ"}
+{"uuid":"gyBKnc2D2mLyQ8up","deleted":true}
+{"name":"GradeTable.PNG","date":"2019-09-15T22:37:10.243Z","url":"https://cdn.glitch.com/5cd46ecf-8f21-44d2-941d-1799ff06883e%2FGradeTable.PNG","type":"image/png","size":9468,"imageWidth":1670,"imageHeight":221,"thumbnail":"https://cdn.glitch.com/5cd46ecf-8f21-44d2-941d-1799ff06883e%2Fthumbnails%2FGradeTable.PNG","thumbnailWidth":330,"thumbnailHeight":44,"uuid":"ilUkSUhHfqYIw109"}
+{"name":"favicon (2).ico","date":"2019-10-04T15:59:56.794Z","url":"https://cdn.glitch.com/3a7a7745-805f-4bc9-9091-f891637e22a2%2Ffavicon%20(2).ico","type":"image/x-icon","size":318,"imageWidth":16,"imageHeight":16,"thumbnail":"https://cdn.glitch.com/3a7a7745-805f-4bc9-9091-f891637e22a2%2Ffavicon%20(2).ico","thumbnailWidth":16,"thumbnailHeight":16,"uuid":"4riQPjUDuKjm5fQ4"}
+{"uuid":"ilUkSUhHfqYIw109","deleted":true}
+{"uuid":"2XFISO0ezBjOTcjZ","deleted":true}
+{"uuid":"4riQPjUDuKjm5fQ4","deleted":true}
+{"name":"faviconCheck.ico","date":"2019-10-04T16:01:32.951Z","url":"https://cdn.glitch.com/3a7a7745-805f-4bc9-9091-f891637e22a2%2FfaviconCheck.ico","type":"image/x-icon","size":318,"imageWidth":16,"imageHeight":16,"thumbnail":"https://cdn.glitch.com/3a7a7745-805f-4bc9-9091-f891637e22a2%2FfaviconCheck.ico","thumbnailWidth":16,"thumbnailHeight":16,"uuid":"wE3HPcJdaSgbPE5C"}
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
index 39e2788d..b63613b3
--- a/README.md
+++ b/README.md
@@ -1,51 +1,14 @@
-# cs4241-FinalProject
+## Scheduler
-For your final project, you'll implement a course project that exhibits your mastery of the course materials.
-Similar to A4, this project gives you an opportunity to be creative and to pursue individual research and learning.
+https://fp-start.glitch.me
-## General description
+This is an application that allows for users to schedule meetings, and assign tasks to users for each meeting that they have created.
-Your project should consist of a complete Web application, exhibiting facets of the three main sections of the course material:
+Features of the application include:
-- Static Web page content and design. You should have a project that is accessible, easily navigable, and features significant content.
-- Dynamic behavior implemented with JavaScript.
-- Server-side programming *using Node.js*. Typically this will take the form of some sort of persistent data, authentication, and possibly server-side computation.
+- Passport authentication for users
+- Seperate pages for allowing users to view meetings, make meetings, assign tasks, and view their own messages and tasks.
+- Messages that are automatically stored for users to notify them when they are assigned or unassigned from a task.
-Additionally, you should incorporate features that you independently research, design, and implement for your project.
-## Project ideation
-Excellent projects serve someone/some group; for this assignment you need to define your users and stakeholders. I encourage you to identify projects that will have impact, either artistically, politically, or in terms of productivity. Consider creating something useful for a cause or hobby you care about.
-
-## Logistics
-
-### Team size
-Students are encouraged to work in teams of 2-5 students for the project. This will allow you to build a good project without expending an excessive amount of effort. While I would expect a team of four or five students to produce a project with more features, I expect a every team's work to exhibit all of the required facets described above.
-
-### Deliverables
-
-__Proposal:__
-Provide an outline of your project direction and the names of the team members.
-The outline should have enough detail so that staff can determine if it meets the minimum expectations, or if it goes too far to be reasonable by the deadline.
-This file must be named proposal.md so we can find it.
-Submit a PR to turn it in by Monday, September 30th, before class
-
-There are no other scheduled checkpoints for your project.
-You must be done in time to present before the final project demo day (October 10th).
-
-#### Turning in Your Outline / Project
-
-**NOTE: code is due before the project presentation day due to the end of term / grading schedule constraints**
-Submit a second PR on the final project repo to turn in your app and code.
-
-Deploy your app, in the form of a webpage, to Glitch/Heroku/Digital Ocean or some other service.
-Folks on the same team do not need to post the same webpage, but must instead clearly state who is on the team in their proposal.
-(Staff will use the proposal to build the grading sheet.)
-
-## Final Presentation
-
-Presentations will occur during the final day of class.
-
-## FAQs
-
-- **Can I use XYZ framework?** You can use any web-based frameworks or tools available, but for your server programming you need to use node.js.
diff --git a/assets/3a7a7745-805f-4bc9-9091-f891637e22a2%2FfaviconCheck.ico?v=1570204892951 b/assets/3a7a7745-805f-4bc9-9091-f891637e22a2%2FfaviconCheck.ico?v=1570204892951
new file mode 100644
index 00000000..998d1b29
Binary files /dev/null and b/assets/3a7a7745-805f-4bc9-9091-f891637e22a2%2FfaviconCheck.ico?v=1570204892951 differ
diff --git a/package.json b/package.json
new file mode 100755
index 00000000..be01b08c
--- /dev/null
+++ b/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "fp-start",
+ "version": "0.1.0",
+ "description": "A nice description",
+ "author": "Many ",
+ "scripts": {
+ "start": "node server.improved.js"
+ },
+ "dependencies": {
+ "body-parser": "^1.19.0",
+ "express": "^4.17.1",
+ "express-session": "^1.16.2",
+ "passport": "^0.4.0",
+ "passport-local": "^1.0.0",
+ "sqlite3": "^4.1.0",
+ "response-time": "^2.3.2",
+ "serve-favicon": "^2.5.0",
+ "helmet": "^3.21.0",
+ "express-slash": "^2.0.1",
+ "morgan": "1.9.1",
+ "compression": "^1.7.4"
+ }
+}
diff --git a/proposal.md b/proposal.md
new file mode 100644
index 00000000..6053f7b2
--- /dev/null
+++ b/proposal.md
@@ -0,0 +1,8 @@
+# Proposal
+
+Team members: Peter Jankowski, Tom Graham, Rosana Pochat
+
+Project details:
+
+We want to make a calendar application that allows for people to sign up, and set up meetings with other registered users. Our website will allow for people to set up task lists in advance of a meeting, assign tasks to users from a meeting’s task list, and notify users as the meeting deadline approaches. We will also allow for users to adjust the look of the site when they are logged in.
+
diff --git a/public/css/index.css b/public/css/index.css
new file mode 100644
index 00000000..3eb89a06
--- /dev/null
+++ b/public/css/index.css
@@ -0,0 +1,21 @@
+.form-control {
+ margin-left:25%;
+ width:50%;
+}
+
+label {
+ margin-left:25%;
+}
+
+details {
+ margin-left:25%;
+ margin-right:25%;
+}
+
+#myCanvas{
+ background-color: black;
+}
+
+.btn {
+ margin-left:25%;
+}
\ No newline at end of file
diff --git a/public/index.html b/public/index.html
new file mode 100755
index 00000000..e06990bf
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,60 @@
+
+
+
+ CS4241 Final Project
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Scheduler App
+
Login Page
+
+
+
+
+
+
+
+
+
+
+
diff --git a/public/js/calendarScripts.js b/public/js/calendarScripts.js
new file mode 100644
index 00000000..9c95c0e4
--- /dev/null
+++ b/public/js/calendarScripts.js
@@ -0,0 +1,123 @@
+// Here is where the js will go for allowing users to add, remove, and display meetings by date
+
+let isHidden = true;
+
+const hide = function( e ) {
+ e.preventDefault();
+ document.getElementById("tablePrint").innerHTML = '
';
+ isHidden = true;
+}
+
+// Get all meetings from the database for this date
+const view = function( e ) {
+ e.preventDefault();
+
+ const dateInput = document.querySelector( '#enteredDate' );
+ if (dateInput.value !== "") {
+ let meetingsArray;
+ const json = { date: dateInput.value, },
+ body = JSON.stringify( json );
+
+ fetch( '/viewMyMeetings', {
+ method:'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' },
+ body: body
+ })
+ .then( function( response ) {
+
+ // Fetch all tasks for this meeting in the database to add to a table
+ response.json().then((data) => {
+ meetingsArray = data.meetingsArray;
+ let numTasks = meetingsArray.length;
+ let myTable = '
Meeting Name:
';
+ myTable += "
Meeting Date:
";
+ myTable += "
Meeting Creator:
";
+ myTable += "
Meeting Details:
";
+ for (let i = 0; i < numTasks; i++) { // Make the table with one row per task
+ myTable += "
" + meetingsArray[i].name + "
";
+ myTable += "
" + meetingsArray[i].date + "
";
+ myTable += "
" + meetingsArray[i].username + "
";
+ myTable += "
" + meetingsArray[i].details + "
";
+ }
+ myTable += "
";
+ document.getElementById("tablePrint").innerHTML = myTable;
+ isHidden = false;
+ });
+ });
+ return false;
+ } else {
+ alert("Enter a full date to see meetings on that date");
+ }
+}
+
+const submit = function( e ) { // Submit request for a new meeting
+ e.preventDefault()
+
+ const nameInput = document.querySelector( '#meetingName' ),
+ detailsInput = document.querySelector( '#meetingDetails' ),
+ dateInput = document.querySelector('#enteredDate'),
+ json = { name: nameInput.value, date: dateInput.value, details: detailsInput.value },
+ body = JSON.stringify( json );
+
+ fetch( '/submitMeeting', { //This meeting will be made originally with no tasks in it, just details
+ method:'POST',
+ body: JSON.stringify( json ),
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include'
+ })
+ .then( function( response ) {
+ // Update the task list for the user
+ response.json().then((data) => {
+ //act now that the new meeting has been created
+ if (data.meetingAdded) {
+ alert("Meeting created");
+ } else {
+ alert("You already have a meeting of that name");
+ }
+ if (!isHidden) {
+ view(e);
+ }
+ });
+ });
+ return false;
+}
+
+const remove = function( e ) { // Delete a task with a specified id number
+ // prevent default form action from being carried out
+ e.preventDefault();
+
+ const nameInput = document.querySelector( '#meetingName' ),
+ dateInput = document.querySelector('#enteredDate'),
+ json = { name: nameInput.value, date: dateInput.value },
+ body = JSON.stringify( json );
+
+ fetch( '/removeMeeting', {
+ method:'DELETE',
+ body: JSON.stringify( json ),
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include'
+ })
+ .then( function( response ) {
+ // Simply redisplay the table on the response after the deletion occurs
+ // if it is not currently hidden
+ response.json().then((data) => {
+ document.getElementById("tablePrint").innerHTML = '
';
+ if (!isHidden) {
+ view(e);
+ }
+ });
+ });
+ return false;
+}
+
+window.onload = function() { // Link each button to its respective function
+ const viButton = document.querySelector( '#viewButton' ),
+ siButton = document.querySelector( '#submitButton' ),
+ hiButton = document.querySelector( '#hideButton' ),
+ reButton = document.querySelector( '#removeButton' );
+ viButton.onclick = view;
+ siButton.onclick = submit;
+ hiButton.onclick = hide;
+ reButton.onclick = remove;
+}
diff --git a/public/js/loginScripts.js b/public/js/loginScripts.js
new file mode 100644
index 00000000..6dfa64e9
--- /dev/null
+++ b/public/js/loginScripts.js
@@ -0,0 +1,67 @@
+// Some Javascript code here, to run on the front end on the login page
+
+window.onload = function() { // Link each button to its respective function
+ const newButton = document.querySelector( '#signupButton' );
+ newButton.onclick = signUpFunc;
+ const logButton = document.querySelector( '#loginButton' );
+ logButton.onclick = loginFunc;
+}
+
+const signUpFunc = function( e ) {
+ e.preventDefault();
+ // Handles a new user signing up
+
+ const nameInput = document.querySelector( '#newname' ),
+ passInput = document.querySelector( '#newpass' ),
+ json = { username: nameInput.value, password: passInput.value},
+ body = JSON.stringify( json );
+ console.log(body);
+
+ fetch( '/signUp', {
+ method:'POST',
+ body
+ })
+ .then( function( response ) {
+ // Inform the user of what the letter grade of the student is, and
+ // refresh the table view with the new student in it
+ response.json().then((data) => {
+ console.log(data);
+ if (data.userAdded === true) {
+ alert("New user added: " + nameInput.value);
+ } else {
+ alert("That username has already been taken!");
+ }
+ })
+ return false;
+ })
+}
+
+const loginFunc = function( e ) { // Handles logins
+ e.preventDefault();
+ const nameInput = document.querySelector( '#loginName' ),
+ passInput = document.querySelector( '#pass' ),
+ json = { username: nameInput.value, password: passInput.value},
+ body = JSON.stringify( json );
+ console.log(body);
+
+ fetch( '/login', {
+ method:'POST',
+ body: body,
+ headers: { 'Content-Type': 'application/json' }
+ })
+ .then( function( response ) {
+ // Inform the user of what the letter grade of the student is, and
+ // refresh the table view with the new student in it
+ console.log( response.status );
+ if (response.status === 200 || response.status === 304) {
+ loginRedir();
+ } else {
+ alert("Login failed!");
+ }
+ return false;
+ })
+}
+
+const loginRedir = function( e ) {
+ window.location.replace('https://fp-start.glitch.me/mainview.html');
+}
diff --git a/public/js/mainScripts.js b/public/js/mainScripts.js
new file mode 100644
index 00000000..5ef29d7c
--- /dev/null
+++ b/public/js/mainScripts.js
@@ -0,0 +1,222 @@
+// Here is where the js will go for allowing users to add, remove, and display meetings by date
+
+let isHidden = true;
+let isHiddenTasks = true;
+
+const drawCal = function (date) {
+ let dateInput = document.querySelector( '#enteredDate' );
+ if (date) {
+ dateInput.value = date;
+ }
+ const calendarHeader = document.querySelector( '#calendarHeader' );
+ const month = dateInput.value.substring(5, 7);
+ const yearStr = dateInput.value.substring(0, 4);
+ let monthStr;
+ let dayLimit;
+ if (month === "01") {
+ monthStr = "January";
+ dayLimit = 31;
+ } else if (month === "02") {
+ monthStr = "February";
+ dayLimit = 28;
+ // Take leap years into account
+ if (Number(yearStr) % 4 === 0 && (Number(yearStr) % 100 !== 0 || Number(yearStr) % 400 === 0)) {
+ dayLimit++;
+ }
+ } else if (month === "03") {
+ monthStr = "March";
+ dayLimit = 31;
+ } else if (month === "04") {
+ monthStr = "April";
+ dayLimit = 30;
+ } else if (month === "05") {
+ monthStr = "May";
+ dayLimit = 31;
+ } else if (month === "06") {
+ monthStr = "June";
+ dayLimit = 30;
+ } else if (month === "07") {
+ monthStr = "July";
+ dayLimit = 31;
+ } else if (month === "08") {
+ monthStr = "August";
+ dayLimit = 31;
+ } else if (month === "09") {
+ monthStr = "September";
+ dayLimit = 30;
+ } else if (month === "10") {
+ monthStr = "October";
+ dayLimit = 31;
+ } else if (month === "11") {
+ monthStr = "November";
+ dayLimit = 30;
+ } else if (month === "12") {
+ monthStr = "December";
+ dayLimit = 31;
+ }
+ calendarHeader.innerHTML = "Calendar: " + monthStr + " " + yearStr;
+ const canvas = document.getElementById('myCanvas');
+ // Get our 2D drawing context
+ const ctx = canvas.getContext('2d');
+ const draw = function () {
+ ctx.fillStyle = '#212529';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.fillStyle = '#ffffff';
+ // Draw the lines on the calendar
+ for (let i = 100; i < 700; i+=100) {
+ ctx.fillRect(i, 0, 1, canvas.height);
+ ctx.fillRect(0, i, canvas.width, 1);
+ }
+ ctx.font = "30px Times New Roman";
+ // Fill the top row with day names
+ ctx.fillText("Sun", 25, 75);
+ ctx.fillText("Mon", 125, 75);
+ ctx.fillText("Tue", 225, 75);
+ ctx.fillText("Wed", 325, 75);
+ ctx.fillText("Thu", 425, 75);
+ ctx.fillText("Fri", 525, 75);
+ ctx.fillText("Sat", 625, 75);
+
+ // Now start filling in the days of the month
+ let date = new Date(dateInput.value + "T00:00:00");
+ // Get the weekday of the first day of the month
+ let firstDay = date.getDate();
+ let weekday = date.getDay();
+ while (firstDay % 7 != 1) {
+ firstDay--;
+ weekday--;
+ if (weekday === -1) {
+ weekday = 6;
+ }
+ }
+ // weekday now corresponds to the day in the week for the first day of the month
+ let currentHeight = 175;
+ let currentX = 25 + (100 * weekday); // Set the x position based on the starting weekday
+ for (let i = 1; i < dayLimit+1; i++) {
+ if (i === date.getDate()) {
+ ctx.fillStyle = '#ff4000';
+ ctx.fillText(i, currentX, currentHeight);
+ ctx.fillStyle = '#ffffff';
+ } else {
+ ctx.fillText(i, currentX, currentHeight);
+ }
+ currentX += 100;
+ if (currentX > 625) {
+ currentX = 25;
+ currentHeight += 100;
+ }
+ }
+ }
+ draw();
+}
+
+// Hide the table of tasks
+const hide = function( e ) {
+ e.preventDefault();
+ document.getElementById("tablePrintM").innerHTML = '
';
+ isHiddenTasks = true;
+}
+
+// Get all meetings from the database for this date and this user
+const view = function(e) {
+ e.preventDefault();
+
+ const dateInput = document.querySelector( '#enteredDate' );
+ if (dateInput.value !== "") {
+ let meetingsArray;
+ const json = { date: dateInput.value, },
+ body = JSON.stringify( json );
+
+ fetch( '/viewMeetings', {
+ method:'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' },
+ body: body
+ })
+ .then( function( response ) {
+
+ // Fetch all tasks for this meeting in the database to add to a table
+ console.log( response );
+ response.json().then((data) => {
+ meetingsArray = data.meetingsArray;
+ let numTasks = meetingsArray.length;
+ let myTable = '
Meeting Name:
';
+ myTable += "
Meeting Date:
";
+ myTable += "
Meeting Creator:
";
+ myTable += "
Meeting Details:
";
+ for (let i = 0; i < numTasks; i++) { // Make the table with one row per task
+ myTable += "
" + meetingsArray[i].name + "
";
+ myTable += "
" + meetingsArray[i].date + "
";
+ myTable += "
" + meetingsArray[i].username + "
";
+ myTable += "
" + meetingsArray[i].details + "
";
+ }
+ myTable += "
";
+ document.getElementById("tablePrint").innerHTML = myTable;
+ isHidden = false;
+ drawCal();
+ });
+ });
+ return false;
+ } else {
+ alert("Enter a full date to see meetings on that date that you have made");
+ }
+}
+
+const viewTasks = function(e) {
+ e.preventDefault();
+ let tasksArray;
+
+ const nameInput = document.querySelector( '#meetingname' ),
+ json = { meeting: nameInput.value, },
+ body = JSON.stringify( json );
+
+ fetch( '/viewTasks', {
+ method:'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' },
+ body: body
+ })
+ .then( function( response ) {
+
+ // Fetch all tasks for this meeting in the database to add to a table
+ console.log( response );
+ response.json().then((data) => {
+ console.log( data );
+ if (data.tasksArray) {
+ tasksArray = data.tasksArray;
+ let numTasks = tasksArray.length;
+ let myTable = '
' + nameInput.value + '
Task Name:
';
+ myTable += "
Assigned to:
";
+ myTable += "
Date:
";
+ myTable += "
Details:
";
+ for (let i = 0; i < numTasks; i++) { // Make the table with one row per task
+ myTable += "
" + tasksArray[i].taskName + "
";
+ myTable += "
" + tasksArray[i].assigneeName + "
";
+ myTable += "
" + tasksArray[i].date + "
";
+ myTable += "
" + tasksArray[i].details + "
";
+ }
+ myTable += "
";
+ document.getElementById("tablePrintM").innerHTML = myTable;
+ isHidden = false;
+ } else {
+ alert("You have not made a meeting with the name that you entered.")
+ }
+ });
+ });
+ return false;
+}
+
+window.onload = function() { // Link each button to its respective function
+ const viButton = document.querySelector( '#viewButton' ),
+ viTaButton = document.querySelector(' #viewButtonM '),
+ hiButton = document.querySelector( '#hideButtonM' );
+ viButton.onclick = view;
+ hiButton.onclick = hide;
+ viTaButton.onclick = viewTasks;
+ let today = new Date();
+ let day = String(today.getDate()).padStart(2, '0');
+ let month = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
+ let year = today.getFullYear();
+ today = year + '-' + month + '-' + day;
+ drawCal(today);
+}
diff --git a/public/js/meetingScripts.js b/public/js/meetingScripts.js
new file mode 100644
index 00000000..f5de7c74
--- /dev/null
+++ b/public/js/meetingScripts.js
@@ -0,0 +1,130 @@
+// Code specifically for viewing and managing a task list for each meeting
+
+let isHidden = true;
+
+// Each task has one meeting and one assigned user that it relates to, although names can be shared
+// Each meeting has a unique ID, and is findable as a unique combination for the meeting maker's username and the MeetingName
+
+const submitTask = function( e ) { // Submit request for a new task for a user
+ // prevent default form action from being carried out
+ e.preventDefault()
+
+ const nameInput = document.querySelector( '#meetingname' ),
+ userInput = document.querySelector( '#assigneename' ),
+ taskInput = document.querySelector( '#taskname' ),
+ detailsInput = document.querySelector( '#details' ),
+ json = { meeting: nameInput.value, task: taskInput.value, name: userInput.value, details: detailsInput.value },
+ body = JSON.stringify( json );
+
+ fetch( '/submitTask', { //Note that on the server side, this will also give the assigned user a new message about their task
+ method:'POST',
+ body: JSON.stringify( json ),
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include'
+ })
+ .then( function( response ) {
+ // Update the task list for the user
+ console.log( response );
+ response.json().then((data) => {
+ document.getElementById("tablePrint").innerHTML = '
';
+ if (!isHidden) {
+ viewMeetingTasks(e);
+ }
+ if (data.taskAdded === false) {
+ alert("Cannot add task: Meeting not found")
+ }
+ });
+ });
+ return false;
+}
+
+const viewMeetingTasks = function(e) {
+ e.preventDefault();
+ let tasksArray;
+
+ const nameInput = document.querySelector( '#meetingname' ),
+ json = { meeting: nameInput.value, },
+ body = JSON.stringify( json );
+
+ fetch( '/viewTasks', {
+ method:'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' },
+ body: body
+ })
+ .then( function( response ) {
+
+ // Fetch all tasks for this meeting in the database to add to a table
+ console.log( response );
+ response.json().then((data) => {
+ console.log(data);
+ if (data.tasksArray) {
+ tasksArray = data.tasksArray;
+ let numTasks = tasksArray.length;
+ let myTable = '
' + nameInput.value + '
Task Name:
';
+ myTable += "
Assigned to:
";
+ myTable += "
Date:
";
+ myTable += "
Details:
";
+ for (let i = 0; i < numTasks; i++) { // Make the table with one row per task
+ myTable += "
" + tasksArray[i].taskName + "
";
+ myTable += "
" + tasksArray[i].assigneeName + "
";
+ myTable += "
" + tasksArray[i].date + "
";
+ myTable += "
" + tasksArray[i].details + "
";
+ }
+ myTable += "
";
+ document.getElementById("tablePrint").innerHTML = myTable;
+ isHidden = false;
+ } else {
+ alert("You have not made a meeting with the name that you entered.")
+ }
+ });
+ });
+ return false;
+}
+
+const hide = function( e ) {
+ e.preventDefault();
+ document.getElementById("tablePrint").innerHTML = '
';
+ isHidden = true;
+}
+
+const deleteTask = function( e ) { // Delete a task with a specified id number
+ // prevent default form action from being carried out
+ e.preventDefault();
+
+ const userInput = document.querySelector( '#assigneename' ),
+ taskInput = document.querySelector( '#taskname' ),
+ nameInput = document.querySelector( '#meetingname' ),
+ json = { name: userInput.value, meeting: nameInput.value, task: taskInput.value, };
+
+ fetch( '/removeTask', {
+ method:'DELETE',
+ body: JSON.stringify( json ),
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include'
+ })
+ .then( function( response ) {
+ // Simply redisplay the table on the response after the deletion occurs
+ // if it is not hidden
+ console.log( response );
+ response.json().then((data) => {
+ console.log(data);
+ document.getElementById("tablePrint").innerHTML = '
';
+ if (!isHidden) {
+ viewMeetingTasks(e);
+ }
+ });
+ });
+ return false;
+}
+
+window.onload = function() { // Link each button to its respective function
+ const inButton = document.querySelector( '#inputButton' );
+ const viButton = document.querySelector( '#viewButton' );
+ const deButton = document.querySelector( '#removeButton' );
+ const hiButton = document.querySelector( '#hideButton' );
+ hiButton.onclick = hide;
+ viButton.onclick = viewMeetingTasks;
+ inButton.onclick = submitTask;
+ deButton.onclick = deleteTask;
+}
diff --git a/public/js/messageScripts.js b/public/js/messageScripts.js
new file mode 100644
index 00000000..9a3f2dcd
--- /dev/null
+++ b/public/js/messageScripts.js
@@ -0,0 +1,132 @@
+// Code specifically for messages and tasks that the user has received
+
+// Note that we don't allow for users to send messages themselves, but messages will be automatically
+// generated for them whenever they are assigned a task in another meeting
+let isHidden = true;
+let isHiddenTasks = true;
+
+const submit = function( e ) { // Submit request for a new or updated student's grades
+ // prevent default form action from being carried out
+ e.preventDefault()
+
+ const nameInput = document.querySelector( '#yourname' ),
+ gradeInput = document.querySelector( '#yourgrade' ),
+ json = { yourname: nameInput.value, yourgrade: gradeInput.value },
+ body = JSON.stringify( json );
+
+ fetch( '/submit', {
+ method:'POST',
+ body: JSON.stringify( json ),
+ headers: { 'Content-Type': 'application/json' },
+ credentials: 'include'
+ })
+ .then( function( response ) {
+ // Inform the user of what the letter grade of the student is, and
+ // refresh the table view with the new student in it
+ console.log( response );
+ response.json().then((data) => {
+ document.getElementById("tablePrint").innerHTML = '
';
+ if (!isHidden) {
+ view(e);
+ }
+ alert("The grade of this student is : "
+ + data.numericGrade + " (" + data.letterGrade + ")");
+ });
+ });
+ return false;
+}
+
+// Get all messages from the db for this user
+const view = function(e) {
+ e.preventDefault();
+
+ fetch( '/viewMessages', {
+ method:'POST',
+ credentials: 'include',
+ headers: { 'Content-Type': 'application/json' }
+ })
+ .then( function( response ) {
+
+ // Fetch all students in the database to add to a table
+ console.log( response );
+ response.json().then((data) => {
+ console.log(data);
+ let messagesArray = data.messagesArray;
+ let num = messagesArray.length;
+ let myTable = '
From:
';
+ myTable += "
Contents:
";
+ for (let i = 0; i < num; i++) { // Make the table with one row per student
+ myTable += "
+ Welcome to your Home Screen. Browser diferent views through the Navigation Bar on top, or look at meetings and tasks you have scheduled down below.
+
+
+
+
+
+
+
Meeting Information
+
+
+ Show all meetings on the date entered.
+
+
+
+
+
+ You can only view, assign or unassign tasks to meetings that you have created. You can't view or assign tasks to meetings that you did not create.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Add and remove tasks for your meeting with the entered name. Note that to remove a task,
+ you must specify the user for which the task has been assigned, since multiple users can
+ be assigned tasks with the same name.
+
+