// var map = null; var selectedMarker = null; var timelineObj = null; var rep_selectedEventId = 0; var rep_selectedDateTS = 0; var rep_selectedStation = 0; var rep_selectedEvtTS = 0; // Calendar var CurrentDate=(new Date())/1000; var today=new Date(); var SY=1900+today.getYear(); var SMO=today.getMonth()+1; var SD=today.getDate(); var SelectedDay = SD; var Dates = new Array(); function CheckDate(D){ for(j_index=0;j_index GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate); loadCalendarDates(); }; function ShiftFWD(){ CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate); BuildCalendar(); SMO = GetMonthNum(CurrentDate); SY = GetYear(CurrentDate); if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate); loadCalendarDates(); }; function GetMonthName(UTS){ // Unix Time Stamp var MoNames= new Array(); MoNames[0]='January'; MoNames[1]='February'; MoNames[2]='March'; MoNames[3]='April'; MoNames[4]='May'; MoNames[5]='June'; MoNames[6]='July'; MoNames[7]='August'; MoNames[8]='September'; MoNames[9]='October'; MoNames[10]='November'; MoNames[11]='December'; CDate=new Date(); CDate.setTime(UTS*1000); CMo=CDate.getMonth(); return MoNames[CMo]; }; function GetMonthShift(UTS){ // Unix Time Stamp CDate=new Date(); CDate.setTime(UTS*1000); CDate.setTime((UTS-(CDate.getDate()-1)*86400)*1000); return CDate.getDay(); }; function GetMonthLength(UTS){ // Unix Time Stamp CDate=new Date(); CDate.setTime(UTS*1000); CD=CDate.getDate(); RetVal=31; CDate.setTime((UTS+(31-CD)*86400)*1000); if ( CDate.getDate()==31) return RetVal; RetVal=30; CDate.setTime((UTS+(30-CD)*86400)*1000); if ( CDate.getDate()==30) return RetVal; RetVal=29; CDate.setTime((UTS+(29-CD)*86400)*1000); if ( CDate.getDate()==29) return RetVal; RetVal=28; CDate.setTime((UTS+(28-CD)*86400)*1000); if ( CDate.getDate()==28) return RetVal; return -1; }; function GetMonthNum(UTS){ // Unix Time Stamp CDate=new Date(); CDate.setTime(UTS*1000); return CDate.getMonth()+1; }; function GetYear(UTS){ // Unix Time Stamp CDate=new Date(); CDate.setTime(UTS*1000); y=CDate.getYear(); if (y<100)y+=2000; if (y<200)y+=1900; return y; }; function GetDay(UTS){ // Unix Time Stamp CDate=new Date(); CDate.setTime(UTS*1000); y=CDate.getDate(); return y; }; function selectDate( m, d ){ SY = GetYear(CurrentDate); SMO = m; SD = d; SelectedDay = SD; getData( 'arch' ); }; function BuildCalendar( ){ Msh=GetMonthShift(CurrentDate); Mnm=GetMonthName(CurrentDate); Mln=GetMonthLength(CurrentDate); Mid=GetMonthNum(CurrentDate); Mye=GetYear(CurrentDate); InDTA=''; InDTA+=''; InDTA+=''; for(index=0;index'+(index-Msh+1).toString()+''; if( SD == index ){ InDTA+=''; } else { InDTA+=''; }; } else { if( SD == index ){ InDTA+=''; } else { InDTA+=''; }; }; if ((index+1)%7==0){ InDTA+=''; }; }; for(;(index)%7!=0;index++){ InDTA+=''; }; InDTA+='
'+Mnm+' '+Mye+'
SuMoTuWeThFrSa
'+(index-Msh+1).toString()+'
'+(index-Msh+1).toString()+'
'+(index-Msh+1).toString()+'
'+(index-Msh+1).toString()+'
 
