Skip to content

Commit

Permalink
Adjust vnc sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
netham45 committed Aug 9, 2024
1 parent 894b43f commit 6173cab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
24 changes: 14 additions & 10 deletions site/js/iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ let iframeInterval = false;
function iframeOnload() {
if (iframeInterval != false)
clearInterval(iframeInterval);
iframeInterval = setInterval(iframeResize, 1000);
iframeResize();
setTimeout(iframeResize, 200);
setTimeout(iframeResize, 400);
setTimeout(iframeResize, 600);
setTimeout(iframeResize, 800);
setTimeout(iframeResize, 800);
iframeInterval = setInterval(iframeOnresize, 1000);
iframeOnresize();
setTimeout(iframeOnresize, 200);
setTimeout(iframeOnresize, 400);
setTimeout(iframeOnresize, 600);
setTimeout(iframeOnresize, 800);
setTimeout(iframeOnresize, 800);
}

function iframeResize() {
export function iframeOnresize() {
var iframe = document.querySelectorAll("DIV#dialog IFRAME")[0];
var canvas = iframe.contentWindow.document.getElementsByTagName("canvas")[0];
var maxWidth = window.innerWidth * 0.75;
var maxHeight = window.innerHeight * 0.75;
var width = canvas.width < maxWidth ? canvas.width : maxWidth;
var height = canvas.height < maxHeight? canvas.height : maxHeight;
if (canvas.width > 0 && canvas.height > 0) {
iframe.style.width = (canvas.width) + "px";
iframe.style.height = (canvas.height) + "px";
iframe.style.width = width + "px";
iframe.style.height = height + "px";
} else {
iframe.style.width = "400px";
iframe.style.height = "600px";
Expand Down
3 changes: 2 additions & 1 deletion site/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {highlightActiveSink, highlightActiveSource, highlightActiveRoutes, onloa
import { selectedRoute, selectedSink, selectedSource, editorActive, editorType, setSelectedSource, setSelectedSink, setSelectedRoute, setEditorActive, setEditorType } from "./global.js";
import {onload as audioOnload} from "./audio.js";
import {onload as sortOnload} from "./sort.js";
import {onload as iframeOnload} from "./iframe.js";
import {onload as iframeOnload, iframeOnresize} from "./iframe.js";
import {onload as dragOnload} from "./drag.js";
import {onload as dialogOnload, dismissShadow, showShadow} from "./dialog.js";
import {onload as controlsOnload} from "./controls.js";
Expand Down Expand Up @@ -134,6 +134,7 @@ function onload() {
function onresize() {
drawLines();
backgroundOnresize();
iframeOnresize();
}

window.addEventListener('load', onload);
Expand Down

0 comments on commit 6173cab

Please sign in to comment.