diff --git a/content/assets/scripts/message.js b/content/assets/scripts/message.js
index 280bc25d..950621b2 100644
--- a/content/assets/scripts/message.js
+++ b/content/assets/scripts/message.js
@@ -5,28 +5,51 @@ const formButton = form.find('button[type="submit"]');
const responseError = $("#cammieFormResponseError");
const responseSuccess = $("#cammieFormResponseSuccess");
-$("#cammieForm").submit((e) => {
- e.preventDefault();
- formButton.addClass("is-loading");
- return $.ajax({
- url: "https://kelder.zeus.ugent.be/messages/",
- contentType: "text/plain",
- type: "POST",
- headers: formName.val() ? { "X-Username": formName.val()} : {},
- data: formMessage.val(),
- success() {
+const socket = io("https://kelder.zeus.ugent.be");
+
+socket.on('replymessage', function(obj) {
+ alert("Kelder says: " + obj['message']);
+})
+
+socket.on('status',function(data){
+ console.log("reply")
+ if (data.ok){
responseError.addClass("is-hidden");
responseSuccess.removeClass("is-hidden");
responseSuccess.text("Message has been successfully sent.");
formMessage.val("");
- },
- error() {
+ } else {
responseSuccess.addClass("is-hidden");
responseError.removeClass("is-hidden");
responseError.text("Something went wrong, please try again later.");
- },
- complete() {
- formButton.removeClass("is-loading");
- },
- });
+ }
+ formButton.removeClass("is-loading");
+ /* return data.message; */
+})
+
+$("#cammieForm").submit((e) => {
+ e.preventDefault();
+ formButton.addClass("is-loading");
+ socket.emit("message",{username: formName.val(), message: formMessage.val()})
+ /* return $.ajax({ */
+ /* url: "https://kelder.zeus.ugent.be/messages/", */
+ /* contentType: "text/plain", */
+ /* type: "POST", */
+ /* headers: formName.val() ? { "X-Username": formName.val()} : {}, */
+ /* data: formMessage.val(), */
+ /* success() { */
+ /* responseError.addClass("is-hidden"); */
+ /* responseSuccess.removeClass("is-hidden"); */
+ /* responseSuccess.text("Message has been successfully sent."); */
+ /* formMessage.val(""); */
+ /* }, */
+ /* error() { */
+ /* responseSuccess.addClass("is-hidden"); */
+ /* responseError.removeClass("is-hidden"); */
+ /* responseError.text("Something went wrong, please try again later."); */
+ /* }, */
+ /* complete() { */
+ /* formButton.removeClass("is-loading"); */
+ /* }, */
+ /* }); */
});
diff --git a/content/cammie.erb b/content/cammie.erb
index b75898a5..4610ab99 100644
--- a/content/cammie.erb
+++ b/content/cammie.erb
@@ -6,10 +6,6 @@ title: Cammie
<%= asset :js, :cammie %>
<%= asset :js, :message %>