This commit is contained in:
Nordi98 2025-06-26 03:23:18 +02:00
parent a32228ba5f
commit 93926f0de7
5 changed files with 126 additions and 213 deletions

View file

@ -10,7 +10,6 @@
margin: 0;
padding: 0;
overflow: hidden;
background-color: transparent;
}
#image {
position: absolute;
@ -25,57 +24,25 @@
<body>
<img id="image" src="" alt="Image" style="display:none;">
<script>
// Globale Variable, um den Status zu verfolgen
let isDisplayed = false;
window.addEventListener('message', function(event) {
if (event.data.action === 'show') {
document.getElementById('image').src = event.data.imageUrl;
document.getElementById('image').style.display = 'block';
isDisplayed = true;
console.log("Showing image:", event.data.imageUrl);
} else if (event.data.action === 'hide') {
document.getElementById('image').style.display = 'none';
isDisplayed = false;
console.log("Hiding image");
}
});
document.addEventListener("keydown", function(event) {
if (event.key === "Escape" && isDisplayed) {
document.getElementById('image').style.display = 'none';
isDisplayed = false;
// Sende Nachricht zurück an den Client
fetch(`https://${GetParentResourceName()}/hideFrame`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({})
})
.then(response => {
console.log("Frame hidden successfully");
})
.catch(error => {
console.error("Error hiding frame:", error);
});
}
});
// Sicherheitsmechanismus: Wenn die Seite geladen wird, stelle sicher, dass der Focus zurückgesetzt wird
window.onload = function() {
fetch(`https://${GetParentResourceName()}/pageLoaded`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({})
if (event.key === "Escape") {
document.getElementById('image').style.display = 'none';
axios.post(`https://${GetParentResourceName()}/hideFrame`, {})
.then(function (response) {
})
.catch(error => {
console.error("Error notifying page load:", error);
.catch(function (error) {
});
};
}
});
</script>
</body>
</html>