'; tab=document.getElementById('calendar_TD'); tab.innerHTML=InDTA; }; function loadCalendarDates(){ Ext.MessageBox.wait("GetLabel('_Loading_Calo_');?>","GetLabel('_Please_Wait_');?>",{ width: '100%', hidden: true, progress: true, closable: false }); Ext.Ajax.request({ url: '/lib/controller/getEventDates.php', params: { NID: selecredActiveSourceFilter, UID: , SID: '', SYE: SY, SMO: SMO }, success: function( response, opts ){ Ext.MessageBox.hide(); var data = Ext.decode( response.responseText ); if( data.status == 'ok' ){ Dates = data.days; BuildCalendar(); //for( var i = 0; i < data.days.length; i++ ){ // //}; }; }, failure: function( response, opts ) { Ext.MessageBox.hide(); } }); }; var eventsListStore = new Ext.data.JsonStore({ root: 'log', totalProperty: 'totalCount', idProperty: 'id', remoteSort: true, fields: [{ name: 'id', type: 'int' },{ name: 'date', type: 'string' },{ name: 'time', type: 'string' },{ name: 'device', type: 'string' },{ name: 'event', type: 'int' },{ name: 'data', type: 'string', },{ name: 'has_target', type: 'boolean' },{ name: 'has_geo', type: 'boolean' },{ name: 'has_images', type: 'boolean' },{ name: 'images', type: 'Array' },{ name: 'dev_type', type: 'int' },{ name: 'geo', type: 'object' }] /*, proxy : new Ext.data.HttpProxy({ method: 'POST', prettyUrls: false, url: '/lib/controller/getEventRecords.php', headers: { UID: , SID: '', NID: 1 } })*/ }); var videosListStore = new Ext.data.JsonStore({ root: 'videos', // totalProperty: 'totalCount', idProperty: 'id', remoteSort: true, fields: [{ name: 'id', type: 'int' },{ name: 'sts', type: 'int' },{ name: 'ets', type: 'int' },{ name: 'side', type: 'string' },{ name: 'name', type: 'string', },{ name: 'fps', type: 'int', }] }); var EventPanelWindow = null; function showEventPanel(){ if( EventPanelWindow == null ){ EventPanelWindow = new Ext.Window({ modal: true, title: 'GetLabel("_EVENT_VIEWER_");?>', width: winW*0.66, height: winH*0.66, layout: 'fit', closeAction: 'hide', items:[{ title: 'Cameras', html:'koko', autoScroll: true, height: 320 },{ html: 'koko22', height: 320 }] }); }; EventPanelWindow .show(); }; function ModeRenderer(val){ var p1, p2, p3; if( ( val & 1 ) == 1 ){ p1 = 'Video Source'; } else { p1 = 'NO Video Source'; }; if( ( val & 2 ) == 2 ){ p2 = 'Audio Source'; } else { p2 = 'NO Audio Source'; }; if( ( val & 4 ) == 4 ){ p3 = 'PTZ Control'; } else { p3 = 'NO PTZ Control'; }; return p1+p2+p3; }; function LocRenderer( val ){ if( val ){ return 'Location'; }; return 'NO Location'; }; function PicRenderer( val ){ if( val ){ return ''; }; return ''; }; function EvtTypeRenderer( val ){ switch( val ){ case 6: return 'Device Enters Into Study Mode'; case 7: return 'Device Is BUSY'; case 8: return 'Flip Complete'; case 9: return 'Scan Complete'; case 10: case 11: case 12: case 13: case 14: return 'Target'; case 36: return 'Region Of Interest'; default: return 'Event ['+val+']'; }; }; var eventsListColModel_ops = { columns: [ {header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, {header: "Date",width: 100, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' }, {header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' }, {header: "Device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' }, {header: "Event", width: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer }, {header: "Info", width: 200, sortable: false, dataindex: 'data' }, {header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer }, {header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer } ], defaults: { sortable: true, menuDisabled: true, width: 100 }, listeners: { hiddenchange: function(cm, colIndex, hidden) { //saveConfig(colIndex, hidden); } } }; var SelectedRow = -1; var eventsListSelModel_ops = { singleSelect: true, listeners: { rowselect: function(sm, row, rec ) { loadEventProperties( rec.data ); SelectedEvent = rec.data.id; SelectedRow = row; //alert( SelectedEvent ); //var CB = Ext.getCmp('con_to_src'); //CB.enable(); } } }; function loadTimeLineGroups( NID ){ Ext.Ajax.request({ url: '/lib/controller/getTimeLineGroups.php', params: { NID: NID, UID: , SID: '' }, success: function( response, opts ){ // If the response is JSON, you have to decode it var data = Ext.decode(response.responseText); //for(var i = 0; i < data.length; i++) { //tlGroups.add(data[i]); //}; tlGroups.update( data ); loadTimeLineItems( SelectedSite ); tlInterval = window.setInterval( loadTimeLineItems, 333, SelectedSite ); }, failure: function( response, opts ) { //Ext.fly('some_div').update('Fail!'); }/*, callback: function(options,success,response){ // use this if you need to perform your own success/failure checking }*/ }); }; function clickDeviceSelector( id ){ var rr = document.getElementById(id+'_div'); if( selecredActiveSourceFilter != id ){ if( selecredActiveSourceFilter > 0 ){ var oo = document.getElementById( selecredActiveSourceFilter + '_div'); oo.classList.remove( "cardDeviceSourceSelected" ); oo.classList.add( "cardDeviceSource" ); }; rr.classList.remove( "cardDeviceSource" ); rr.classList.add( "cardDeviceSourceSelected" ); selecredActiveSourceFilter = id; turnOffAllGzButThis( selecredActiveSourceFilter ); } else { selecredActiveSourceFilter = 0; rr.classList.remove( "cardDeviceSourceSelected" ); rr.classList.add( "cardDeviceSource" ); turnAllGzOn(); var tPanel = Ext.getCmp('prop_content'); tPanel.remove(0); tPanel.add( { title: 'Event Information', border: false, frame: false, collapsible: false, draggable: false, html: '

Select an Event from TimeLine to See Information

' } ); tPanel.doLayout(); }; }; function getZoneByNode( nid ){ var rVal = -1; for( var i=0; i < ActiveZones.totalCount; i++ ){ if( ActiveZones.zones[i].dev_id == nid ){ rVal = i; break; }; }; return rVal; }; function turnOffAllGzButThis( nid ){ var chocho = -1; for( var i=0; i < ActiveZones.totalCount; i++ ){ if( ActiveZones.zones[i].dev_id == nid ) chocho = i; map.removeLayer( ActiveZones.fig[i] ); map.removeLayer( ActiveZones.zang[i] ); map.removeLayer( ActiveZones.center[i] ); }; if( chocho > -1 ){ map.addLayer( ActiveZones.fig[chocho] ); map.addLayer( ActiveZones.zang[chocho] ); map.addLayer( ActiveZones.center[chocho] ); var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) ); map.flyToBounds( cVisible.getBounds() ); }; }; function turnAllGzOn(){ var tall = Array(); for( var i=0; i < ActiveZones.totalCount; i++ ){ tall[i*3] = ActiveZones.fig[i]; tall[i*3+1] = ActiveZones.zang[i]; tall[i*3+2] = ActiveZones.center[i]; if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] ); if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] ); if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] ); }; var cVisible = L.featureGroup( tall ); map.flyToBounds( cVisible.getBounds() ); }; function loadMapZones( SID ){ Ext.Ajax.request({ url: '/lib/controller/getGeoZones.php', params: { SITE: SID, UID: , SID: '' }, success: function( response, opts ){ // If the response is JSON, you have to decode it var data = Ext.decode(response.responseText); var pp = Ext.getCmp('sources_panel'); if( typeof pp !== 'undefined' ) pp.removeAll(); ActiveZones = data; ActiveZones.fig = new Array(); ActiveZones.zang = new Array(); ActiveZones.center = new Array(); for(var i = 0; i < data.totalCount; i++ ) { switch( data.zones[i].type ){ case 'circle':{ //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map ); ActiveZones.fig[i] = new L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ); //map.addLayer( ActiveZones.fig[i] ); break; }; case 'poly':{ ActiveZones.fig[i] = new L.polygon( data.zones[i].points, {color: data.zones[i].color, dashArray: "4 1 2 3", weight: 1, opacity: 0.8, clickable: false, interactive: false, bubblingMouseEvents: false });//.addTo(map); //map.addLayer( ActiveZones.fig[i] ); break; }; case 'image':{ ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map ); //map.addLayer( ActiveZones.fig[i] ); break; }; case 'image_rot':{ ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, { opacity: 0.8 //, //interactive: true, //attribution: "Historical building plan © Instituto Geográfico Nacional de España" });//.addTo( map ); //map.addLayer( ActiveZones.fig[i] ); break; }; }; if( data.zones[i].dev_is_source ){ if( typeof pp !== 'undefined' ) { var sty = ''; if( selecredActiveSourceFilter == data.zones[i].dev_id ){ sty = 'cardDeviceSourceSelected'; } else { sty = 'cardDeviceSource'; }; pp.add( { id: data.zones[i].dev_id+'_container', frame: false, border: false, width: 130, height: 130, html: '

'+data.zones[i].dev_name+'

' }); }; }; if( data.zones[i].zang != undefined ){ //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map); ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map ); }; if( data.zones[i].center != undefined ){ //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map); ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map ); }; }; if( selecredActiveSourceFilter == 0 ){ turnAllGzOn(); } else { turnOffAllGzButThis( selecredActiveSourceFilter ); }; if( typeof pp !== 'undefined' ) pp.doLayout(); //LoadMapEvents( SelectedSite ); //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite ); }, failure: function( response, opts ) { //Ext.fly('some_div').update('Fail!'); } }); }; var cevt = Array(); var coz = Array(); function showEventsOnMap( data, removeCursor = true ){ if( removeCursor ) map.removeLayer( selectedMarker ); if( cevt.length ){ for( i=0; i< cevt.length; i++ ){ if( cevt[i]!= null ){ cevt[i].remove(); delete( cevt[i] ); cevt[i] = null; }; }; }; if( coz.length ){ for( i=0; i< coz.length; i++ ){ if( coz[i]!= null ){ coz[i].remove(); delete( coz[i] ); coz[i]=null; }; }; }; var zz = ( 1.0 / ( data.log.length + 0 ) ); var idx = 0; for( i=0; i < data.log.length; i++ ){ if( data.log[i].has_geo ){ var cp_color='#FF0000'; switch( data.log[i].event ){ case 36: cp_color='#0000FF'; break; }; cevt[idx] = L.circleMarker( [data.log[i].geo.lat, data.log[i].geo.lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){ loadEventPropertiesByID( this.options.id ); } ); cevt[idx].addTo(map); idx++; }; }; }; var sesVideosStartTS = 0; function VideoButtonRenderer( value, metaData, record, rowIndex, colIndex, store ){ return 'Download'; } function VideoStartRenderer( value, metaData, record, rowIndex, colIndex, store ){ var csec = parseInt((record.data.sts - sesVideosStartTS)/1000); var cmin = parseInt( csec / 60 ); var chour = parseInt( csec / 3600 ); csec = csec % 60; var oms=''; if( chour ){ oms= String(chour).padStart(2, '0')+':'+String(cmin).padStart(2, '0')+':'+String(csec).padStart(2, '0'); } else { if( cmin ){ oms= '00:'+String(cmin).padStart(2, '0')+':'+String(csec).padStart(2, '0'); } else { oms= '00:00:'+String(csec).padStart(2, '0'); }; }; return oms; } function VideoSideRenderer( value ){ if( value == 'L' ){ return sesVideosListLName;//''; }; return sesVideosListRName;//''; } function VideoLengthRenderer( value, metaData, record, rowIndex, colIndex, store ){ return parseInt((record.data.ets - record.data.sts)/1000)+ ' sec.'; } var videosListColModel_ops = { columns: [ {header: "ID", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, {header: "Time",width: 120, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'sts', renderer: VideoStartRenderer }, {header: "Length", width: 100, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ets', renderer: VideoLengthRenderer }, {header: "Side", width: 100, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'side' ,renderer: VideoSideRenderer }, /*{header: "Name", width: 180, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'name' },*/ {header: "Download", width: 100, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'id', renderer: VideoButtonRenderer } ], defaults: { sortable: true, menuDisabled: true, width: 100 }, listeners: { hiddenchange: function(cm, colIndex, hidden) { //saveConfig(colIndex, hidden); } } }; var SelectedVideo = -1; var SelectedVideoRow = null; var videosListSelModel_ops = { singleSelect: true, listeners: { rowselect: function(sm, row, rec ) { //loadEventProperties( rec.data ); SelectedVideo = rec.data.id; SelectedVideoRow = row; //alert( SelectedEvent ); //var CB = Ext.getCmp('con_to_src'); //CB.enable(); } } }; var CompositeVideoStatus = 0; var CompositeVideoProgress = 0; var CompositeVideoStatusTO = null; var sesVideosListWindow = null; var sesVideosListRName = ''; var sesVideosListLName = ''; var sesVideosListRExists = false; var sesVideosListLExists = false; var CompositeVideoRightInfo = null; var CompositeVideoLeftInfo = null; function startVideoComposer(){ Ext.Ajax.request({ url: '/lib/controller/doSessionOperations.php', params: { SESSION: SelectedSessionID, OPID: 3, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ CompositeVideoStatus = 1; CompositeVideoProgress = 0; CompositeVideoStatusUpdate(); } else { Ext.Msg.show({ title:'GetLabel('_ERROR_MSG_');?>', msg: data.msg, buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR }); }; }, failure: failureAJAXFunction }); } function CompositeVideoStatusUpdate(){ var rr = Ext.getCmp('EvtVidCompDownPanel'); rr.removeAll(); switch( CompositeVideoStatus ){ case 0:{ rr.add({ xtype: 'panel', frame: false, border: false, html: '
Compose Videos into one file
 
Start Video Composer
 
' }); break; }; case 1:{ rr.add({ border: false, frame: false, //layout: 'vbox', //layoutConfig: { // align: 'center' //}, items:[{ html: '
Composing Video
' },{ xtype: 'progress', value: CompositeVideoProgress }] }); //CompositeVideoStatusTO = window.setTimeout( 1000, eventVideosStatusUpdater ); eventVideosStatusUpdater(); break; }; case 2:{ if( sesVideosListRExists ){ rr.add({ xtype: 'panel', frame: false, border: false, html: '
Composed Video from '+sesVideosListRName+' side
Resolution:'+CompositeVideoRightInfo.pic_size+'
Frame rate:'+CompositeVideoRightInfo.fps+'
Codec:'+CompositeVideoRightInfo.codec+'
Duration:'+CompositeVideoRightInfo.duration+'
File size:'+CompositeVideoRightInfo.file_size+'
Download
' }); }; if( sesVideosListLExists ){ rr.add({ xtype: 'panel', frame: false, border: false, html: '
Composed Video from '+sesVideosListLName+' side
Resolution:'+CompositeVideoLeftInfo.pic_size+'
Frame rate:'+CompositeVideoLeftInfo.fps+'
Codec:'+CompositeVideoLeftInfo.codec+'
Duration:'+CompositeVideoLeftInfo.duration+'
File size:'+CompositeVideoLeftInfo.file_size+'
Download
' }); }; break; }; }; rr.doLayout(); } function hideEventsVideos(){ //if( sesVideosListWindow != null ){ // sesVideosListWindow.hide(); //} if( CompositeVideoStatusTO!= null ) window.clearTimeout( CompositeVideoStatusTO ); CompositeVideoStatusTO = null; sesVideosListWindow = null; } function eventVideosStatusUpdater(){ Ext.Ajax.request({ url: '/lib/controller/getComposerStatus.php', params: { SESSION: SelectedSessionID, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); CompositeVideoStatusUpdate() CompositeVideoStatusTO = window.setTimeout( 1000, eventVideosStatusUpdater ); } }); } function showEventsVideos(){ if( sesVideosListWindow == null ){ sesVideosListWindow = new Ext.Window({ title: 'Videos', modal: true, width: 490, height: 560, closeAction: 'close', resizable: false, items:[{ xtype: 'grid', height: 350, ds: videosListStore, cm: new Ext.grid.ColumnModel( videosListColModel_ops ), sm: new Ext.grid.RowSelectionModel( videosListSelModel_ops ), },{ xtype: 'panel', border: false, frame: false, id: 'EvtVidCompDownPanel', autoScroll: true, items:[] }], listeners:{ close: hideEventsVideos } }); }; sesVideosListWindow.show(); CompositeVideoStatusUpdate(); }; function LoadMapEventsZ( Mode ){ if( tlLoadLocker ) return; tlLoadLocker = true; Ext.Ajax.request({ url: '/lib/controller/getGeoAlerts.php', params: { SITE: , UID: , SID: '', MODE: Mode }, success: function( response, opts ){ if( cevt.length ){ for( i=0; i< cevt.length; i++ ){ if( cevt[i]!= null ){ cevt[i].remove(); delete( cevt[i] ); cevt[i] = null; }; }; }; if( coz.length ){ for( i=0; i< coz.length; i++ ){ if( coz[i]!= null ){ coz[i].remove(); delete( coz[i] ); coz[i]=null; }; }; }; var data = Ext.decode( response.responseText ); var zz = ( 1.0 / ( data.evt.length + 0 ) ); for( i=0; i < data.evt.length; i++ ){ cevt[i] = L.circleMarker( [data.evt[i].lat,data.evt[i].lon], {id:data.evt[i].id, color: '#FF0000', radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){ loadEventProperties( this.options.id ); } ); cevt[i].addTo(map); }; for( i=0; i < data.other.length; i++ ){ switch( data.other[i].type ){ case 'circle':{ coz[i] = L.circleMarker( data.other[i].loc, {id:data.other[i].id, color: data.other[i].color, radius: 5, stroke: false, fillOpacity: 1.0 } ); coz[i].addTo(map); break; }; }; }; //eventsListStore.reload(); tlLoadLocker = false; }, failure: function( response, opts ) { //Ext.fly('some_div').update('Fail!'); tlLoadLocker = false; } }); }; function loadEventPropertiesByID( id ){ var d = eventsListStore.findExact( 'id', id ); if( d > -1 ) { var EventRec = eventsListStore.getAt( d ); loadEventProperties( EventRec.data ); }; }; function loadEventProperties( EventRec ){ var tPanel = Ext.getCmp('prop_content'); tPanel.removeAll();// remove( 0 ); var tt = ''; if( selectedMarker!= null ){ selectedMarker.remove(); //map.removeLayer( selectedMarker ); if( EventRec.has_geo ){ tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon; selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]); selectedMarker.addTo( map ); }; }; tPanel.add( { title: 'Event Details', html: '

' + EventRec.device+'

'+tt+'
' } ); if( EventRec.has_images ){ for( var i=0; i < EventRec.images.length; i++ ){ tPanel.add( { frame: false, html: '' }); }; }; tPanel.doLayout(); }; function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){ if( tlLoadLocker ) return; tlLoadLocker = true; if( Mode == 'arch' ){ Ext.MessageBox.wait("Loading Data","Please Wait",{ width: '100%', hidden: true, animate: true, progress: true, closable: false }); }; Ext.Ajax.request({ url: '/lib/controller/getEventRecords.php', params: { SITE: , UID: , SID: '', MODE: Mode, FIL: selecredActiveSourceFilter, SDA: SD, SMO: SMO, SYE: SY, STM: ST, ETM: ET, STR: SR, DIR: DR }, success: function( response, opts ){ tlLoadLocker = false; var data = Ext.decode(response.responseText); if( data.updateFROMTO ){ Ext.getCmp('STimeFROM').setValue( data.STT ); Ext.getCmp('STimeTO').setValue( data.ENT ); if( data.SLD > 0 ){ SMO = GetMonthNum(data.SLD); SY = GetYear(data.SLD); SD = GetDay(data.SLD); BuildCalendar(); }; }; eventsListStore.loadData( data, false ); if( Mode == 'arch' ){ showEventsOnMap( data, true ); Ext.MessageBox.hide(); if( DR > 0 ){ Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 ); Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow(); }; if( DR < 0 ){ Ext.getCmp('evtArchLog').getView().focusRow( 0 ); Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow(); }; } else { showEventsOnMap( data, false ); //LoadMapEventsZ( Mode ); }; }, failure: failureAJAXFunction }); }; function loadArchive(){ debugger; if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; timelineObj = null; }; stopStatusUpdater(); setUserContent( 2 ); var tPanel = Ext.getCmp('main_portal'); tPanel.removeAll( true ); Ext.getCmp('main_content').setTitle( 'Events Archive' ); tPanel.add({ columnWidth: 0.83, frame: false, border: false, items: [{ title: 'Site Map', frame: false, border: false, layout: 'vbox', layoutConfig: { align : 'stretch', pack : 'start', }, height: PanelH-300, items:[{ height: PanelH-325, flex: 1, frame: false, border: false, layout: 'fit', items:{ id: 'event_map', html: ' ' } }] },{ frame: false, border: false, collapsible: false, draggable: false, layout: 'hbox', items:[{ layout: 'form', title: 'Date/Time', width: 200, frame: true, border: false, labelAlign: 'right', labelWidth: 50, defaults: { width: 80}, items: [{ xtype: 'combo', id: 'STimeFROM', fieldLabel: 'From', editable: false, typeAhead: true, triggerAction: 'all', width: 120, lazyRender:true, mode: 'local', store: new Ext.data.ArrayStore({ id: 0, fields: ['ss', 'displayText' ], data: [] }), valueField: 'ss', displayField: 'displayText' },{ xtype: 'combo', id: 'STimeTO', fieldLabel: 'Till', editable: false, typeAhead: true, triggerAction: 'all', width: 120, lazyRender:true, mode: 'local', store: new Ext.data.ArrayStore({ id: 0, fields: ['ss', 'displayText' ], data: [] }), valueField: 'ss', displayField: 'displayText' }], html: '
', buttons: [{ xtype: 'button', text: 'Display History', handler: function(){ var STU = Ext.getCmp('STimeFROM').getValue(); var ETU = Ext.getCmp('STimeTO').getValue(); getData( 'arch', STU, ETU ); } }] },{ title: 'Event Log', frame: false, height: 303, id: 'evtArchLog', xtype: 'grid', ds: eventsListStore, cm: new Ext.grid.ColumnModel( eventsListColModel_ops ), sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ), listeners:{ keydown: function( e ) { if( e.getKey() == e.UP ){ if( SelectedRow == 0 ){ var id = eventsListStore.getAt( 0 ).id; getData( 'arch', 0, 0, id, 1 ); }; }; if( e.getKey() == e.DOWN ){ if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){ var id = eventsListStore.getAt( SelectedRow ).id; getData( 'arch', 0, 0, id, -1 ); Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow(); Ext.getCmp('evtArchLog').focus( false, true ); }; }; } } }] }] }); tPanel.add({ columnWidth: 0.17, frame: true, title: 'Event Information', id: 'prop_content', border: false, items: [{ html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' }] }); tPanel.doLayout(); /* Ext.getCmp('evtLog').getEl().set({tabindex: "0"}); Ext.getCmp('evtLog').getEl().addKeyMap({ eventName: "keyup", binding: [{ key: Ext.EventObject.SPACE, fn: function(){ alert("Space key pressed"); } },{ key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT], shift: true, fn: function(){ alert("Left or right pressed while pressing shift"); } }] }); */ //BuildCalendar(); loadCalendarDates(); map = L.map('event_map',{ attributionControl: true, //preferCanvas: true, zoomControl: true, center: [SiteLat, SiteLon], /*zoomControl: false, zoom: 17, minZoom: 17, maxZoom: 17,*/ keyboard: false }).setView([SiteLat, SiteLon], 17); //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("GetLabel('_SYS_ANCHORT_LBL_');?>"); var mapLayers = []; /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', { subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], attribution: '© Bing Maps', detectRetina: true });*/ mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', maxNativeZoom: 18, maxZoom: 24, }) // https://leaflet-extras.github.io/leaflet-providers/preview/ mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012', maxZoom: 19 }); mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community', maxZoom: 19 }); mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community', maxZoom: 24 }); mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde attribution: 'Map data © OpenStreetMap contributors', maxZoom: 19 }); mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", { attribution: 'Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA) ', maxZoom: 19 }); /* mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', maxZoom: 22 }); mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', maxZoom: 22 }); mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', maxZoom: 22 }); */ var baseMaps = { "MyMap": mapLayers["MyMap"], "OpenStreetMap": mapLayers["OpenStreetMap"], "OpenTopoMap": mapLayers["OpenTopoMap"], "EsriSat": mapLayers["EsriSat"], "EsriStreet": mapLayers["EsriStreet"], "EsriTopo": mapLayers["EsriTopo"], //"Bing": mapLayers["Bing"], //"OSM-Cycle": mapLayers["Cycle"], //"Landscape": mapLayers["Landscape"], //"Outdoor": mapLayers["Outdoor"], }; L.control.layers( baseMaps ).addTo(map); mapLayers["MyMap"].addTo(map); /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', maxNativeZoom: 18, maxZoom: 24, }).addTo(map); */ //loadTimeLineGroups( selectedSite ); loadMapZones( SelectedSite ); getData( 'arch' ); //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }}); }; function loadMonitoring(){ if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; timelineObj = null; }; setUserContent( 1 ); var tPanel = Ext.getCmp('main_portal'); tPanel.removeAll( true ); Ext.getCmp('main_content').setTitle( 'Events Monitoring' ); tPanel.add({ columnWidth: 0.83, frame: false, border: false, items: [{ title: 'getLabel('_MAP_MONITORING_');?>', frame: false, border: false, collapsible: false, draggable: false, layout: 'vbox', layoutConfig: { align : 'stretch', pack : 'start', }, height: PanelH-300, items:[{ height: PanelH-325, flex: 1, frame: false, border: false, layout: 'fit', items:{ id: 'event_map', html: ' ' } }] },{ frame: false, border: true, collapsible: false, draggable: false, layout: 'hbox', items:[{ title: 'Alarm Sources', xtype: 'panel', border: false, frame: false, collapsible: false, draggable: false, id: 'sources_panel', width: 160, autoScroll: 'auto', height: 303 },{ title: 'Event Log', height: 303, xtype: 'grid', border: false, frame: false, collapsible: false, draggable: false, ds: eventsListStore, cm: new Ext.grid.ColumnModel( eventsListColModel_ops ), sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ), bbar: [{ text: 'Clear', handler: function(){ Ext.Ajax.request({ url: '/lib/controller/clearEventCloud.php', params: { UID: , SID: '' }, success: function( response, opts ){ }, failure: function( response, opts ) { } }); } }] }] }] }); tPanel.add({ columnWidth: 0.17, title: 'Event Information', frame: true, id: 'prop_content', border: false, items: [{ html:'
GetLabel('_PLS_SEL_LEFT_ITEM_');?>
' }] }); tPanel.doLayout(); map = L.map('event_map',{ attributionControl: true, //preferCanvas: true, zoomControl: true, center: [SiteLat, SiteLon], /*zoomControl: false, zoom: 17, minZoom: 17, maxZoom: 17,*/ keyboard: false }).setView([SiteLat, SiteLon], 17); //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("GetLabel('_SYS_ANCHORT_LBL_');?>"); var mapLayers = []; /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', { subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], attribution: '© Bing Maps', detectRetina: true });*/ mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', maxNativeZoom: 18, maxZoom: 24, }) // https://leaflet-extras.github.io/leaflet-providers/preview/ mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012', maxZoom: 19 }); mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community', maxZoom: 19 }); mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community', maxZoom: 24 }); mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde attribution: 'Map data © OpenStreetMap contributors', maxZoom: 19 }); mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", { attribution: 'Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA) ', maxZoom: 19 }); /* mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', maxZoom: 22 }); mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', maxZoom: 22 }); mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], { attribution: 'Maps © Thunderforest, Data © OpenStreetMap contributors', maxZoom: 22 }); */ var baseMaps = { "MyMap": mapLayers["MyMap"], "OpenStreetMap": mapLayers["OpenStreetMap"], "OpenTopoMap": mapLayers["OpenTopoMap"], "EsriSat": mapLayers["EsriSat"], "EsriStreet": mapLayers["EsriStreet"], "EsriTopo": mapLayers["EsriTopo"], //"Bing": mapLayers["Bing"], //"OSM-Cycle": mapLayers["Cycle"], //"Landscape": mapLayers["Landscape"], //"Outdoor": mapLayers["Outdoor"], }; L.control.layers( baseMaps ).addTo(map); mapLayers["MyMap"].addTo(map); /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', maxNativeZoom: 18, maxZoom: 24, }).addTo(map); */ loadMapZones( SelectedSite ); tlInterval = window.setInterval( getData, 333, 'live' ); }; function loadOnlineMonitoring(devID){ var tPanel = Ext.getCmp('main_content'); if( tlInterval!= null ){ window.clearInterval( tlInterval ); tlInterval = null; timelineObj = null; }; tPanel.remove(0); tPanel.add({ html: 'Device Monitoring '+devID }); tPanel.doLayout(); }; var mSesPlay = null; function ts2dts( b ){ var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var a = new Date( b ); var year = a.getFullYear(); var month = months[a.getMonth()]; var date = a.getDate(); var hour = a.getHours(); var min = "0" + a.getMinutes(); var sec = "0" + a.getSeconds(); return date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) ; }; function drawSessionDataOnSlider( a, b , z, v ){ var cel = Ext.getCmp("hpl_slider").getEl(); var c = document.createElement('canvas'); var ctx = c.getContext('2d'); c.width = cel.getWidth(); c.height = cel.getHeight(); var tK = ( cel.getWidth() - 7 ) / ( b - a ); var rib = (tK>3)?tK:3; ctx.fillStyle='#00000000'; //ctx.fillStyle='#00FF00'; ctx.fillRect( 7, 0, cel.getWidth(), cel.getHeight() ); ctx.fillStyle='#FF0000'; for( var i=0; i< z.length; i++ ){ var cX = 7 + Math.round( tK * ( z[i].ts /1000 - a ) ); ctx.fillRect( cX, 0, rib, 12 );//25 }; ctx.fillStyle='#0000FF'; for( var i=0; i< v.length; i++ ){ var cX = 7 + Math.round( tK * ( v[i].sts /1000 - a ) ); var cD = 7 + Math.round( tK * ( v[i].ets /1000 - a ) ); var cW = cD - cX; ctx.fillRect( cX, 13, cW, 25 ); }; cel.setStyle('background','url(' + c.toDataURL() + ')'); }; var max_grad_levels = 16; function getTransperecy( i ){ if( i == 0 ) return 'FF'; var k = 128.0 / max_grad_levels; var l = parseInt( k*(max_grad_levels-i) ).toString(16); if( l.length < 2 ) l = '0'+l; return l; }; function getSize( i ){ var k = 75.0 / max_grad_levels; return 25+parseInt( k * i ); }; class argusSessionPlayer{ sessionId; mMapID; startTime; endTime; currentTime; rVideoJS = null; lVideoJS = null; rVideoJS_id = null; lVideoJS_id = null; rVideoJS_playing = false; lVideoJS_playing = false; rVideoJS_cid = -1; lVideoJS_cid = -1; mapLayout; lVideos; rVideos; Events; basePath; mTimer = null; mPaused = true; mLooping = true; mAutoPlay = false; nextRTimestamp = 0.0; nextLTimestamp = 0.0; mSvgElements;//076.png checkLVideoTime(){ const t = mSesPlay.lVideoJS.currentTime(); // seconds while( t >= mSesPlay.nextLTimestamp ){ mSesPlay.lVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextLTimestamp }); mSesPlay.nextLTimestamp += 0.1; // next 100 ms of video time }; } checkRVideoTime(){ const t = mSesPlay.rVideoJS.currentTime(); // seconds while( t >= mSesPlay.nextRTimestamp ){ mSesPlay.rVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextRTimestamp }); mSesPlay.nextRTimestamp += 0.1; // next 100 ms of video time }; } constructor( session_id, autoplay ) { this.sessionId = session_id; this.currentTime = 0; this.startTime = 0; this.endTime = 0; this.lVideos = []; this.rVideos = []; this.Events = []; this.rEvents = []; this.lEvents = []; this.mSvgElements = []; if( autoplay != undefined ) this.mAutoPlay = autoplay; Ext.Ajax.request({ url: '/lib/controller/getSessionData.php', params: { SESSION: this.sessionId, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode( response.responseText ); //debugger; if( data.status == 'ok' ){ mSesPlay.mapLayout = data.layout; //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id ); //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id ); mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id ); //debugger; if( data.data_ok ){ mSesPlay.startTime = data.start_ts; mSesPlay.endTime = data.start_ts + data.length; mSesPlay.basePath = window.location.origin + data.basepath +'/'; mSesPlay.rVideos = []; mSesPlay.lVideos = []; mSesPlay.nextRTimestamp = 0.0; mSesPlay.nextLTimestamp = 0.0; sesVideosListRName = data.r_module_name; sesVideosListLName = data.l_module_name; if( data.composed_video ){ if( data.composed_video_status == 'D' ){ CompositeVideoStatus = 2; sesVideosListRExists = data.composed_right_video_exists; sesVideosListLExists = data.composed_left_video_exists; if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null; if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null; } else { CompositeVideoStatus = 1; CompositeVideoProgress = data.composed_video_progress; CompositeVideoLeftInfo = null; CompositeVideoRightInfo = null; sesVideosListRExists = false; sesVideosListLExists = false; } } else CompositeVideoStatus = 0; var tt = Ext.getCmp('hpl_slider'); tt.setMinValue( 0 ); tt.setMaxValue( data.length / 1000 ); if( data.events.length ){ mSesPlay.Events = data.events; for( var i=0; i < data.events.length; i++ ){ if( data.events[i].side == 'L' ){ mSesPlay.lEvents.push( data.events[i] ); } else { mSesPlay.rEvents.push( data.events[i] ); }; }; }; if( data.videos.length ){ videosListStore.loadData( data, false ); for( var i=0; i < data.videos.length; i++ ){ if( mSesPlay.currentTime == 0 ){ mSesPlay.currentTime = data.videos[i].sts; } else { if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts; }; if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] ); }; sesVideosStartTS = mSesPlay.currentTime; } else { sesVideosStartTS = 0; videosListStore.removeAll(); }; if( mSesPlay.rVideos.length ) { mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id; mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id ); mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); }); mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );}); // New imp mSesPlay.rVideoJS.on('play', () => { mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1; }); mSesPlay.rVideoJS.on( 'timeupdate', mSesPlay.checkRVideoTime ); mSesPlay.rVideoJS.on('seeking', () => { mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1; }); mSesPlay.rVideoJS.on('videotick', (e) => { mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 ); }); mSesPlay.rVideoJS.on('ended', function() { console.log("Video Ended!"); if( mSesPlay.rVideoJS_cid < mSesPlay.rVideos.length ){ mSesPlay.rVideoJS_cid++; var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.rVideos[mSesPlay.rVideoJS_cid].name }; mSesPlay.rVideoJS.src( ns ); mSesPlay.rVideoJS.play(); mSesPlay.rVideoJS_playing = true; }; }); }; if( mSesPlay.lVideos.length ){ mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id; mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id ); mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); }); mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );}); // New imp mSesPlay.lVideoJS.on('play', () => { mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1; }); mSesPlay.lVideoJS.on( 'timeupdate', mSesPlay.checkLVideoTime ); mSesPlay.lVideoJS.on('seeking', () => { mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1; }); mSesPlay.lVideoJS.on('videotick', (e) => { mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 ); }); mSesPlay.lVideoJS.on('ended', function() { console.log("Video Ended!"); if( mSesPlay.lVideoJS_cid < mSesPlay.lVideos.length ){ mSesPlay.lVideoJS_cid++; var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.lVideos[mSesPlay.lVideoJS_cid].name }; mSesPlay.lVideoJS.src( ns ); mSesPlay.lVideoJS.play(); mSesPlay.lVideoJS_playing = true; }; }); }; drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos ); mSesPlay.setPosition( 0 ); if( mSesPlay.mAutoPlay ) mSesPlay.play(); } else { Ext.Msg.show({ title:'GetLabel('_SESSION_DATA_');?>', msg: 'GetLabel('_SESS_DATA_NOTF_');?>', buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR }); } }; }, failure: failureAJAXFunction }); } checkPlayebleTime( ct ){ if( this.rVideos.length ){ var fid = -1; if( this.rVideoJS_cid < this.rVideos.length - 1 ){ for(var i=this.rVideoJS_cid+1; i < this.rVideos.length; i++ ){ if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){ fid = i; break; }; }; if( fid < 0 ){ //No Segments for Now; //this.rVideoJS_playing = false; this.rVideoJS_cid = 1; var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name }; this.rVideoJS.src( ns ); this.rVideoJS_playing = true; } else { if( this.rVideoJS_cid != fid ){ this.rVideoJS_cid = fid; var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name }; this.rVideoJS.src( ns ); }; this.rVideoJS_playing = true; }; }; }; if( this.lVideos.length ){ var fid = -1; for(var i=this.lVideos.length-1; i > 0; i-- ){ if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){ fid = i; break; }; }; if( fid < 0 ){ //No Segments for Now; //this.lVideoJS_playing = false; this.lVideoJS_cid = 1; var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name }; this.lVideoJS.src( ns ); this.lVideoJS_playing = true; } else { if( this.lVideoJS_cid != fid ){ this.lVideoJS_cid = fid; var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name }; this.lVideoJS.src( ns ); }; this.lVideoJS_playing = true; }; //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 ); }; } action( currentTime = 0 ){ if( !this.mPaused ){ this.currentTime = currentTime; if( this.currentTime == 0 ) this.currentTime = this.startTime; //debugger; this.currentTime = this.checkPlayebleTime( this.currentTime ); var zz = document.getElementById('hpl_time_mon'); if( zz != undefined ){ zz.innerHTML = ts2dts( this.currentTime ); }; //Check videos if( this.rVideos.length ){ var fid = -1; for(var i=0; i= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){ fid = i; break; }; }; if( fid < 0 ){ //No Segments for Now; this.rVideoJS_playing = false; } else { if( this.rVideoJS_cid != fid ){ this.rVideoJS_cid = fid; var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name }; this.rVideoJS.src( ns ); }; this.rVideoJS_playing = true; }; //if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 ); }; if( this.lVideos.length ){ var fid = -1; for(var i=0; i= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){ fid = i; break; }; }; if( fid < 0 ){ //No Segments for Now; this.lVideoJS_playing = false; } else { if( this.lVideoJS_cid != fid ){ this.lVideoJS_cid = fid; var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name }; this.lVideoJS.src( ns ); }; this.lVideoJS_playing = true; }; //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 ); }; if( this.Events.length ){ var sid = -1; for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) { sid = i; break; }; if( sid > -1 ){ for( var i=0; i< max_grad_levels; i++ ){ var cid = sid-i; var csize = getSize( i ); //debugger; if( typeof this.mSvgElements[i] === 'undefined') { if( cid > -1 ){ var svgns = "http://www.w3.org/2000/svg"; this.mSvgElements[i] = document.createElementNS(svgns, 'rect'); this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%'); this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); this.mSvgElements[i].setAttribute('height', ''+csize); this.mSvgElements[i].setAttribute('width', ''+csize); this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i)); var tt = document.getElementById('svgTrackMap'); var zz = document.getElementById('scheme_anch'); tt.insertBefore( this.mSvgElements[i], zz ); //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]); }; } else { if( cid > -1 ){ this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%'); this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); this.mSvgElements[i].setAttribute('height', ''+csize); this.mSvgElements[i].setAttribute('width', ''+csize); this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) ); } else { this.mSvgElements[i].setAttribute('fill', '#FF000000'); }; }; }; } else for( var i=0; i< max_grad_levels; i++ ) if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000'); }; var tt = Ext.getCmp('hpl_slider'); if( tt!= undefined ){ tt.suspendEvents(); tt.setValue( ( this.currentTime - this.startTime ) / 1000, true ); tt.resumeEvents(); }; //this.currentTime += 250; if( this.currentTime > this.endTime ) if( this.mLooping ){ this.currentTime = 0; } else { //Stop this.play(); }; }; } play(){ var zz = Ext.getCmp( 'hpl_pl_btn' ); if( this.mPaused ){ this.mPaused = false; if( this.rVideos.length ){ if( !this.rVideoJS_playing ) this.rVideoJS.play(); this.rVideoJS_playing = true; }; if( this.lVideos.length ){ if( !this.lVideoJS_playing ) this.lVideoJS.play(); this.lVideoJS_playing = true; }; zz.setIconClass( 'plr_op_pause' ); zz.setText('Pause'); } else { this.mPaused = true; if( this.rVideos.length ){ if( this.rVideoJS_playing ) this.rVideoJS.pause(); this.rVideoJS_playing = false; }; if( this.lVideos.length ){ if( this.lVideoJS_playing ) this.lVideoJS.pause(); this.lVideoJS_playing = false; }; zz.setIconClass( 'plr_op_play' ); zz.setText('Play'); }; this.action( this.currentTime ); //if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 ); } pause(){ this.mPaused = true; } toggleLoop(){ this.mLooping = !this.mLooping; if( this.mLooping ) if( this.currentTime > this.endTime ){ this.currentTime = 0; // Start this.play(); }; } setPosition( pos_time ){ //this.currentTime = this.startTime + pos_time*1000; var nt = this.startTime + pos_time*1000; var zz = document.getElementById('hpl_time_mon'); zz.innerHTML = ts2dts( nt ); if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( nt - this.rVideos[this.rVideoJS_cid].sts ) / 1000 ); if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( nt - this.lVideos[this.lVideoJS_cid].sts ) / 1000 ); } onLVideoEnd(){ } onRVideoEnd(){ } dispose(){ if( this.mTimer != null ) clearInterval( this.mTimer ); this.mTimer = null; if( this.rVideoJS!= null ){ this.rVideoJS.dispose(); this.rVideoJS = null; }; if( this.lVideoJS!= null ){ this.lVideoJS.dispose(); this.lVideoJS = null; }; } } // canvas aproach /////////////////////////////////////////// /* const player = videojs('my-video'); let nextTimestamp = 0; let rafId = null; function tick() { if (player.paused() || player.ended()) return; const t = player.currentTime(); while (t >= nextTimestamp) { player.trigger({ type: 'videotick', timestamp: nextTimestamp }); nextTimestamp += 0.1; } rafId = requestAnimationFrame(tick); } player.on('play', () => { nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1; cancelAnimationFrame(rafId); rafId = requestAnimationFrame(tick); }); player.on('pause', () => cancelAnimationFrame(rafId)); player.on('ended', () => cancelAnimationFrame(rafId)); player.on('seeking', () => { nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1; }); player.on('videotick', (e) => { console.log(e.timestamp); }); */ class _argusSessionPlayer{ sessionId; mMapID; startTime; endTime; currentTime; rVideoJS = null; lVideoJS = null; rVideoJS_id = null; lVideoJS_id = null; rVideoJS_playing = false; lVideoJS_playing = false; rVideoJS_cid = -1; lVideoJS_cid = -1; mapLayout; lVideos; rVideos; Events; basePath; mTimer = null; mPaused = true; mLooping = true; mSvgElements;//076.png constructor( session_id ) { this.sessionId = session_id; this.currentTime = 0; this.startTime = 0; this.endTime = 0; this.lVideos = []; this.rVideos = []; this.Events = []; this.mSvgElements = []; Ext.Ajax.request({ url: '/lib/controller/getSessionData.php', params: { SESSION: this.sessionId, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode( response.responseText ); //debugger; if( data.status == 'ok' ){ mSesPlay.mapLayout = data.layout; //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id ); //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id ); mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id ); //debugger; if( data.data_ok ){ if( data.r_module_id ){ mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id; mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id ); //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' ); mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); }); mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );}); }; mSesPlay.startTime = data.start_ts; mSesPlay.endTime = data.start_ts + data.length; mSesPlay.basePath = window.location.origin + data.basepath +'/'; mSesPlay.rVideos = []; mSesPlay.lVideos = []; if( data.videos.length ){ for( var i=0; i < data.videos.length; i++ ) if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] ); }; if( data.events.length ) mSesPlay.Events = data.events; var tt = Ext.getCmp('hpl_slider'); tt.setMinValue( 0 ); tt.setMaxValue( data.length / 1000 ); drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos ); //player.on('ended', function() { // this.dispose(); //}); //alert( data.basepath +'/'+data.videos[0].name ); //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name }); //mSesPlay.rVideoJS.ready(function() { //mSesPlay.rVideoJS.play(); //var howLoudIsIt = player.volume(); //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half //}); //mSesPlay.rVideoJS.on("timeupdate", function(){ // method will be calledd each 250 msecs //}); if( data.l_module_id ){ mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id; mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id ); //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' ); //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name }); //mSesPlay.lVideoJS.ready(function() { //mSesPlay.rVideoJS.play(); //var howLoudIsIt = player.volume(); // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half //}); mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); }); mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );}); }; //mSesPlay.lVideoJS.on("timeupdate", function(){ // // method will be calledd each 250 msecs //}); mSesPlay.setPosition( 0 ); } else { Ext.Msg.show({ title:'GetLabel('_SESSION_DATA_');?>', msg: 'GetLabel('_SESS_DATA_NOTF_');?>', buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR }); } }; }, failure: failureAJAXFunction }); } action(){ if( !this.mPaused ){ if( this.currentTime == 0 ) this.currentTime = this.startTime; var zz = document.getElementById('hpl_time_mon'); //debugger; if( zz != undefined ){ zz.innerHTML = ts2dts( this.currentTime ); }; //Check videos if( this.rVideos.length ){ var fid = -1; for(var i=0; i= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){ fid = i; break; }; }; if( fid < 0 ){ //No Segments for Now; this.rVideoJS_playing = false; } else { if( this.rVideoJS_cid != fid ){ this.rVideoJS_cid = fid; var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name }; this.rVideoJS.src( ns ); }; this.rVideoJS_playing = true; }; if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 ); }; if( this.lVideos.length ){ var fid = -1; for(var i=0; i= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){ fid = i; break; }; }; if( fid < 0 ){ //No Segments for Now; this.lVideoJS_playing = false; } else { if( this.lVideoJS_cid != fid ){ this.lVideoJS_cid = fid; var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name }; this.lVideoJS.src( ns ); }; this.lVideoJS_playing = true; }; if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 ); }; if( this.Events.length ){ var sid = -1; for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) { sid = i; break; }; if( sid > -1 ){ for( var i=0; i< max_grad_levels; i++ ){ var cid = sid-i; var csize = getSize( i ); //debugger; if( typeof this.mSvgElements[i] === 'undefined') { if( cid > -1 ){ var svgns = "http://www.w3.org/2000/svg"; this.mSvgElements[i] = document.createElementNS(svgns, 'rect'); this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%'); this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); this.mSvgElements[i].setAttribute('height', ''+csize); this.mSvgElements[i].setAttribute('width', ''+csize); this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i)); var tt = document.getElementById('svgTrackMap'); var zz = document.getElementById('scheme_anch'); tt.insertBefore( this.mSvgElements[i], zz ); //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]); }; } else { if( cid > -1 ){ this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%'); this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) ); this.mSvgElements[i].setAttribute('height', ''+csize); this.mSvgElements[i].setAttribute('width', ''+csize); this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) ); } else { this.mSvgElements[i].setAttribute('fill', '#FF000000'); }; }; }; } else for( var i=0; i< max_grad_levels; i++ ) if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000'); }; var tt = Ext.getCmp('hpl_slider'); if( tt!= undefined ){ tt.suspendEvents(); tt.setValue( ( this.currentTime - this.startTime ) / 1000, true ); tt.resumeEvents(); }; this.currentTime += 250; if( this.currentTime > this.endTime ) if( this.mLooping ){ this.currentTime = 0; } else { //Stop this.play(); }; }; } play(){ var zz = Ext.getCmp( 'hpl_pl_btn' ); if( this.mPaused ){ this.mPaused = false; if( this.rVideoJS_playing ) this.rVideoJS.play(); if( this.lVideoJS_playing ) this.lVideoJS.play(); zz.setIconClass( 'plr_op_pause' ); zz.setText('Pause'); } else { this.mPaused = true; if( this.rVideoJS_playing ) this.rVideoJS.pause(); if( this.lVideoJS_playing ) this.lVideoJS.pause(); zz.setIconClass( 'plr_op_play' ); zz.setText('Play'); }; if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 ); } pause(){ this.mPaused = true; } toggleLoop(){ this.mLooping = !this.mLooping; if( this.mLooping ) if( this.currentTime > this.endTime ){ this.currentTime = 0; // Start this.play(); }; } setPosition( pos_time ){ this.currentTime = this.startTime + pos_time*1000; var zz = document.getElementById('hpl_time_mon'); zz.innerHTML = ts2dts( this.currentTime ); } onLVideoEnd(){ } onRVideoEnd(){ } dispose(){ if( this.mTimer != null ) clearInterval( this.mTimer ); this.mTimer = null; if( this.rVideoJS!= null ){ this.rVideoJS.dispose(); this.rVideoJS = null; }; if( this.lVideoJS!= null ){ this.lVideoJS.dispose(); this.lVideoJS = null; }; } } var SelectedSessionID = 0; function loadHistorySessionView( session_id ){ autoRiseEvent = false; SelectedSessionID = rep_selectedEventId = session_id; Ext.Ajax.request({ url: '/lib/controller/getHistorySessionView.php', params: { SESSION: rep_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(); changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId ); updateUserContent(); mSesPlay = new argusSessionPlayer( rep_selectedEventId , true ); fetchStatus(); }; }, failure: failureAJAXFunction }); }; function deleteSession( session_id ){ if( session_id == 0 ) return; Ext.Msg.show({ title:'GetLabel('_RYS_DEL_SES_');?>', msg: 'GetLabel('_RYS_DEL_SESSION_');?>', buttons: Ext.Msg.YESNOCANCEL, icon: Ext.MessageBox.QUESTION, fn: function(btn, text){ if( btn == 'yes' ){ Ext.Ajax.request({ url: '/lib/controller/doSessionOperations.php', params: { SESSION: session_id, OPID: 1, UID: , SID: '' }, success: function( response, opts ){ Ext.Msg.hide(); var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ getBackToMap(); } else { Ext.Msg.show({ title:'GetLabel('_ERROR_MSG_');?>', msg: data.msg, buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR }); }; }, failure: failureAJAXFunction }); }; } }); }; function loadHistoryStationEvt( e ){ loadHistoryStation( e.target.options.mycustomid ); }; function loadHistoryStation( STT, buba ){ if( buba == undefined ){ autoRiseEvent = false; } else { autoRiseEvent = buba; }; rep_selectedStation = STT; changeContent( 2, 1, rep_selectedStation ); updateUserContent(); Ext.Ajax.request({ url: '/lib/controller/getHistoryStationView.php', params: { STT: rep_selectedStation, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); if( data.status == 'ok' ){ Ext.getCmp('main_content').removeAll(true); Ext.getCmp('main_content').add( Ext.decode( data.content ) ); Ext.getCmp('main_content').doLayout(); Ext.getCmp('left_side_menu').removeAll(true); Ext.getCmp('left_side_menu').add({ xtype: 'panel', frame: true, border: false, items: [{ html: '
GetLabel('_PLS_SEL_CAL_DATE_');?>
', height: PanelH - 30 }] }); Ext.getCmp('left_side_menu').doLayout(); } else { }; }, failure: failureAJAXFunction }); }; function loadReportDayTree( ts ){ ReportSelectionMode = 1;//Day Selected rep_selectedDateTS = ts; //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."}); //ReportMask.show(); Ext.Ajax.request({ url: '/lib/controller/getHistoryDay.php', params: { UID: , SID: '', STT: rep_selectedStation, DTS: rep_selectedDateTS }, success: function(response, opts ){ var data = Ext.decode( response.responseText ); var sPanel = Ext.getCmp('left_side_menu'); sPanel.removeAll( true ); sPanel.add({ xtype: 'panel', layout: 'vbox', frame: true, border: false, items:[{ xtype: 'spacer', height: 3 },{ html: '

