Skip to content

Commit

Permalink
Fix popup logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonacox committed Jul 20, 2024
1 parent 3440c56 commit 4de3617
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions chatbot/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@
<div class="popup-box" style="width: 90%;">
<h2 class="popup-title">System Settings</h2>
<div class="popup-content">
<p class="popup-content-text" id="popup-content-text">The TinyLLM Chatbot can be customized by changing the prompts used to generate responses.</p>
<p class="popup-content-text">The TinyLLM Chatbot can be customized by changing the prompts used to generate responses.</p>
<form id="settingsForm">
<div class="popup-table-container" id="conversation">
<div class="popup-table-container">
<table>
<thead>
<tr>
Expand All @@ -289,6 +289,25 @@ <h2 class="popup-title">System Settings</h2>
</div>
</div>
</div>
<div class="popup-overlay" id="debugOverlay">
<div class="popup-box" style="width: 90%;">
<h2 class="popup-title">Session Conversation Thread</h2>
<div class="popup-content">
<form id="settingsForm">
<div class="popup-table-container" id="conversation">
JSON session data will be displayed here
</div>
<div class="popup-divider"></div>
<div class="popup-button-container">
<div id="popup-buttons">
<button type="button" class="dialogue-button" onclick="closeDialogue()">Close</button>
<button type="button" class="dialogue-button" onclick="convCopy()">Copy</button>
</div>
</div>
</form>
</div>
</div>
</div>
<script>
function openDialogue() {
document.getElementById("dialogueOverlay").style.display = "flex";
Expand Down Expand Up @@ -326,6 +345,10 @@ <h2 class="popup-title">System Settings</h2>

function closeDialogue() {
document.getElementById("dialogueOverlay").style.display = "none";
document.getElementById("debugOverlay").style.display = "none";
// Set focus back to the text input field
var textInput = document.getElementById("messageInput");
textInput.focus();
}

function resetSettings() {
Expand Down Expand Up @@ -567,13 +590,7 @@ <h2 class="popup-title">System Settings</h2>
}

if (data.voice === "conversation") {
document.getElementById("dialogueOverlay").style.display = "flex";
document.querySelector('.popup-title').textContent = 'Conversation Thread';
document.getElementById('popup-content-text').textContent = 'The conversation thread shows the interaction between the user and the chatbot.';
document.getElementById('popup-buttons').innerHTML = `
<button type="button" class="dialogue-button" onclick="closeDialogue()">Close</button>
<button type="button" class="dialogue-button" onclick="convCopy()">Copy</button>
`;
document.getElementById("debugOverlay").style.display = "flex";
// First clear the form from any previous settings
document.getElementById("conversation").innerHTML = `
<pre style='white-space: pre-wrap'>${JSON.stringify(data.update, null, 2)}</pre>
Expand All @@ -586,7 +603,7 @@ <h2 class="popup-title">System Settings</h2>

// Function to copy conversation to clipboard
function convCopy(button) {
const conversation = document.querySelector('.popup-table-container');
const conversation = document.getElementById('conversation');
const conversationText = conversation.textContent || conversation.innerText;

if (navigator.clipboard) {
Expand Down

0 comments on commit 4de3617

Please sign in to comment.