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

2715 lines
89 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var map = null;
  3. var selectedMarker = null;
  4. var timelineObj = null;
  5. var rep_selectedEventId = 0;
  6. var rep_selectedDateTS = 0;
  7. var rep_selectedStation = 0;
  8. var rep_selectedEvtTS = 0;
  9. // Calendar
  10. var CurrentDate=(new Date())/1000;
  11. var today=new Date();
  12. var SY=1900+today.getYear();
  13. var SMO=today.getMonth()+1;
  14. var SD=today.getDate();
  15. var SelectedDay = SD;
  16. var Dates = new Array();
  17. function CheckDate(D){
  18. for(j_index=0;j_index<Dates.length;j_index++){
  19. if (Dates[j_index]==D)return true;
  20. };
  21. return false;
  22. };
  23. function ShiftBAK(){
  24. CurrentDate=CurrentDate-24*3600*GetMonthLength(CurrentDate);
  25. BuildCalendar();
  26. SMO = GetMonthNum(CurrentDate);
  27. SY = GetYear(CurrentDate);
  28. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  29. loadCalendarDates();
  30. };
  31. function ShiftFWD(){
  32. CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate);
  33. BuildCalendar();
  34. SMO = GetMonthNum(CurrentDate);
  35. SY = GetYear(CurrentDate);
  36. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  37. loadCalendarDates();
  38. };
  39. function GetMonthName(UTS){ // Unix Time Stamp
  40. var MoNames= new Array();
  41. MoNames[0]='January';
  42. MoNames[1]='February';
  43. MoNames[2]='March';
  44. MoNames[3]='April';
  45. MoNames[4]='May';
  46. MoNames[5]='June';
  47. MoNames[6]='July';
  48. MoNames[7]='August';
  49. MoNames[8]='September';
  50. MoNames[9]='October';
  51. MoNames[10]='November';
  52. MoNames[11]='December';
  53. CDate=new Date();
  54. CDate.setTime(UTS*1000);
  55. CMo=CDate.getMonth();
  56. return MoNames[CMo];
  57. };
  58. function GetMonthShift(UTS){ // Unix Time Stamp
  59. CDate=new Date();
  60. CDate.setTime(UTS*1000);
  61. CDate.setTime((UTS-(CDate.getDate()-1)*86400)*1000);
  62. return CDate.getDay();
  63. };
  64. function GetMonthLength(UTS){ // Unix Time Stamp
  65. CDate=new Date();
  66. CDate.setTime(UTS*1000);
  67. CD=CDate.getDate();
  68. RetVal=31;
  69. CDate.setTime((UTS+(31-CD)*86400)*1000);
  70. if ( CDate.getDate()==31) return RetVal;
  71. RetVal=30;
  72. CDate.setTime((UTS+(30-CD)*86400)*1000);
  73. if ( CDate.getDate()==30) return RetVal;
  74. RetVal=29;
  75. CDate.setTime((UTS+(29-CD)*86400)*1000);
  76. if ( CDate.getDate()==29) return RetVal;
  77. RetVal=28;
  78. CDate.setTime((UTS+(28-CD)*86400)*1000);
  79. if ( CDate.getDate()==28) return RetVal;
  80. return -1;
  81. };
  82. function GetMonthNum(UTS){ // Unix Time Stamp
  83. CDate=new Date();
  84. CDate.setTime(UTS*1000);
  85. return CDate.getMonth()+1;
  86. };
  87. function GetYear(UTS){ // Unix Time Stamp
  88. CDate=new Date();
  89. CDate.setTime(UTS*1000);
  90. y=CDate.getYear();
  91. if (y<100)y+=2000;
  92. if (y<200)y+=1900;
  93. return y;
  94. };
  95. function GetDay(UTS){ // Unix Time Stamp
  96. CDate=new Date();
  97. CDate.setTime(UTS*1000);
  98. y=CDate.getDate();
  99. return y;
  100. };
  101. function selectDate( m, d ){
  102. SY = GetYear(CurrentDate);
  103. SMO = m;
  104. SD = d;
  105. SelectedDay = SD;
  106. getData( 'arch' );
  107. };
  108. function BuildCalendar( ){
  109. Msh=GetMonthShift(CurrentDate);
  110. Mnm=GetMonthName(CurrentDate);
  111. Mln=GetMonthLength(CurrentDate);
  112. Mid=GetMonthNum(CurrentDate);
  113. Mye=GetYear(CurrentDate);
  114. InDTA='<table cellpadding="2" cellspacing="0"><tr height="19px"><td valign="middle"><a href="#" onclick="ShiftBAK();"><img src="/style/img/calendar/l_cal_b.gif"></a></td><td colspan="5" class="CalendarMN" align="center">'+Mnm+' '+Mye+'</td><td><a href="#" onclick="ShiftFWD();"><img border=0 src="/style/img/calendar/r_cal_b.gif"></a></td></tr>';
  115. InDTA+='<tr><td class="CalendarWT" align="center">Su</td><td class="CalendarWT" align="center">Mo</td><td class="CalendarWT" align="center">Tu</td><td class="CalendarWT" align="center">We</td><td class="CalendarWT" align="center">Th</td><td class="CalendarWT" align="center">Fr</td><td class="CalendarWT" align="center">Sa</td></tr>';
  116. InDTA+='<tr>';
  117. for(index=0;index<Msh;index++){
  118. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  119. };
  120. for(;index<(Mln+Msh);index++){
  121. if( CheckDate(index-Msh+1) ){
  122. //InDTA+='<td style="padding: 1px"><div id="ds'+Mid.toString()+(index-Msh+1).toString()+'" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" href="#" title="'+(index-Msh+1).toString()+'" class="CalendarDE">'+(index-Msh+1).toString()+'</a></td>';
  123. if( SD == index ){
  124. InDTA+='<td style="padding: 1px"><div id="selected_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Selected" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
  125. } else {
  126. InDTA+='<td style="padding: 1px"><div id="have_data_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Have Events" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
  127. };
  128. } else {
  129. if( SD == index ){
  130. InDTA+='<td style="padding: 1px"><div id="selected_day" class="calendar_t" title="Selected">'+(index-Msh+1).toString()+'</a></td>';
  131. } else {
  132. InDTA+='<td style="padding: 1px"><div id="no_data_day" class="calendar_t" title="No Events">'+(index-Msh+1).toString()+'</a></td>';
  133. };
  134. };
  135. if ((index+1)%7==0){
  136. InDTA+='</tr><tr>';
  137. };
  138. };
  139. for(;(index)%7!=0;index++){
  140. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  141. };
  142. InDTA+='</tr></table>';
  143. tab=document.getElementById('calendar_TD');
  144. tab.innerHTML=InDTA;
  145. };
  146. function loadCalendarDates(){
  147. Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Calo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
  148. width: '100%',
  149. hidden: true,
  150. progress: true,
  151. closable: false
  152. });
  153. Ext.Ajax.request({
  154. url: '/lib/controller/getEventDates.php',
  155. params: {
  156. NID: selecredActiveSourceFilter,
  157. UID: <?=$UserID;?>,
  158. SID: '<?=$Session;?>',
  159. SYE: SY,
  160. SMO: SMO
  161. },
  162. success: function( response, opts ){
  163. Ext.MessageBox.hide();
  164. var data = Ext.decode( response.responseText );
  165. if( data.status == 'ok' ){
  166. Dates = data.days;
  167. BuildCalendar();
  168. //for( var i = 0; i < data.days.length; i++ ){
  169. //
  170. //};
  171. };
  172. },
  173. failure: function( response, opts ) {
  174. Ext.MessageBox.hide();
  175. }
  176. });
  177. };
  178. var eventsListStore = new Ext.data.JsonStore({
  179. root: 'log',
  180. totalProperty: 'totalCount',
  181. idProperty: 'id',
  182. remoteSort: true,
  183. fields: [{
  184. name: 'id',
  185. type: 'int'
  186. },{
  187. name: 'date',
  188. type: 'string'
  189. },{
  190. name: 'time',
  191. type: 'string'
  192. },{
  193. name: 'device',
  194. type: 'string'
  195. },{
  196. name: 'event',
  197. type: 'int'
  198. },{
  199. name: 'data',
  200. type: 'string',
  201. },{
  202. name: 'has_target',
  203. type: 'boolean'
  204. },{
  205. name: 'has_geo',
  206. type: 'boolean'
  207. },{
  208. name: 'has_images',
  209. type: 'boolean'
  210. },{
  211. name: 'images',
  212. type: 'Array'
  213. },{
  214. name: 'dev_type',
  215. type: 'int'
  216. },{
  217. name: 'geo',
  218. type: 'object'
  219. }] /*,
  220. proxy : new Ext.data.HttpProxy({
  221. method: 'POST',
  222. prettyUrls: false,
  223. url: '/lib/controller/getEventRecords.php',
  224. headers: {
  225. UID: <?=$UserID;?>,
  226. SID: '<?=$Session;?>',
  227. NID: 1
  228. }
  229. })*/
  230. });
  231. var videosListStore = new Ext.data.JsonStore({
  232. root: 'videos',
  233. // totalProperty: 'totalCount',
  234. idProperty: 'id',
  235. remoteSort: true,
  236. fields: [{
  237. name: 'id',
  238. type: 'int'
  239. },{
  240. name: 'sts',
  241. type: 'int'
  242. },{
  243. name: 'ets',
  244. type: 'int'
  245. },{
  246. name: 'side',
  247. type: 'string'
  248. },{
  249. name: 'name',
  250. type: 'string',
  251. },{
  252. name: 'fps',
  253. type: 'int',
  254. }]
  255. });
  256. var EventPanelWindow = null;
  257. function showEventPanel(){
  258. if( EventPanelWindow == null ){
  259. EventPanelWindow = new Ext.Window({
  260. modal: true,
  261. title: '<?=$Labels->GetLabel("_EVENT_VIEWER_");?>',
  262. width: winW*0.66,
  263. height: winH*0.66,
  264. layout: 'fit',
  265. closeAction: 'hide',
  266. items:[{
  267. title: 'Cameras',
  268. html:'koko',
  269. autoScroll: true,
  270. height: 320
  271. },{
  272. html: 'koko22',
  273. height: 320
  274. }]
  275. });
  276. };
  277. EventPanelWindow .show();
  278. };
  279. function ModeRenderer(val){
  280. var p1, p2, p3;
  281. if( ( val & 1 ) == 1 ){
  282. p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
  283. } else {
  284. p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
  285. };
  286. if( ( val & 2 ) == 2 ){
  287. p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
  288. } else {
  289. p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
  290. };
  291. if( ( val & 4 ) == 4 ){
  292. p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
  293. } else {
  294. p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
  295. };
  296. return p1+p2+p3;
  297. };
  298. function LocRenderer( val ){
  299. if( val ){
  300. return '<img src="/style/icons/icons/accept.png" alt="Location" />';
  301. };
  302. return '<img src="/style/icons/icons/bullet_white.png" alt="NO Location" />';
  303. };
  304. function PicRenderer( val ){
  305. if( val ){
  306. return '<img src="/style/icons/icons/camera_link.png"/>';
  307. };
  308. return '<img src="/style/icons/icons/bullet_white.png"/>';
  309. };
  310. function EvtTypeRenderer( val ){
  311. switch( val ){
  312. case 6: return 'Device Enters Into Study Mode';
  313. case 7: return 'Device Is BUSY';
  314. case 8: return 'Flip Complete';
  315. case 9: return 'Scan Complete';
  316. case 10:
  317. case 11:
  318. case 12:
  319. case 13:
  320. case 14: return 'Target';
  321. case 36: return 'Region Of Interest';
  322. default: return 'Event ['+val+']';
  323. };
  324. };
  325. var eventsListColModel_ops = {
  326. columns: [
  327. {header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  328. {header: "Date",width: 100, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' },
  329. {header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' },
  330. {header: "Device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
  331. {header: "Event", width: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer },
  332. {header: "Info", width: 200, sortable: false, dataindex: 'data' },
  333. {header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer },
  334. {header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer }
  335. ],
  336. defaults: {
  337. sortable: true,
  338. menuDisabled: true,
  339. width: 100
  340. },
  341. listeners: {
  342. hiddenchange: function(cm, colIndex, hidden) {
  343. //saveConfig(colIndex, hidden);
  344. }
  345. }
  346. };
  347. var SelectedRow = -1;
  348. var eventsListSelModel_ops = {
  349. singleSelect: true,
  350. listeners: {
  351. rowselect: function(sm, row, rec ) {
  352. loadEventProperties( rec.data );
  353. SelectedEvent = rec.data.id;
  354. SelectedRow = row;
  355. //alert( SelectedEvent );
  356. //var CB = Ext.getCmp('con_to_src');
  357. //CB.enable();
  358. }
  359. }
  360. };
  361. function loadTimeLineGroups( NID ){
  362. Ext.Ajax.request({
  363. url: '/lib/controller/getTimeLineGroups.php',
  364. params: {
  365. NID: NID,
  366. UID: <?=$UserID;?>,
  367. SID: '<?=$Session;?>'
  368. },
  369. success: function( response, opts ){
  370. // If the response is JSON, you have to decode it
  371. var data = Ext.decode(response.responseText);
  372. //for(var i = 0; i < data.length; i++) {
  373. //tlGroups.add(data[i]);
  374. //};
  375. tlGroups.update( data );
  376. loadTimeLineItems( SelectedSite );
  377. tlInterval = window.setInterval( loadTimeLineItems, 333, SelectedSite );
  378. },
  379. failure: function( response, opts ) {
  380. //Ext.fly('some_div').update('Fail!');
  381. }/*,
  382. callback: function(options,success,response){
  383. // use this if you need to perform your own success/failure checking
  384. }*/
  385. });
  386. };
  387. function clickDeviceSelector( id ){
  388. var rr = document.getElementById(id+'_div');
  389. if( selecredActiveSourceFilter != id ){
  390. if( selecredActiveSourceFilter > 0 ){
  391. var oo = document.getElementById( selecredActiveSourceFilter + '_div');
  392. oo.classList.remove( "cardDeviceSourceSelected" );
  393. oo.classList.add( "cardDeviceSource" );
  394. };
  395. rr.classList.remove( "cardDeviceSource" );
  396. rr.classList.add( "cardDeviceSourceSelected" );
  397. selecredActiveSourceFilter = id;
  398. turnOffAllGzButThis( selecredActiveSourceFilter );
  399. } else {
  400. selecredActiveSourceFilter = 0;
  401. rr.classList.remove( "cardDeviceSourceSelected" );
  402. rr.classList.add( "cardDeviceSource" );
  403. turnAllGzOn();
  404. var tPanel = Ext.getCmp('prop_content');
  405. tPanel.remove(0);
  406. tPanel.add( {
  407. title: 'Event Information',
  408. border: false,
  409. frame: false,
  410. collapsible: false,
  411. draggable: false,
  412. html: '<p align="center">Select an Event from TimeLine to See Information</p>'
  413. } );
  414. tPanel.doLayout();
  415. };
  416. };
  417. function getZoneByNode( nid ){
  418. var rVal = -1;
  419. for( var i=0; i < ActiveZones.totalCount; i++ ){
  420. if( ActiveZones.zones[i].dev_id == nid ){
  421. rVal = i;
  422. break;
  423. };
  424. };
  425. return rVal;
  426. };
  427. function turnOffAllGzButThis( nid ){
  428. var chocho = -1;
  429. for( var i=0; i < ActiveZones.totalCount; i++ ){
  430. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  431. map.removeLayer( ActiveZones.fig[i] );
  432. map.removeLayer( ActiveZones.zang[i] );
  433. map.removeLayer( ActiveZones.center[i] );
  434. };
  435. if( chocho > -1 ){
  436. map.addLayer( ActiveZones.fig[chocho] );
  437. map.addLayer( ActiveZones.zang[chocho] );
  438. map.addLayer( ActiveZones.center[chocho] );
  439. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  440. map.flyToBounds( cVisible.getBounds() );
  441. };
  442. };
  443. function turnAllGzOn(){
  444. var tall = Array();
  445. for( var i=0; i < ActiveZones.totalCount; i++ ){
  446. tall[i*3] = ActiveZones.fig[i];
  447. tall[i*3+1] = ActiveZones.zang[i];
  448. tall[i*3+2] = ActiveZones.center[i];
  449. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  450. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  451. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  452. };
  453. var cVisible = L.featureGroup( tall );
  454. map.flyToBounds( cVisible.getBounds() );
  455. };
  456. function loadMapZones( SID ){
  457. Ext.Ajax.request({
  458. url: '/lib/controller/getGeoZones.php',
  459. params: {
  460. SITE: SID,
  461. UID: <?=$UserID;?>,
  462. SID: '<?=$Session;?>'
  463. },
  464. success: function( response, opts ){
  465. // If the response is JSON, you have to decode it
  466. var data = Ext.decode(response.responseText);
  467. var pp = Ext.getCmp('sources_panel');
  468. if( typeof pp !== 'undefined' ) pp.removeAll();
  469. ActiveZones = data;
  470. ActiveZones.fig = new Array();
  471. ActiveZones.zang = new Array();
  472. ActiveZones.center = new Array();
  473. for(var i = 0; i < data.totalCount; i++ ) {
  474. switch( data.zones[i].type ){
  475. case 'circle':{
  476. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  477. 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 } );
  478. //map.addLayer( ActiveZones.fig[i] );
  479. break;
  480. };
  481. case 'poly':{
  482. 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);
  483. //map.addLayer( ActiveZones.fig[i] );
  484. break;
  485. };
  486. case 'image':{
  487. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  488. //map.addLayer( ActiveZones.fig[i] );
  489. break;
  490. };
  491. case 'image_rot':{
  492. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  493. opacity: 0.8 //,
  494. //interactive: true,
  495. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geográfico Nacional de España</a>"
  496. });//.addTo( map );
  497. //map.addLayer( ActiveZones.fig[i] );
  498. break;
  499. };
  500. };
  501. if( data.zones[i].dev_is_source ){
  502. if( typeof pp !== 'undefined' ) {
  503. var sty = '';
  504. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  505. sty = 'cardDeviceSourceSelected';
  506. } else {
  507. sty = 'cardDeviceSource';
  508. };
  509. pp.add( {
  510. id: data.zones[i].dev_id+'_container',
  511. frame: false,
  512. border: false,
  513. width: 130,
  514. height: 130,
  515. html: '<div id="'+data.zones[i].dev_id+'_div" class="'+sty+'" onclick="clickDeviceSelector('+data.zones[i].dev_id+');"><img id="'+data.zones[i].dev_id+'_ind" width="16px" src="/style/assets/led_green_blink_300ms.gif"><center><img src="/style/assets/'+data.zones[i].dev_type+'_node.png"><br/><p class="dev_name">'+data.zones[i].dev_name+'</p></center></div>'
  516. });
  517. };
  518. };
  519. if( data.zones[i].zang != undefined ){
  520. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  521. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  522. };
  523. if( data.zones[i].center != undefined ){
  524. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  525. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
  526. };
  527. };
  528. if( selecredActiveSourceFilter == 0 ){
  529. turnAllGzOn();
  530. } else {
  531. turnOffAllGzButThis( selecredActiveSourceFilter );
  532. };
  533. if( typeof pp !== 'undefined' ) pp.doLayout();
  534. //LoadMapEvents( SelectedSite );
  535. //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite );
  536. },
  537. failure: function( response, opts ) {
  538. //Ext.fly('some_div').update('Fail!');
  539. }
  540. });
  541. };
  542. var cevt = Array();
  543. var coz = Array();
  544. function showEventsOnMap( data, removeCursor = true ){
  545. if( removeCursor ) map.removeLayer( selectedMarker );
  546. if( cevt.length ){
  547. for( i=0; i< cevt.length; i++ ){
  548. if( cevt[i]!= null ){
  549. cevt[i].remove();
  550. delete( cevt[i] );
  551. cevt[i] = null;
  552. };
  553. };
  554. };
  555. if( coz.length ){
  556. for( i=0; i< coz.length; i++ ){
  557. if( coz[i]!= null ){
  558. coz[i].remove();
  559. delete( coz[i] );
  560. coz[i]=null;
  561. };
  562. };
  563. };
  564. var zz = ( 1.0 / ( data.log.length + 0 ) );
  565. var idx = 0;
  566. for( i=0; i < data.log.length; i++ ){
  567. if( data.log[i].has_geo ){
  568. var cp_color='#FF0000';
  569. switch( data.log[i].event ){
  570. case 36: cp_color='#0000FF'; break;
  571. };
  572. 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 ){
  573. loadEventPropertiesByID( this.options.id );
  574. } );
  575. cevt[idx].addTo(map);
  576. idx++;
  577. };
  578. };
  579. };
  580. var sesVideosStartTS = 0;
  581. function VideoButtonRenderer( value, metaData, record, rowIndex, colIndex, store ){
  582. return '<a class="small_vd_btn" href="/lib/controller/getVideoSegment.php?SESSION='+rep_selectedEventId+'&VID='+record.data.id+'">Download</a>';
  583. }
  584. function VideoStartRenderer( value, metaData, record, rowIndex, colIndex, store ){
  585. var csec = parseInt((record.data.sts - sesVideosStartTS)/1000);
  586. var cmin = parseInt( csec / 60 );
  587. var chour = parseInt( csec / 3600 );
  588. csec = csec % 60;
  589. var oms='';
  590. if( chour ){
  591. oms= String(chour).padStart(2, '0')+':'+String(cmin).padStart(2, '0')+':'+String(csec).padStart(2, '0');
  592. } else {
  593. if( cmin ){
  594. oms= '00:'+String(cmin).padStart(2, '0')+':'+String(csec).padStart(2, '0');
  595. } else {
  596. oms= '00:00:'+String(csec).padStart(2, '0');
  597. };
  598. };
  599. return oms;
  600. }
  601. function VideoSideRenderer( value ){
  602. if( value == 'L' ){
  603. return sesVideosListLName;//'<img height="16px" src="/style/assets/lside.png">';
  604. };
  605. return sesVideosListRName;//'<img height="16px" src="/style/assets/rside.png">';
  606. }
  607. function VideoLengthRenderer( value, metaData, record, rowIndex, colIndex, store ){
  608. return parseInt((record.data.ets - record.data.sts)/1000)+ ' sec.';
  609. }
  610. var videosListColModel_ops = {
  611. columns: [
  612. {header: "ID", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  613. {header: "Time",width: 120, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'sts', renderer: VideoStartRenderer },
  614. {header: "Length", width: 100, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ets', renderer: VideoLengthRenderer },
  615. {header: "Side", width: 100, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'side' ,renderer: VideoSideRenderer },
  616. /*{header: "Name", width: 180, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'name' },*/
  617. {header: "Download", width: 100, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'id', renderer: VideoButtonRenderer }
  618. ],
  619. defaults: {
  620. sortable: true,
  621. menuDisabled: true,
  622. width: 100
  623. },
  624. listeners: {
  625. hiddenchange: function(cm, colIndex, hidden) {
  626. //saveConfig(colIndex, hidden);
  627. }
  628. }
  629. };
  630. var SelectedVideo = -1;
  631. var SelectedVideoRow = null;
  632. var videosListSelModel_ops = {
  633. singleSelect: true,
  634. listeners: {
  635. rowselect: function(sm, row, rec ) {
  636. //loadEventProperties( rec.data );
  637. SelectedVideo = rec.data.id;
  638. SelectedVideoRow = row;
  639. //alert( SelectedEvent );
  640. //var CB = Ext.getCmp('con_to_src');
  641. //CB.enable();
  642. }
  643. }
  644. };
  645. var CompositeVideoStatus = 0;
  646. var oldCompositeVideoStatus = -1;
  647. var CompositeVideoProgress = 0;
  648. var CompositeVideoStatusTO = null;
  649. var sesVideosListWindow = null;
  650. var sesVideosListRName = '';
  651. var sesVideosListLName = '';
  652. var sesVideosListRExists = false;
  653. var sesVideosListLExists = false;
  654. var CompositeVideoRightInfo = null;
  655. var CompositeVideoLeftInfo = null;
  656. function startVideoComposer(){
  657. Ext.Ajax.request({
  658. url: '/lib/controller/doSessionOperations.php',
  659. params: {
  660. SESSION: SelectedSessionID,
  661. OPID: 3,
  662. UID: <?=$UserID;?>,
  663. SID: '<?=$Session;?>'
  664. },
  665. success: function( response, opts ){
  666. var data = Ext.decode(response.responseText);
  667. if( data.status == 'ok' ){
  668. CompositeVideoStatus = 1;
  669. CompositeVideoProgress = 0;
  670. CompositeVideoStatusUpdate();
  671. setDonatStatus( 1, 0, CompositeVideoProgress );
  672. CompositeVideoStatusTO = window.setTimeout( eventVideosStatusUpdater, 1000 );
  673. } else {
  674. Ext.Msg.show({
  675. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  676. msg: data.msg,
  677. buttons: Ext.Msg.OK,
  678. icon: Ext.MessageBox.ERROR
  679. });
  680. };
  681. },
  682. failure: failureAJAXFunction
  683. });
  684. }
  685. function CompositeVideoStatusUpdate(){
  686. if( oldCompositeVideoStatus != CompositeVideoStatus ){
  687. var rr = Ext.getCmp('EvtVidCompDownPanel');
  688. rr.removeAll();
  689. oldCompositeVideoStatus = CompositeVideoStatus;
  690. switch( CompositeVideoStatus ){
  691. case 0:{
  692. rr.add({
  693. xtype: 'panel',
  694. frame: false,
  695. border: false,
  696. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=2>Compose Videos into one file</td></tr><tr><td colspan=2>&nbsp;</td></tr><tr><td align="center" colspan=2><a class="big_vd_btn" href="javascript:startVideoComposer()">Start Video Composer</a></td></tr><tr><td colspan=2>&nbsp;</td></tr></table></div>'
  697. });
  698. break;
  699. };
  700. case 1:{
  701. rr.add({
  702. border: false,
  703. frame: false,
  704. //layout: 'vbox',
  705. //layoutConfig: {
  706. // align: 'center'
  707. //},
  708. items:[{
  709. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center">Composing Video<br/>You may close this window<br/>and<br/>come back later to download video.</td><td width="100px" align="center"><svg class="donut" width="80" height="100%" viewBox="0 0 42 42"><circle id="status_1_donut0_segment2" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#b1c94e" stroke-width="3" stroke-dasharray="0 100" stroke-dashoffset="25"></circle><circle id="status_1_donut0_segment3" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#aaddff" stroke-width="3" stroke-dasharray="0 100" stroke-dashoffset="25"></circle><circle id="status_1_donut0_segment1" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="3" stroke-dasharray="0 100" stroke-dashoffset="25"></circle><g class="chart-text-black"><text x="50%" y="50%" class="chart-number" id="status_1_totalValue0">0%</text><text x="50%" y="50%" class="chart-label">DONE</text></g></svg></td></tr></table></div>'
  710. }],
  711. listeners:{
  712. afterrender: function(){
  713. setDonatStatus( 1, 0, 29 );
  714. }
  715. }
  716. });
  717. eventVideosStatusUpdater();
  718. break;
  719. };
  720. case 2:{
  721. if( sesVideosListRExists ){
  722. rr.add({
  723. xtype: 'panel',
  724. frame: false,
  725. border: false,
  726. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=3>Composed Video from '+sesVideosListRName+' side</td></tr><tr><td align="right">Duration:</td><td colspan=2>'+CompositeVideoRightInfo.duration+'</td></tr><tr><td align="right">File size:</td><td colspan=2>'+CompositeVideoRightInfo.file_size+'</td></tr><tr><td align="center" colspan=2><div id="r_d_button"></div></td><td align="center"><div id="r_e_button"></div></td></tr><tr><td colspan=3>&nbsp;</td></tr></table></div>'
  727. });
  728. rr.doLayout();
  729. new Ext.Button({
  730. text: 'Download',
  731. width: '80%',
  732. renderTo: 'r_d_button',
  733. handler: function(){
  734. const l = document.createElement('a');
  735. l.style.display = 'none';
  736. l.href = '/lib/controller/getComposedVideo.php?SESSION='+rep_selectedEventId+'&SIDE=L';
  737. document.body.appendChild(l);
  738. l.click();
  739. }
  740. });
  741. new Ext.Button({
  742. text: 'Delete',
  743. width: '80%',
  744. renderTo: 'r_e_button',
  745. handler: function(){
  746. Ext.Ajax.request({
  747. url: '/lib/controller/doSessionOperations.php',
  748. params: {
  749. SESSION: rep_selectedEventId,
  750. OPID: 4,
  751. UID: <?=$UserID;?>,
  752. SID: '<?=$Session;?>'
  753. },
  754. success: function( response, opts ){
  755. var data = Ext.decode(response.responseText);
  756. if( data.status == 'ok' ){
  757. CompositeVideoStatus = 0;
  758. CompositeVideoProgress = 0;
  759. CompositeVideoStatusUpdate();
  760. } else {
  761. Ext.Msg.show({
  762. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  763. msg: data.msg,
  764. buttons: Ext.Msg.OK,
  765. icon: Ext.MessageBox.ERROR
  766. });
  767. };
  768. },
  769. failure: failureAJAXFunction
  770. });
  771. }
  772. });
  773. };
  774. if( sesVideosListLExists ){
  775. rr.add({
  776. xtype: 'panel',
  777. frame: false,
  778. border: false,
  779. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=3>Composed Video from '+sesVideosListLName+' side</td></tr><tr><td align="right">Duration:</td><td colspan=2>'+CompositeVideoLeftInfo.duration+'</td></tr><tr><td align="right">File size:</td><td colspan=2>'+CompositeVideoLeftInfo.file_size+'</td></tr><tr><td align="center" colspan=2><div id="l_d_button"></div></td><td align="center"><div id="l_e_button"></div></td></tr><tr><td colspan=3>&nbsp;</td></tr></table></div>'
  780. });
  781. rr.doLayout();
  782. new Ext.Button({
  783. text: 'Download',
  784. width: '80%',
  785. renderTo: 'l_d_button',
  786. handler: function(){
  787. const l = document.createElement('a');
  788. l.style.display = 'none';
  789. l.href = '/lib/controller/getComposedVideo.php?SESSION='+rep_selectedEventId+'&SIDE=L';
  790. document.body.appendChild(l);
  791. l.click();
  792. }
  793. });
  794. new Ext.Button({
  795. text: 'Delete',
  796. width: '80%',
  797. renderTo: 'l_e_button',
  798. handler: function(){
  799. Ext.Ajax.request({
  800. url: '/lib/controller/doSessionOperations.php',
  801. params: {
  802. SESSION: rep_selectedEventId,
  803. OPID: 4,
  804. UID: <?=$UserID;?>,
  805. SID: '<?=$Session;?>'
  806. },
  807. success: function( response, opts ){
  808. var data = Ext.decode(response.responseText);
  809. if( data.status == 'ok' ){
  810. CompositeVideoStatus = 0;
  811. CompositeVideoProgress = 0;
  812. CompositeVideoStatusUpdate();
  813. } else {
  814. Ext.Msg.show({
  815. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  816. msg: data.msg,
  817. buttons: Ext.Msg.OK,
  818. icon: Ext.MessageBox.ERROR
  819. });
  820. };
  821. },
  822. failure: failureAJAXFunction
  823. });
  824. }
  825. });
  826. };
  827. break;
  828. };
  829. };
  830. rr.doLayout();
  831. };
  832. }
  833. function hideEventsVideos(){
  834. if( CompositeVideoStatusTO!= null ) window.clearTimeout( CompositeVideoStatusTO );
  835. CompositeVideoStatusTO = null;
  836. sesVideosListWindow = null;
  837. oldCompositeVideoStatus = -1;
  838. }
  839. function eventVideosStatusUpdater(){
  840. Ext.Ajax.request({
  841. url: '/lib/controller/getComposerStatus.php',
  842. params: {
  843. SESSION: SelectedSessionID,
  844. UID: <?=$UserID;?>,
  845. SID: '<?=$Session;?>'
  846. },
  847. success: function( response, opts ){
  848. var data = Ext.decode(response.responseText);
  849. if( data.status == 'ok' ){
  850. if( data.composed_video_status == 'D'){
  851. CompositeVideoStatus = 2;
  852. sesVideosListRExists = data.composed_right_video_exists;
  853. sesVideosListLExists = data.composed_left_video_exists;
  854. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  855. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  856. CompositeVideoStatusUpdate();
  857. } else {
  858. CompositeVideoStatusUpdate();
  859. CompositeVideoProgress = data.composed_video_progress;
  860. setDonatStatus( 1, 0, CompositeVideoProgress );
  861. CompositeVideoStatusTO = window.setTimeout( eventVideosStatusUpdater, 1000 );
  862. };
  863. }
  864. }
  865. });
  866. }
  867. function showEventsVideos(){
  868. if( sesVideosListWindow == null ){
  869. sesVideosListWindow = new Ext.Window({
  870. title: 'Videos',
  871. modal: true,
  872. width: 510,
  873. height: 560,
  874. closeAction: 'close',
  875. resizable: false,
  876. items:[{
  877. xtype: 'grid',
  878. height: 350,
  879. ds: videosListStore,
  880. cm: new Ext.grid.ColumnModel( videosListColModel_ops ),
  881. sm: new Ext.grid.RowSelectionModel( videosListSelModel_ops ),
  882. },{
  883. xtype: 'panel',
  884. border: false,
  885. frame: false,
  886. id: 'EvtVidCompDownPanel',
  887. autoScroll: true,
  888. items:[]
  889. }],
  890. listeners:{
  891. close: hideEventsVideos
  892. }
  893. });
  894. };
  895. sesVideosListWindow.show();
  896. CompositeVideoStatusUpdate();
  897. };
  898. function LoadMapEventsZ( Mode ){
  899. if( tlLoadLocker ) return;
  900. tlLoadLocker = true;
  901. Ext.Ajax.request({
  902. url: '/lib/controller/getGeoAlerts.php',
  903. params: {
  904. SITE: <?=$SiteID;?>,
  905. UID: <?=$UserID;?>,
  906. SID: '<?=$Session;?>',
  907. MODE: Mode
  908. },
  909. success: function( response, opts ){
  910. if( cevt.length ){
  911. for( i=0; i< cevt.length; i++ ){
  912. if( cevt[i]!= null ){
  913. cevt[i].remove();
  914. delete( cevt[i] );
  915. cevt[i] = null;
  916. };
  917. };
  918. };
  919. if( coz.length ){
  920. for( i=0; i< coz.length; i++ ){
  921. if( coz[i]!= null ){
  922. coz[i].remove();
  923. delete( coz[i] );
  924. coz[i]=null;
  925. };
  926. };
  927. };
  928. var data = Ext.decode( response.responseText );
  929. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  930. for( i=0; i < data.evt.length; i++ ){
  931. 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 ){
  932. loadEventProperties( this.options.id );
  933. } );
  934. cevt[i].addTo(map);
  935. };
  936. for( i=0; i < data.other.length; i++ ){
  937. switch( data.other[i].type ){
  938. case 'circle':{
  939. 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 } );
  940. coz[i].addTo(map);
  941. break;
  942. };
  943. };
  944. };
  945. //eventsListStore.reload();
  946. tlLoadLocker = false;
  947. },
  948. failure: function( response, opts ) {
  949. //Ext.fly('some_div').update('Fail!');
  950. tlLoadLocker = false;
  951. }
  952. });
  953. };
  954. function loadEventPropertiesByID( id ){
  955. var d = eventsListStore.findExact( 'id', id );
  956. if( d > -1 ) {
  957. var EventRec = eventsListStore.getAt( d );
  958. loadEventProperties( EventRec.data );
  959. };
  960. };
  961. function loadEventProperties( EventRec ){
  962. var tPanel = Ext.getCmp('prop_content');
  963. tPanel.removeAll();// remove( 0 );
  964. var tt = '';
  965. if( selectedMarker!= null ){
  966. selectedMarker.remove();
  967. //map.removeLayer( selectedMarker );
  968. if( EventRec.has_geo ){
  969. tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
  970. selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
  971. selectedMarker.addTo( map );
  972. };
  973. };
  974. tPanel.add( {
  975. title: 'Event Details',
  976. html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
  977. } );
  978. if( EventRec.has_images ){
  979. for( var i=0; i < EventRec.images.length; i++ ){
  980. tPanel.add( {
  981. frame: false,
  982. html: '<img width="100%" src="/lib/controller/getPicture.php?PID='+EventRec.images[i]+'" data-enlargeable000 ondblclick="fullScreen(\'img-'+EventRec.id+'\');" style="cursor: zoom-in" id="img-'+EventRec.id+'"/>'
  983. });
  984. };
  985. };
  986. tPanel.doLayout();
  987. };
  988. function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){
  989. if( tlLoadLocker ) return;
  990. tlLoadLocker = true;
  991. if( Mode == 'arch' ){
  992. Ext.MessageBox.wait("Loading Data","Please Wait",{
  993. width: '100%',
  994. hidden: true,
  995. animate: true,
  996. progress: true,
  997. closable: false
  998. });
  999. };
  1000. Ext.Ajax.request({
  1001. url: '/lib/controller/getEventRecords.php',
  1002. params: {
  1003. SITE: <?=$SiteID;?>,
  1004. UID: <?=$UserID;?>,
  1005. SID: '<?=$Session;?>',
  1006. MODE: Mode,
  1007. FIL: selecredActiveSourceFilter,
  1008. SDA: SD,
  1009. SMO: SMO,
  1010. SYE: SY,
  1011. STM: ST,
  1012. ETM: ET,
  1013. STR: SR,
  1014. DIR: DR
  1015. },
  1016. success: function( response, opts ){
  1017. tlLoadLocker = false;
  1018. var data = Ext.decode(response.responseText);
  1019. if( data.updateFROMTO ){
  1020. Ext.getCmp('STimeFROM').setValue( data.STT );
  1021. Ext.getCmp('STimeTO').setValue( data.ENT );
  1022. if( data.SLD > 0 ){
  1023. SMO = GetMonthNum(data.SLD);
  1024. SY = GetYear(data.SLD);
  1025. SD = GetDay(data.SLD);
  1026. BuildCalendar();
  1027. };
  1028. };
  1029. eventsListStore.loadData( data, false );
  1030. if( Mode == 'arch' ){
  1031. showEventsOnMap( data, true );
  1032. Ext.MessageBox.hide();
  1033. if( DR > 0 ){
  1034. Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
  1035. Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
  1036. };
  1037. if( DR < 0 ){
  1038. Ext.getCmp('evtArchLog').getView().focusRow( 0 );
  1039. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  1040. };
  1041. } else {
  1042. showEventsOnMap( data, false );
  1043. //LoadMapEventsZ( Mode );
  1044. };
  1045. },
  1046. failure: failureAJAXFunction
  1047. });
  1048. };
  1049. function loadArchive(){
  1050. debugger;
  1051. if( tlInterval!= null ){
  1052. window.clearInterval( tlInterval );
  1053. tlInterval = null;
  1054. timelineObj = null;
  1055. };
  1056. stopStatusUpdater();
  1057. setUserContent( 2 );
  1058. var tPanel = Ext.getCmp('main_portal');
  1059. tPanel.removeAll( true );
  1060. Ext.getCmp('main_content').setTitle( 'Events Archive' );
  1061. tPanel.add({
  1062. columnWidth: 0.83,
  1063. frame: false,
  1064. border: false,
  1065. items: [{
  1066. title: 'Site Map',
  1067. frame: false,
  1068. border: false,
  1069. layout: 'vbox',
  1070. layoutConfig: {
  1071. align : 'stretch',
  1072. pack : 'start',
  1073. },
  1074. height: PanelH-300,
  1075. items:[{
  1076. height: PanelH-325,
  1077. flex: 1,
  1078. frame: false,
  1079. border: false,
  1080. layout: 'fit',
  1081. items:{
  1082. id: 'event_map',
  1083. html: '&nbsp;'
  1084. }
  1085. }]
  1086. },{
  1087. frame: false,
  1088. border: false,
  1089. collapsible: false,
  1090. draggable: false,
  1091. layout: 'hbox',
  1092. items:[{
  1093. layout: 'form',
  1094. title: 'Date/Time',
  1095. width: 200,
  1096. frame: true,
  1097. border: false,
  1098. labelAlign: 'right',
  1099. labelWidth: 50,
  1100. defaults: { width: 80},
  1101. items: [{
  1102. xtype: 'combo',
  1103. id: 'STimeFROM',
  1104. fieldLabel: 'From',
  1105. editable: false,
  1106. typeAhead: true,
  1107. triggerAction: 'all',
  1108. width: 120,
  1109. lazyRender:true,
  1110. mode: 'local',
  1111. store: new Ext.data.ArrayStore({
  1112. id: 0,
  1113. fields: ['ss', 'displayText' ],
  1114. data: [<?php
  1115. $zuzu = array();
  1116. for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1117. echo implode( ',', $zuzu ); ?>]
  1118. }),
  1119. valueField: 'ss',
  1120. displayField: 'displayText'
  1121. },{
  1122. xtype: 'combo',
  1123. id: 'STimeTO',
  1124. fieldLabel: 'Till',
  1125. editable: false,
  1126. typeAhead: true,
  1127. triggerAction: 'all',
  1128. width: 120,
  1129. lazyRender:true,
  1130. mode: 'local',
  1131. store: new Ext.data.ArrayStore({
  1132. id: 0,
  1133. fields: ['ss', 'displayText' ],
  1134. data: [<?php
  1135. $zuzu = array();
  1136. for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1137. echo implode( ',', $zuzu ); ?>]
  1138. }),
  1139. valueField: 'ss',
  1140. displayField: 'displayText'
  1141. }],
  1142. html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
  1143. buttons: [{
  1144. xtype: 'button',
  1145. text: 'Display History',
  1146. handler: function(){
  1147. var STU = Ext.getCmp('STimeFROM').getValue();
  1148. var ETU = Ext.getCmp('STimeTO').getValue();
  1149. getData( 'arch', STU, ETU );
  1150. }
  1151. }]
  1152. },{
  1153. title: 'Event Log',
  1154. frame: false,
  1155. height: 303,
  1156. id: 'evtArchLog',
  1157. xtype: 'grid',
  1158. ds: eventsListStore,
  1159. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1160. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1161. listeners:{
  1162. keydown: function( e ) {
  1163. if( e.getKey() == e.UP ){
  1164. if( SelectedRow == 0 ){
  1165. var id = eventsListStore.getAt( 0 ).id;
  1166. getData( 'arch', 0, 0, id, 1 );
  1167. };
  1168. };
  1169. if( e.getKey() == e.DOWN ){
  1170. if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
  1171. var id = eventsListStore.getAt( SelectedRow ).id;
  1172. getData( 'arch', 0, 0, id, -1 );
  1173. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  1174. Ext.getCmp('evtArchLog').focus( false, true );
  1175. };
  1176. };
  1177. }
  1178. }
  1179. }]
  1180. }]
  1181. });
  1182. tPanel.add({
  1183. columnWidth: 0.17,
  1184. frame: true,
  1185. title: 'Event Information',
  1186. id: 'prop_content',
  1187. border: false,
  1188. items: [{
  1189. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1190. }]
  1191. });
  1192. tPanel.doLayout();
  1193. /*
  1194. Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
  1195. Ext.getCmp('evtLog').getEl().addKeyMap({
  1196. eventName: "keyup",
  1197. binding: [{
  1198. key: Ext.EventObject.SPACE,
  1199. fn: function(){ alert("Space key pressed"); }
  1200. },{
  1201. key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
  1202. shift: true,
  1203. fn: function(){ alert("Left or right pressed while pressing shift"); }
  1204. }]
  1205. });
  1206. */
  1207. //BuildCalendar();
  1208. loadCalendarDates();
  1209. map = L.map('event_map',{
  1210. attributionControl: true,
  1211. //preferCanvas: true,
  1212. zoomControl: true,
  1213. center: [SiteLat, SiteLon],
  1214. /*zoomControl: false,
  1215. zoom: 17,
  1216. minZoom: 17,
  1217. maxZoom: 17,*/
  1218. keyboard: false
  1219. }).setView([SiteLat, SiteLon], 17);
  1220. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1221. var mapLayers = [];
  1222. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1223. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1224. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1225. detectRetina: true
  1226. });*/
  1227. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1228. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1229. maxNativeZoom: 18,
  1230. maxZoom: 24,
  1231. })
  1232. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1233. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1234. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1235. maxZoom: 19
  1236. });
  1237. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1238. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1239. maxZoom: 19
  1240. });
  1241. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1242. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; 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',
  1243. maxZoom: 24
  1244. });
  1245. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1246. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1247. maxZoom: 19
  1248. });
  1249. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1250. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1251. maxZoom: 19
  1252. });
  1253. /*
  1254. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1255. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1256. maxZoom: 22
  1257. });
  1258. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1259. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1260. maxZoom: 22
  1261. });
  1262. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1263. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1264. maxZoom: 22
  1265. });
  1266. */
  1267. var baseMaps = {
  1268. "MyMap": mapLayers["MyMap"],
  1269. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1270. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1271. "EsriSat": mapLayers["EsriSat"],
  1272. "EsriStreet": mapLayers["EsriStreet"],
  1273. "EsriTopo": mapLayers["EsriTopo"],
  1274. //"Bing": mapLayers["Bing"],
  1275. //"OSM-Cycle": mapLayers["Cycle"],
  1276. //"Landscape": mapLayers["Landscape"],
  1277. //"Outdoor": mapLayers["Outdoor"],
  1278. };
  1279. L.control.layers( baseMaps ).addTo(map);
  1280. mapLayers["MyMap"].addTo(map);
  1281. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1282. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1283. maxNativeZoom: 18,
  1284. maxZoom: 24,
  1285. }).addTo(map); */
  1286. //loadTimeLineGroups( selectedSite );
  1287. loadMapZones( SelectedSite );
  1288. getData( 'arch' );
  1289. //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  1290. };
  1291. function loadMonitoring(){
  1292. if( tlInterval!= null ){
  1293. window.clearInterval( tlInterval );
  1294. tlInterval = null;
  1295. timelineObj = null;
  1296. };
  1297. setUserContent( 1 );
  1298. var tPanel = Ext.getCmp('main_portal');
  1299. tPanel.removeAll( true );
  1300. Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
  1301. tPanel.add({
  1302. columnWidth: 0.83,
  1303. frame: false,
  1304. border: false,
  1305. items: [{
  1306. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  1307. frame: false,
  1308. border: false,
  1309. collapsible: false,
  1310. draggable: false,
  1311. layout: 'vbox',
  1312. layoutConfig: {
  1313. align : 'stretch',
  1314. pack : 'start',
  1315. },
  1316. height: PanelH-300,
  1317. items:[{
  1318. height: PanelH-325,
  1319. flex: 1,
  1320. frame: false,
  1321. border: false,
  1322. layout: 'fit',
  1323. items:{
  1324. id: 'event_map',
  1325. html: '&nbsp;'
  1326. }
  1327. }]
  1328. },{
  1329. frame: false,
  1330. border: true,
  1331. collapsible: false,
  1332. draggable: false,
  1333. layout: 'hbox',
  1334. items:[{
  1335. title: 'Alarm Sources',
  1336. xtype: 'panel',
  1337. border: false,
  1338. frame: false,
  1339. collapsible: false,
  1340. draggable: false,
  1341. id: 'sources_panel',
  1342. width: 160,
  1343. autoScroll: 'auto',
  1344. height: 303
  1345. },{
  1346. title: 'Event Log',
  1347. height: 303,
  1348. xtype: 'grid',
  1349. border: false,
  1350. frame: false,
  1351. collapsible: false,
  1352. draggable: false,
  1353. ds: eventsListStore,
  1354. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1355. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1356. bbar: [{
  1357. text: 'Clear',
  1358. handler: function(){
  1359. Ext.Ajax.request({
  1360. url: '/lib/controller/clearEventCloud.php',
  1361. params: {
  1362. UID: <?=$UserID;?>,
  1363. SID: '<?=$Session;?>'
  1364. },
  1365. success: function( response, opts ){
  1366. },
  1367. failure: function( response, opts ) {
  1368. }
  1369. });
  1370. }
  1371. }]
  1372. }]
  1373. }]
  1374. });
  1375. tPanel.add({
  1376. columnWidth: 0.17,
  1377. title: 'Event Information',
  1378. frame: true,
  1379. id: 'prop_content',
  1380. border: false,
  1381. items: [{
  1382. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1383. }]
  1384. });
  1385. tPanel.doLayout();
  1386. map = L.map('event_map',{
  1387. attributionControl: true,
  1388. //preferCanvas: true,
  1389. zoomControl: true,
  1390. center: [SiteLat, SiteLon],
  1391. /*zoomControl: false,
  1392. zoom: 17,
  1393. minZoom: 17,
  1394. maxZoom: 17,*/
  1395. keyboard: false
  1396. }).setView([SiteLat, SiteLon], 17);
  1397. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1398. var mapLayers = [];
  1399. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1400. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1401. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1402. detectRetina: true
  1403. });*/
  1404. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1405. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1406. maxNativeZoom: 18,
  1407. maxZoom: 24,
  1408. })
  1409. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1410. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1411. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1412. maxZoom: 19
  1413. });
  1414. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1415. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1416. maxZoom: 19
  1417. });
  1418. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1419. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; 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',
  1420. maxZoom: 24
  1421. });
  1422. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1423. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1424. maxZoom: 19
  1425. });
  1426. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1427. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1428. maxZoom: 19
  1429. });
  1430. /*
  1431. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1432. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1433. maxZoom: 22
  1434. });
  1435. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1436. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1437. maxZoom: 22
  1438. });
  1439. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1440. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1441. maxZoom: 22
  1442. });
  1443. */
  1444. var baseMaps = {
  1445. "MyMap": mapLayers["MyMap"],
  1446. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1447. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1448. "EsriSat": mapLayers["EsriSat"],
  1449. "EsriStreet": mapLayers["EsriStreet"],
  1450. "EsriTopo": mapLayers["EsriTopo"],
  1451. //"Bing": mapLayers["Bing"],
  1452. //"OSM-Cycle": mapLayers["Cycle"],
  1453. //"Landscape": mapLayers["Landscape"],
  1454. //"Outdoor": mapLayers["Outdoor"],
  1455. };
  1456. L.control.layers( baseMaps ).addTo(map);
  1457. mapLayers["MyMap"].addTo(map);
  1458. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1459. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1460. maxNativeZoom: 18,
  1461. maxZoom: 24,
  1462. }).addTo(map); */
  1463. loadMapZones( SelectedSite );
  1464. tlInterval = window.setInterval( getData, 333, 'live' );
  1465. };
  1466. function loadOnlineMonitoring(devID){
  1467. var tPanel = Ext.getCmp('main_content');
  1468. if( tlInterval!= null ){
  1469. window.clearInterval( tlInterval );
  1470. tlInterval = null;
  1471. timelineObj = null;
  1472. };
  1473. tPanel.remove(0);
  1474. tPanel.add({
  1475. html: 'Device Monitoring '+devID
  1476. });
  1477. tPanel.doLayout();
  1478. };
  1479. var mSesPlay = null;
  1480. function ts2dts( b ){
  1481. var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  1482. var a = new Date( b );
  1483. var year = a.getFullYear();
  1484. var month = months[a.getMonth()];
  1485. var date = a.getDate();
  1486. var hour = a.getHours();
  1487. var min = "0" + a.getMinutes();
  1488. var sec = "0" + a.getSeconds();
  1489. return date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) ;
  1490. };
  1491. function drawSessionDataOnSlider( a, b , z, v ){
  1492. var cel = Ext.getCmp("hpl_slider").getEl();
  1493. var c = document.createElement('canvas');
  1494. var ctx = c.getContext('2d');
  1495. c.width = cel.getWidth();
  1496. c.height = cel.getHeight();
  1497. var tK = ( cel.getWidth() - 7 ) / ( b - a );
  1498. var rib = (tK>3)?tK:3;
  1499. ctx.fillStyle='#00000000';
  1500. //ctx.fillStyle='#00FF00';
  1501. ctx.fillRect( 7, 0, cel.getWidth(), cel.getHeight() );
  1502. ctx.fillStyle='#FF0000';
  1503. for( var i=0; i< z.length; i++ ){
  1504. var cX = 7 + Math.round( tK * ( z[i].ts /1000 - a ) );
  1505. ctx.fillRect( cX, 0, rib, 12 );//25
  1506. };
  1507. ctx.fillStyle='#0000FF';
  1508. for( var i=0; i< v.length; i++ ){
  1509. var cX = 7 + Math.round( tK * ( v[i].sts /1000 - a ) );
  1510. var cD = 7 + Math.round( tK * ( v[i].ets /1000 - a ) );
  1511. var cW = cD - cX;
  1512. ctx.fillRect( cX, 13, cW, 25 );
  1513. };
  1514. cel.setStyle('background','url(' + c.toDataURL() + ')');
  1515. };
  1516. var max_grad_levels = 16;
  1517. function getTransperecy( i ){
  1518. if( i == 0 ) return 'FF';
  1519. var k = 128.0 / max_grad_levels;
  1520. var l = parseInt( k*(max_grad_levels-i) ).toString(16);
  1521. if( l.length < 2 ) l = '0'+l;
  1522. return l;
  1523. };
  1524. function getSize( i ){
  1525. var k = 75.0 / max_grad_levels;
  1526. return 25+parseInt( k * i );
  1527. };
  1528. class argusSessionPlayer{
  1529. sessionId;
  1530. mMapID;
  1531. startTime;
  1532. endTime;
  1533. currentTime;
  1534. rVideoJS = null;
  1535. lVideoJS = null;
  1536. rVideoJS_id = null;
  1537. lVideoJS_id = null;
  1538. rVideoJS_playing = false;
  1539. lVideoJS_playing = false;
  1540. rVideoJS_cid = -1;
  1541. lVideoJS_cid = -1;
  1542. mapLayout;
  1543. lVideos;
  1544. rVideos;
  1545. Events;
  1546. basePath;
  1547. mTimer = null;
  1548. mPaused = true;
  1549. mLooping = true;
  1550. mAutoPlay = false;
  1551. nextRTimestamp = 0.0;
  1552. nextLTimestamp = 0.0;
  1553. mSvgElements;//076.png
  1554. checkLVideoTime(){
  1555. const t = mSesPlay.lVideoJS.currentTime(); // seconds
  1556. while( t >= mSesPlay.nextLTimestamp ){
  1557. mSesPlay.lVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextLTimestamp });
  1558. mSesPlay.nextLTimestamp += 0.1; // next 100 ms of video time
  1559. };
  1560. }
  1561. checkRVideoTime(){
  1562. const t = mSesPlay.rVideoJS.currentTime(); // seconds
  1563. while( t >= mSesPlay.nextRTimestamp ){
  1564. mSesPlay.rVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextRTimestamp });
  1565. mSesPlay.nextRTimestamp += 0.1; // next 100 ms of video time
  1566. };
  1567. }
  1568. constructor( session_id, autoplay ) {
  1569. this.sessionId = session_id;
  1570. this.currentTime = 0;
  1571. this.startTime = 0;
  1572. this.endTime = 0;
  1573. this.lVideos = [];
  1574. this.rVideos = [];
  1575. this.Events = [];
  1576. this.rEvents = [];
  1577. this.lEvents = [];
  1578. this.mSvgElements = [];
  1579. if( autoplay != undefined ) this.mAutoPlay = autoplay;
  1580. Ext.Ajax.request({
  1581. url: '/lib/controller/getSessionData.php',
  1582. params: {
  1583. SESSION: this.sessionId,
  1584. UID: <?=$UserID;?>,
  1585. SID: '<?=$Session;?>'
  1586. },
  1587. success: function( response, opts ){
  1588. var data = Ext.decode( response.responseText );
  1589. //debugger;
  1590. if( data.status == 'ok' ){
  1591. mSesPlay.mapLayout = data.layout;
  1592. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1593. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1594. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1595. //debugger;
  1596. if( data.data_ok ){
  1597. mSesPlay.startTime = data.start_ts;
  1598. mSesPlay.endTime = data.start_ts + data.length;
  1599. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1600. mSesPlay.rVideos = [];
  1601. mSesPlay.lVideos = [];
  1602. mSesPlay.nextRTimestamp = 0.0;
  1603. mSesPlay.nextLTimestamp = 0.0;
  1604. sesVideosListRName = data.r_module_name;
  1605. sesVideosListLName = data.l_module_name;
  1606. if( data.composed_video ){
  1607. if( data.composed_video_status == 'D' ){
  1608. CompositeVideoStatus = 2;
  1609. sesVideosListRExists = data.composed_right_video_exists;
  1610. sesVideosListLExists = data.composed_left_video_exists;
  1611. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  1612. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  1613. } else {
  1614. CompositeVideoStatus = 1;
  1615. CompositeVideoProgress = data.composed_video_progress;
  1616. CompositeVideoLeftInfo = null;
  1617. CompositeVideoRightInfo = null;
  1618. sesVideosListRExists = false;
  1619. sesVideosListLExists = false;
  1620. }
  1621. } else CompositeVideoStatus = 0;
  1622. var tt = Ext.getCmp('hpl_slider');
  1623. tt.setMinValue( 0 );
  1624. tt.setMaxValue( data.length / 1000 );
  1625. if( data.events.length ){
  1626. mSesPlay.Events = data.events;
  1627. for( var i=0; i < data.events.length; i++ ){
  1628. if( data.events[i].side == 'L' ){
  1629. mSesPlay.lEvents.push( data.events[i] );
  1630. } else {
  1631. mSesPlay.rEvents.push( data.events[i] );
  1632. };
  1633. };
  1634. };
  1635. if( data.videos.length ){
  1636. videosListStore.loadData( data, false );
  1637. for( var i=0; i < data.videos.length; i++ ){
  1638. if( mSesPlay.currentTime == 0 ){
  1639. mSesPlay.currentTime = data.videos[i].sts;
  1640. } else {
  1641. if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts;
  1642. };
  1643. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] );
  1644. else mSesPlay.lVideos.push( data.videos[i] );
  1645. };
  1646. sesVideosStartTS = mSesPlay.currentTime;
  1647. } else {
  1648. sesVideosStartTS = 0;
  1649. videosListStore.removeAll();
  1650. };
  1651. if( mSesPlay.rVideos.length ) {
  1652. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1653. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1654. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  1655. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1656. // New imp
  1657. mSesPlay.rVideoJS.on('play', () => {
  1658. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1659. });
  1660. mSesPlay.rVideoJS.on( 'timeupdate', mSesPlay.checkRVideoTime );
  1661. mSesPlay.rVideoJS.on('seeking', () => {
  1662. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1663. });
  1664. mSesPlay.rVideoJS.on('videotick', (e) => {
  1665. mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 );
  1666. });
  1667. mSesPlay.rVideoJS.on('ended', function() {
  1668. console.log("Video Ended!");
  1669. if( mSesPlay.rVideoJS_cid < mSesPlay.rVideos.length ){
  1670. mSesPlay.rVideoJS_cid++;
  1671. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.rVideos[mSesPlay.rVideoJS_cid].name };
  1672. mSesPlay.rVideoJS.src( ns );
  1673. mSesPlay.rVideoJS.play();
  1674. mSesPlay.rVideoJS_playing = true;
  1675. };
  1676. });
  1677. };
  1678. if( mSesPlay.lVideos.length ){
  1679. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1680. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1681. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  1682. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1683. // New imp
  1684. mSesPlay.lVideoJS.on('play', () => {
  1685. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1686. });
  1687. mSesPlay.lVideoJS.on( 'timeupdate', mSesPlay.checkLVideoTime );
  1688. mSesPlay.lVideoJS.on('seeking', () => {
  1689. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1690. });
  1691. mSesPlay.lVideoJS.on('videotick', (e) => {
  1692. mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 );
  1693. });
  1694. mSesPlay.lVideoJS.on('ended', function() {
  1695. console.log("Video Ended!");
  1696. if( mSesPlay.lVideoJS_cid < mSesPlay.lVideos.length ){
  1697. mSesPlay.lVideoJS_cid++;
  1698. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.lVideos[mSesPlay.lVideoJS_cid].name };
  1699. mSesPlay.lVideoJS.src( ns );
  1700. mSesPlay.lVideoJS.play();
  1701. mSesPlay.lVideoJS_playing = true;
  1702. };
  1703. });
  1704. };
  1705. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  1706. mSesPlay.setPosition( 0 );
  1707. if( mSesPlay.mAutoPlay ) mSesPlay.play();
  1708. } else {
  1709. Ext.Msg.show({
  1710. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1711. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1712. buttons: Ext.Msg.OK,
  1713. icon: Ext.MessageBox.ERROR
  1714. });
  1715. }
  1716. };
  1717. },
  1718. failure: failureAJAXFunction
  1719. });
  1720. }
  1721. checkPlayebleTime( ct ){
  1722. if( this.rVideos.length ){
  1723. var fid = -1;
  1724. if( this.rVideoJS_cid < this.rVideos.length - 1 ){
  1725. for(var i=this.rVideoJS_cid+1; i < this.rVideos.length; i++ ){
  1726. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1727. fid = i;
  1728. break;
  1729. };
  1730. };
  1731. if( fid < 0 ){
  1732. //No Segments for Now;
  1733. //this.rVideoJS_playing = false;
  1734. this.rVideoJS_cid = 1;
  1735. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1736. this.rVideoJS.src( ns );
  1737. this.rVideoJS_playing = true;
  1738. } else {
  1739. if( this.rVideoJS_cid != fid ){
  1740. this.rVideoJS_cid = fid;
  1741. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1742. this.rVideoJS.src( ns );
  1743. };
  1744. this.rVideoJS_playing = true;
  1745. };
  1746. };
  1747. };
  1748. if( this.lVideos.length ){
  1749. var fid = -1;
  1750. for(var i=this.lVideos.length-1; i > 0; i-- ){
  1751. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1752. fid = i;
  1753. break;
  1754. };
  1755. };
  1756. if( fid < 0 ){
  1757. //No Segments for Now;
  1758. //this.lVideoJS_playing = false;
  1759. this.lVideoJS_cid = 1;
  1760. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1761. this.lVideoJS.src( ns );
  1762. this.lVideoJS_playing = true;
  1763. } else {
  1764. if( this.lVideoJS_cid != fid ){
  1765. this.lVideoJS_cid = fid;
  1766. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1767. this.lVideoJS.src( ns );
  1768. };
  1769. this.lVideoJS_playing = true;
  1770. };
  1771. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1772. };
  1773. }
  1774. action( currentTime = 0 ){
  1775. if( !this.mPaused ){
  1776. this.currentTime = currentTime;
  1777. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1778. //debugger;
  1779. this.currentTime = this.checkPlayebleTime( this.currentTime );
  1780. var zz = document.getElementById('hpl_time_mon');
  1781. if( zz != undefined ){
  1782. zz.innerHTML = ts2dts( this.currentTime );
  1783. };
  1784. //Check videos
  1785. if( this.rVideos.length ){
  1786. var fid = -1;
  1787. for(var i=0; i<this.rVideos.length; i++ ){
  1788. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1789. fid = i;
  1790. break;
  1791. };
  1792. };
  1793. if( fid < 0 ){
  1794. //No Segments for Now;
  1795. this.rVideoJS_playing = false;
  1796. } else {
  1797. if( this.rVideoJS_cid != fid ){
  1798. this.rVideoJS_cid = fid;
  1799. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1800. this.rVideoJS.src( ns );
  1801. };
  1802. this.rVideoJS_playing = true;
  1803. };
  1804. //if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1805. };
  1806. if( this.lVideos.length ){
  1807. var fid = -1;
  1808. for(var i=0; i<this.lVideos.length; i++ ){
  1809. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1810. fid = i;
  1811. break;
  1812. };
  1813. };
  1814. if( fid < 0 ){
  1815. //No Segments for Now;
  1816. this.lVideoJS_playing = false;
  1817. } else {
  1818. if( this.lVideoJS_cid != fid ){
  1819. this.lVideoJS_cid = fid;
  1820. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1821. this.lVideoJS.src( ns );
  1822. };
  1823. this.lVideoJS_playing = true;
  1824. };
  1825. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1826. };
  1827. if( this.Events.length ){
  1828. var sid = -1;
  1829. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1830. sid = i;
  1831. break;
  1832. };
  1833. if( sid > -1 ){
  1834. for( var i=0; i< max_grad_levels; i++ ){
  1835. var cid = sid-i;
  1836. var csize = getSize( i );
  1837. //debugger;
  1838. if( typeof this.mSvgElements[i] === 'undefined') {
  1839. if( cid > -1 ){
  1840. var svgns = "http://www.w3.org/2000/svg";
  1841. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1842. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1843. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1844. this.mSvgElements[i].setAttribute('height', ''+csize);
  1845. this.mSvgElements[i].setAttribute('width', ''+csize);
  1846. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1847. var tt = document.getElementById('svgTrackMap');
  1848. var zz = document.getElementById('scheme_anch');
  1849. tt.insertBefore( this.mSvgElements[i], zz );
  1850. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1851. };
  1852. } else {
  1853. if( cid > -1 ){
  1854. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1855. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1856. this.mSvgElements[i].setAttribute('height', ''+csize);
  1857. this.mSvgElements[i].setAttribute('width', ''+csize);
  1858. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1859. } else {
  1860. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1861. };
  1862. };
  1863. };
  1864. } else
  1865. for( var i=0; i< max_grad_levels; i++ )
  1866. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1867. };
  1868. var tt = Ext.getCmp('hpl_slider');
  1869. if( tt!= undefined ){
  1870. tt.suspendEvents();
  1871. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1872. tt.resumeEvents();
  1873. };
  1874. //this.currentTime += 250;
  1875. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1876. this.currentTime = 0;
  1877. } else {
  1878. //Stop
  1879. this.play();
  1880. };
  1881. };
  1882. }
  1883. play(){
  1884. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1885. if( this.mPaused ){
  1886. this.mPaused = false;
  1887. if( this.rVideos.length ){
  1888. if( !this.rVideoJS_playing ) this.rVideoJS.play();
  1889. this.rVideoJS_playing = true;
  1890. };
  1891. if( this.lVideos.length ){
  1892. if( !this.lVideoJS_playing ) this.lVideoJS.play();
  1893. this.lVideoJS_playing = true;
  1894. };
  1895. zz.setIconClass( 'plr_op_pause' );
  1896. zz.setText('Pause');
  1897. } else {
  1898. this.mPaused = true;
  1899. if( this.rVideos.length ){
  1900. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  1901. this.rVideoJS_playing = false;
  1902. };
  1903. if( this.lVideos.length ){
  1904. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  1905. this.lVideoJS_playing = false;
  1906. };
  1907. zz.setIconClass( 'plr_op_play' );
  1908. zz.setText('Play');
  1909. };
  1910. this.action( this.currentTime );
  1911. //if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  1912. }
  1913. pause(){
  1914. this.mPaused = true;
  1915. }
  1916. toggleLoop(){
  1917. this.mLooping = !this.mLooping;
  1918. if( this.mLooping ) if( this.currentTime > this.endTime ){
  1919. this.currentTime = 0;
  1920. // Start
  1921. this.play();
  1922. };
  1923. }
  1924. setPosition( pos_time ){
  1925. //this.currentTime = this.startTime + pos_time*1000;
  1926. var nt = this.startTime + pos_time*1000;
  1927. var zz = document.getElementById('hpl_time_mon');
  1928. zz.innerHTML = ts2dts( nt );
  1929. if( this.rVideoJS_playing )
  1930. this.rVideoJS.currentTime( ( nt - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1931. if( this.lVideoJS_playing )
  1932. this.lVideoJS.currentTime( ( nt - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1933. }
  1934. onLVideoEnd(){
  1935. }
  1936. onRVideoEnd(){
  1937. }
  1938. dispose(){
  1939. if( this.mTimer != null ) clearInterval( this.mTimer );
  1940. this.mTimer = null;
  1941. if( this.rVideoJS!= null ){
  1942. this.rVideoJS.dispose();
  1943. this.rVideoJS = null;
  1944. };
  1945. if( this.lVideoJS!= null ){
  1946. this.lVideoJS.dispose();
  1947. this.lVideoJS = null;
  1948. };
  1949. }
  1950. }
  1951. // canvas aproach ///////////////////////////////////////////
  1952. /*
  1953. const player = videojs('my-video');
  1954. let nextTimestamp = 0;
  1955. let rafId = null;
  1956. function tick() {
  1957. if (player.paused() || player.ended())
  1958. return;
  1959. const t = player.currentTime();
  1960. while (t >= nextTimestamp) {
  1961. player.trigger({
  1962. type: 'videotick',
  1963. timestamp: nextTimestamp
  1964. });
  1965. nextTimestamp += 0.1;
  1966. }
  1967. rafId = requestAnimationFrame(tick);
  1968. }
  1969. player.on('play', () => {
  1970. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  1971. cancelAnimationFrame(rafId);
  1972. rafId = requestAnimationFrame(tick);
  1973. });
  1974. player.on('pause', () => cancelAnimationFrame(rafId));
  1975. player.on('ended', () => cancelAnimationFrame(rafId));
  1976. player.on('seeking', () => {
  1977. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  1978. });
  1979. player.on('videotick', (e) => {
  1980. console.log(e.timestamp);
  1981. });
  1982. */
  1983. class _argusSessionPlayer{
  1984. sessionId;
  1985. mMapID;
  1986. startTime;
  1987. endTime;
  1988. currentTime;
  1989. rVideoJS = null;
  1990. lVideoJS = null;
  1991. rVideoJS_id = null;
  1992. lVideoJS_id = null;
  1993. rVideoJS_playing = false;
  1994. lVideoJS_playing = false;
  1995. rVideoJS_cid = -1;
  1996. lVideoJS_cid = -1;
  1997. mapLayout;
  1998. lVideos;
  1999. rVideos;
  2000. Events;
  2001. basePath;
  2002. mTimer = null;
  2003. mPaused = true;
  2004. mLooping = true;
  2005. mSvgElements;//076.png
  2006. constructor( session_id ) {
  2007. this.sessionId = session_id;
  2008. this.currentTime = 0;
  2009. this.startTime = 0;
  2010. this.endTime = 0;
  2011. this.lVideos = [];
  2012. this.rVideos = [];
  2013. this.Events = [];
  2014. this.mSvgElements = [];
  2015. Ext.Ajax.request({
  2016. url: '/lib/controller/getSessionData.php',
  2017. params: {
  2018. SESSION: this.sessionId,
  2019. UID: <?=$UserID;?>,
  2020. SID: '<?=$Session;?>'
  2021. },
  2022. success: function( response, opts ){
  2023. var data = Ext.decode( response.responseText );
  2024. //debugger;
  2025. if( data.status == 'ok' ){
  2026. mSesPlay.mapLayout = data.layout;
  2027. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  2028. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  2029. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  2030. //debugger;
  2031. if( data.data_ok ){
  2032. if( data.r_module_id ){
  2033. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  2034. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  2035. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  2036. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  2037. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  2038. };
  2039. mSesPlay.startTime = data.start_ts;
  2040. mSesPlay.endTime = data.start_ts + data.length;
  2041. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  2042. mSesPlay.rVideos = [];
  2043. mSesPlay.lVideos = [];
  2044. if( data.videos.length ){
  2045. for( var i=0; i < data.videos.length; i++ )
  2046. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  2047. };
  2048. if( data.events.length ) mSesPlay.Events = data.events;
  2049. var tt = Ext.getCmp('hpl_slider');
  2050. tt.setMinValue( 0 );
  2051. tt.setMaxValue( data.length / 1000 );
  2052. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  2053. //player.on('ended', function() {
  2054. // this.dispose();
  2055. //});
  2056. //alert( data.basepath +'/'+data.videos[0].name );
  2057. //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  2058. //mSesPlay.rVideoJS.ready(function() {
  2059. //mSesPlay.rVideoJS.play();
  2060. //var howLoudIsIt = player.volume();
  2061. //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half
  2062. //});
  2063. //mSesPlay.rVideoJS.on("timeupdate", function(){
  2064. // method will be calledd each 250 msecs
  2065. //});
  2066. if( data.l_module_id ){
  2067. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  2068. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  2069. //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  2070. //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  2071. //mSesPlay.lVideoJS.ready(function() {
  2072. //mSesPlay.rVideoJS.play();
  2073. //var howLoudIsIt = player.volume();
  2074. // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half
  2075. //});
  2076. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  2077. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  2078. };
  2079. //mSesPlay.lVideoJS.on("timeupdate", function(){
  2080. // // method will be calledd each 250 msecs
  2081. //});
  2082. mSesPlay.setPosition( 0 );
  2083. } else {
  2084. Ext.Msg.show({
  2085. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  2086. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  2087. buttons: Ext.Msg.OK,
  2088. icon: Ext.MessageBox.ERROR
  2089. });
  2090. }
  2091. };
  2092. },
  2093. failure: failureAJAXFunction
  2094. });
  2095. }
  2096. action(){
  2097. if( !this.mPaused ){
  2098. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  2099. var zz = document.getElementById('hpl_time_mon');
  2100. //debugger;
  2101. if( zz != undefined ){
  2102. zz.innerHTML = ts2dts( this.currentTime );
  2103. };
  2104. //Check videos
  2105. if( this.rVideos.length ){
  2106. var fid = -1;
  2107. for(var i=0; i<this.rVideos.length; i++ ){
  2108. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2109. fid = i;
  2110. break;
  2111. };
  2112. };
  2113. if( fid < 0 ){
  2114. //No Segments for Now;
  2115. this.rVideoJS_playing = false;
  2116. } else {
  2117. if( this.rVideoJS_cid != fid ){
  2118. this.rVideoJS_cid = fid;
  2119. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2120. this.rVideoJS.src( ns );
  2121. };
  2122. this.rVideoJS_playing = true;
  2123. };
  2124. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2125. };
  2126. if( this.lVideos.length ){
  2127. var fid = -1;
  2128. for(var i=0; i<this.lVideos.length; i++ ){
  2129. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2130. fid = i;
  2131. break;
  2132. };
  2133. };
  2134. if( fid < 0 ){
  2135. //No Segments for Now;
  2136. this.lVideoJS_playing = false;
  2137. } else {
  2138. if( this.lVideoJS_cid != fid ){
  2139. this.lVideoJS_cid = fid;
  2140. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2141. this.lVideoJS.src( ns );
  2142. };
  2143. this.lVideoJS_playing = true;
  2144. };
  2145. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2146. };
  2147. if( this.Events.length ){
  2148. var sid = -1;
  2149. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  2150. sid = i;
  2151. break;
  2152. };
  2153. if( sid > -1 ){
  2154. for( var i=0; i< max_grad_levels; i++ ){
  2155. var cid = sid-i;
  2156. var csize = getSize( i );
  2157. //debugger;
  2158. if( typeof this.mSvgElements[i] === 'undefined') {
  2159. if( cid > -1 ){
  2160. var svgns = "http://www.w3.org/2000/svg";
  2161. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  2162. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2163. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2164. this.mSvgElements[i].setAttribute('height', ''+csize);
  2165. this.mSvgElements[i].setAttribute('width', ''+csize);
  2166. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  2167. var tt = document.getElementById('svgTrackMap');
  2168. var zz = document.getElementById('scheme_anch');
  2169. tt.insertBefore( this.mSvgElements[i], zz );
  2170. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  2171. };
  2172. } else {
  2173. if( cid > -1 ){
  2174. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2175. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2176. this.mSvgElements[i].setAttribute('height', ''+csize);
  2177. this.mSvgElements[i].setAttribute('width', ''+csize);
  2178. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  2179. } else {
  2180. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2181. };
  2182. };
  2183. };
  2184. } else
  2185. for( var i=0; i< max_grad_levels; i++ )
  2186. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2187. };
  2188. var tt = Ext.getCmp('hpl_slider');
  2189. if( tt!= undefined ){
  2190. tt.suspendEvents();
  2191. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  2192. tt.resumeEvents();
  2193. };
  2194. this.currentTime += 250;
  2195. if( this.currentTime > this.endTime ) if( this.mLooping ){
  2196. this.currentTime = 0;
  2197. } else {
  2198. //Stop
  2199. this.play();
  2200. };
  2201. };
  2202. }
  2203. play(){
  2204. var zz = Ext.getCmp( 'hpl_pl_btn' );
  2205. if( this.mPaused ){
  2206. this.mPaused = false;
  2207. if( this.rVideoJS_playing ) this.rVideoJS.play();
  2208. if( this.lVideoJS_playing ) this.lVideoJS.play();
  2209. zz.setIconClass( 'plr_op_pause' );
  2210. zz.setText('Pause');
  2211. } else {
  2212. this.mPaused = true;
  2213. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  2214. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  2215. zz.setIconClass( 'plr_op_play' );
  2216. zz.setText('Play');
  2217. };
  2218. if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  2219. }
  2220. pause(){
  2221. this.mPaused = true;
  2222. }
  2223. toggleLoop(){
  2224. this.mLooping = !this.mLooping;
  2225. if( this.mLooping ) if( this.currentTime > this.endTime ){
  2226. this.currentTime = 0;
  2227. // Start
  2228. this.play();
  2229. };
  2230. }
  2231. setPosition( pos_time ){
  2232. this.currentTime = this.startTime + pos_time*1000;
  2233. var zz = document.getElementById('hpl_time_mon');
  2234. zz.innerHTML = ts2dts( this.currentTime );
  2235. }
  2236. onLVideoEnd(){
  2237. }
  2238. onRVideoEnd(){
  2239. }
  2240. dispose(){
  2241. if( this.mTimer != null ) clearInterval( this.mTimer );
  2242. this.mTimer = null;
  2243. if( this.rVideoJS!= null ){
  2244. this.rVideoJS.dispose();
  2245. this.rVideoJS = null;
  2246. };
  2247. if( this.lVideoJS!= null ){
  2248. this.lVideoJS.dispose();
  2249. this.lVideoJS = null;
  2250. };
  2251. }
  2252. }
  2253. var SelectedSessionID = 0;
  2254. function loadHistorySessionView( session_id ){
  2255. autoRiseEvent = false;
  2256. SelectedSessionID = rep_selectedEventId = session_id;
  2257. Ext.Ajax.request({
  2258. url: '/lib/controller/getHistorySessionView.php',
  2259. params: {
  2260. SESSION: rep_selectedEventId,
  2261. UID: <?=$UserID;?>,
  2262. SID: '<?=$Session;?>'
  2263. },
  2264. success: function( response, opts ){
  2265. var data = Ext.decode(response.responseText);
  2266. if( data.status == 'ok' ){
  2267. monitoringViewLevel = 5;
  2268. if( mSesPlay!= null ) {
  2269. mSesPlay.dispose();
  2270. mSesPlay = null;
  2271. };
  2272. Ext.getCmp('main_content').removeAll(true);
  2273. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2274. Ext.getCmp('main_content').doLayout();
  2275. changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId );
  2276. updateUserContent();
  2277. mSesPlay = new argusSessionPlayer( rep_selectedEventId , true );
  2278. fetchStatus();
  2279. };
  2280. },
  2281. failure: failureAJAXFunction
  2282. });
  2283. };
  2284. function deleteSession( session_id ){
  2285. if( session_id == 0 ) return;
  2286. Ext.Msg.show({
  2287. title:'<?=$Labels->GetLabel('_RYS_DEL_SES_');?>',
  2288. msg: '<?=$Labels->GetLabel('_RYS_DEL_SESSION_');?>',
  2289. buttons: Ext.Msg.YESNOCANCEL,
  2290. icon: Ext.MessageBox.QUESTION,
  2291. fn: function(btn, text){
  2292. if( btn == 'yes' ){
  2293. Ext.Ajax.request({
  2294. url: '/lib/controller/doSessionOperations.php',
  2295. params: {
  2296. SESSION: session_id,
  2297. OPID: 1,
  2298. UID: <?=$UserID;?>,
  2299. SID: '<?=$Session;?>'
  2300. },
  2301. success: function( response, opts ){
  2302. Ext.Msg.hide();
  2303. var data = Ext.decode(response.responseText);
  2304. if( data.status == 'ok' ){
  2305. getBackToMap();
  2306. } else {
  2307. Ext.Msg.show({
  2308. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  2309. msg: data.msg,
  2310. buttons: Ext.Msg.OK,
  2311. icon: Ext.MessageBox.ERROR
  2312. });
  2313. };
  2314. },
  2315. failure: failureAJAXFunction
  2316. });
  2317. };
  2318. }
  2319. });
  2320. };
  2321. function loadHistoryStationEvt( e ){
  2322. loadHistoryStation( e.target.options.mycustomid );
  2323. };
  2324. function loadHistoryStation( STT, buba ){
  2325. if( buba == undefined ){
  2326. autoRiseEvent = false;
  2327. } else {
  2328. autoRiseEvent = buba;
  2329. };
  2330. rep_selectedStation = STT;
  2331. changeContent( 2, 1, rep_selectedStation );
  2332. updateUserContent();
  2333. Ext.Ajax.request({
  2334. url: '/lib/controller/getHistoryStationView.php',
  2335. params: {
  2336. STT: rep_selectedStation,
  2337. UID: <?=$UserID;?>,
  2338. SID: '<?=$Session;?>'
  2339. },
  2340. success: function( response, opts ){
  2341. var data = Ext.decode(response.responseText);
  2342. if( data.status == 'ok' ){
  2343. Ext.getCmp('main_content').removeAll(true);
  2344. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2345. Ext.getCmp('main_content').doLayout();
  2346. Ext.getCmp('left_side_menu').removeAll(true);
  2347. Ext.getCmp('left_side_menu').add({
  2348. xtype: 'panel',
  2349. frame: true,
  2350. border: false,
  2351. items: [{
  2352. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  2353. height: PanelH - 30
  2354. }]
  2355. });
  2356. Ext.getCmp('left_side_menu').doLayout();
  2357. } else {
  2358. };
  2359. },
  2360. failure: failureAJAXFunction
  2361. });
  2362. };
  2363. function loadReportDayTree( ts ){
  2364. ReportSelectionMode = 1;//Day Selected
  2365. rep_selectedDateTS = ts;
  2366. //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  2367. //ReportMask.show();
  2368. Ext.Ajax.request({
  2369. url: '/lib/controller/getHistoryDay.php',
  2370. params: {
  2371. UID: <?=$UserID;?>,
  2372. SID: '<?=$Session;?>',
  2373. STT: rep_selectedStation,
  2374. DTS: rep_selectedDateTS
  2375. },
  2376. success: function(response, opts ){
  2377. var data = Ext.decode( response.responseText );
  2378. var sPanel = Ext.getCmp('left_side_menu');
  2379. sPanel.removeAll( true );
  2380. sPanel.add({
  2381. xtype: 'panel',
  2382. layout: 'vbox',
  2383. frame: true,
  2384. border: false,
  2385. items:[{
  2386. xtype: 'spacer',
  2387. height: 3
  2388. },{
  2389. html: '<p class="cur_date">'+( new Date( ts * 1000)).toLocaleDateString()+'</p><p class="cur_sessions">'+data.sessions+'</p><p class="cur_events">'+data.events+'</p><p class="cur_videos">'+data.videos+'</p>',
  2390. frame: false,
  2391. width: '100%',
  2392. border: false
  2393. },{
  2394. xtype: 'spacer',
  2395. height: 5
  2396. },{
  2397. xtype: 'treepanel',
  2398. autoScroll: true,
  2399. width: '100%',
  2400. height: PanelH-206,
  2401. border: true,
  2402. frame: true,
  2403. loader: new Ext.tree.TreeLoader(),
  2404. rootVisible: false,
  2405. root: new Ext.tree.AsyncTreeNode( data ),
  2406. listeners: {
  2407. click: function(n) {
  2408. if( n.attributes.leaf ){
  2409. Ext.getCmp('chu_adate').show();
  2410. sPanel.doLayout();
  2411. loadHistorySessionView( n.attributes.sid );
  2412. };
  2413. }
  2414. }
  2415. },{
  2416. xtype: 'spacer',
  2417. height: 10
  2418. },{
  2419. xtype: 'button',
  2420. id: 'chu_adate',
  2421. text: 'Show Dates',
  2422. hidden: true,
  2423. width: '100%',
  2424. iconCls: 'reports_dates_btn',
  2425. scale: 'large',
  2426. handler: function(){
  2427. Ext.getCmp('chu_adate').hide();
  2428. loadHistoryStation( rep_selectedStation );
  2429. }
  2430. }]
  2431. });
  2432. sPanel.doLayout();
  2433. changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS );
  2434. updateUserContent();
  2435. //ReportMask.hide();
  2436. }
  2437. });
  2438. };
  2439. function noHistDialog(){
  2440. Ext.Msg.show({
  2441. title:'<?=$Labels->GetLabel('_GEN_MSG_');?>',
  2442. msg: '<?=$Labels->GetLabel('_NO_REPORTS_4_STATION_');?>',
  2443. buttons: Ext.Msg.OK,
  2444. icon: Ext.MessageBox.INFO
  2445. });
  2446. };
  2447. var history_map = null;
  2448. function initHistoryMap( map_id, x, y ){
  2449. if( tlInterval!= null ){
  2450. window.clearTimeout( tlInterval );
  2451. tlInterval = null;
  2452. };
  2453. var mapLayers = [];
  2454. if( history_map != null ){
  2455. history_map.off();
  2456. history_map.remove();
  2457. history_map = null;
  2458. };
  2459. history_map = L.map( map_id,{
  2460. crs: L.CRS.Simple,
  2461. attributionControl: false,
  2462. preferCanvas: true,
  2463. zoomControl: true,
  2464. center: [x,y],
  2465. zoom: 0,
  2466. minZoom: -3,
  2467. maxZoom: 0,
  2468. keyboard: false
  2469. });
  2470. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  2471. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( history_map );
  2472. Ext.Ajax.request({
  2473. url: '/lib/controller/listHistoryStations.php',
  2474. params: {
  2475. UID: <?=$UserID;?>,
  2476. SID: '<?=$Session;?>'
  2477. },
  2478. success: function( response, opts ){
  2479. var data = Ext.decode(response.responseText);
  2480. if( data.status == 'ok' ){
  2481. for( i=0; i < data.stations.length; i++ ){
  2482. if( data.stations[i].status ){
  2483. 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 );
  2484. } else {
  2485. 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 );
  2486. };
  2487. };
  2488. };
  2489. },
  2490. failure: failureAJAXFunction
  2491. });
  2492. };
  2493. function getBackToHistoryMap(){
  2494. autoRiseEvent = false;
  2495. changeContent( 2, 0 );
  2496. updateUserContent();
  2497. var tP = Ext.getCmp('left_side_menu');
  2498. tP.removeAll( true );
  2499. tP.add({
  2500. layout:'vbox',
  2501. frame: false,
  2502. border: false,
  2503. items:[{
  2504. xtype: 'panel',
  2505. frame: true,
  2506. border: false,
  2507. items: [{
  2508. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  2509. height: PanelH - 30
  2510. }]
  2511. }]
  2512. });
  2513. tP.doLayout();
  2514. loadHistoryMapView();
  2515. };
  2516. function loadHistoryMapView(){
  2517. autoRiseEvent = false;
  2518. Ext.Ajax.request({
  2519. url: '/lib/controller/getHistoryMapView.php',
  2520. params: {
  2521. UID: <?=$UserID;?>,
  2522. SID: '<?=$Session;?>'
  2523. },
  2524. success: function( response, opts ){
  2525. var data = Ext.decode(response.responseText);
  2526. if( data.status == 'ok' ){
  2527. monitoringViewLevel = 0;
  2528. Ext.getCmp('main_content').removeAll(true);
  2529. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2530. Ext.getCmp('main_content').doLayout();
  2531. };
  2532. },
  2533. failure: failureAJAXFunction
  2534. });
  2535. return;
  2536. };
  2537. function initReportsView(){
  2538. if( tlInterval!= null ){
  2539. window.clearInterval( tlInterval );
  2540. tlInterval = null;
  2541. timelineObj = null;
  2542. };
  2543. var tP = Ext.getCmp('left_side_menu');
  2544. tP.removeAll( true );
  2545. tP.add({
  2546. layout:'vbox',
  2547. frame: false,
  2548. border: false,
  2549. items:[{
  2550. xtype: 'panel',
  2551. frame: true,
  2552. border: false,
  2553. items: [{
  2554. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel("_PLS_SEL_STA_ONMAP_");?></div>',
  2555. height: PanelH - 30
  2556. }]
  2557. }]
  2558. });
  2559. tP.doLayout();
  2560. monitoringViewLevel = contentView.l[2].v;
  2561. switch( monitoringViewLevel ){
  2562. case 0:{
  2563. loadHistoryMapView();
  2564. break;
  2565. };
  2566. case 1:{
  2567. loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent );
  2568. break;
  2569. };
  2570. case 2:{
  2571. var tA = contentView.l[2].p.split('-');
  2572. rep_selectedStation = parseInt( tA[0] );
  2573. rep_selectedDateTS = parseInt( tA[1] );
  2574. loadHistoryStation( rep_selectedStation, autoRiseEvent );
  2575. loadReportDayTree( rep_selectedDateTS );
  2576. break;
  2577. };
  2578. case 5:{
  2579. var tA = contentView.l[2].p.split('-');
  2580. rep_selectedStation = parseInt( tA[0] );
  2581. rep_selectedDateTS = parseInt( tA[1] );
  2582. rep_selectedEventId = parseInt( tA[2] );
  2583. loadReportDayTree( rep_selectedDateTS );
  2584. loadHistorySessionView( rep_selectedEventId );
  2585. break;
  2586. };
  2587. };
  2588. //Ext.getCmp('main_content').doLayout();
  2589. };