'+( new Date( ts * 1000)).toLocaleDateString()+'

'+data.sessions+'

'+data.events+'

'+data.videos+'

', frame: false, width: '100%', border: false },{ xtype: 'spacer', height: 5 },{ xtype: 'treepanel', autoScroll: true, width: '100%', height: PanelH-206, border: true, frame: true, loader: new Ext.tree.TreeLoader(), rootVisible: false, root: new Ext.tree.AsyncTreeNode( data ), listeners: { click: function(n) { if( n.attributes.leaf ){ Ext.getCmp('chu_adate').show(); sPanel.doLayout(); loadHistorySessionView( n.attributes.sid ); }; } } },{ xtype: 'spacer', height: 10 },{ xtype: 'button', id: 'chu_adate', text: 'Show Dates', hidden: true, width: '100%', iconCls: 'reports_dates_btn', scale: 'large', handler: function(){ Ext.getCmp('chu_adate').hide(); loadHistoryStation( rep_selectedStation ); } }] }); sPanel.doLayout(); changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS ); updateUserContent(); //ReportMask.hide(); } }); }; function noHistDialog(){ Ext.Msg.show({ title:'GetLabel('_GEN_MSG_');?>', msg: 'GetLabel('_NO_REPORTS_4_STATION_');?>', buttons: Ext.Msg.OK, icon: Ext.MessageBox.INFO }); }; var history_map = null; function initHistoryMap( map_id, x, y ){ if( tlInterval!= null ){ window.clearTimeout( tlInterval ); tlInterval = null; }; var mapLayers = []; if( history_map != null ){ history_map.off(); history_map.remove(); history_map = null; }; history_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( history_map ); Ext.Ajax.request({ url: '/lib/controller/listHistoryStations.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++ ){ if( data.stations[i].status ){ stationMarkers[ data.stations[i].id ] = L.marker([data.stations[i].y, data.stations[i].x], { draggable: false, icon: GREEN_Icon, zIndexOffset: 1000, mycustomid: data.stations[i].id } ).addTo( history_map ).on('click', loadHistoryStationEvt ); } else { 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( history_map ).on('click', noHistDialog ); }; }; }; }, failure: failureAJAXFunction }); }; function getBackToHistoryMap(){ autoRiseEvent = false; changeContent( 2, 0 ); updateUserContent(); var tP = Ext.getCmp('left_side_menu'); tP.removeAll( true ); tP.add({ layout:'vbox', frame: false, border: false, items:[{ xtype: 'panel', frame: true, border: false, items: [{ html: '
GetLabel('_PLS_SEL_STA_ONMAP_');?>
', height: PanelH - 30 }] }] }); tP.doLayout(); loadHistoryMapView(); }; function loadHistoryMapView(){ autoRiseEvent = false; Ext.Ajax.request({ url: '/lib/controller/getHistoryMapView.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; }; function initReportsView(){ 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:[{ xtype: 'panel', frame: true, border: false, items: [{ html: '
GetLabel("_PLS_SEL_STA_ONMAP_");?>
', height: PanelH - 30 }] }] }); tP.doLayout(); monitoringViewLevel = contentView.l[2].v; switch( monitoringViewLevel ){ case 0:{ loadHistoryMapView(); break; }; case 1:{ loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent ); break; }; case 2:{ var tA = contentView.l[2].p.split('-'); rep_selectedStation = parseInt( tA[0] ); rep_selectedDateTS = parseInt( tA[1] ); loadHistoryStation( rep_selectedStation, autoRiseEvent ); loadReportDayTree( rep_selectedDateTS ); break; }; case 5:{ var tA = contentView.l[2].p.split('-'); rep_selectedStation = parseInt( tA[0] ); rep_selectedDateTS = parseInt( tA[1] ); rep_selectedEventId = parseInt( tA[2] ); loadReportDayTree( rep_selectedDateTS ); loadHistorySessionView( rep_selectedEventId ); break; }; }; //Ext.getCmp('main_content').doLayout(); };