fix: connect UI refresh functions for complete auto-refresh support
This commit is contained in:
parent
64b91d69de
commit
63cb565dc5
2 changed files with 23 additions and 10 deletions
|
|
@ -37,6 +37,10 @@ export function setUserLanguagePreference(langCode) {
|
|||
console.log("Language preference saved:", langCode);
|
||||
// Trigger UI refresh when language changes
|
||||
refreshUILanguage();
|
||||
// Also trigger the UI-specific refresh function if available
|
||||
if (typeof window !== "undefined" && window.refreshUILanguage) {
|
||||
window.refreshUILanguage();
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Failed to save language preference:", error);
|
||||
}
|
||||
|
|
|
|||
29
src/ui.js
29
src/ui.js
|
|
@ -15,6 +15,7 @@ import {
|
|||
getUserLanguagePreference,
|
||||
setUserLanguagePreference,
|
||||
} from "./ui-translations.js";
|
||||
import { NATIVE_LANGUAGE_NAMES } from "./translation.js";
|
||||
|
||||
// Refresh UI elements when language preference changes
|
||||
function refreshUILanguage() {
|
||||
|
|
@ -2783,7 +2784,11 @@ You have complete knowledge of this page content and can reference any details,
|
|||
const pageTitle = document.title || window.location.hostname;
|
||||
|
||||
// FIRST: Generate intro message with specialized intro system prompt
|
||||
const introSystemPrompt = `You are Hermes AI, powered by Nous Research, embedded on a webpage. Your task is to generate a warm, welcoming 3-paragraph introduction that shows you understand the specific page the user is viewing.
|
||||
// Get user's preferred language and localize the system prompt
|
||||
const userLang = getUserLanguagePreference();
|
||||
const languageName = NATIVE_LANGUAGE_NAMES[userLang] || "English";
|
||||
|
||||
const introSystemPrompt = `${getUIText("systemPromptIntro")}
|
||||
|
||||
PAGE INFORMATION:
|
||||
Title: "${pageTitle}"
|
||||
|
|
@ -2793,11 +2798,11 @@ FULL PAGE CONTENT:
|
|||
${pageContent}
|
||||
|
||||
Generate a 3-paragraph introduction that:
|
||||
1. Introduces yourself as Hermes AI and acknowledges the specific page/content
|
||||
2. Explains how you can help with this page content and related topics
|
||||
3. Invites questions and explains your capabilities
|
||||
${getUIText("systemPromptTask1")}
|
||||
${getUIText("systemPromptTask2")}
|
||||
${getUIText("systemPromptTask3")}
|
||||
|
||||
Reference specific details from the page content to show understanding.`;
|
||||
${getUIText("systemPromptInstructions")} ${languageName}.`;
|
||||
|
||||
const introPrompt = "Generate the welcoming introduction message now.";
|
||||
|
||||
|
|
@ -4063,7 +4068,8 @@ export function openTTSModal() {
|
|||
const speedValue = document.createElement("span");
|
||||
speedValue.textContent = "0.9";
|
||||
|
||||
speedLabel.textContent = `Speed: ${speedValue.textContent}`;
|
||||
speedLabel.textContent = `${getUIText("speedLabel")} ${speedValue.textContent}`;
|
||||
speedLabel.setAttribute("data-i18n", "speedLabel");
|
||||
const speedSlider = document.createElement("input");
|
||||
speedSlider.type = "range";
|
||||
speedSlider.min = "0.25";
|
||||
|
|
@ -4073,14 +4079,15 @@ export function openTTSModal() {
|
|||
|
||||
speedSlider.oninput = () => {
|
||||
speedValue.textContent = speedSlider.value;
|
||||
speedLabel.textContent = `Speed: ${speedSlider.value}`;
|
||||
speedLabel.textContent = `${getUIText("speedLabel")} ${speedSlider.value}`;
|
||||
};
|
||||
|
||||
article.appendChild(speedLabel);
|
||||
article.appendChild(speedSlider);
|
||||
|
||||
const playButton = document.createElement("button");
|
||||
playButton.textContent = "Play Text";
|
||||
playButton.textContent = getUIText("playText");
|
||||
playButton.setAttribute("data-i18n", "playText");
|
||||
if (USE_CUSTOM_STYLING) {
|
||||
playButton.style.cssText = `
|
||||
padding: 12px 24px;
|
||||
|
|
@ -4313,12 +4320,14 @@ export function openTranslateModal() {
|
|||
"display: flex; gap: 10px; margin-bottom: 20px;";
|
||||
|
||||
const pageTab = document.createElement("button");
|
||||
pageTab.textContent = "📄 Translate Page";
|
||||
pageTab.textContent = getUIText("translatePageTab");
|
||||
pageTab.setAttribute("data-i18n", "translatePageTab");
|
||||
pageTab.style.cssText =
|
||||
"flex: 1; padding: 10px; border: 2px solid #4CAF50; border-radius: 6px; background: #4CAF50; color: white; cursor: pointer;";
|
||||
|
||||
const customTab = document.createElement("button");
|
||||
customTab.textContent = "✏️ Custom Text";
|
||||
customTab.textContent = getUIText("customTextTab");
|
||||
customTab.setAttribute("data-i18n", "customTextTab");
|
||||
customTab.style.cssText =
|
||||
"flex: 1; padding: 10px; border: 2px solid #4CAF50; border-radius: 6px; background: white; color: #4CAF50; cursor: pointer;";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue