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.

187 lines
5.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var mWindowID = <?=(isset($_GET['w']))?intval($_GET['w']):0;?>;
  3. var mAuxWindows = [];
  4. function isMasterWindow(){
  5. var cWindowSessionID = window.localStorage.getItem("cWindowSID");
  6. if( cWindowSessionID == undefined ){
  7. window.localStorage.clear();
  8. window.localStorage.setItem("cWindowSID", '<?=$Session;?>' );
  9. } else {
  10. if( cWindowSessionID != '<?=$Session;?>' ){
  11. window.localStorage.clear();
  12. window.localStorage.setItem("cWindowSID", '<?=$Session;?>' );
  13. } else {
  14. return false;
  15. };
  16. };
  17. return true;
  18. };
  19. function refreshAuxWindows(){
  20. };
  21. function closeAuxWindows(){
  22. };
  23. function isFullScreen() {
  24. return document.fullscreenElement !== null;
  25. }
  26. let previousX = window.screenX;
  27. let previousY = window.screenY;
  28. setInterval(() => {
  29. const currentX = window.screenX;
  30. const currentY = window.screenY;
  31. if (currentX !== previousX || currentY !== previousY) {
  32. // Window has moved
  33. console.log("Window moved!");
  34. console.log("New Position X:", currentX, "Y:", currentY);
  35. previousX = currentX;
  36. previousY = currentY;
  37. }
  38. }, 700); // Check every 700 milliseconds
  39. /*
  40. if (!('getScreenDetails' in window)) {
  41. // Returning a one-element array with the current screen,
  42. // noting that there might be more.
  43. window.getScreenDetails = async () => [window.screen];
  44. // Set to `false`, noting that this might be a lie.
  45. window.screen.isExtended = false;
  46. }
  47. */
  48. async function getDisplayInfo() {
  49. if (window.screen.isExtended) {
  50. console.log("Multiple displays detected.");
  51. } else {
  52. console.log("Single display detected.");
  53. }
  54. if ('getScreenDetails' in window) {
  55. try {
  56. const screenDetails = await window.getScreenDetails();
  57. screenDetails.screens.forEach((screen, index) => {
  58. console.log(`Display ${index + 1}:`);
  59. console.log(` Width: ${screen.width}`);
  60. console.log(` Height: ${screen.height}`);
  61. console.log(` Left: ${screen.left}`);
  62. console.log(` Top: ${screen.top}`);
  63. });
  64. } catch (error) {
  65. console.error("Error getting screen details:", error);
  66. }
  67. } else {
  68. console.log("window.getScreenDetails() is not supported.");
  69. console.log(`Display 0:`);
  70. console.log(` Width: ${window.screen.width}`);
  71. console.log(` Height: ${window.screen.height}`);
  72. console.log(` Left: ${window.screen.left}`);
  73. console.log(` Top: ${window.screen.top}`);
  74. }
  75. };
  76. function doCheckWindowSize(){
  77. //var zz = window.getScreenDetails();
  78. if ('getScreenDetails' in window) {
  79. screenDetails = window.getScreenDetails();
  80. screenDetails.addEventListener('screenschange', (event) => {
  81. if (screenDetails.screens.length !== currentScreenLength) {
  82. currentScreenLength = screenDetails.screens.length;
  83. //updateScreenInfo();
  84. }
  85. });
  86. try {
  87. permission =
  88. ((navigator.permissions.query({ name: 'window-management' })).state === 'granted')
  89. ? 'Granted'
  90. : 'No Permission';
  91. } catch (err) {
  92. console.error(err);
  93. }
  94. currentScreenLength = screenDetails.screens.length;
  95. //updateScreenInfo();
  96. } else {
  97. screenDetails = window.screen;
  98. permission = 'Window Management API - NOT SUPPORTED';
  99. currentScreenLength = 1;
  100. //updateScreenInfo();
  101. };
  102. getDisplayInfo();
  103. if( isMasterWindow() ){
  104. //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);
  105. if (parseInt(navigator.appVersion)>3) {
  106. if (navigator.appName=="Netscape") {
  107. winW2 = window.innerWidth;
  108. winH2 = window.innerHeight;
  109. if ( winH2<700 ) winH2=700;
  110. };
  111. if (navigator.appName.indexOf("Microsoft")!=-1) {
  112. winW2 = document.body.offsetWidth;
  113. winH2 = document.body.offsetHeight;
  114. if ( winH2<700 ) winH2=700;
  115. };
  116. };
  117. if ( winW2 != winW || winH2!=winH ){
  118. updateUserScreenResolution( winW2, winH2 );
  119. };
  120. } else {
  121. //requestBodyFullscreen();
  122. //alert( "AUX Window:"+mWindowID );
  123. };
  124. };
  125. function requestBodyFullscreen() {
  126. const body = document.body;
  127. if (body.requestFullscreen) {
  128. body.requestFullscreen();
  129. } else if (body.mozRequestFullScreen) { /* Firefox */
  130. body.mozRequestFullScreen();
  131. } else if (body.webkitRequestFullscreen) { /* Chrome, Safari, Opera */
  132. body.webkitRequestFullscreen();
  133. } else if (body.msRequestFullscreen) { /* IE/Edge */
  134. body.msRequestFullscreen();
  135. }
  136. };
  137. function exitBodyFullscreen() {
  138. if (document.exitFullscreen) {
  139. document.exitFullscreen();
  140. } else if (document.mozCancelFullScreen) { /* Firefox */
  141. document.mozCancelFullScreen();
  142. } else if (document.webkitExitFullscreen) { /* Chrome, Safari, Opera */
  143. document.webkitExitFullscreen();
  144. } else if (document.msExitFullscreen) { /* IE/Edge */
  145. document.msExitFullscreen();
  146. }
  147. };
  148. function initMultiWindows(){
  149. return;
  150. document.addEventListener('fullscreenchange', function() {
  151. if (isFullScreen()) {
  152. console.log("Fullscreen mode activated.");
  153. } else {
  154. console.log("Fullscreen mode deactivated.");
  155. }
  156. });
  157. document.addEventListener("fullscreenerror", (event) => {
  158. console.log("Fullscreen Error.");
  159. });
  160. if( mWindowID == 0 ){
  161. } else {
  162. //Unreg Windows
  163. mAuxWindows = undefined;
  164. window.addEventListener('beforeunload', function(event) {
  165. console.log("BeforeUnload Woerks!");
  166. //event.preventDefault();
  167. //event.returnValue = null;
  168. });
  169. };
  170. doCheckWindowSize();
  171. };