Skip to content

Commit

Permalink
added save button for the persona
Browse files Browse the repository at this point in the history
  • Loading branch information
mlnomadpy committed Mar 24, 2024
1 parent 3ad0d66 commit 0c9f2d9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
5 changes: 3 additions & 2 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@
<!-- Custom Prompt Input and Predefined Prompts Dropdown -->
<div class="prompt-section">
<label for="customPrompt">Your Own Persona:</label>
<input type="text" id="personaName" placeholder="Name your Persona">
<input type="text" id="customPrompt" placeholder="Describe the Persona and what you want to do?">
<button id="savePersona">Save Persona</button>

<select id="predefinedPrompts">
<option value="">Select your Persona</option>
<option value="eminem">Eminem</option>
<option value="polikar">Dr. Polikar</option>
<option value="trafford">Professor Trafford</option>
<!-- Add more predefined prompts as needed -->
</select>
</div>
Expand Down
38 changes: 37 additions & 1 deletion popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ document.addEventListener('DOMContentLoaded', function() {
const searchResults = document.getElementById('searchResults');
const apiKeyInput = document.getElementById('apiKey');
const saveApiKeyButton = document.getElementById('saveApiKey');
const savePersonaKeyButton = document.getElementById('savePersona');
const summarizeButton = document.getElementById('summarizeButton');
let searchTimeout;

Expand All @@ -32,7 +33,16 @@ document.addEventListener('DOMContentLoaded', function() {
alert('API Key saved');
});
});
savePersonaKeyButton.addEventListener('click', function() {

chrome.storage.sync.set({'apiKey': apiKeyInput.value}, function() {
alert('API Key saved');
});
const personaName = document.getElementById('personaName').value
const personaDescription = document.getElementById('customPrompt').value
storePersona(personaName, personaDescription);
createOption(personaName, personaDescription);
});
// searchInput.addEventListener('input', function() {
// clearTimeout(searchTimeout); // Clear existing timeout to debounce the search
// const query = searchInput.value.trim();
Expand Down Expand Up @@ -65,8 +75,16 @@ document.addEventListener('DOMContentLoaded', function() {
// }
// });
// }
// TODO: add load all personas


summarizeButton.addEventListener('click', function() {
const customPrompt = document.getElementById('customPrompt').value;
const predefinedPrompt = document.getElementById('predefinedPrompts').value;
const prompt = customPrompt || predefinedPrompt;

summarizeSelectedPages(prompt);
});

summarizeButton.addEventListener('click', function() {
const customPrompt = document.getElementById('customPrompt').value;
const predefinedPrompt = document.getElementById('predefinedPrompts').value;
Expand Down Expand Up @@ -180,5 +198,23 @@ document.addEventListener('DOMContentLoaded', function() {




function storePersona(persona, personaContent) {
chrome.storage.local.set({ [persona]: personaContent }, function() {
if (chrome.runtime.lastError) {
console.error("Error storing HTML content for", url, ":", chrome.runtime.lastError.message);
} else {
console.log("HTML content stored successfully for", url);
}
});
}
function createOption(personaName, personaContent){
let select = document.getElementById('predefinedPrompts');
let opt = document.createElement('option');
opt.value = personaContent;
opt.innerHTML = personaName;
select.appendChild(opt);

}
});

0 comments on commit 0c9f2d9

Please sign in to comment.