From c0d9f89c4fd078131a12c7ab3836db28f45a5629 Mon Sep 17 00:00:00 2001 From: rishi2019194 <58341663+rishi2019194@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:25:35 -0400 Subject: [PATCH 1/4] Added error message when feedback requested without selecting any movie --- src/recommenderapp/static/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/recommenderapp/static/script.js b/src/recommenderapp/static/script.js index c20e5c9d4..9c24a404f 100644 --- a/src/recommenderapp/static/script.js +++ b/src/recommenderapp/static/script.js @@ -116,6 +116,12 @@ $(document).ready(function () { 2: "Yet to watch", 3: "Like", }; + + // to check if any movies selected before giving feedback + if(myForm.length == 0){ + alert("No movies found. Please add movies to provide feedback."); + return; + } var error = false; // Flag to track errors for (var i = 0; i < myForm.length; i++) { From a4eae4fda07ab4cc3681a4ff2d4b1895e8008c77 Mon Sep 17 00:00:00 2001 From: rishi2019194 <58341663+rishi2019194@users.noreply.github.com> Date: Sun, 15 Oct 2023 19:55:54 -0400 Subject: [PATCH 2/4] Resolved error for sending multiple email notifications and added email sent success msg --- src/recommenderapp/static/script.js | 21 +++++++++++++++++++-- src/recommenderapp/templates/success.html | 9 +++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/recommenderapp/static/script.js b/src/recommenderapp/static/script.js index 9c24a404f..b410dc5b2 100644 --- a/src/recommenderapp/static/script.js +++ b/src/recommenderapp/static/script.js @@ -170,9 +170,19 @@ $(document).ready(function () { }); $("#notifyButton").click(function () { - data = JSON.parse(localStorage.getItem("fbData")); + var data = JSON.parse(localStorage.getItem("fbData")); + + if (!data) { + alert("No feedback data found. Please provide feedback."); + return; + } + var emailString = $("#emailField").val(); data.email = emailString; + + // Remove the "emailSent" flag to allow sending the email again + localStorage.removeItem("emailSent"); + $.ajax({ type: "POST", url: "/sendMail", @@ -182,7 +192,13 @@ $(document).ready(function () { cache: false, data: JSON.stringify(data), success: function (response) { - localStorage.removeItem("fbData"); + // localStorage.removeItem("fbData"); + $("#emailSentSuccess").show(); + // Hide the success message after 5 seconds (5000 milliseconds) + setTimeout(function () { + $("#emailSentSuccess").fadeOut("slow"); + }, 2000); + console.log("Email sent successfully!") console.log(response); }, error: function (error) { @@ -191,4 +207,5 @@ $(document).ready(function () { }, }); }); + }); diff --git a/src/recommenderapp/templates/success.html b/src/recommenderapp/templates/success.html index 94c48ad91..9993a69d6 100644 --- a/src/recommenderapp/templates/success.html +++ b/src/recommenderapp/templates/success.html @@ -65,6 +65,15 @@