Spaces:
Running
Running
File size: 1,993 Bytes
a744c1a bb44a9e a744c1a bb44a9e a744c1a bb44a9e a744c1a bb44a9e a744c1a bb44a9e a744c1a bb44a9e a744c1a 5c9215b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
document.addEventListener("DOMContentLoaded", function () {
function toggleElements() {
let taskDropdown = document.querySelector("select[name='tasks']");
let numberInput = document.getElementById("number");
let numberLabel = document.getElementById("number_label");
let questionInput = document.getElementById("question");
let questionLabel = document.getElementById("question_label");
let submitButton = document.getElementById("submit_btn");
numberInput.style.display = "none";
numberLabel.style.display = "none";
questionInput.style.display = "none";
questionLabel.style.display = "none";
submitButton.disabled = true;
if (taskDropdown.value === "summarization") {
numberLabel.textContent = "Enter minimum length: ";
numberInput.style.display = "inline";
numberLabel.style.display = "inline";
submitButton.disabled = false;
} else if (taskDropdown.value === "keywords") {
numberLabel.textContent = "Count: ";
numberInput.style.display = "inline";
numberLabel.style.display = "inline";
submitButton.disabled = false;
} else if (taskDropdown.value === "Q&A") {
questionInput.style.display = "inline";
questionLabel.style.display = "inline";
submitButton.disabled = false;
}
}
function updateCount() {
let textArea = document.getElementById("user_text");
let countDisplay = document.getElementById("charCount");
if (textArea) {
let remaining = 5000 - textArea.value.length;
countDisplay.textContent = `${remaining} characters remaining`;
}
}
document.querySelector("select[name='tasks']").addEventListener("change", toggleElements);
document.getElementById("user_text").addEventListener("input", updateCount);
toggleElements();
updateCount();
}); |