Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +107 -92
templates/index.html
CHANGED
|
@@ -17,10 +17,8 @@
|
|
| 17 |
--background-card: #ffffff;
|
| 18 |
--border-color: #e0e0e0;
|
| 19 |
--highlight-color: #fffde7;
|
| 20 |
-
/* ##### INÍCIO DA MUDANÇA DE ESTILO ##### */
|
| 21 |
/* Cor única para todas as sugestões da IA */
|
| 22 |
--ai-suggestion-color: #8e44ad;
|
| 23 |
-
/* ##### FIM DA MUDANÇA DE ESTILO ##### */
|
| 24 |
}
|
| 25 |
body {
|
| 26 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
@@ -57,18 +55,25 @@
|
|
| 57 |
margin-bottom: 30px;
|
| 58 |
}
|
| 59 |
.search-box { display: flex; gap: 10px; }
|
| 60 |
-
input[type="text"] {
|
| 61 |
flex: 1;
|
| 62 |
padding: 12px 15px;
|
| 63 |
border: 1px solid var(--border-color);
|
| 64 |
border-radius: 4px;
|
| 65 |
font-size: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
}
|
| 67 |
-
input[type="text"]:focus {
|
| 68 |
border-color: var(--accent-green);
|
| 69 |
box-shadow: 0 0 0 2px rgba(90, 130, 79, 0.2);
|
| 70 |
outline: none;
|
| 71 |
}
|
|
|
|
| 72 |
button {
|
| 73 |
background-color: var(--accent-green);
|
| 74 |
color: white;
|
|
@@ -259,14 +264,14 @@
|
|
| 259 |
position: relative;
|
| 260 |
}
|
| 261 |
#manual-feedback-area h3 { color: var(--primary-green); margin-top: 0; margin-bottom: 15px; font-size: 1.2rem; }
|
| 262 |
-
|
| 263 |
-
.manual-feedback-box
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
|
| 271 |
/* Estilos da IA */
|
| 272 |
.ai-suggestion-container { background-color: var(--light-green-bg); border: 1px solid var(--accent-green); border-radius: 8px; padding: 20px; margin-top: 20px; margin-bottom: 20px; text-align: center; display: none; }
|
|
@@ -274,20 +279,16 @@
|
|
| 274 |
#ai-suggestion-button:hover:not(:disabled) { background-color: #71368a; }
|
| 275 |
#ai-suggestion-status { margin-top: 15px; font-size: 0.9em; color: var(--text-light); font-weight: 500; }
|
| 276 |
|
| 277 |
-
/* ##### INÍCIO DA MUDANÇA DE ESTILO ##### */
|
| 278 |
-
/* Destaque para todos os rankings da IA */
|
| 279 |
.result-item[class*="ai-highlight-"] {
|
| 280 |
border-left-color: var(--ai-suggestion-color) !important;
|
| 281 |
box-shadow: 0 0 15px rgba(142, 68, 173, 0.2);
|
| 282 |
overflow: visible; /* Garante que a tag não seja cortada */
|
| 283 |
}
|
| 284 |
|
| 285 |
-
/* Adiciona padding no topo do header para dar espaço para a tag */
|
| 286 |
.result-item[class*="ai-highlight-"] .result-header {
|
| 287 |
padding-top: 2.5em;
|
| 288 |
}
|
| 289 |
|
| 290 |
-
/* Tag ::before para todos os rankings */
|
| 291 |
.result-item[class*="ai-highlight-"]::before {
|
| 292 |
position: absolute; top: 0; right: 0; color: white;
|
| 293 |
padding: 5px 15px; font-size: 0.8em; font-weight: bold;
|
|
@@ -295,11 +296,9 @@
|
|
| 295 |
background-color: var(--ai-suggestion-color); /* Cor única */
|
| 296 |
}
|
| 297 |
|
| 298 |
-
/* Texto específico para cada ranking */
|
| 299 |
.ai-highlight-1::before { content: "1ª Sugestão da IA"; }
|
| 300 |
.ai-highlight-2::before { content: "2ª Sugestão da IA"; }
|
| 301 |
.ai-highlight-3::before { content: "3ª Sugestão da IA"; }
|
| 302 |
-
/* ##### FIM DA MUDANÇA DE ESTILO ##### */
|
| 303 |
</style>
|
| 304 |
</head>
|
| 305 |
<body>
|
|
@@ -326,15 +325,17 @@
|
|
| 326 |
|
| 327 |
<div id="results-container"></div>
|
| 328 |
|
|
|
|
| 329 |
<div id="manual-feedback-area">
|
| 330 |
-
<h3>Se não
|
| 331 |
<div class="manual-feedback-box">
|
| 332 |
-
<input type="text" id="
|
| 333 |
-
<
|
| 334 |
-
<
|
| 335 |
</div>
|
| 336 |
<div id="manual-feedback-status" style="margin-top: 10px; font-size: 0.9em; font-weight: bold;"></div>
|
| 337 |
</div>
|
|
|
|
| 338 |
|
| 339 |
<div id="log-container"></div>
|
| 340 |
</div>
|
|
@@ -343,6 +344,7 @@
|
|
| 343 |
<div class="footer"><p>Ferramenta de busca abrangente para o Rol de Procedimentos com reordenação semântica de resultados e sugestão de IA- Versão Beta, não oficial.</p></div>
|
| 344 |
|
| 345 |
<script>
|
|
|
|
| 346 |
const searchInput = document.getElementById('search-input');
|
| 347 |
const searchButton = document.getElementById('search-button');
|
| 348 |
const loader = document.getElementById('loader');
|
|
@@ -352,27 +354,32 @@
|
|
| 352 |
const correctionInfoDiv = document.getElementById('correction-info');
|
| 353 |
const logContainer = document.getElementById('log-container');
|
| 354 |
const manualFeedbackArea = document.getElementById('manual-feedback-area');
|
| 355 |
-
const
|
| 356 |
-
const
|
|
|
|
| 357 |
const manualFeedbackStatus = document.getElementById('manual-feedback-status');
|
| 358 |
-
const tussSuggestionsList = document.getElementById('tuss-suggestions');
|
| 359 |
const aiSuggestionContainer = document.getElementById('ai-suggestion-container');
|
| 360 |
const aiSuggestionButton = document.getElementById('ai-suggestion-button');
|
| 361 |
const aiSuggestionStatus = document.getElementById('ai-suggestion-status');
|
| 362 |
|
| 363 |
let lastSearchQuery = '';
|
| 364 |
let feedbackAlreadySentForCurrentSearch = false;
|
| 365 |
-
let debounceTimeout;
|
| 366 |
-
let currentRawTussInput = '';
|
| 367 |
let currentResultsForAI = [];
|
| 368 |
|
| 369 |
function resetState() {
|
| 370 |
feedbackAlreadySentForCurrentSearch = false;
|
| 371 |
-
document.querySelectorAll('.feedback-button').forEach(b => {
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
manualFeedbackStatus.textContent = '';
|
| 377 |
|
| 378 |
aiSuggestionContainer.style.display = 'none';
|
|
@@ -392,11 +399,13 @@
|
|
| 392 |
}
|
| 393 |
|
| 394 |
function disableAllFeedbackButtons() {
|
| 395 |
-
document.querySelectorAll('.feedback-button').forEach(b => {
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
|
|
|
| 399 |
}
|
|
|
|
| 400 |
|
| 401 |
async function performSearch() {
|
| 402 |
const query = searchInput.value.trim();
|
|
@@ -550,40 +559,48 @@
|
|
| 550 |
}
|
| 551 |
itemDiv.appendChild(bodyDiv);
|
| 552 |
|
|
|
|
| 553 |
const feedbackButton = document.createElement('button');
|
| 554 |
feedbackButton.className = 'feedback-button';
|
| 555 |
-
feedbackButton.textContent = '
|
| 556 |
-
feedbackButton.onclick = () => submitFeedback(originalQuery, result.Codigo_TUSS, feedbackButton
|
| 557 |
itemDiv.appendChild(feedbackButton);
|
|
|
|
| 558 |
|
| 559 |
return itemDiv;
|
| 560 |
}
|
| 561 |
|
| 562 |
-
|
| 563 |
-
|
| 564 |
if (feedbackAlreadySentForCurrentSearch) return;
|
| 565 |
-
if (!confirm(
|
| 566 |
|
| 567 |
-
|
| 568 |
-
if(statusDiv) statusDiv.textContent = 'Enviando...';
|
| 569 |
|
| 570 |
try {
|
| 571 |
const response = await fetch('/submit_feedback', {
|
| 572 |
method: 'POST',
|
| 573 |
headers: { 'Content-Type': 'application/json' },
|
| 574 |
-
body: JSON.stringify({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
});
|
| 576 |
-
if (!response.ok) throw new Error('Falha no envio
|
| 577 |
|
| 578 |
feedbackAlreadySentForCurrentSearch = true;
|
| 579 |
-
|
| 580 |
-
|
| 581 |
disableAllFeedbackButtons();
|
| 582 |
} catch (error) {
|
| 583 |
-
|
| 584 |
-
|
|
|
|
| 585 |
}
|
| 586 |
}
|
|
|
|
| 587 |
|
| 588 |
async function getAiSuggestions() {
|
| 589 |
if (!lastSearchQuery || currentResultsForAI.length === 0) return;
|
|
@@ -642,56 +659,54 @@
|
|
| 642 |
searchInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') performSearch(); });
|
| 643 |
aiSuggestionButton.addEventListener('click', getAiSuggestions);
|
| 644 |
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
} else {
|
| 656 |
-
tussSuggestionsList.innerHTML = '';
|
| 657 |
-
tussSuggestionsList.style.display = 'none';
|
| 658 |
}
|
| 659 |
-
});
|
| 660 |
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
}
|
| 665 |
-
});
|
| 666 |
|
| 667 |
-
async function fetchTussSuggestions(tussPrefix) {
|
| 668 |
try {
|
| 669 |
-
const response = await fetch(
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
} catch (error) {
|
| 674 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 675 |
}
|
| 676 |
-
}
|
| 677 |
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
if (suggestions.length > 0) {
|
| 681 |
-
suggestions.forEach(item => {
|
| 682 |
-
const li = document.createElement('li');
|
| 683 |
-
li.innerHTML = `<span class="suggestion-code">${item.tuss_code}</span> <span class="suggestion-desc">${item.tuss_description}</span> <span class="suggestion-rol">${item.rol_name}</span>`;
|
| 684 |
-
li.addEventListener('click', () => {
|
| 685 |
-
manualTussInput.value = item.tuss_code;
|
| 686 |
-
tussSuggestionsList.style.display = 'none';
|
| 687 |
-
});
|
| 688 |
-
tussSuggestionsList.appendChild(li);
|
| 689 |
-
});
|
| 690 |
-
tussSuggestionsList.style.display = 'block';
|
| 691 |
-
} else {
|
| 692 |
-
tussSuggestionsList.style.display = 'none';
|
| 693 |
-
}
|
| 694 |
-
}
|
| 695 |
|
| 696 |
searchInput.focus();
|
| 697 |
</script>
|
|
|
|
| 17 |
--background-card: #ffffff;
|
| 18 |
--border-color: #e0e0e0;
|
| 19 |
--highlight-color: #fffde7;
|
|
|
|
| 20 |
/* Cor única para todas as sugestões da IA */
|
| 21 |
--ai-suggestion-color: #8e44ad;
|
|
|
|
| 22 |
}
|
| 23 |
body {
|
| 24 |
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
|
|
| 55 |
margin-bottom: 30px;
|
| 56 |
}
|
| 57 |
.search-box { display: flex; gap: 10px; }
|
| 58 |
+
input[type="text"], textarea {
|
| 59 |
flex: 1;
|
| 60 |
padding: 12px 15px;
|
| 61 |
border: 1px solid var(--border-color);
|
| 62 |
border-radius: 4px;
|
| 63 |
font-size: 16px;
|
| 64 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 65 |
+
}
|
| 66 |
+
/* ##### INÍCIO DA MUDANÇA DE ESTILO ##### */
|
| 67 |
+
textarea {
|
| 68 |
+
resize: vertical;
|
| 69 |
+
min-height: 60px;
|
| 70 |
}
|
| 71 |
+
input[type="text"]:focus, textarea:focus {
|
| 72 |
border-color: var(--accent-green);
|
| 73 |
box-shadow: 0 0 0 2px rgba(90, 130, 79, 0.2);
|
| 74 |
outline: none;
|
| 75 |
}
|
| 76 |
+
/* ##### FIM DA MUDANÇA DE ESTILO ##### */
|
| 77 |
button {
|
| 78 |
background-color: var(--accent-green);
|
| 79 |
color: white;
|
|
|
|
| 264 |
position: relative;
|
| 265 |
}
|
| 266 |
#manual-feedback-area h3 { color: var(--primary-green); margin-top: 0; margin-bottom: 15px; font-size: 1.2rem; }
|
| 267 |
+
/* ##### INÍCIO DA MUDANÇA DE ESTILO ##### */
|
| 268 |
+
.manual-feedback-box {
|
| 269 |
+
display: flex;
|
| 270 |
+
flex-direction: column;
|
| 271 |
+
align-items: stretch;
|
| 272 |
+
gap: 10px;
|
| 273 |
+
}
|
| 274 |
+
/* ##### FIM DA MUDANÇA DE ESTILO ##### */
|
| 275 |
|
| 276 |
/* Estilos da IA */
|
| 277 |
.ai-suggestion-container { background-color: var(--light-green-bg); border: 1px solid var(--accent-green); border-radius: 8px; padding: 20px; margin-top: 20px; margin-bottom: 20px; text-align: center; display: none; }
|
|
|
|
| 279 |
#ai-suggestion-button:hover:not(:disabled) { background-color: #71368a; }
|
| 280 |
#ai-suggestion-status { margin-top: 15px; font-size: 0.9em; color: var(--text-light); font-weight: 500; }
|
| 281 |
|
|
|
|
|
|
|
| 282 |
.result-item[class*="ai-highlight-"] {
|
| 283 |
border-left-color: var(--ai-suggestion-color) !important;
|
| 284 |
box-shadow: 0 0 15px rgba(142, 68, 173, 0.2);
|
| 285 |
overflow: visible; /* Garante que a tag não seja cortada */
|
| 286 |
}
|
| 287 |
|
|
|
|
| 288 |
.result-item[class*="ai-highlight-"] .result-header {
|
| 289 |
padding-top: 2.5em;
|
| 290 |
}
|
| 291 |
|
|
|
|
| 292 |
.result-item[class*="ai-highlight-"]::before {
|
| 293 |
position: absolute; top: 0; right: 0; color: white;
|
| 294 |
padding: 5px 15px; font-size: 0.8em; font-weight: bold;
|
|
|
|
| 296 |
background-color: var(--ai-suggestion-color); /* Cor única */
|
| 297 |
}
|
| 298 |
|
|
|
|
| 299 |
.ai-highlight-1::before { content: "1ª Sugestão da IA"; }
|
| 300 |
.ai-highlight-2::before { content: "2ª Sugestão da IA"; }
|
| 301 |
.ai-highlight-3::before { content: "3ª Sugestão da IA"; }
|
|
|
|
| 302 |
</style>
|
| 303 |
</head>
|
| 304 |
<body>
|
|
|
|
| 325 |
|
| 326 |
<div id="results-container"></div>
|
| 327 |
|
| 328 |
+
<!-- ##### INÍCIO DA MUDANÇA DE HTML ##### -->
|
| 329 |
<div id="manual-feedback-area">
|
| 330 |
+
<h3>Se você não encontrou seu procedimento, digite o nome e uma breve explicação. Não utilize dados pessoais.</h3>
|
| 331 |
<div class="manual-feedback-box">
|
| 332 |
+
<input type="text" id="procedure-name-input" placeholder="Nome do procedimento">
|
| 333 |
+
<textarea id="procedure-explanation-input" rows="3" maxlength="150" placeholder="Breve explicação (máximo 150 caracteres)"></textarea>
|
| 334 |
+
<button id="submit-suggestion-button">Enviar Sugestão</button>
|
| 335 |
</div>
|
| 336 |
<div id="manual-feedback-status" style="margin-top: 10px; font-size: 0.9em; font-weight: bold;"></div>
|
| 337 |
</div>
|
| 338 |
+
<!-- ##### FIM DA MUDANÇA DE HTML ##### -->
|
| 339 |
|
| 340 |
<div id="log-container"></div>
|
| 341 |
</div>
|
|
|
|
| 344 |
<div class="footer"><p>Ferramenta de busca abrangente para o Rol de Procedimentos com reordenação semântica de resultados e sugestão de IA- Versão Beta, não oficial.</p></div>
|
| 345 |
|
| 346 |
<script>
|
| 347 |
+
// ##### INÍCIO DA MUDANÇA DE JAVASCRIPT #####
|
| 348 |
const searchInput = document.getElementById('search-input');
|
| 349 |
const searchButton = document.getElementById('search-button');
|
| 350 |
const loader = document.getElementById('loader');
|
|
|
|
| 354 |
const correctionInfoDiv = document.getElementById('correction-info');
|
| 355 |
const logContainer = document.getElementById('log-container');
|
| 356 |
const manualFeedbackArea = document.getElementById('manual-feedback-area');
|
| 357 |
+
const procedureNameInput = document.getElementById('procedure-name-input');
|
| 358 |
+
const procedureExplanationInput = document.getElementById('procedure-explanation-input');
|
| 359 |
+
const submitSuggestionButton = document.getElementById('submit-suggestion-button');
|
| 360 |
const manualFeedbackStatus = document.getElementById('manual-feedback-status');
|
|
|
|
| 361 |
const aiSuggestionContainer = document.getElementById('ai-suggestion-container');
|
| 362 |
const aiSuggestionButton = document.getElementById('ai-suggestion-button');
|
| 363 |
const aiSuggestionStatus = document.getElementById('ai-suggestion-status');
|
| 364 |
|
| 365 |
let lastSearchQuery = '';
|
| 366 |
let feedbackAlreadySentForCurrentSearch = false;
|
|
|
|
|
|
|
| 367 |
let currentResultsForAI = [];
|
| 368 |
|
| 369 |
function resetState() {
|
| 370 |
feedbackAlreadySentForCurrentSearch = false;
|
| 371 |
+
document.querySelectorAll('.feedback-button').forEach(b => {
|
| 372 |
+
b.disabled = false;
|
| 373 |
+
b.textContent = 'Confirmar este como o procedimento correto';
|
| 374 |
+
b.classList.remove('success', 'error');
|
| 375 |
+
});
|
| 376 |
+
|
| 377 |
+
// Resetar novo formulário de sugestão
|
| 378 |
+
procedureNameInput.value = ''; procedureNameInput.disabled = false;
|
| 379 |
+
procedureExplanationInput.value = ''; procedureExplanationInput.disabled = false;
|
| 380 |
+
submitSuggestionButton.disabled = false;
|
| 381 |
+
submitSuggestionButton.textContent = 'Enviar Sugestão';
|
| 382 |
+
submitSuggestionButton.classList.remove('success', 'error');
|
| 383 |
manualFeedbackStatus.textContent = '';
|
| 384 |
|
| 385 |
aiSuggestionContainer.style.display = 'none';
|
|
|
|
| 399 |
}
|
| 400 |
|
| 401 |
function disableAllFeedbackButtons() {
|
| 402 |
+
document.querySelectorAll('.feedback-button').forEach(b => {
|
| 403 |
+
b.disabled = true;
|
| 404 |
+
if (!b.classList.contains('success')) b.textContent = 'Confirmação Enviada';
|
| 405 |
+
});
|
| 406 |
+
// Não desabilitar o botão de sugestão, pois é uma ação diferente
|
| 407 |
}
|
| 408 |
+
// ##### FIM DA MUDANÇA DE JAVASCRIPT #####
|
| 409 |
|
| 410 |
async function performSearch() {
|
| 411 |
const query = searchInput.value.trim();
|
|
|
|
| 559 |
}
|
| 560 |
itemDiv.appendChild(bodyDiv);
|
| 561 |
|
| 562 |
+
// ##### INÍCIO DA MUDANÇA DE JAVASCRIPT #####
|
| 563 |
const feedbackButton = document.createElement('button');
|
| 564 |
feedbackButton.className = 'feedback-button';
|
| 565 |
+
feedbackButton.textContent = 'Confirmar este como o procedimento correto';
|
| 566 |
+
feedbackButton.onclick = () => submitFeedback(originalQuery, result.Codigo_TUSS, feedbackButton);
|
| 567 |
itemDiv.appendChild(feedbackButton);
|
| 568 |
+
// ##### FIM DA MUDANÇA DE JAVASCRIPT #####
|
| 569 |
|
| 570 |
return itemDiv;
|
| 571 |
}
|
| 572 |
|
| 573 |
+
// ##### INÍCIO DA MUDANÇA DE JAVASCRIPT #####
|
| 574 |
+
async function submitFeedback(originalQuery, tussCodeSubmitted, buttonElement) {
|
| 575 |
if (feedbackAlreadySentForCurrentSearch) return;
|
| 576 |
+
if (!confirm("Você confirma que este é o procedimento que estava procurando? Sua confirmação ajuda a melhorar a busca para todos.")) return;
|
| 577 |
|
| 578 |
+
buttonElement.disabled = true;
|
|
|
|
| 579 |
|
| 580 |
try {
|
| 581 |
const response = await fetch('/submit_feedback', {
|
| 582 |
method: 'POST',
|
| 583 |
headers: { 'Content-Type': 'application/json' },
|
| 584 |
+
body: JSON.stringify({
|
| 585 |
+
query: originalQuery,
|
| 586 |
+
tuss_code: tussCodeSubmitted,
|
| 587 |
+
feedback_type: 'confirm_result',
|
| 588 |
+
tuss_code_raw_input: ''
|
| 589 |
+
})
|
| 590 |
});
|
| 591 |
+
if (!response.ok) throw new Error('Falha no envio da confirmação.');
|
| 592 |
|
| 593 |
feedbackAlreadySentForCurrentSearch = true;
|
| 594 |
+
buttonElement.textContent = 'Confirmação Enviada!';
|
| 595 |
+
buttonElement.classList.add('success');
|
| 596 |
disableAllFeedbackButtons();
|
| 597 |
} catch (error) {
|
| 598 |
+
buttonElement.textContent = 'Erro no Envio';
|
| 599 |
+
buttonElement.classList.add('error');
|
| 600 |
+
buttonElement.disabled = false;
|
| 601 |
}
|
| 602 |
}
|
| 603 |
+
// ##### FIM DA MUDANÇA DE JAVASCRIPT #####
|
| 604 |
|
| 605 |
async function getAiSuggestions() {
|
| 606 |
if (!lastSearchQuery || currentResultsForAI.length === 0) return;
|
|
|
|
| 659 |
searchInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') performSearch(); });
|
| 660 |
aiSuggestionButton.addEventListener('click', getAiSuggestions);
|
| 661 |
|
| 662 |
+
// ##### INÍCIO DA MUDANÇA DE JAVASCRIPT #####
|
| 663 |
+
// Listener para o novo botão de sugestão
|
| 664 |
+
submitSuggestionButton.addEventListener('click', async () => {
|
| 665 |
+
const name = procedureNameInput.value.trim();
|
| 666 |
+
const explanation = procedureExplanationInput.value.trim();
|
| 667 |
+
|
| 668 |
+
if (!name || !explanation) {
|
| 669 |
+
manualFeedbackStatus.textContent = 'Por favor, preencha o nome e a explicação.';
|
| 670 |
+
manualFeedbackStatus.style.color = '#dc3545';
|
| 671 |
+
return;
|
|
|
|
|
|
|
|
|
|
| 672 |
}
|
|
|
|
| 673 |
|
| 674 |
+
submitSuggestionButton.disabled = true;
|
| 675 |
+
manualFeedbackStatus.textContent = 'Enviando...';
|
| 676 |
+
manualFeedbackStatus.style.color = 'var(--text-light)';
|
|
|
|
|
|
|
| 677 |
|
|
|
|
| 678 |
try {
|
| 679 |
+
const response = await fetch('/submit_suggestion', {
|
| 680 |
+
method: 'POST',
|
| 681 |
+
headers: { 'Content-Type': 'application/json' },
|
| 682 |
+
body: JSON.stringify({
|
| 683 |
+
query: lastSearchQuery,
|
| 684 |
+
name: name,
|
| 685 |
+
explanation: explanation
|
| 686 |
+
})
|
| 687 |
+
});
|
| 688 |
+
|
| 689 |
+
const data = await response.json();
|
| 690 |
+
if (!response.ok) throw new Error(data.message || 'Falha no envio da sugestão.');
|
| 691 |
+
|
| 692 |
+
manualFeedbackStatus.textContent = 'Sugestão recebida. Obrigado!';
|
| 693 |
+
manualFeedbackStatus.style.color = '#28a745';
|
| 694 |
+
submitSuggestionButton.textContent = 'Enviado!';
|
| 695 |
+
submitSuggestionButton.classList.add('success');
|
| 696 |
+
procedureNameInput.disabled = true;
|
| 697 |
+
procedureExplanationInput.disabled = true;
|
| 698 |
+
|
| 699 |
} catch (error) {
|
| 700 |
+
manualFeedbackStatus.textContent = `Erro: ${error.message}`;
|
| 701 |
+
manualFeedbackStatus.style.color = '#dc3545';
|
| 702 |
+
submitSuggestionButton.disabled = false;
|
| 703 |
+
submitSuggestionButton.textContent = 'Enviar Sugestão';
|
| 704 |
+
submitSuggestionButton.classList.remove('success', 'error');
|
| 705 |
}
|
| 706 |
+
});
|
| 707 |
|
| 708 |
+
// Lógicas antigas de autocompletar TUSS foram removidas
|
| 709 |
+
// ##### FIM DA MUDANÇA DE JAVASCRIPT #####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 710 |
|
| 711 |
searchInput.focus();
|
| 712 |
</script>
|