Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfn19 committed May 27, 2024
1 parent 90cb20c commit 62514c5
Showing 1 changed file with 34 additions and 65 deletions.
99 changes: 34 additions & 65 deletions annonym-feedbackts/src/os.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,4 @@
// to get os will use json or map

// const os = window.navigator.userAgent

// const url = window.location.href

// let osmap = new Map();
// let osarray = [os];
// let urlarray = [url];

// if statement to prevent spaming of the same button

// async function preventspamf() {
// const response = await fetch("/feedbackrawjson");
// const data = await response.json();
// console.log(data);

// let tfeedback = data[0].afeedbackm;
// console.log(tfeedback);

// let feedbackdata;

// for (let i = 0; i < data.length; i++) {
// feedbackdata = data[i].afeedbackm;
// console.log(feedbackdata);
// }

// const body = {
// jsonform: osarray,
// feedback: document.querySelector("#feedbackid").value,
// currenturl: urlarray,
// }

// if (body.feedback == feedbackdata) {
// console.log("can't submit, data already exists");
// } else {
// function sendjson() {

// fetch("/sendmap", {
// method: "POST",
// headers: {
// "Content-Type": "application/json"
// },
// body: JSON.stringify(body)
// })
// }

// document.querySelector("#submitbtn").addEventListener("click", sendjson);
// }
// }

// document.querySelector("#submitbtn").addEventListener("click", preventspamf);
// to get os, url & feedback will use json or map

const os = window.navigator.userAgent

Expand All @@ -59,20 +8,40 @@ let osmap = new Map();
let osarray = [os];
let urlarray = [url];

function sendjson() {
const body = {
jsonform: osarray,
feedback: document.querySelector("#feedbackid").value,
currenturl: urlarray,
let buttonstate = 0;

if (buttonstate == 1) {
const myTimeout = setTimeout(timeoutoverf, 40000);
console.log("can't submit, timeout is: " + myTimeout);
} else if (buttonstate == 0) {
document.getElementById('submitbtn').onclick = function() {
console.log("button was clicked");
buttonstate =+ 1;
console.log(buttonstate);
}

fetch("/sendmap", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body)
})
function sendjson() {
const body = {
jsonform: osarray,
feedback: document.querySelector("#feedbackid").value,
currenturl: urlarray,
}

fetch("/sendmap", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body)
})

cooldown = 1000;
}

document.querySelector("#submitbtn").addEventListener("click", sendjson);
}

document.querySelector("#submitbtn").addEventListener("click", sendjson);
function timeoutoverf() {
console.log("timeout over");
buttonstate =- 1;
}

0 comments on commit 62514c5

Please sign in to comment.