diff --git a/assets/css/style.css b/assets/css/style.css index ae7210d..6f56898 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -651,6 +651,17 @@ main { color: #DDDDDD; } +button.btn-selectable.selected { + color: #000 !important; + background-color: lightgreen !important; +} + +#feedback-modal { + width: fit-content; + min-width: 300px; + height: fit-content; +} + /* Media Queries */ @media(max-width: 800px) { .container{ @@ -678,4 +689,4 @@ main { .welcome-msg { font-size: 14px; } -} \ No newline at end of file +} diff --git a/assets/js/main.js b/assets/js/main.js index a3d3546..6c680d4 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -41,6 +41,7 @@ $(document).ready(function(){ $(".tabs").tabs(); $(".collapsible").collapsible(); $(".tooltipped").tooltip(); + $(".modal").modal(); fetchRepos(); fetchTeam(); @@ -405,6 +406,46 @@ class TypeWriter { } } +function showToast(htmlData, classData = "blue white-text", icon = "info") { + let toastIcon = getMaterialIcon(icon, "left", false); + return M.toast({html: toastIcon + htmlData, classes: classData}); +} + +$("button.btn-selectable").click(function() { + $(this).toggleClass("selected").siblings().removeClass("selected"); +}); + +$("#feedback-form").on("submit", function(e) { + e.preventDefault(); + + let form = $(this); + let submitBtn = form.find("button[type='submit']"); + let modal = $("#feedback-modal"); + let formdata = new FormData(this); + let quickFeedback = $("#feedback-form button.btn-selectable.selected").attr("data-value"); + quickFeedback = (typeof quickFeedback == "undefined") ? "none" : quickFeedback; + formdata.append("quick-feedback", quickFeedback); + + $.ajax({ + url: "url-to-submit-feedback", + data: formdata, + method: "POST", + timeout: 15000, + contentType: false, + processData: false, + beforeSend: function() { + submitBtn.html("Submitting...").attr("disabled", true); + } + }).done(function() { + showToast("Feedback Submitted!", "green", "done"); + }).fail(function() { + showToast("Failed to submit feedback!", "red", "error"); + }).always(function() { + modal.modal("close"); + submitBtn.html("Submit").attr("disabled", false); + }); +}); + function init() { const textElement = document.querySelector(".txt-type"); const words = JSON.parse(textElement.getAttribute("data-words")); diff --git a/index.html b/index.html index 47234d2..dd2b818 100644 --- a/index.html +++ b/index.html @@ -139,6 +139,36 @@

Members

+ +