Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Sep 23, 2024
1 parent 96f5b2c commit fa5107f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/widgets/IFrame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<teleport to=".widgets-view">
<iframe
v-show="iframe_loaded"
ref="iframe"
:src="widget.options.source"
:style="iframeStyle"
frameborder="0"
Expand Down Expand Up @@ -62,6 +63,11 @@ import { isValidURL } from '@/libs/utils'
import { useAppInterfaceStore } from '@/stores/appInterface'
import { useWidgetManagerStore } from '@/stores/widgetManager'
import type { Widget } from '@/types/widgets'
import { useMainVehicleStore } from '@/stores/mainVehicle'
import { ConnectionManager } from '@/libs/connection/connection-manager'
const vehicleStore = useMainVehicleStore()
const interfaceStore = useAppInterfaceStore()
const widgetStore = useWidgetManagerStore()
Expand Down Expand Up @@ -133,12 +139,17 @@ const iframeOpacity = computed<number>(() => {
return (100 - transparency.value) / 100
})
const iframe = ref()
/**
* Called when iframe finishes loading
*/
function loadFinished(): void {
console.log('Finished loading')
iframe_loaded.value = true
setTimeout(() => {
iframe.value.contentWindow.MavlinkSignal = ConnectionManager.onRead
}, 1000)
}
watch(
Expand Down
35 changes: 35 additions & 0 deletions test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Print window.exposed_interface</title>
</head>
<body>
<h1>window.exposed_interface Content:</h1>
Pitch: <div id="output"></div>

<script>
let registered = false;
const outputDiv = document.getElementById('output');
function printExposedInterface() {
const decoder = new TextDecoder()
if (window.MavlinkSignal && !registered) {
registered = true;
window.MavlinkSignal.add((message) => {
const msg = JSON.parse(decoder.decode(message))['message']
if (msg.type !== 'ATTITUDE') {
return
}
outputDiv.innerHTML = `<pre>${msg.pitch}</pre>`;
})
}
}
// Initial print
printExposedInterface();

// Set interval to print every 5 seconds
setInterval(printExposedInterface, 1000);
</script>
</body>
</html>

0 comments on commit fa5107f

Please sign in to comment.