Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

188 lines
5.6 KiB

//<?php require_once('../../js_asm.php'); ?>
var mWindowID = <?=(isset($_GET['w']))?intval($_GET['w']):0;?>;
var mAuxWindows = [];
function isMasterWindow(){
var cWindowSessionID = window.localStorage.getItem("cWindowSID");
if( cWindowSessionID == undefined ){
window.localStorage.clear();
window.localStorage.setItem("cWindowSID", '<?=$Session;?>' );
} else {
if( cWindowSessionID != '<?=$Session;?>' ){
window.localStorage.clear();
window.localStorage.setItem("cWindowSID", '<?=$Session;?>' );
} else {
return false;
};
};
return true;
};
function refreshAuxWindows(){
};
function closeAuxWindows(){
};
function isFullScreen() {
return document.fullscreenElement !== null;
}
let previousX = window.screenX;
let previousY = window.screenY;
setInterval(() => {
const currentX = window.screenX;
const currentY = window.screenY;
if (currentX !== previousX || currentY !== previousY) {
// Window has moved
console.log("Window moved!");
console.log("New Position X:", currentX, "Y:", currentY);
previousX = currentX;
previousY = currentY;
}
}, 700); // Check every 700 milliseconds
/*
if (!('getScreenDetails' in window)) {
// Returning a one-element array with the current screen,
// noting that there might be more.
window.getScreenDetails = async () => [window.screen];
// Set to `false`, noting that this might be a lie.
window.screen.isExtended = false;
}
*/
async function getDisplayInfo() {
if (window.screen.isExtended) {
console.log("Multiple displays detected.");
} else {
console.log("Single display detected.");
}
if ('getScreenDetails' in window) {
try {
const screenDetails = await window.getScreenDetails();
screenDetails.screens.forEach((screen, index) => {
console.log(`Display ${index + 1}:`);
console.log(` Width: ${screen.width}`);
console.log(` Height: ${screen.height}`);
console.log(` Left: ${screen.left}`);
console.log(` Top: ${screen.top}`);
});
} catch (error) {
console.error("Error getting screen details:", error);
}
} else {
console.log("window.getScreenDetails() is not supported.");
console.log(`Display 0:`);
console.log(` Width: ${window.screen.width}`);
console.log(` Height: ${window.screen.height}`);
console.log(` Left: ${window.screen.left}`);
console.log(` Top: ${window.screen.top}`);
}
};
function doCheckWindowSize(){
//var zz = window.getScreenDetails();
if ('getScreenDetails' in window) {
screenDetails = window.getScreenDetails();
screenDetails.addEventListener('screenschange', (event) => {
if (screenDetails.screens.length !== currentScreenLength) {
currentScreenLength = screenDetails.screens.length;
//updateScreenInfo();
}
});
try {
permission =
((navigator.permissions.query({ name: 'window-management' })).state === 'granted')
? 'Granted'
: 'No Permission';
} catch (err) {
console.error(err);
}
currentScreenLength = screenDetails.screens.length;
//updateScreenInfo();
} else {
screenDetails = window.screen;
permission = 'Window Management API - NOT SUPPORTED';
currentScreenLength = 1;
//updateScreenInfo();
};
getDisplayInfo();
if( isMasterWindow() ){
//window.open('/?w=1', 'app_second', 'location=0,menubar=0,status=0,titlebar=0,toolbar=0,left=20,top=20,width=' + screen.availWidth + ',height=' + screen.availHeight);
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName=="Netscape") {
winW2 = window.innerWidth;
winH2 = window.innerHeight;
if ( winH2<700 ) winH2=700;
};
if (navigator.appName.indexOf("Microsoft")!=-1) {
winW2 = document.body.offsetWidth;
winH2 = document.body.offsetHeight;
if ( winH2<700 ) winH2=700;
};
};
if ( winW2 != winW || winH2!=winH ){
updateUserScreenResolution( winW2, winH2 );
};
} else {
//requestBodyFullscreen();
//alert( "AUX Window:"+mWindowID );
};
};
function requestBodyFullscreen() {
const body = document.body;
if (body.requestFullscreen) {
body.requestFullscreen();
} else if (body.mozRequestFullScreen) { /* Firefox */
body.mozRequestFullScreen();
} else if (body.webkitRequestFullscreen) { /* Chrome, Safari, Opera */
body.webkitRequestFullscreen();
} else if (body.msRequestFullscreen) { /* IE/Edge */
body.msRequestFullscreen();
}
};
function exitBodyFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) { /* Firefox */
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) { /* Chrome, Safari, Opera */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) { /* IE/Edge */
document.msExitFullscreen();
}
};
function initMultiWindows(){
return;
document.addEventListener('fullscreenchange', function() {
if (isFullScreen()) {
console.log("Fullscreen mode activated.");
} else {
console.log("Fullscreen mode deactivated.");
}
});
document.addEventListener("fullscreenerror", (event) => {
console.log("Fullscreen Error.");
});
if( mWindowID == 0 ){
} else {
//Unreg Windows
mAuxWindows = undefined;
window.addEventListener('beforeunload', function(event) {
console.log("BeforeUnload Woerks!");
//event.preventDefault();
//event.returnValue = null;
});
};
doCheckWindowSize();
};