Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
bc73cb13
Commit
bc73cb13
authored
Jun 23, 2024
by
Timothy J. Baek
Browse files
enh: iframe message event listener
parent
37a05232
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
src/routes/+layout.svelte
src/routes/+layout.svelte
+27
-0
No files found.
src/routes/+layout.svelte
View file @
bc73cb13
...
@@ -50,6 +50,33 @@
...
@@ -50,6 +50,33 @@
}
}
};
};
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);
window.addEventListener('resize', onResize);
const setWakeLock = async () => {
const setWakeLock = async () => {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment