Place a button to check fairness

This commit is contained in:
Lexi / Zoe 2018-10-16 23:48:40 +02:00
parent bc810fb9d0
commit afac80c54a
1 changed files with 21 additions and 3 deletions

View File

@ -2,6 +2,12 @@
// Content script to be run on pages
// ---------------------------------
function checkTextarea(textarea) {
console.log("click " + textarea.id + " -> " + textarea.value);
// TODO make queries to the fairlanguage server
}
(function() {
// Only run this script once
if (window.hasRun) {
@ -11,9 +17,21 @@
// Search for all text areas
document.querySelectorAll("textarea").forEach(function(textarea) {
// Do something with it...
console.log(textarea);
// for testing: highlight textarea with red border
// TODO
textarea.style.border = "2px solid red";
});
// Create a "Check fairness" button which is placed next to the textarea
// TODO image button integrated into the textarea...
var buttonCheck = document.createElement("button");
buttonCheck.textContent = "Check fairness!";
// Add click event listener
buttonCheck.addEventListener("click", (e) => {
checkTextarea(textarea);
});
// Append button to the textarea
textarea.after(buttonCheck);
});
})();