refactor: rename hermes modal to uncloseai embedded modal
This commit is contained in:
parent
05cfcf2b95
commit
087e828583
3 changed files with 32 additions and 32 deletions
|
|
@ -317,7 +317,7 @@ export function extractPageContent() {
|
|||
const documentClone = document.cloneNode(true);
|
||||
|
||||
// Remove any open modals/dialogs that shouldn't be in the translation
|
||||
const modalsToRemove = documentClone.querySelectorAll('dialog[open], #hermes-modal, [id*="modal"], [class*="modal"]');
|
||||
const modalsToRemove = documentClone.querySelectorAll('dialog[open], #uncloseai-embedded-modal, [id*="modal"], [class*="modal"]');
|
||||
modalsToRemove.forEach(modal => modal.remove());
|
||||
|
||||
// Return the entire HTML of the document to preserve head, styles, and scripts
|
||||
|
|
|
|||
56
src/ui.js
56
src/ui.js
|
|
@ -124,7 +124,7 @@ const USE_CUSTOM_STYLING = window.UNCLOSEAI_CUSTOM_STYLING !== false;
|
|||
const SHOW_FLOATING_BUTTON = window.UNCLOSEAI_FLOATING_BUTTON !== false;
|
||||
|
||||
// Global variable to track modal state
|
||||
let hermesModalOpen = false;
|
||||
let uncloseaiEmbeddedModalOpen = false;
|
||||
|
||||
// Initialize uncloseai elements based on class
|
||||
export function initializeUncloseaiElements() {
|
||||
|
|
@ -527,23 +527,23 @@ function setupFloatingButtonHandler(floatingButton) {
|
|||
// Try multiple ways to access the modal function
|
||||
let modalFunction = null;
|
||||
|
||||
if (typeof toggleHermesModal === 'function') {
|
||||
console.log("Found toggleHermesModal in local scope");
|
||||
modalFunction = toggleHermesModal;
|
||||
} else if (typeof window.toggleHermesModal === 'function') {
|
||||
console.log("Found toggleHermesModal on window");
|
||||
modalFunction = window.toggleHermesModal;
|
||||
if (typeof toggleUncloseaiEmbeddedModal === 'function') {
|
||||
console.log("Found toggleUncloseaiEmbeddedModal in local scope");
|
||||
modalFunction = toggleUncloseaiEmbeddedModal;
|
||||
} else if (typeof window.toggleUncloseaiEmbeddedModal === 'function') {
|
||||
console.log("Found toggleUncloseaiEmbeddedModal on window");
|
||||
modalFunction = window.toggleUncloseaiEmbeddedModal;
|
||||
} else {
|
||||
console.log("toggleHermesModal not found, trying dynamic import");
|
||||
console.log("toggleUncloseaiEmbeddedModal not found, trying dynamic import");
|
||||
// Try to import it dynamically as a fallback
|
||||
try {
|
||||
const uiModule = await import('./ui.js');
|
||||
if (uiModule.toggleHermesModal) {
|
||||
console.log("Successfully imported toggleHermesModal");
|
||||
modalFunction = uiModule.toggleHermesModal;
|
||||
if (uiModule.toggleUncloseaiEmbeddedModal) {
|
||||
console.log("Successfully imported toggleUncloseaiEmbeddedModal");
|
||||
modalFunction = uiModule.toggleUncloseaiEmbeddedModal;
|
||||
}
|
||||
} catch (importError) {
|
||||
console.error("Could not import toggleHermesModal:", importError);
|
||||
console.error("Could not import toggleUncloseaiEmbeddedModal:", importError);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -551,7 +551,7 @@ function setupFloatingButtonHandler(floatingButton) {
|
|||
console.log("Calling modal function");
|
||||
await modalFunction();
|
||||
} else {
|
||||
console.error("toggleHermesModal function not available in any form");
|
||||
console.error("toggleUncloseaiEmbeddedModal function not available in any form");
|
||||
alert("AI modal not available in this context");
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -568,9 +568,9 @@ function setupFloatingButtonHandler(floatingButton) {
|
|||
}
|
||||
|
||||
// New mobile-first Hermes modal
|
||||
async function openHermesModalNew() {
|
||||
async function openUncloseaiEmbeddedModalNew() {
|
||||
const modal = document.createElement("dialog");
|
||||
modal.id = "hermes-modal";
|
||||
modal.id = "uncloseai-embedded-modal";
|
||||
|
||||
// Mobile-first: full screen on mobile, centered on desktop
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
|
|
@ -669,7 +669,7 @@ async function openHermesModalNew() {
|
|||
closeBtn.onclick = () => {
|
||||
modal.close();
|
||||
document.body.removeChild(modal);
|
||||
hermesModalOpen = false;
|
||||
uncloseaiEmbeddedModalOpen = false;
|
||||
};
|
||||
|
||||
// Add settings/menu button
|
||||
|
|
@ -1250,7 +1250,7 @@ async function openHermesModalNew() {
|
|||
if (e.target === modal) {
|
||||
modal.close();
|
||||
document.body.removeChild(modal);
|
||||
hermesModalOpen = false;
|
||||
uncloseaiEmbeddedModalOpen = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1647,21 +1647,21 @@ You have complete knowledge of this page content and can reference any details,
|
|||
}
|
||||
|
||||
// Function to toggle Hermes modal
|
||||
export async function toggleHermesModal() {
|
||||
const existingModal = document.getElementById("hermes-modal");
|
||||
export async function toggleUncloseaiEmbeddedModal() {
|
||||
const existingModal = document.getElementById("uncloseai-embedded-modal");
|
||||
if (existingModal) {
|
||||
document.body.removeChild(existingModal);
|
||||
hermesModalOpen = false;
|
||||
uncloseaiEmbeddedModalOpen = false;
|
||||
} else {
|
||||
await openHermesModalNew();
|
||||
hermesModalOpen = true;
|
||||
await openUncloseaiEmbeddedModalNew();
|
||||
uncloseaiEmbeddedModalOpen = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Function to open Hermes modal - Mobile-first design
|
||||
export async function openHermesModal() {
|
||||
export async function openUncloseaiEmbeddedModal() {
|
||||
const modal = document.createElement("dialog");
|
||||
modal.id = "hermes-modal";
|
||||
modal.id = "uncloseai-embedded-modal";
|
||||
|
||||
// Mobile-first: full screen on mobile, centered on desktop
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
|
|
@ -1853,7 +1853,7 @@ export async function openHermesModal() {
|
|||
}
|
||||
closeButton.onclick = () => {
|
||||
document.body.removeChild(modal);
|
||||
hermesModalOpen = false;
|
||||
uncloseaiEmbeddedModalOpen = false;
|
||||
};
|
||||
|
||||
header.appendChild(titleContainer);
|
||||
|
|
@ -2366,7 +2366,7 @@ Format: Start with "Greetings! I'm Hermes..." and make it sound natural and enga
|
|||
if (e.target === modal) {
|
||||
modal.close();
|
||||
document.body.removeChild(modal);
|
||||
hermesModalOpen = false;
|
||||
uncloseaiEmbeddedModalOpen = false;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -2526,7 +2526,7 @@ Format: Start with "Greetings! I'm Hermes..." and make it sound natural and enga
|
|||
// TTS Modal functionality
|
||||
export function openTTSModal() {
|
||||
// Check if Hermes modal is open to set appropriate z-index
|
||||
const hermesModal = document.getElementById("hermes-modal");
|
||||
const hermesModal = document.getElementById("uncloseai-embedded-modal");
|
||||
const zIndex = hermesModal ? "2001" : "1001";
|
||||
|
||||
const modal = document.createElement("dialog");
|
||||
|
|
@ -2820,7 +2820,7 @@ export function openTTSModal() {
|
|||
// Open translation modal
|
||||
export function openTranslateModal() {
|
||||
// Check if Hermes modal is open to set appropriate z-index
|
||||
const hermesModal = document.getElementById("hermes-modal");
|
||||
const hermesModal = document.getElementById("uncloseai-embedded-modal");
|
||||
const zIndex = hermesModal ? "2001" : "1001";
|
||||
|
||||
const modal = document.createElement("dialog");
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ export const createFloatingAIButton = UI.createFloatingAIButton;
|
|||
export const initializeUncloseaiElements = UI.initializeUncloseaiElements;
|
||||
export const createFullInterface = UI.createFullInterface;
|
||||
export const createCustomInterface = UI.createCustomInterface;
|
||||
export const toggleHermesModal = UI.toggleHermesModal;
|
||||
export const openHermesModal = UI.openHermesModal;
|
||||
export const toggleUncloseaiEmbeddedModal = UI.toggleUncloseaiEmbeddedModal;
|
||||
export const openUncloseaiEmbeddedModal = UI.openUncloseaiEmbeddedModal;
|
||||
export const openTTSModal = UI.openTTSModal;
|
||||
export const openTranslateModal = UI.openTranslateModal;
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ window.speakText = TTS.speakText;
|
|||
window.uploadFile = FileUpload.uploadFile;
|
||||
window.openTTSModal = UI.openTTSModal;
|
||||
window.openTranslateModal = UI.openTranslateModal;
|
||||
window.toggleHermesModal = async () => await UI.toggleHermesModal();
|
||||
window.toggleUncloseaiEmbeddedModal = async () => await UI.toggleUncloseaiEmbeddedModal();
|
||||
window.extractWebpageContent = Content.extractWebpageContent;
|
||||
window.getSelectedModel = Models.getSelectedModel;
|
||||
window.getSelectedModelEndpoint = Models.getSelectedModelEndpoint;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue