// var ssSeconds = 0; var ssOldSeconds = 0; function ssShowSS() { ssStopTimer(); document.removeEventListener( "mousemove", ssResetTimer ); document.removeEventListener( "mousedown", ssResetTimer ); document.removeEventListener( "keypress", ssResetTimer ); document.removeEventListener( "touchmove", ssResetTimer ); document.addEventListener( "mousemove", ssHideSS, false ); document.addEventListener( "mousedown", ssHideSS, false ); document.addEventListener( "keypress", ssHideSS, false ); document.addEventListener( "touchmove", ssHideSS, false ); document.getElementById('ss_bg').className='ss_bg_overlay'; document.getElementById('ss_content').className='ss_overlay'; ssSeconds = 0; ssOldSeconds = 0; ssShowTime(); if( ssInterval == null ){ ssInterval = window.setInterval( ssShowTime, 333 ); }; ssIsActive = true; }; function ssShowTime(){ document.getElementById('ss_content').style.fontSize = '240px'; var currentdate = new Date(); if( ssOldSeconds == 0 ){ ssOldSeconds = currentdate.getSeconds(); } else { if( ssOldSeconds != currentdate.getSeconds() ) { ssOldSeconds = currentdate.getSeconds(); ssSeconds++; }; }; if( ssSeconds > 300 ){ document.getElementById('ss_content').style.color = '#606060'; } else { document.getElementById('ss_content').style.color = '#c0c0c0'; }; var cTime = (( currentdate.getHours()<10 )? '0'+currentdate.getHours(): currentdate.getHours() ) + ":" + (( currentdate.getMinutes()<10 )? '0'+currentdate.getMinutes(): currentdate.getMinutes() ) + ":" + (( currentdate.getSeconds()<10 )? '0'+currentdate.getSeconds(): currentdate.getSeconds() ); document.getElementById('ss_content').innerHTML= cTime; }; function ssResetTimer() { ssStopTimer(); ssStartTimer(); }; function ssStartTimer() { if( ssTimer == null ){ ssTimer = window.setTimeout( ssShowSS, ssTimeOut ); }; }; function ssStopTimer() { if( ssTimer ){ window.clearTimeout( ssTimer ); ssTimer = null; }; }; function ssSetupTimer() { document.addEventListener( "mousemove", ssResetTimer, false); document.addEventListener( "mousedown", ssResetTimer, false); document.addEventListener( "keypress", ssResetTimer, false); document.addEventListener( "touchmove", ssResetTimer, false); ssStartTimer(); }; function ssHideSS(){ document.getElementById('ss_bg').className='ss_hidden'; document.getElementById('ss_content').className='ss_hidden'; document.removeEventListener( "mousemove", ssHideSS ); document.removeEventListener( "mousedown", ssHideSS ); document.removeEventListener( "keypress", ssHideSS ); document.removeEventListener( "touchmove", ssHideSS ); if( ssInterval != null ){ window.clearInterval( ssInterval ); ssInterval = null; }; ssSetupTimer(); ssIsActive = false; }; var sndBeep = null; var sndExcl = null; function playSound( t ){ if( SoundEnable ){ switch( t ){ case 1:{ if( sndBeep == null ) sndBeep = new Howl({ src: [ '/style/assets/audio/beep-07a.mp3', '/style/assets/audio/beep-07a.wav' ], loop: false, volume: 0.99, onend: function() { //console.log('Finished!'); } }); sndBeep.volume( SoundMode / 3 ); if( !sndBeep.playing() ) sndBeep.play(); break; }; default:{ if( sndExcl == null ) sndExcl = new Howl({ src: [ '/style/assets/audio/button-42.mp3', '/style/assets/audio/button-42.wav' ], loop: false, volume: 0.99 }); sndExcl.volume( SoundMode / 3 ); if( !sndExcl.playing() ) sndExcl.play(); }; }; }; }; function doRefresh(){ if( mWindowID ){ window.location="/?w="+mWindowID+"&t=" + uuidv4(); } else { refreshAuxWindows(); window.location="/?t=" + uuidv4(); }; }; function doLogout(){ if( mWindowID ){ window.location = '/login.php?w='+mWindowID+'&UID=1'; } else { closeAuxWindows(); window.location = '/login.php?UID=1'; }; }; function stopStatusUpdater(){ if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; }; }; function failureAJAXFunction( responce, opts ){ if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; }; doLogout(); }; function updateUserScreenResolution( x, y ){ Ext.Ajax.request({ url: '/lib/controller/updateUserSettings.php', params: { UID: , SID: '', SSS: 15, WID: x, HEI: y }, success: function( response, opts ){ doRefresh(); }, failure: failureAJAXFunction }); }; function setUserContent( c_id ){ initView = c_id; Ext.Ajax.request({ url: '/lib/controller/updateUserSettings.php', params: { UID: , SID: '', SSS: 26, CID: initView }, success: function(){ content_lvl0 = Math.floor( initView / 1000 ); content_lvl1 = Math.floor( ( initView % 1000 )/ 100 ); content_lvl2 = Math.floor( ( initView % 100 )/ 10 ); content_lvl3 = initView % 10; }, failure: failureAJAXFunction }); }; function updateUserContent(){ cid = content_lvl3 + content_lvl2 * 10 + content_lvl1*100 + content_lvl0*1000; if( initView != cid ) { setUserContent( cid ); return true; }; return false; }; var gSessionValidatorInterval = null; function sessionValidator(){ var cTS = (new Date())/1000; Ext.Ajax.request({ url: '/lib/controller/validateUserSession.php', params: { UID: , SID: '', CTS: cTS }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( !data.sessionIsValid ){ playSound(); Ext.Msg.show({ title:'GetLabel('_REQ_FAILURE_');?>', msg: 'GetLabel('_AJX_REQFAILURE_');?>', buttons: Ext.Msg.OK, icon: Ext.MessageBox.INFO, fn: doLogout }); }; }, failure: failureAJAXFunction }); }; var NotificationStack = null; function tryKeepScreenAlive(minutes) { navigator.wakeLock.request("screen").then(lock => { setTimeout(() => lock.release(), minutes * 60 * 1000); }); } function showContent( cid ){ var lvl0 = Math.floor( cid / 1000 ); var lvl1 = Math.floor( ( cid % 1000 )/ 100 ); var lvl2 = Math.floor( ( cid % 100 )/ 10 ); var lvl3 = cid % 10; var refresh = ( lvl0 != content_lvl0 ); if( lvl3 != content_lvl3 ){ content_lvl3 = lvl3; }; if( lvl2 != content_lvl2 ){ content_lvl2 = lvl2; }; if( lvl1 != content_lvl1 ){ content_lvl1 = lvl1; }; if( lvl0 != content_lvl0 ){ content_lvl0 = lvl0; }; updateUserContent(); if( refresh ){ switch( content_lvl0 ){ case 0:{ var tt = Ext.getCmp('tbtn_0'); tt.toggle( true, true ); tt = Ext.getCmp('tbtn_1'); tt.toggle( false, true ); tt = Ext.getCmp('tbtn_2'); tt.toggle( false, true ); var tP = Ext.getCmp('left_side_menu'); tP.setVisible( false ); var tZ = Ext.getCmp('right_side_menu'); tZ.setVisible( false ); initMonitoring(); Ext.getCmp('main_viewport').doLayout(); break; }; case 1:{ var tt = Ext.getCmp('tbtn_0'); tt.toggle( false, true ); tt = Ext.getCmp('tbtn_1'); tt.toggle( true, true ); tt = Ext.getCmp('tbtn_2'); tt.toggle( false, true ); var tP = Ext.getCmp('left_side_menu'); tP.setVisible( true ); var tZ = Ext.getCmp('right_side_menu'); tZ.setVisible( false ); initReportsView(); Ext.getCmp('main_viewport').doLayout(); break; }; case 2:{ var tt = Ext.getCmp('tbtn_0'); tt.toggle( false, true ); tt = Ext.getCmp('tbtn_1'); tt.toggle( false, true ); tt = Ext.getCmp('tbtn_2'); tt.toggle( true, true ); var tP = Ext.getCmp('left_side_menu'); tP.setVisible( true ); var tZ = Ext.getCmp('right_side_menu'); tZ.setVisible( false ); initSettingsView(); Ext.getCmp('main_viewport').doLayout(); break; }; }; }; }; Ext.onReady(function(){ document.body.style.userSelect = 'none'; document.body.style.webkitUserSelect = 'none'; document.addEventListener('selectstart', (e) => { e.preventDefault(); }); document.addEventListener('dragstart', (e) => { e.preventDefault(); }); if ('wakeLock' in navigator) { // Screen Wake Lock API supported tryKeepScreenAlive(10); }; doCheckWindowSize(); //initMultiWindows(); loadSystemDevices(); gSessionValidatorInterval = window.setInterval( sessionValidator, 10000 ); NotificationStack = new PNotify.Stack({dir1: 'down', firstpos1: 25}); window.onresize = doCheckWindowSize; Ext.QuickTips.init(); if( ssEnabled ){ ssSetupTimer(); $(window).focus(function() { ssResetTimer(); }); $(window).blur(function() { ssStopTimer(); }); }; if( mWindowID == 0 ){ var viewport = new Ext.Viewport({ id: 'main_viewport', layout:'border', frame: false, border: false, items: [{ xtype: 'panel', region: 'north', baseCls: 'x-plain', height: 60, //layout: 'fit', layout: 'hbox', frame: false, border: false, items:[{ xtype: 'panel', width: '100%', layout: 'table', baseCls: 'x-plain', layoutConfig: { columns: 13 }, frame: false, border: true, margins: {top:10, right:10, bottom:10, left:10}, items:[{ xtype: 'panel', baseCls: 'x-plain', frame: false, border: false, margins: {top:5, right:20, bottom:0, left:20}, html: '' },{ xtype: 'spacer', width: 10 },{ xtype: 'button', text: 'GetLabel('_MONITORING_');?>', id: 'tbtn_0', iconCls: 'mon', scale: 'large', enableToggle: true, //pressed: (Math.floor(initView/100)==0), allowDepress: false, toggleGroup: 'gopa_gopa', toggleHandler: function( bt, state ){ if( state ) showContent( 0 ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'button', text: 'GetLabel('_REPO_HISTORY_');?>', id: 'tbtn_1', iconCls: 'rep', scale: 'large', enableToggle: true, //pressed: (Math.floor(initView/100)==1), allowDepress: false, toggleGroup: 'gopa_gopa', toggleHandler: function( bt, state ){ if( state ) showContent( 1000 ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'button', text: 'GetLabel('_SETTINGS_');?>', id: 'tbtn_2', iconCls: 'cog', scale: 'large', enableToggle: true, allowDepress: false, toggleGroup: 'gopa_gopa', toggleHandler: function( bt, state ){ if( state ) showContent( 2000 ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'panel', baseCls: 'x-plain', frame: false, border: false, margins: {top:5, right:0, bottom:0, left:0}, width: PanelW - Data['language']) == 4)?'-90':'';?>, html: '

'+ap_title+'

' },{ xtype: 'spacer', width: 10 },{ xtype: 'button', id: 'logout_btn', text: 'Logout', iconCls: 'lout', scale: 'large', style:'text-align: right;', handler: doLogout }{ xtype: 'button', id: 'snd_mode_btn', text: 'GetLabel('_SOUND_');?>', iconCls: 'snd'+SoundMode, scale: 'large', style:'text-align: right;', handler: function(){ if( SoundMode == 0 ){ SoundMode = 3; SoundEnable = true; } else { SoundMode --; if( SoundMode == 0 ) SoundEnable = false; }; Ext.getCmp('snd_mode_btn').setIconClass( 'snd'+SoundMode ); playSound(); doApplicationOperation( 6, SoundMode ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'button', id: 'logout_btn', text: 'GetLabel('_LOGOUT_');?>', iconCls: 'lout', scale: 'large', style:'text-align: right;', handler: doLogout } ] }] },{ xtype: 'panel', id:'left_side_menu', region:'west', bsaseCls:'x-plain', layout: 'fit', collapsible: true, split: true, width: 180, minWidth: 180, maxWidth: 180, hidden: (Math.floor(initView/100)==0), margins: '5 0 5 5', cmargins:'5 5 5 5', items: [] },{ xtype: 'panel', region:'center', margins: '5 5 5 0', id: 'main_content', //title: 'GetLabel('_SYS_DASHBOARD_');?>', items:[{ xtype: 'portal', id: 'main_portal', frame: false, border: false, items:{ html: '' }//, //listeners:{ // drop: function( a ){ // updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position ); // } //} }] },{ xtype: 'panel', region:'east', id:'right_side_menu', //title: '', margins: '5 5 5 0', //id: 'help_content', frame: false, border: false, collapsible: false, split:true, width:200, minWidth: 150, maxWidth: 200, items:[] }] }); } else { var viewport = new Ext.Viewport({ id: 'main_viewport', layout:'border', frame: false, border: false, items: [{ xtype: 'panel', region: 'north', baseCls: 'x-plain', height: 60, //layout: 'fit', layout: 'hbox', frame: false, border: false, items:[{ xtype: 'panel', width: '100%', layout: 'table', baseCls: 'x-plain', layoutConfig: { columns: 10 }, frame: false, border: true, margins: {top:10, right:10, bottom:10, left:10}, items:[{ xtype: 'panel', baseCls: 'x-plain', frame: false, border: false, margins: {top:5, right:20, bottom:0, left:20}, html: '' },{ xtype: 'spacer', width: 10 },{ xtype: 'button', text: 'GetLabel('_MONITORING_');?>', id: 'tbtn_0', iconCls: 'mon', scale: 'large', menu:{ xtype: 'menu', activeItem: 0, items: [{ text: 'GetLabel('_MONITORING_');?>[0]'//, //iconCls: 'mon', //scale: 'large' },{ text: 'GetLabel('_MONITORING_');?>[1]'//, //iconCls: 'mon', //scale: 'large' }] }, enableToggle: true, //pressed: (Math.floor(initView/100)==0), allowDepress: false, toggleGroup: 'gopa_gopa', toggleHandler: function( bt, state ){ if( state ) showContent( 0 ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'button', text: 'GetLabel('_REPO_HISTORY_');?>', id: 'tbtn_1', iconCls: 'rep', scale: 'large', enableToggle: true, //pressed: (Math.floor(initView/100)==1), allowDepress: false, toggleGroup: 'gopa_gopa', toggleHandler: function( bt, state ){ if( state ) showContent( 1000 ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'button', text: 'GetLabel('_SETTINGS_');?>', id: 'tbtn_2', iconCls: 'cog', scale: 'large', enableToggle: true, allowDepress: false, toggleGroup: 'gopa_gopa', toggleHandler: function( bt, state ){ if( state ) showContent( 2000 ); } },{ xtype: 'spacer', width: 10 },{ xtype: 'panel', baseCls: 'x-plain', frame: false, border: false, margins: {top:5, right:0, bottom:0, left:0}, width: PanelW - Data['language']) == 4)?'-90':'';?>, html: '

'+ap_title+'

' },{ xtype: 'spacer', width: 10 }] }] },{ xtype: 'panel', id:'left_side_menu', region:'west', bsaseCls:'x-plain', layout: 'fit', collapsible: true, split: true, width: 180, minWidth: 180, maxWidth: 180, hidden: (Math.floor(initView/100)==0), margins: '5 0 5 5', cmargins:'5 5 5 5', items: [] },{ xtype: 'panel', region:'center', margins: '5 5 5 0', id: 'main_content', //title: 'GetLabel('_SYS_DASHBOARD_');?>', items:[{ xtype: 'portal', id: 'main_portal', frame: false, border: false, items:{ html: '' }//, //listeners:{ // drop: function( a ){ // updateDashBoardItemLayout( a.panel.id, a.columnIndex, a.position ); // } //} }] },{ xtype: 'panel', region:'east', id:'right_side_menu', //title: '', margins: '5 5 5 0', //id: 'help_content', frame: false, border: false, collapsible: false, split:true, width:200, minWidth: 150, maxWidth: 200, items:[] }] }); }; if( initView[mWindowID]!= undefined ){ showContent( initView[mWindowID] ); } else { initView[mWindowID] = 0; showContent( initView[mWindowID] ); }; });