Commit f33ca4c9 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

refac

parent bc73cb13
......@@ -127,6 +127,41 @@
}
onMount(async () => {
window.addEventListener('message', async (event) => {
if (event.origin === window.origin) {
// Replace with your iframe's origin
console.log('Message received from iframe:', event.data);
if (event.data.type === 'input:prompt') {
console.log(event.data.text);
const inputElement = document.getElementById('chat-textarea');
if (inputElement) {
prompt = event.data.text;
inputElement.focus();
}
}
if (event.data.type === 'action:submit') {
console.log(event.data.text);
if (prompt !== '') {
await tick();
submitPrompt(prompt);
}
}
if (event.data.type === 'input:prompt:submit') {
console.log(event.data.text);
if (prompt !== '') {
await tick();
submitPrompt(event.data.text);
}
}
}
});
if (!$chatId) {
chatId.subscribe(async (value) => {
if (!value) {
......
......@@ -50,33 +50,6 @@
}
};
window.addEventListener('message', (event) => {
if (event.origin === window.origin) {
// Replace with your iframe's origin
console.log('Message received from iframe:', event.data);
if (event.data.type === 'input:prompt') {
console.log(event.data.text);
const inputElement = document.getElementById('chat-textarea');
if (inputElement) {
inputElement.value = event.data.text;
inputElement.focus();
}
}
if (event.data.type === 'action:submit-prompt') {
console.log(event.data.text);
const submitButtonElement = document.getElementById('send-message-button');
if (submitButtonElement) {
submitButtonElement.click();
}
}
}
});
window.addEventListener('resize', onResize);
const setWakeLock = async () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment