// var monitoringViewLevel = 0; var monitoringActiveSession = false; var mon_selectedEventId = 0; var mon_selectedPlatform = 0; var mon_selectedStation = 0; var mon_selectedTrack = 0; var mon_selectedModule = 0; var autoRiseEvent = true; var activeEvents = []; var expiredEvents = []; function imgLoadEvent(){ alert('l c'); }; function createEventTagContent( a ){ var gif='green_2.gif'; var add=','+a.status; if( a.status == 0 ){ gif='red_2.gif'; }; if( mon_selectedEventId == a.id ){ return '
'; }; return '
'+a.station_name+'
'+a.platform_name+'
'+a.track_tag+'
'; }; var GREEN_Icon = L.icon({ iconUrl: '/style/assets/igr.png', iconSize: [44, 44], iconAnchor: [22, 22], popupAnchor: [0, -22] //shadowUrl: 'leaf-shadow.png', //shadowSize: [50, 64], // size of the shadow //shadowAnchor: [4, 62], // the same for the shadow }); var BLUE_Icon = L.icon({ iconUrl: '/style/assets/irs.png', iconSize: [44, 44], iconAnchor: [22, 22], popupAnchor: [0, -22] //shadowUrl: 'leaf-shadow.png', //shadowSize: [50, 64], // size of the shadow //shadowAnchor: [4, 62], // the same for the shadow }); var RED_Icon = L.icon({ iconUrl: '/style/assets/ira.png', iconSize: [44, 44], iconAnchor: [22, 22], popupAnchor: [0, -22] }); var REDB_Icon = L.icon({ iconUrl: '/style/assets/irabl.gif', iconSize: [44, 44], iconAnchor: [22, 22], popupAnchor: [0, -22] }); var GREY_Icon = L.icon({ iconUrl: '/style/assets/ign.png', iconSize: [44, 44], iconAnchor: [22, 22], popupAnchor: [0, -22] }); var GREYN_Icon = L.icon({ iconUrl: '/style/assets/ign.png', iconSize: [44, 44], iconAnchor: [22, 22], popupAnchor: [0, -22] }); function makePtzMove( me ){ var name = me.target.id; const myArray = name.split("_"); Ext.Ajax.request({ url: '/lib/controller/doModuleOperations.php', params: { UID: , SID: '', OPID: 8, MID: myArray[3], MOV: myArray[2] }, failure: failureAJAXFunction }); }; function makePtzStop( me ){ var name = me.target.id; const myArray = name.split("_"); Ext.Ajax.request({ url: '/lib/controller/doModuleOperations.php', params: { SITE: , UID: , SID: '', OPID: 8, MID: myArray[3], MOV: 0 }, failure: failureAJAXFunction }); }; function makePtzHome( me ){ var name = me.target.id; const myArray = name.split("_"); Ext.Ajax.request({ url: '/lib/controller/doModuleOperation.php', params: { SITE: , UID: , SID: '', OPID: 9, MID: myArray[3], MOV: 0 }, failure: failureAJAXFunction }); }; var fsDrawID = 0; function exitFullScreen( evt ){ if( document.fullscreenElement ){ } else { if( fsDrawID ){ console.log("Leaving fullscreen mode."); }; }; }; function fullScreen( id = '' ){ if( id == '' || document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement ){ if( document.exitFullscreen ){ document.exitFullscreen(); }else if( document.mozCancelFullScreen ){ document.mozCancelFullScreen(); }else if( document.webkitExitFullscreen ){ document.webkitExitFullscreen(); }else if( document.msExitFullscreen ){ document.msExitFullscreen(); }; if( fsDrawID ){ console.log('resized'); }; }else{ var element = document.getElementById( id ); if( element.requestFullscreen ){ element.requestFullscreen(); }else if( element.mozRequestFullScreen ){ element.mozRequestFullScreen(); }else if( element.webkitRequestFullscreen ){ element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); }else if( element.msRequestFullscreen ){ element.msRequestFullscreen(); }; }; }; function loadStationViewEvt( e ){ loadStationView( e.target.options.mycustomid ); }; function loadStationView( STT, buba ){ if( buba == undefined ){ autoRiseEvent = false; } else { autoRiseEvent = buba; }; if( mon_selectedEventId ) unselectEvent(); mon_selectedStation = STT; changeContent( 1, 1, mon_selectedStation ); updateUserContent(); Ext.Ajax.request({ url: '/lib/controller/getMonitoringStationView.php', params: { STT: mon_selectedStation, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 1; Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); if( data.pids != undefined ){ if( data.pids.length > 0 ){ //for( i=0; i, SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ var tv = Ext.getCmp('trx_view'); if( tv != undefined ){ var tt = Ext.getCmp('sets_ui'); if( tt != undefined ){ tv.remove( tt ); }; tv.add( Ext.decode( data.content ) ); tv.doLayout(); }; }; }//, //failure: failureAJAXFunction }); }; function doSessionOperation( session_id, op, param, reload ){ Ext.Ajax.request({ url: '/lib/controller/doSessionOperations.php', params: { SESSION: session_id, OPID: op, OPAR: param, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ if( reload ){ }; }; }, failure: failureAJAXFunction }); }; function loadPlatformView( pid, buba ){ if( buba == undefined ){ autoRiseEvent = false; } else { autoRiseEvent = buba; }; if( mon_selectedEventId ) unselectEvent( mon_selectedEventId ); mon_selectedPlatform = pid; changeContent( 1, 2, pid ); updateUserContent(); Ext.Ajax.request({ url: '/lib/controller/getMonitoringPlatformView.php', params: { PID: mon_selectedPlatform, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 2; Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); correctPlatformView( data.pid ); fetchStatus(); }; }, failure: failureAJAXFunction }); return; }; function loadTrackViewBySession( session_id ){ autoRiseEvent = false; mSvgElements = []; Ext.Ajax.request({ url: '/lib/controller/getMonitoringTrackView.php', params: { SESSION: session_id, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 3; mon_selectedTrack = data.track_id; changeContent( 1, 3, mon_selectedTrack ); updateUserContent(); Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); tt=document.getElementById('trx_status_txt'); tt.classList.remove('static_status_text'); tt.classList.add('blinking_status_text'); tt.innerText = 'ACTIVE'; tt=document.getElementById('trx_status_cell'); tt.classList.remove('top_status_hidden'); tt.classList.add('top_status_red_lbl'); monitoringActiveSession = true; fetchStatus(); }; }, failure: failureAJAXFunction }); return; }; function loadTrackView( tid ){ autoRiseEvent = false; mon_selectedTrack = tid; changeContent( 1, 3, mon_selectedTrack ); updateUserContent(); mSvgElements = []; Ext.Ajax.request({ url: '/lib/controller/getMonitoringTrackView.php', params: { TID: mon_selectedTrack, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 3; mon_selectedPlatform = data.platform_id; mon_selectedStation = data.station_id; Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); tt=document.getElementById('trx_status_txt'); tt.innerText = 'LIVE VIEW'; monitoringActiveSession = false; tt=document.getElementById('trx_status_cell'); tt.classList.remove('top_status_hidden'); tt.classList.add('top_status_green_lbl'); fetchStatus(); }; }, failure: failureAJAXFunction }); return; }; function loadModuleView( pid, mid ){ autoRiseEvent = false; if( mon_selectedEventId ) unselectEvent( mon_selectedEventId ); changeContent( 1, 4, pid+'-'+mid ); updateUserContent(); Ext.Ajax.request({ url: '/lib/controller/getMonitoringModuleView.php', params: { PID: pid, MID: mid, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 4; Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); correctModuleView( mid ); fetchStatus(); }; }, failure: failureAJAXFunction }); return; }; function loadMapView(){ autoRiseEvent = false; if( mon_selectedEventId ) unselectEvent( mon_selectedEventId ); Ext.Ajax.request({ url: '/lib/controller/getMonitoringMapView.php', params: { UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 0; Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); }; }, failure: failureAJAXFunction }); return; }; var monitoring_map = null; var c_icon = null; var stationMarkers = []; function initMonitoringMap( map_id, x, y ){ var mapLayers = []; if( monitoring_map != null ){ monitoring_map.off(); monitoring_map.remove(); monitoring_map = null; }; monitoring_map = L.map( map_id,{ crs: L.CRS.Simple, attributionControl: false, preferCanvas: true, zoomControl: true, center: [x,y], zoom: 0, minZoom: -3, maxZoom: 0, keyboard: false }); var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]]; var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( monitoring_map ); Ext.Ajax.request({ url: '/lib/controller/listStations.php', params: { UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ for( i=0; i < data.stations.length; i++ ){ stationMarkers[ data.stations[i].id ] = L.marker([data.stations[i].y, data.stations[i].x], { draggable: false, icon: GREY_Icon, zIndexOffset: 1000, mycustomid: data.stations[i].id } ).addTo( monitoring_map ).on('click', loadStationViewEvt );; }; }; // Ready -> Start Getting data fetchStatus(); }, failure: failureAJAXFunction }); }; function getBackToMap(){ autoRiseEvent = true; changeContent( 1, 0 ); updateUserContent(); loadMapView(); }; function initMonitoring( x, y ){ if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; timelineObj = null; }; var tP = Ext.getCmp('left_side_menu'); tP.removeAll( true ); tP.add({ layout:'vbox', frame: false, border: false, items:[{ width: "100%", height: 42, html: '
Active Alerts
' },{ id: 'sme_inner', //layout:'vbox', width: "100%", height: PanelH/2-24, frame: false, border: false, autoScroll: true, cls: 'thin-scrollbar',//'hide-scrollbar', // Apply the CSS class items:[], listeners: { render: function(p) { p.body.on('scroll', function(e, t) { if (t.scrollTop + t.clientHeight >= t.scrollHeight) { console.log('A Scrolled to end!'); // Handle reaching the bottom here }; }); } } },{ width: "100%", height: 42, html: '
Expired Alerts
' },{ id: 'sme_outer', //layout:'vbox', width: "100%", height: PanelH/2-24, frame: false, border: true, autoScroll: true, cls: 'thin-scrollbar',//'hide-scrollbar', // Apply the CSS class items:[], listeners: { render: function(p) { p.body.on('scroll', function(e, t) { if (t.scrollTop + t.clientHeight >= t.scrollHeight) { console.log('E Scrolled to end!'); // Handle reaching the bottom here }; }); } } }] }); tP.doLayout(); monitoringViewLevel = contentView.l[1].v; switch( monitoringViewLevel ){ case 0:{ loadMapView(); break; }; case 1:{ loadStationView( parseInt( contentView.l[1].p ), autoRiseEvent ); break; }; case 2:{ loadPlatformView( parseInt( contentView.l[1].p ), autoRiseEvent ); break; }; case 3:{ loadTrackView( parseInt( contentView.l[1].p ), autoRiseEvent ); break; }; case 4:{ var tA = contentView.l[1].p.split('-'); a = parseInt( tA[0] ); b = parseInt( tA[1] ); loadModuleView( a, b ); break; }; case 5:{ selectEvent( parseInt( contentView.l[1].p ), true ); break; }; }; Ext.getCmp('main_content').doLayout(); }; var statusLTS = 0; var statusLID = 0; function manageSideTags( tag_area, buba ){ var tP = Ext.getCmp( tag_area ); if( tP != undefined ){ if( buba != undefined ){ if( buba.length ){ var idx_a = 0; //alert( tag_area + ' has '+tP.items.getCount() ); while( a = tP.getComponent( idx_a ) ){ var f=false; for( var zz=0; zz < buba.length; zz++ ){ if( a.getId() == 'tag_panel_'+buba[zz].id ){ f = true; break; }; }; if( !f ) { tt--; tP.remove( a, true ); } else idx_a++; }; tP.doLayout(); var aa = tP.items.getRange(); var tt = aa.length; for( var zz=0; zz < buba.length; zz++ ){ var f=false; for( var i=0; i < aa.length; i++ ){ if( aa[i].getId() == 'tag_panel_'+buba[zz].id ){ f = true; break; }; }; if( !f ){ tP.insert( 0,{ id: 'tag_panel_'+buba[zz].id, width: "100%", html: createEventTagContent( buba[zz] ) }); tt++; }; if( tt > 32 ){ tP.remove( aa[31], true ); tt--; }; }; if( tag_area == 'sme_inner' ){ // Active activeEvents = []; for( var zz=0; zz < buba.length; zz++ ) activeEvents[zz]={id: buba[zz].id}; } else { // Expired expiredEvents = []; for( var zz=0; zz < buba.length; zz++ ) expiredEvents[zz]={id: buba[zz].id}; }; } else { tP.removeAll( true ); if( tag_area == 'sme_inner' ){ // Active activeEvents = []; } else { // Expired expiredEvents = []; }; }; } else { tP.removeAll( true ); if( tag_area == 'sme_inner' ){ // Active activeEvents = []; } else { // Expired expiredEvents = []; }; }; tP.doLayout(); }; }; var mSvgElements = []; function fetchStatus(){ if( tlInterval!= null ){ window.clearTimeout( tlInterval ); tlInterval = null; }; switch(monitoringViewLevel){ case 0:{ var ll = monitoring_map.getCenter(); CX = ll.lat; CY = ll.lng; ajax_params = { VLVL: monitoringViewLevel, UID: , SID: '', LTS: statusLTS, LID: statusLID, MX: CX, MY: CY }; break; }; case 1:{ ajax_params = { VLVL: monitoringViewLevel, UID: , SID: '', LTS: statusLTS, LID: statusLID, SSID: mon_selectedStation }; break; }; case 2:{ ajax_params = { VLVL: monitoringViewLevel, UID: , SID: '', PID: mon_selectedPlatform, LTS: statusLTS, LID: statusLID }; break; }; case 3:{ ajax_params = { VLVL: monitoringViewLevel, UID: , SID: '', TID: mon_selectedTrack, LTS: statusLTS, LID: statusLID }; break; }; case 4:{ ajax_params = { VLVL: monitoringViewLevel, UID: , SID: '', MID: mon_selectedModule, LTS: statusLTS, LID: statusLID }; break; }; case 5:{ ajax_params = { VLVL: monitoringViewLevel, UID: , SID: '', SESSION: mon_selectedEventId, LTS: statusLTS, LID: statusLID }; break; }; }; Ext.Ajax.request({ url: '/lib/controller/getStatus.php', params: ajax_params, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ if( monitoringViewLevel == data.VLVL ){ statusLTS = data.LTS; if( autoRiseEvent ){ if( data.active_session_id != undefined ){ if( data.active_session_id > 0 ){ if( ssIsActive ) ssHideSS(); if( data.active_session_id != mon_selectedEventId ){ playSound( 1 ); selectEvent( data.active_session_id, false ); return; }; }; }; }; //debugger; switch( monitoringViewLevel ){ case 0:{ //Map for( i=0; i < data.station_ids.length; i++ ){ switch( data.station_status[i] ){ case 0: { if( stationMarkers[data.station_ids[i]].options.icon != GREY_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREY_Icon ); break; }; case 1: { if( stationMarkers[data.station_ids[i]].options.icon != BLUE_Icon ) stationMarkers[data.station_ids[i]].setIcon( BLUE_Icon ); break; }; case 2: { if( stationMarkers[data.station_ids[i]].options.icon != GREEN_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREEN_Icon ); break; }; case 3: { if( ( Math.floor(Date.now() / 1000) % 2 ) == 0 ) { if( stationMarkers[data.station_ids[i]].options.icon != GREEN_Icon ) stationMarkers[data.station_ids[i]].setIcon( GREEN_Icon ); } else { if( stationMarkers[data.station_ids[i]].options.icon != RED_Icon ) stationMarkers[data.station_ids[i]].setIcon( RED_Icon ); }; break; }; case 4: { if( stationMarkers[data.station_ids[i]].options.icon != REDB_Icon ) stationMarkers[data.station_ids[i]].setIcon( REDB_Icon ); break; }; }; }; break; }; case 1:{ //Platforms if( data.platforms != undefined ){ for( i=0; i< data.platforms.length; i++ ){ var tt = document.getElementById( 'plat_table_'+data.platforms[i].id ); if( data.platforms[i].status == 1 ){ if( tt.classList.contains('active_green') ){ tt.classList.remove('active_green'); tt.classList.add('active_red'); }; } else { if( tt.classList.contains('active_red') ){ tt.classList.remove('active_red'); tt.classList.add('active_green'); }; }; if( data.platforms[i].modules != undefined ){ for( j=0; j 0 ){ var tt = document.getElementById('plat_video_'+mon_selectedPlatform+'_'+data.modules[i].id ); if( tt != undefined ){ //if( tt.src != data.modules[i].img ) tt.src = data.modules[i].img; }; tt = document.getElementById('plat_status_'+mon_selectedPlatform+'_'+data.modules[i].id ); if( tt != undefined ){ switch( data.modules[i].status ){ case 1: tt.innerHTML=''; break; case 2: tt.innerHTML=''; break; case 3: tt.innerHTML=''; break; }; }; }; }; }; if( data.scada != undefined ){ var tt = document.getElementById('scada_status'); switch( data.scada.status ){ case 0:{ tt.innerHTML='GetLabel('_NOT_ASSIGNED_');?>'; tt.setAttribute('class', 'mon_scada_status_tag_na'); tt = document.getElementById('scada_a'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_b'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_c'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_d'); tt.setAttribute('class', 'mon_scada_head'); break; }; case 1:{ tt.innerHTML='GetLabel('__DISABLED__');?>'; tt.setAttribute('class', 'mon_scada_status_tag_na'); tt = document.getElementById('scada_a'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_b'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_c'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_d'); tt.setAttribute('class', 'mon_scada_head'); break; }; case 2:{//offline tt.innerHTML='GetLabel('__OFFLINE__');?>'; tt.setAttribute('class', 'mon_scada_status_tag_na'); tt = document.getElementById('scada_a'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_b'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_c'); tt.setAttribute('class', 'mon_scada_head'); tt = document.getElementById('scada_d'); tt.setAttribute('class', 'mon_scada_head'); break; }; case 3:{//online tt.innerHTML='GetLabel('__ONLINE__');?>'; tt.setAttribute('class', 'mon_scada_status_tag_ok'); tt = document.getElementById('scada_a'); if( data.scada.A ){ tt.setAttribute('class', 'mon_scada_head_active'); } else { tt.setAttribute('class', 'mon_scada_head_ok'); }; tt = document.getElementById('scada_b'); if( data.scada.B ){ tt.setAttribute('class', 'mon_scada_head_active'); } else { tt.setAttribute('class', 'mon_scada_head_ok'); }; tt = document.getElementById('scada_c'); if( data.scada.C ){ tt.setAttribute('class', 'mon_scada_head_active'); } else { tt.setAttribute('class', 'mon_scada_head_ok'); }; tt = document.getElementById('scada_d'); if( data.scada.D ){ tt.setAttribute('class', 'mon_scada_head_active'); } else { tt.setAttribute('class', 'mon_scada_head_ok'); }; break; }; }; }; if( data.events != undefined ){ var sid = data.events.length - 1; if( sid > -1 ){ for( var i=0; i< max_grad_levels; i++ ){ var cid = sid-i; var csize = getSize( i ); //debugger; if( typeof mSvgElements[i] === 'undefined') { if( cid > -1 ){ var svgns = "http://www.w3.org/2000/svg"; mSvgElements[i] = document.createElementNS(svgns, 'rect'); mSvgElements[i].setAttribute('x', data.events[cid].x+'%'); mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); mSvgElements[i].setAttribute('height', ''+csize); mSvgElements[i].setAttribute('width', ''+csize); mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i)); var tt = document.getElementById('svgTrackMap'); var zz = document.getElementById('scheme_anch'); tt.insertBefore( mSvgElements[i], zz ); //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]); }; } else { if( cid > -1 ){ mSvgElements[i].setAttribute('x', data.events[cid].x+'%'); mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); mSvgElements[i].setAttribute('height', ''+csize); mSvgElements[i].setAttribute('width', ''+csize); mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) ); } else { mSvgElements[i].setAttribute('fill', '#FF000000'); }; }; }; } else for( var i=0; i< max_grad_levels; i++ ) if( typeof mSvgElements[i] !== 'undefined') mSvgElements[i].setAttribute('fill', '#FF000000'); }; if( data.scada != undefined ){ }; break; }; case 3:{ // Track if( data.active_session_id != undefined ){ if( data.active_session_id > 0 ){ if( mon_selectedEventId != data.active_session_id ){ mon_selectedEventId = data.active_session_id; monitoringActiveSession = true; for( var zz=0; zz< activeEvents.length; zz++ ){ var tP = document.getElementById('event_tag_'+activeEvents[zz].id ); if( tP != undefined ){ tP.className =''; if( activeEvents[zz].id == mon_selectedEventId ){ tP.classList.add("evt_side_tag_selected"); } else { tP.classList.add("evt_side_tag"); }; }; }; addSetSessionUI( mon_selectedEventId ); tt=document.getElementById('trx_status_txt'); tt.classList.remove('static_status_text'); tt.classList.add('blinking_status_text'); tt.innerText = 'ACTIVE'; tt=document.getElementById('trx_status_cell'); tt.classList.remove('top_status_hidden'); tt.classList.remove('top_status_green_lbl'); tt.classList.add('top_status_red_lbl'); }; } else { if( mon_selectedEventId ){ mon_selectedEventId = 0; monitoringActiveSession = false; tt=document.getElementById('trx_status_txt'); tt.classList.remove('blinking_status_text'); tt.classList.add('static_status_text'); tt.innerText = 'LIVE VEW'; tt=document.getElementById('trx_status_cell'); tt.classList.remove('top_status_hidden'); tt.classList.remove('top_status_red_lbl'); tt.classList.add('top_status_green_lbl'); }; }; }; if( data.modules != undefined ){ for( var i=0; i< data.modules.length; i++){ if( data.modules[i].status > 0 ){ var tt = document.getElementById('plat_video_img_'+data.modules[i].id ); if( tt != undefined ){ if( tt.src != data.modules[i].img ) tt.src = data.modules[i].img; }; //tt = document.getElementById('plat_status_'+mon_selectedPlatform+'_'+data.modules[i].id ); tt = document.getElementById('cam_ctrl_'+data.modules[i].id ); if( tt != undefined ){ if( data.modules[i].status > 1 ) { if( tt.style.display != 'block' )tt.style.display = 'block'; } else { if( tt.style.display != 'none' )tt.style.display = 'none'; }; }; }; }; }; if( data.events != undefined ){ var sid = data.events.length - 1; if( sid > -1 ){ for( var i=0; i< max_grad_levels; i++ ){ var cid = sid-i; var csize = getSize( i ); //debugger; if( typeof mSvgElements[i] === 'undefined') { if( cid > -1 ){ var svgns = "http://www.w3.org/2000/svg"; mSvgElements[i] = document.createElementNS(svgns, 'rect'); mSvgElements[i].setAttribute('x', data.events[cid].x+'%'); mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); mSvgElements[i].setAttribute('height', ''+csize); mSvgElements[i].setAttribute('width', ''+csize); mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i)); var tt = document.getElementById('svgTrackMap'); var zz = document.getElementById('scheme_anch'); tt.insertBefore( mSvgElements[i], zz ); //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]); }; } else { if( cid > -1 ){ mSvgElements[i].setAttribute('x', data.events[cid].x+'%'); mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); mSvgElements[i].setAttribute('height', ''+csize); mSvgElements[i].setAttribute('width', ''+csize); mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) ); } else { mSvgElements[i].setAttribute('fill', '#FF000000'); }; }; }; } else for( var i=0; i< max_grad_levels; i++ ) if( typeof mSvgElements[i] !== 'undefined') mSvgElements[i].setAttribute('fill', '#FF000000'); }; if( data.scada != undefined ){ }; break; }; }; var tt = document.getElementById('a_title'); if( tt != null ){ if( data.actual_count > 0 ){ tt.innerHTML = 'Active Alerts
['+data.actual_count+']'; } else { tt.innerHTML = 'Active Alerts'; }; manageSideTags('sme_inner', data.actual ); }; if( tt != null ){ tt = document.getElementById('e_title'); if( data.expired_count > 0 ){ tt.innerHTML = 'Expired Alerts
['+data.expired_count+']'; } else { tt.innerHTML = 'Expired Alerts'; }; manageSideTags('sme_outer', data.expired ); }; }; }; if( contentView.l[0].v == 0 ){ tlInterval = window.setTimeout( fetchStatus, 333, selectedSite ); }; }, failure: failureAJAXFunction }); }; function selectEvent( ii, bb ){ mon_selectedEventId = ii; if( tlInterval!= null ){ window.clearTimeout( tlInterval ); tlInterval = null; }; for( var zz=0; zz< expiredEvents.length; zz++ ){ var tP = document.getElementById('event_tag_'+expiredEvents[zz].id ); if( tP != undefined ){ tP.className =''; if( expiredEvents[zz].id == mon_selectedEventId ){ monitoringActiveSession = false; tP.classList.add("evt_side_tag_selected"); } else { tP.classList.add("evt_side_tag"); }; }; }; for( var zz=0; zz< activeEvents.length; zz++ ){ var tP = document.getElementById('event_tag_'+activeEvents[zz].id ); if( tP != undefined ){ tP.className =''; if( activeEvents[zz].id == mon_selectedEventId ){ monitoringActiveSession = true; tP.classList.add("evt_side_tag_selected"); } else { tP.classList.add("evt_side_tag"); }; }; }; if( bb ){ loadMonitoringSessionView( ii ); } else { loadTrackViewBySession( ii ); }; }; function setSessionStatus( a , b, autoremove ){ if( autoremove ) alert( 'Autoremove' ); Ext.Ajax.request({ url: '/lib/controller/doSessionOperations.php', params: { SESSION: a, OPID: 2, OPAR: b, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ var tv = Ext.getCmp('trx_view'); if( tv != undefined ){ var tt = Ext.getCmp('sets_ui'); if( tt != undefined ){ tv.remove( tt ); }; tv.add( Ext.decode( data.content ) ); tv.doLayout(); }; }; }, failure: failureAJAXFunction }); }; function unselectEvent( ii ){ mon_selectedEventId = 0; for( var zz=0; zz< activeEvents.length; zz++ ){ var tP = document.getElementById('event_tag_'+activeEvents[zz].id ); if( tP != undefined ){ tP.className =''; tP.classList.add("evt_side_tag"); }; }; for( var zz=0; zz< expiredEvents.length; zz++ ){ var tP = document.getElementById('event_tag_'+expiredEvents[zz].id ); if( tP != undefined ){ tP.className =''; tP.classList.add("evt_side_tag"); }; }; }; function loadMonitoringSessionView( session_id ){ autoRiseEvent = false; mon_selectedEventId = session_id; changeContent( 1, 5, mon_selectedEventId ); updateUserContent(); Ext.Ajax.request({ url: '/lib/controller/getMonitoringSessionView.php', params: { SESSION: mon_selectedEventId, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ monitoringViewLevel = 5; if( mSesPlay!= null ) { mSesPlay.dispose(); mSesPlay = null; }; Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); tt=document.getElementById('trx_status_txt'); //tt.classList.remove('static_status_text'); //tt.classList.add('blinking_status_text'); tt.innerText = 'EXPIRED'; tt=document.getElementById('trx_status_cell'); tt.classList.remove('top_status_hidden'); tt.classList.remove('top_status_red_lbl'); tt.classList.remove('top_status_green_lbl'); tt.classList.add('top_status_orange_lbl'); mSesPlay = new argusSessionPlayer( mon_selectedEventId ); mSesPlay.play(); fetchStatus(); }; }, failure: failureAJAXFunction }); }; var peerConnections = []; async function startWhepClient( video_id, ip_address, stream_id ){ const STREAM_PATH = stream_id; // 'stream_3'; // Replace with your stream name const MEDIAMTX_URL = 'http://'+ip_address+':8889/'+STREAM_PATH+'/whep'; // 1. Initialize the RTCPeerConnection //if( peerConnection == null ){ const peerConnection = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] // Standard STUN for local/NAT routing }); peerConnections[video_id] = peerConnection; //}; // 2. Set up media placeholders (MediaMTX requires transceivers before the offer) peerConnection.addTransceiver('video', { direction: 'recvonly' }); //peerConnection.addTransceiver('audio', { direction: 'recvonly' }); // 3. Handle incoming stream track peerConnection.ontrack = (event) => { var videoElement = document.getElementById( video_id ); if (videoElement && event.streams[0]) { videoElement.srcObject = event.streams[0]; } }; // 4. Create and set Local Description (Offer) const offer = await peerConnection.createOffer(); await peerConnection.setLocalDescription(offer); // 5. Send Offer to MediaMTX via HTTP POST const response = await fetch(MEDIAMTX_URL, { method: 'POST', headers: { 'Content-Type': 'application/sdp' }, body: peerConnection.localDescription.sdp }); if (!response.ok) { throw new Error(`MediaMTX WHEP signaling failed: ${response.statusText}`); } // 6. Set Remote Description (Answer) received from MediaMTX const answerSdp = await response.text(); await peerConnection.setRemoteDescription(new RTCSessionDescription({ type: 'answer', sdp: answerSdp })); }; function stopWhepClient( video_id, stream_id ){ if( peerConnections[video_id] != undefined ){ peerConnections[video_id].getReceivers().forEach( receiver => { if( receiver.track ){ receiver.track.stop(); } }); peerConnections[video_id].close(); delete( peerConnections[video_id] ); var videoElement = document.getElementById( video_id ); videoElement.srcObject = null; videoElement.load(); }; }
'+a.station_name+'
'+a.platform_name+'
'+a.track_tag+'