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.

2607 lines
85 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 CompositeVideoProgress = 0;
  647. var CompositeVideoStatusTO = null;
  648. var sesVideosListWindow = null;
  649. var sesVideosListRName = '';
  650. var sesVideosListLName = '';
  651. var sesVideosListRExists = false;
  652. var sesVideosListLExists = false;
  653. var CompositeVideoRightInfo = null;
  654. var CompositeVideoLeftInfo = null;
  655. function startVideoComposer(){
  656. Ext.Ajax.request({
  657. url: '/lib/controller/doSessionOperations.php',
  658. params: {
  659. SESSION: SelectedSessionID,
  660. OPID: 3,
  661. UID: <?=$UserID;?>,
  662. SID: '<?=$Session;?>'
  663. },
  664. success: function( response, opts ){
  665. var data = Ext.decode(response.responseText);
  666. if( data.status == 'ok' ){
  667. CompositeVideoStatus = 1;
  668. CompositeVideoProgress = 0;
  669. CompositeVideoStatusUpdate();
  670. } else {
  671. Ext.Msg.show({
  672. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  673. msg: data.msg,
  674. buttons: Ext.Msg.OK,
  675. icon: Ext.MessageBox.ERROR
  676. });
  677. };
  678. },
  679. failure: failureAJAXFunction
  680. });
  681. }
  682. function CompositeVideoStatusUpdate(){
  683. var rr = Ext.getCmp('EvtVidCompDownPanel');
  684. rr.removeAll();
  685. switch( CompositeVideoStatus ){
  686. case 0:{
  687. rr.add({
  688. xtype: 'panel',
  689. frame: false,
  690. border: false,
  691. 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>'
  692. });
  693. break;
  694. };
  695. case 1:{
  696. rr.add({
  697. border: false,
  698. frame: false,
  699. //layout: 'vbox',
  700. //layoutConfig: {
  701. // align: 'center'
  702. //},
  703. items:[{
  704. html: '<center>Composing Video</center>'
  705. },{
  706. xtype: 'progress',
  707. value: CompositeVideoProgress
  708. }]
  709. });
  710. //CompositeVideoStatusTO = window.setTimeout( 1000, eventVideosStatusUpdater );
  711. eventVideosStatusUpdater();
  712. break;
  713. };
  714. case 2:{
  715. if( sesVideosListRExists ){
  716. rr.add({
  717. xtype: 'panel',
  718. frame: false,
  719. border: false,
  720. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=2>Composed Video from '+sesVideosListRName+' side</td></tr><tr><td align="right">Resolution:</td><td>'+CompositeVideoRightInfo.pic_size+'</td></tr><tr><td align="right">Frame rate:</td><td>'+CompositeVideoRightInfo.fps+'</td></tr><tr><td align="right">Codec:</td><td>'+CompositeVideoRightInfo.codec+'</td></tr><tr><td align="right">Duration:</td><td>'+CompositeVideoRightInfo.duration+'</td></tr><tr><td align="right">File size:</td><td>'+CompositeVideoRightInfo.file_size+'</td></tr><tr><td align="center" colspan=2><a class="big_vd_btn" href="/lib/controller/getComposedVideo.php?SESSION='+rep_selectedEventId+'&SIDE=R">Download</a></td></tr></table></div>'
  721. });
  722. };
  723. if( sesVideosListLExists ){
  724. rr.add({
  725. xtype: 'panel',
  726. frame: false,
  727. border: false,
  728. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=2>Composed Video from '+sesVideosListLName+' side</td></tr><tr><td align="right">Resolution:</td><td>'+CompositeVideoLeftInfo.pic_size+'</td></tr><tr><td align="right">Frame rate:</td><td>'+CompositeVideoLeftInfo.fps+'</td></tr><tr><td align="right">Codec:</td><td>'+CompositeVideoLeftInfo.codec+'</td></tr><tr><td align="right">Duration:</td><td>'+CompositeVideoLeftInfo.duration+'</td></tr><tr><td align="right">File size:</td><td>'+CompositeVideoLeftInfo.file_size+'</td></tr><tr><td align="center" colspan=2><a class="big_vd_btn" href="/lib/controller/getComposedVideo.php?SESSION='+rep_selectedEventId+'&SIDE=L">Download</a></td></tr></table></div>'
  729. });
  730. };
  731. break;
  732. };
  733. };
  734. rr.doLayout();
  735. }
  736. function hideEventsVideos(){
  737. //if( sesVideosListWindow != null ){
  738. // sesVideosListWindow.hide();
  739. //}
  740. if( CompositeVideoStatusTO!= null ) window.clearTimeout( CompositeVideoStatusTO );
  741. CompositeVideoStatusTO = null;
  742. sesVideosListWindow = null;
  743. }
  744. function eventVideosStatusUpdater(){
  745. Ext.Ajax.request({
  746. url: '/lib/controller/getComposerStatus.php',
  747. params: {
  748. SESSION: SelectedSessionID,
  749. UID: <?=$UserID;?>,
  750. SID: '<?=$Session;?>'
  751. },
  752. success: function( response, opts ){
  753. var data = Ext.decode(response.responseText);
  754. CompositeVideoStatusUpdate()
  755. CompositeVideoStatusTO = window.setTimeout( 1000, eventVideosStatusUpdater );
  756. }
  757. });
  758. }
  759. function showEventsVideos(){
  760. if( sesVideosListWindow == null ){
  761. sesVideosListWindow = new Ext.Window({
  762. title: 'Videos',
  763. modal: true,
  764. width: 490,
  765. height: 560,
  766. closeAction: 'close',
  767. resizable: false,
  768. items:[{
  769. xtype: 'grid',
  770. height: 350,
  771. ds: videosListStore,
  772. cm: new Ext.grid.ColumnModel( videosListColModel_ops ),
  773. sm: new Ext.grid.RowSelectionModel( videosListSelModel_ops ),
  774. },{
  775. xtype: 'panel',
  776. border: false,
  777. frame: false,
  778. id: 'EvtVidCompDownPanel',
  779. autoScroll: true,
  780. items:[]
  781. }],
  782. listeners:{
  783. close: hideEventsVideos
  784. }
  785. });
  786. };
  787. sesVideosListWindow.show();
  788. CompositeVideoStatusUpdate();
  789. };
  790. function LoadMapEventsZ( Mode ){
  791. if( tlLoadLocker ) return;
  792. tlLoadLocker = true;
  793. Ext.Ajax.request({
  794. url: '/lib/controller/getGeoAlerts.php',
  795. params: {
  796. SITE: <?=$SiteID;?>,
  797. UID: <?=$UserID;?>,
  798. SID: '<?=$Session;?>',
  799. MODE: Mode
  800. },
  801. success: function( response, opts ){
  802. if( cevt.length ){
  803. for( i=0; i< cevt.length; i++ ){
  804. if( cevt[i]!= null ){
  805. cevt[i].remove();
  806. delete( cevt[i] );
  807. cevt[i] = null;
  808. };
  809. };
  810. };
  811. if( coz.length ){
  812. for( i=0; i< coz.length; i++ ){
  813. if( coz[i]!= null ){
  814. coz[i].remove();
  815. delete( coz[i] );
  816. coz[i]=null;
  817. };
  818. };
  819. };
  820. var data = Ext.decode( response.responseText );
  821. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  822. for( i=0; i < data.evt.length; i++ ){
  823. 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 ){
  824. loadEventProperties( this.options.id );
  825. } );
  826. cevt[i].addTo(map);
  827. };
  828. for( i=0; i < data.other.length; i++ ){
  829. switch( data.other[i].type ){
  830. case 'circle':{
  831. 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 } );
  832. coz[i].addTo(map);
  833. break;
  834. };
  835. };
  836. };
  837. //eventsListStore.reload();
  838. tlLoadLocker = false;
  839. },
  840. failure: function( response, opts ) {
  841. //Ext.fly('some_div').update('Fail!');
  842. tlLoadLocker = false;
  843. }
  844. });
  845. };
  846. function loadEventPropertiesByID( id ){
  847. var d = eventsListStore.findExact( 'id', id );
  848. if( d > -1 ) {
  849. var EventRec = eventsListStore.getAt( d );
  850. loadEventProperties( EventRec.data );
  851. };
  852. };
  853. function loadEventProperties( EventRec ){
  854. var tPanel = Ext.getCmp('prop_content');
  855. tPanel.removeAll();// remove( 0 );
  856. var tt = '';
  857. if( selectedMarker!= null ){
  858. selectedMarker.remove();
  859. //map.removeLayer( selectedMarker );
  860. if( EventRec.has_geo ){
  861. tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
  862. selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
  863. selectedMarker.addTo( map );
  864. };
  865. };
  866. tPanel.add( {
  867. title: 'Event Details',
  868. html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
  869. } );
  870. if( EventRec.has_images ){
  871. for( var i=0; i < EventRec.images.length; i++ ){
  872. tPanel.add( {
  873. frame: false,
  874. 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+'"/>'
  875. });
  876. };
  877. };
  878. tPanel.doLayout();
  879. };
  880. function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){
  881. if( tlLoadLocker ) return;
  882. tlLoadLocker = true;
  883. if( Mode == 'arch' ){
  884. Ext.MessageBox.wait("Loading Data","Please Wait",{
  885. width: '100%',
  886. hidden: true,
  887. animate: true,
  888. progress: true,
  889. closable: false
  890. });
  891. };
  892. Ext.Ajax.request({
  893. url: '/lib/controller/getEventRecords.php',
  894. params: {
  895. SITE: <?=$SiteID;?>,
  896. UID: <?=$UserID;?>,
  897. SID: '<?=$Session;?>',
  898. MODE: Mode,
  899. FIL: selecredActiveSourceFilter,
  900. SDA: SD,
  901. SMO: SMO,
  902. SYE: SY,
  903. STM: ST,
  904. ETM: ET,
  905. STR: SR,
  906. DIR: DR
  907. },
  908. success: function( response, opts ){
  909. tlLoadLocker = false;
  910. var data = Ext.decode(response.responseText);
  911. if( data.updateFROMTO ){
  912. Ext.getCmp('STimeFROM').setValue( data.STT );
  913. Ext.getCmp('STimeTO').setValue( data.ENT );
  914. if( data.SLD > 0 ){
  915. SMO = GetMonthNum(data.SLD);
  916. SY = GetYear(data.SLD);
  917. SD = GetDay(data.SLD);
  918. BuildCalendar();
  919. };
  920. };
  921. eventsListStore.loadData( data, false );
  922. if( Mode == 'arch' ){
  923. showEventsOnMap( data, true );
  924. Ext.MessageBox.hide();
  925. if( DR > 0 ){
  926. Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
  927. Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
  928. };
  929. if( DR < 0 ){
  930. Ext.getCmp('evtArchLog').getView().focusRow( 0 );
  931. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  932. };
  933. } else {
  934. showEventsOnMap( data, false );
  935. //LoadMapEventsZ( Mode );
  936. };
  937. },
  938. failure: failureAJAXFunction
  939. });
  940. };
  941. function loadArchive(){
  942. debugger;
  943. if( tlInterval!= null ){
  944. window.clearInterval( tlInterval );
  945. tlInterval = null;
  946. timelineObj = null;
  947. };
  948. stopStatusUpdater();
  949. setUserContent( 2 );
  950. var tPanel = Ext.getCmp('main_portal');
  951. tPanel.removeAll( true );
  952. Ext.getCmp('main_content').setTitle( 'Events Archive' );
  953. tPanel.add({
  954. columnWidth: 0.83,
  955. frame: false,
  956. border: false,
  957. items: [{
  958. title: 'Site Map',
  959. frame: false,
  960. border: false,
  961. layout: 'vbox',
  962. layoutConfig: {
  963. align : 'stretch',
  964. pack : 'start',
  965. },
  966. height: PanelH-300,
  967. items:[{
  968. height: PanelH-325,
  969. flex: 1,
  970. frame: false,
  971. border: false,
  972. layout: 'fit',
  973. items:{
  974. id: 'event_map',
  975. html: '&nbsp;'
  976. }
  977. }]
  978. },{
  979. frame: false,
  980. border: false,
  981. collapsible: false,
  982. draggable: false,
  983. layout: 'hbox',
  984. items:[{
  985. layout: 'form',
  986. title: 'Date/Time',
  987. width: 200,
  988. frame: true,
  989. border: false,
  990. labelAlign: 'right',
  991. labelWidth: 50,
  992. defaults: { width: 80},
  993. items: [{
  994. xtype: 'combo',
  995. id: 'STimeFROM',
  996. fieldLabel: 'From',
  997. editable: false,
  998. typeAhead: true,
  999. triggerAction: 'all',
  1000. width: 120,
  1001. lazyRender:true,
  1002. mode: 'local',
  1003. store: new Ext.data.ArrayStore({
  1004. id: 0,
  1005. fields: ['ss', 'displayText' ],
  1006. data: [<?php
  1007. $zuzu = array();
  1008. for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1009. echo implode( ',', $zuzu ); ?>]
  1010. }),
  1011. valueField: 'ss',
  1012. displayField: 'displayText'
  1013. },{
  1014. xtype: 'combo',
  1015. id: 'STimeTO',
  1016. fieldLabel: 'Till',
  1017. editable: false,
  1018. typeAhead: true,
  1019. triggerAction: 'all',
  1020. width: 120,
  1021. lazyRender:true,
  1022. mode: 'local',
  1023. store: new Ext.data.ArrayStore({
  1024. id: 0,
  1025. fields: ['ss', 'displayText' ],
  1026. data: [<?php
  1027. $zuzu = array();
  1028. for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1029. echo implode( ',', $zuzu ); ?>]
  1030. }),
  1031. valueField: 'ss',
  1032. displayField: 'displayText'
  1033. }],
  1034. html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
  1035. buttons: [{
  1036. xtype: 'button',
  1037. text: 'Display History',
  1038. handler: function(){
  1039. var STU = Ext.getCmp('STimeFROM').getValue();
  1040. var ETU = Ext.getCmp('STimeTO').getValue();
  1041. getData( 'arch', STU, ETU );
  1042. }
  1043. }]
  1044. },{
  1045. title: 'Event Log',
  1046. frame: false,
  1047. height: 303,
  1048. id: 'evtArchLog',
  1049. xtype: 'grid',
  1050. ds: eventsListStore,
  1051. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1052. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1053. listeners:{
  1054. keydown: function( e ) {
  1055. if( e.getKey() == e.UP ){
  1056. if( SelectedRow == 0 ){
  1057. var id = eventsListStore.getAt( 0 ).id;
  1058. getData( 'arch', 0, 0, id, 1 );
  1059. };
  1060. };
  1061. if( e.getKey() == e.DOWN ){
  1062. if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
  1063. var id = eventsListStore.getAt( SelectedRow ).id;
  1064. getData( 'arch', 0, 0, id, -1 );
  1065. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  1066. Ext.getCmp('evtArchLog').focus( false, true );
  1067. };
  1068. };
  1069. }
  1070. }
  1071. }]
  1072. }]
  1073. });
  1074. tPanel.add({
  1075. columnWidth: 0.17,
  1076. frame: true,
  1077. title: 'Event Information',
  1078. id: 'prop_content',
  1079. border: false,
  1080. items: [{
  1081. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1082. }]
  1083. });
  1084. tPanel.doLayout();
  1085. /*
  1086. Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
  1087. Ext.getCmp('evtLog').getEl().addKeyMap({
  1088. eventName: "keyup",
  1089. binding: [{
  1090. key: Ext.EventObject.SPACE,
  1091. fn: function(){ alert("Space key pressed"); }
  1092. },{
  1093. key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
  1094. shift: true,
  1095. fn: function(){ alert("Left or right pressed while pressing shift"); }
  1096. }]
  1097. });
  1098. */
  1099. //BuildCalendar();
  1100. loadCalendarDates();
  1101. map = L.map('event_map',{
  1102. attributionControl: true,
  1103. //preferCanvas: true,
  1104. zoomControl: true,
  1105. center: [SiteLat, SiteLon],
  1106. /*zoomControl: false,
  1107. zoom: 17,
  1108. minZoom: 17,
  1109. maxZoom: 17,*/
  1110. keyboard: false
  1111. }).setView([SiteLat, SiteLon], 17);
  1112. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1113. var mapLayers = [];
  1114. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1115. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1116. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1117. detectRetina: true
  1118. });*/
  1119. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1120. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1121. maxNativeZoom: 18,
  1122. maxZoom: 24,
  1123. })
  1124. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1125. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1126. 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',
  1127. maxZoom: 19
  1128. });
  1129. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1130. 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',
  1131. maxZoom: 19
  1132. });
  1133. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1134. 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',
  1135. maxZoom: 24
  1136. });
  1137. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1138. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1139. maxZoom: 19
  1140. });
  1141. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1142. 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>) ',
  1143. maxZoom: 19
  1144. });
  1145. /*
  1146. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1147. 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>',
  1148. maxZoom: 22
  1149. });
  1150. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1151. 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>',
  1152. maxZoom: 22
  1153. });
  1154. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1155. 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>',
  1156. maxZoom: 22
  1157. });
  1158. */
  1159. var baseMaps = {
  1160. "MyMap": mapLayers["MyMap"],
  1161. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1162. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1163. "EsriSat": mapLayers["EsriSat"],
  1164. "EsriStreet": mapLayers["EsriStreet"],
  1165. "EsriTopo": mapLayers["EsriTopo"],
  1166. //"Bing": mapLayers["Bing"],
  1167. //"OSM-Cycle": mapLayers["Cycle"],
  1168. //"Landscape": mapLayers["Landscape"],
  1169. //"Outdoor": mapLayers["Outdoor"],
  1170. };
  1171. L.control.layers( baseMaps ).addTo(map);
  1172. mapLayers["MyMap"].addTo(map);
  1173. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1174. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1175. maxNativeZoom: 18,
  1176. maxZoom: 24,
  1177. }).addTo(map); */
  1178. //loadTimeLineGroups( selectedSite );
  1179. loadMapZones( SelectedSite );
  1180. getData( 'arch' );
  1181. //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  1182. };
  1183. function loadMonitoring(){
  1184. if( tlInterval!= null ){
  1185. window.clearInterval( tlInterval );
  1186. tlInterval = null;
  1187. timelineObj = null;
  1188. };
  1189. setUserContent( 1 );
  1190. var tPanel = Ext.getCmp('main_portal');
  1191. tPanel.removeAll( true );
  1192. Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
  1193. tPanel.add({
  1194. columnWidth: 0.83,
  1195. frame: false,
  1196. border: false,
  1197. items: [{
  1198. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  1199. frame: false,
  1200. border: false,
  1201. collapsible: false,
  1202. draggable: false,
  1203. layout: 'vbox',
  1204. layoutConfig: {
  1205. align : 'stretch',
  1206. pack : 'start',
  1207. },
  1208. height: PanelH-300,
  1209. items:[{
  1210. height: PanelH-325,
  1211. flex: 1,
  1212. frame: false,
  1213. border: false,
  1214. layout: 'fit',
  1215. items:{
  1216. id: 'event_map',
  1217. html: '&nbsp;'
  1218. }
  1219. }]
  1220. },{
  1221. frame: false,
  1222. border: true,
  1223. collapsible: false,
  1224. draggable: false,
  1225. layout: 'hbox',
  1226. items:[{
  1227. title: 'Alarm Sources',
  1228. xtype: 'panel',
  1229. border: false,
  1230. frame: false,
  1231. collapsible: false,
  1232. draggable: false,
  1233. id: 'sources_panel',
  1234. width: 160,
  1235. autoScroll: 'auto',
  1236. height: 303
  1237. },{
  1238. title: 'Event Log',
  1239. height: 303,
  1240. xtype: 'grid',
  1241. border: false,
  1242. frame: false,
  1243. collapsible: false,
  1244. draggable: false,
  1245. ds: eventsListStore,
  1246. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1247. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1248. bbar: [{
  1249. text: 'Clear',
  1250. handler: function(){
  1251. Ext.Ajax.request({
  1252. url: '/lib/controller/clearEventCloud.php',
  1253. params: {
  1254. UID: <?=$UserID;?>,
  1255. SID: '<?=$Session;?>'
  1256. },
  1257. success: function( response, opts ){
  1258. },
  1259. failure: function( response, opts ) {
  1260. }
  1261. });
  1262. }
  1263. }]
  1264. }]
  1265. }]
  1266. });
  1267. tPanel.add({
  1268. columnWidth: 0.17,
  1269. title: 'Event Information',
  1270. frame: true,
  1271. id: 'prop_content',
  1272. border: false,
  1273. items: [{
  1274. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1275. }]
  1276. });
  1277. tPanel.doLayout();
  1278. map = L.map('event_map',{
  1279. attributionControl: true,
  1280. //preferCanvas: true,
  1281. zoomControl: true,
  1282. center: [SiteLat, SiteLon],
  1283. /*zoomControl: false,
  1284. zoom: 17,
  1285. minZoom: 17,
  1286. maxZoom: 17,*/
  1287. keyboard: false
  1288. }).setView([SiteLat, SiteLon], 17);
  1289. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1290. var mapLayers = [];
  1291. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1292. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1293. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1294. detectRetina: true
  1295. });*/
  1296. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1297. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1298. maxNativeZoom: 18,
  1299. maxZoom: 24,
  1300. })
  1301. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1302. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1303. 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',
  1304. maxZoom: 19
  1305. });
  1306. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1307. 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',
  1308. maxZoom: 19
  1309. });
  1310. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1311. 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',
  1312. maxZoom: 24
  1313. });
  1314. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1315. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1316. maxZoom: 19
  1317. });
  1318. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1319. 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>) ',
  1320. maxZoom: 19
  1321. });
  1322. /*
  1323. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1324. 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>',
  1325. maxZoom: 22
  1326. });
  1327. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1328. 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>',
  1329. maxZoom: 22
  1330. });
  1331. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1332. 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>',
  1333. maxZoom: 22
  1334. });
  1335. */
  1336. var baseMaps = {
  1337. "MyMap": mapLayers["MyMap"],
  1338. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1339. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1340. "EsriSat": mapLayers["EsriSat"],
  1341. "EsriStreet": mapLayers["EsriStreet"],
  1342. "EsriTopo": mapLayers["EsriTopo"],
  1343. //"Bing": mapLayers["Bing"],
  1344. //"OSM-Cycle": mapLayers["Cycle"],
  1345. //"Landscape": mapLayers["Landscape"],
  1346. //"Outdoor": mapLayers["Outdoor"],
  1347. };
  1348. L.control.layers( baseMaps ).addTo(map);
  1349. mapLayers["MyMap"].addTo(map);
  1350. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1351. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1352. maxNativeZoom: 18,
  1353. maxZoom: 24,
  1354. }).addTo(map); */
  1355. loadMapZones( SelectedSite );
  1356. tlInterval = window.setInterval( getData, 333, 'live' );
  1357. };
  1358. function loadOnlineMonitoring(devID){
  1359. var tPanel = Ext.getCmp('main_content');
  1360. if( tlInterval!= null ){
  1361. window.clearInterval( tlInterval );
  1362. tlInterval = null;
  1363. timelineObj = null;
  1364. };
  1365. tPanel.remove(0);
  1366. tPanel.add({
  1367. html: 'Device Monitoring '+devID
  1368. });
  1369. tPanel.doLayout();
  1370. };
  1371. var mSesPlay = null;
  1372. function ts2dts( b ){
  1373. var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  1374. var a = new Date( b );
  1375. var year = a.getFullYear();
  1376. var month = months[a.getMonth()];
  1377. var date = a.getDate();
  1378. var hour = a.getHours();
  1379. var min = "0" + a.getMinutes();
  1380. var sec = "0" + a.getSeconds();
  1381. return date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) ;
  1382. };
  1383. function drawSessionDataOnSlider( a, b , z, v ){
  1384. var cel = Ext.getCmp("hpl_slider").getEl();
  1385. var c = document.createElement('canvas');
  1386. var ctx = c.getContext('2d');
  1387. c.width = cel.getWidth();
  1388. c.height = cel.getHeight();
  1389. var tK = ( cel.getWidth() - 7 ) / ( b - a );
  1390. var rib = (tK>3)?tK:3;
  1391. ctx.fillStyle='#00000000';
  1392. //ctx.fillStyle='#00FF00';
  1393. ctx.fillRect( 7, 0, cel.getWidth(), cel.getHeight() );
  1394. ctx.fillStyle='#FF0000';
  1395. for( var i=0; i< z.length; i++ ){
  1396. var cX = 7 + Math.round( tK * ( z[i].ts /1000 - a ) );
  1397. ctx.fillRect( cX, 0, rib, 12 );//25
  1398. };
  1399. ctx.fillStyle='#0000FF';
  1400. for( var i=0; i< v.length; i++ ){
  1401. var cX = 7 + Math.round( tK * ( v[i].sts /1000 - a ) );
  1402. var cD = 7 + Math.round( tK * ( v[i].ets /1000 - a ) );
  1403. var cW = cD - cX;
  1404. ctx.fillRect( cX, 13, cW, 25 );
  1405. };
  1406. cel.setStyle('background','url(' + c.toDataURL() + ')');
  1407. };
  1408. var max_grad_levels = 16;
  1409. function getTransperecy( i ){
  1410. if( i == 0 ) return 'FF';
  1411. var k = 128.0 / max_grad_levels;
  1412. var l = parseInt( k*(max_grad_levels-i) ).toString(16);
  1413. if( l.length < 2 ) l = '0'+l;
  1414. return l;
  1415. };
  1416. function getSize( i ){
  1417. var k = 75.0 / max_grad_levels;
  1418. return 25+parseInt( k * i );
  1419. };
  1420. class argusSessionPlayer{
  1421. sessionId;
  1422. mMapID;
  1423. startTime;
  1424. endTime;
  1425. currentTime;
  1426. rVideoJS = null;
  1427. lVideoJS = null;
  1428. rVideoJS_id = null;
  1429. lVideoJS_id = null;
  1430. rVideoJS_playing = false;
  1431. lVideoJS_playing = false;
  1432. rVideoJS_cid = -1;
  1433. lVideoJS_cid = -1;
  1434. mapLayout;
  1435. lVideos;
  1436. rVideos;
  1437. Events;
  1438. basePath;
  1439. mTimer = null;
  1440. mPaused = true;
  1441. mLooping = true;
  1442. mAutoPlay = false;
  1443. nextRTimestamp = 0.0;
  1444. nextLTimestamp = 0.0;
  1445. mSvgElements;//076.png
  1446. checkLVideoTime(){
  1447. const t = mSesPlay.lVideoJS.currentTime(); // seconds
  1448. while( t >= mSesPlay.nextLTimestamp ){
  1449. mSesPlay.lVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextLTimestamp });
  1450. mSesPlay.nextLTimestamp += 0.1; // next 100 ms of video time
  1451. };
  1452. }
  1453. checkRVideoTime(){
  1454. const t = mSesPlay.rVideoJS.currentTime(); // seconds
  1455. while( t >= mSesPlay.nextRTimestamp ){
  1456. mSesPlay.rVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextRTimestamp });
  1457. mSesPlay.nextRTimestamp += 0.1; // next 100 ms of video time
  1458. };
  1459. }
  1460. constructor( session_id, autoplay ) {
  1461. this.sessionId = session_id;
  1462. this.currentTime = 0;
  1463. this.startTime = 0;
  1464. this.endTime = 0;
  1465. this.lVideos = [];
  1466. this.rVideos = [];
  1467. this.Events = [];
  1468. this.rEvents = [];
  1469. this.lEvents = [];
  1470. this.mSvgElements = [];
  1471. if( autoplay != undefined ) this.mAutoPlay = autoplay;
  1472. Ext.Ajax.request({
  1473. url: '/lib/controller/getSessionData.php',
  1474. params: {
  1475. SESSION: this.sessionId,
  1476. UID: <?=$UserID;?>,
  1477. SID: '<?=$Session;?>'
  1478. },
  1479. success: function( response, opts ){
  1480. var data = Ext.decode( response.responseText );
  1481. //debugger;
  1482. if( data.status == 'ok' ){
  1483. mSesPlay.mapLayout = data.layout;
  1484. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1485. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1486. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1487. //debugger;
  1488. if( data.data_ok ){
  1489. mSesPlay.startTime = data.start_ts;
  1490. mSesPlay.endTime = data.start_ts + data.length;
  1491. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1492. mSesPlay.rVideos = [];
  1493. mSesPlay.lVideos = [];
  1494. mSesPlay.nextRTimestamp = 0.0;
  1495. mSesPlay.nextLTimestamp = 0.0;
  1496. sesVideosListRName = data.r_module_name;
  1497. sesVideosListLName = data.l_module_name;
  1498. if( data.composed_video ){
  1499. if( data.composed_video_status == 'D' ){
  1500. CompositeVideoStatus = 2;
  1501. sesVideosListRExists = data.composed_right_video_exists;
  1502. sesVideosListLExists = data.composed_left_video_exists;
  1503. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  1504. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  1505. } else {
  1506. CompositeVideoStatus = 1;
  1507. CompositeVideoProgress = data.composed_video_progress;
  1508. CompositeVideoLeftInfo = null;
  1509. CompositeVideoRightInfo = null;
  1510. sesVideosListRExists = false;
  1511. sesVideosListLExists = false;
  1512. }
  1513. } else CompositeVideoStatus = 0;
  1514. var tt = Ext.getCmp('hpl_slider');
  1515. tt.setMinValue( 0 );
  1516. tt.setMaxValue( data.length / 1000 );
  1517. if( data.events.length ){
  1518. mSesPlay.Events = data.events;
  1519. for( var i=0; i < data.events.length; i++ ){
  1520. if( data.events[i].side == 'L' ){
  1521. mSesPlay.lEvents.push( data.events[i] );
  1522. } else {
  1523. mSesPlay.rEvents.push( data.events[i] );
  1524. };
  1525. };
  1526. };
  1527. if( data.videos.length ){
  1528. videosListStore.loadData( data, false );
  1529. for( var i=0; i < data.videos.length; i++ ){
  1530. if( mSesPlay.currentTime == 0 ){
  1531. mSesPlay.currentTime = data.videos[i].sts;
  1532. } else {
  1533. if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts;
  1534. };
  1535. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] );
  1536. else mSesPlay.lVideos.push( data.videos[i] );
  1537. };
  1538. sesVideosStartTS = mSesPlay.currentTime;
  1539. } else {
  1540. sesVideosStartTS = 0;
  1541. videosListStore.removeAll();
  1542. };
  1543. if( mSesPlay.rVideos.length ) {
  1544. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1545. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1546. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  1547. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1548. // New imp
  1549. mSesPlay.rVideoJS.on('play', () => {
  1550. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1551. });
  1552. mSesPlay.rVideoJS.on( 'timeupdate', mSesPlay.checkRVideoTime );
  1553. mSesPlay.rVideoJS.on('seeking', () => {
  1554. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1555. });
  1556. mSesPlay.rVideoJS.on('videotick', (e) => {
  1557. mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 );
  1558. });
  1559. mSesPlay.rVideoJS.on('ended', function() {
  1560. console.log("Video Ended!");
  1561. if( mSesPlay.rVideoJS_cid < mSesPlay.rVideos.length ){
  1562. mSesPlay.rVideoJS_cid++;
  1563. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.rVideos[mSesPlay.rVideoJS_cid].name };
  1564. mSesPlay.rVideoJS.src( ns );
  1565. mSesPlay.rVideoJS.play();
  1566. mSesPlay.rVideoJS_playing = true;
  1567. };
  1568. });
  1569. };
  1570. if( mSesPlay.lVideos.length ){
  1571. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1572. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1573. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  1574. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1575. // New imp
  1576. mSesPlay.lVideoJS.on('play', () => {
  1577. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1578. });
  1579. mSesPlay.lVideoJS.on( 'timeupdate', mSesPlay.checkLVideoTime );
  1580. mSesPlay.lVideoJS.on('seeking', () => {
  1581. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1582. });
  1583. mSesPlay.lVideoJS.on('videotick', (e) => {
  1584. mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 );
  1585. });
  1586. mSesPlay.lVideoJS.on('ended', function() {
  1587. console.log("Video Ended!");
  1588. if( mSesPlay.lVideoJS_cid < mSesPlay.lVideos.length ){
  1589. mSesPlay.lVideoJS_cid++;
  1590. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.lVideos[mSesPlay.lVideoJS_cid].name };
  1591. mSesPlay.lVideoJS.src( ns );
  1592. mSesPlay.lVideoJS.play();
  1593. mSesPlay.lVideoJS_playing = true;
  1594. };
  1595. });
  1596. };
  1597. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  1598. mSesPlay.setPosition( 0 );
  1599. if( mSesPlay.mAutoPlay ) mSesPlay.play();
  1600. } else {
  1601. Ext.Msg.show({
  1602. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1603. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1604. buttons: Ext.Msg.OK,
  1605. icon: Ext.MessageBox.ERROR
  1606. });
  1607. }
  1608. };
  1609. },
  1610. failure: failureAJAXFunction
  1611. });
  1612. }
  1613. checkPlayebleTime( ct ){
  1614. if( this.rVideos.length ){
  1615. var fid = -1;
  1616. if( this.rVideoJS_cid < this.rVideos.length - 1 ){
  1617. for(var i=this.rVideoJS_cid+1; i < this.rVideos.length; i++ ){
  1618. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1619. fid = i;
  1620. break;
  1621. };
  1622. };
  1623. if( fid < 0 ){
  1624. //No Segments for Now;
  1625. //this.rVideoJS_playing = false;
  1626. this.rVideoJS_cid = 1;
  1627. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1628. this.rVideoJS.src( ns );
  1629. this.rVideoJS_playing = true;
  1630. } else {
  1631. if( this.rVideoJS_cid != fid ){
  1632. this.rVideoJS_cid = fid;
  1633. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1634. this.rVideoJS.src( ns );
  1635. };
  1636. this.rVideoJS_playing = true;
  1637. };
  1638. };
  1639. };
  1640. if( this.lVideos.length ){
  1641. var fid = -1;
  1642. for(var i=this.lVideos.length-1; i > 0; i-- ){
  1643. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1644. fid = i;
  1645. break;
  1646. };
  1647. };
  1648. if( fid < 0 ){
  1649. //No Segments for Now;
  1650. //this.lVideoJS_playing = false;
  1651. this.lVideoJS_cid = 1;
  1652. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1653. this.lVideoJS.src( ns );
  1654. this.lVideoJS_playing = true;
  1655. } else {
  1656. if( this.lVideoJS_cid != fid ){
  1657. this.lVideoJS_cid = fid;
  1658. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1659. this.lVideoJS.src( ns );
  1660. };
  1661. this.lVideoJS_playing = true;
  1662. };
  1663. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1664. };
  1665. }
  1666. action( currentTime = 0 ){
  1667. if( !this.mPaused ){
  1668. this.currentTime = currentTime;
  1669. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1670. //debugger;
  1671. this.currentTime = this.checkPlayebleTime( this.currentTime );
  1672. var zz = document.getElementById('hpl_time_mon');
  1673. if( zz != undefined ){
  1674. zz.innerHTML = ts2dts( this.currentTime );
  1675. };
  1676. //Check videos
  1677. if( this.rVideos.length ){
  1678. var fid = -1;
  1679. for(var i=0; i<this.rVideos.length; i++ ){
  1680. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1681. fid = i;
  1682. break;
  1683. };
  1684. };
  1685. if( fid < 0 ){
  1686. //No Segments for Now;
  1687. this.rVideoJS_playing = false;
  1688. } else {
  1689. if( this.rVideoJS_cid != fid ){
  1690. this.rVideoJS_cid = fid;
  1691. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1692. this.rVideoJS.src( ns );
  1693. };
  1694. this.rVideoJS_playing = true;
  1695. };
  1696. //if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1697. };
  1698. if( this.lVideos.length ){
  1699. var fid = -1;
  1700. for(var i=0; i<this.lVideos.length; i++ ){
  1701. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1702. fid = i;
  1703. break;
  1704. };
  1705. };
  1706. if( fid < 0 ){
  1707. //No Segments for Now;
  1708. this.lVideoJS_playing = false;
  1709. } else {
  1710. if( this.lVideoJS_cid != fid ){
  1711. this.lVideoJS_cid = fid;
  1712. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1713. this.lVideoJS.src( ns );
  1714. };
  1715. this.lVideoJS_playing = true;
  1716. };
  1717. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1718. };
  1719. if( this.Events.length ){
  1720. var sid = -1;
  1721. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1722. sid = i;
  1723. break;
  1724. };
  1725. if( sid > -1 ){
  1726. for( var i=0; i< max_grad_levels; i++ ){
  1727. var cid = sid-i;
  1728. var csize = getSize( i );
  1729. //debugger;
  1730. if( typeof this.mSvgElements[i] === 'undefined') {
  1731. if( cid > -1 ){
  1732. var svgns = "http://www.w3.org/2000/svg";
  1733. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1734. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1735. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1736. this.mSvgElements[i].setAttribute('height', ''+csize);
  1737. this.mSvgElements[i].setAttribute('width', ''+csize);
  1738. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1739. var tt = document.getElementById('svgTrackMap');
  1740. var zz = document.getElementById('scheme_anch');
  1741. tt.insertBefore( this.mSvgElements[i], zz );
  1742. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1743. };
  1744. } else {
  1745. if( cid > -1 ){
  1746. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1747. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1748. this.mSvgElements[i].setAttribute('height', ''+csize);
  1749. this.mSvgElements[i].setAttribute('width', ''+csize);
  1750. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1751. } else {
  1752. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1753. };
  1754. };
  1755. };
  1756. } else
  1757. for( var i=0; i< max_grad_levels; i++ )
  1758. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1759. };
  1760. var tt = Ext.getCmp('hpl_slider');
  1761. if( tt!= undefined ){
  1762. tt.suspendEvents();
  1763. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1764. tt.resumeEvents();
  1765. };
  1766. //this.currentTime += 250;
  1767. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1768. this.currentTime = 0;
  1769. } else {
  1770. //Stop
  1771. this.play();
  1772. };
  1773. };
  1774. }
  1775. play(){
  1776. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1777. if( this.mPaused ){
  1778. this.mPaused = false;
  1779. if( this.rVideos.length ){
  1780. if( !this.rVideoJS_playing ) this.rVideoJS.play();
  1781. this.rVideoJS_playing = true;
  1782. };
  1783. if( this.lVideos.length ){
  1784. if( !this.lVideoJS_playing ) this.lVideoJS.play();
  1785. this.lVideoJS_playing = true;
  1786. };
  1787. zz.setIconClass( 'plr_op_pause' );
  1788. zz.setText('Pause');
  1789. } else {
  1790. this.mPaused = true;
  1791. if( this.rVideos.length ){
  1792. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  1793. this.rVideoJS_playing = false;
  1794. };
  1795. if( this.lVideos.length ){
  1796. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  1797. this.lVideoJS_playing = false;
  1798. };
  1799. zz.setIconClass( 'plr_op_play' );
  1800. zz.setText('Play');
  1801. };
  1802. this.action( this.currentTime );
  1803. //if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  1804. }
  1805. pause(){
  1806. this.mPaused = true;
  1807. }
  1808. toggleLoop(){
  1809. this.mLooping = !this.mLooping;
  1810. if( this.mLooping ) if( this.currentTime > this.endTime ){
  1811. this.currentTime = 0;
  1812. // Start
  1813. this.play();
  1814. };
  1815. }
  1816. setPosition( pos_time ){
  1817. //this.currentTime = this.startTime + pos_time*1000;
  1818. var nt = this.startTime + pos_time*1000;
  1819. var zz = document.getElementById('hpl_time_mon');
  1820. zz.innerHTML = ts2dts( nt );
  1821. if( this.rVideoJS_playing )
  1822. this.rVideoJS.currentTime( ( nt - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1823. if( this.lVideoJS_playing )
  1824. this.lVideoJS.currentTime( ( nt - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1825. }
  1826. onLVideoEnd(){
  1827. }
  1828. onRVideoEnd(){
  1829. }
  1830. dispose(){
  1831. if( this.mTimer != null ) clearInterval( this.mTimer );
  1832. this.mTimer = null;
  1833. if( this.rVideoJS!= null ){
  1834. this.rVideoJS.dispose();
  1835. this.rVideoJS = null;
  1836. };
  1837. if( this.lVideoJS!= null ){
  1838. this.lVideoJS.dispose();
  1839. this.lVideoJS = null;
  1840. };
  1841. }
  1842. }
  1843. // canvas aproach ///////////////////////////////////////////
  1844. /*
  1845. const player = videojs('my-video');
  1846. let nextTimestamp = 0;
  1847. let rafId = null;
  1848. function tick() {
  1849. if (player.paused() || player.ended())
  1850. return;
  1851. const t = player.currentTime();
  1852. while (t >= nextTimestamp) {
  1853. player.trigger({
  1854. type: 'videotick',
  1855. timestamp: nextTimestamp
  1856. });
  1857. nextTimestamp += 0.1;
  1858. }
  1859. rafId = requestAnimationFrame(tick);
  1860. }
  1861. player.on('play', () => {
  1862. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  1863. cancelAnimationFrame(rafId);
  1864. rafId = requestAnimationFrame(tick);
  1865. });
  1866. player.on('pause', () => cancelAnimationFrame(rafId));
  1867. player.on('ended', () => cancelAnimationFrame(rafId));
  1868. player.on('seeking', () => {
  1869. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  1870. });
  1871. player.on('videotick', (e) => {
  1872. console.log(e.timestamp);
  1873. });
  1874. */
  1875. class _argusSessionPlayer{
  1876. sessionId;
  1877. mMapID;
  1878. startTime;
  1879. endTime;
  1880. currentTime;
  1881. rVideoJS = null;
  1882. lVideoJS = null;
  1883. rVideoJS_id = null;
  1884. lVideoJS_id = null;
  1885. rVideoJS_playing = false;
  1886. lVideoJS_playing = false;
  1887. rVideoJS_cid = -1;
  1888. lVideoJS_cid = -1;
  1889. mapLayout;
  1890. lVideos;
  1891. rVideos;
  1892. Events;
  1893. basePath;
  1894. mTimer = null;
  1895. mPaused = true;
  1896. mLooping = true;
  1897. mSvgElements;//076.png
  1898. constructor( session_id ) {
  1899. this.sessionId = session_id;
  1900. this.currentTime = 0;
  1901. this.startTime = 0;
  1902. this.endTime = 0;
  1903. this.lVideos = [];
  1904. this.rVideos = [];
  1905. this.Events = [];
  1906. this.mSvgElements = [];
  1907. Ext.Ajax.request({
  1908. url: '/lib/controller/getSessionData.php',
  1909. params: {
  1910. SESSION: this.sessionId,
  1911. UID: <?=$UserID;?>,
  1912. SID: '<?=$Session;?>'
  1913. },
  1914. success: function( response, opts ){
  1915. var data = Ext.decode( response.responseText );
  1916. //debugger;
  1917. if( data.status == 'ok' ){
  1918. mSesPlay.mapLayout = data.layout;
  1919. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1920. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1921. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1922. //debugger;
  1923. if( data.data_ok ){
  1924. if( data.r_module_id ){
  1925. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1926. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1927. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1928. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  1929. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1930. };
  1931. mSesPlay.startTime = data.start_ts;
  1932. mSesPlay.endTime = data.start_ts + data.length;
  1933. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1934. mSesPlay.rVideos = [];
  1935. mSesPlay.lVideos = [];
  1936. if( data.videos.length ){
  1937. for( var i=0; i < data.videos.length; i++ )
  1938. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  1939. };
  1940. if( data.events.length ) mSesPlay.Events = data.events;
  1941. var tt = Ext.getCmp('hpl_slider');
  1942. tt.setMinValue( 0 );
  1943. tt.setMaxValue( data.length / 1000 );
  1944. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  1945. //player.on('ended', function() {
  1946. // this.dispose();
  1947. //});
  1948. //alert( data.basepath +'/'+data.videos[0].name );
  1949. //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  1950. //mSesPlay.rVideoJS.ready(function() {
  1951. //mSesPlay.rVideoJS.play();
  1952. //var howLoudIsIt = player.volume();
  1953. //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half
  1954. //});
  1955. //mSesPlay.rVideoJS.on("timeupdate", function(){
  1956. // method will be calledd each 250 msecs
  1957. //});
  1958. if( data.l_module_id ){
  1959. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1960. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1961. //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1962. //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  1963. //mSesPlay.lVideoJS.ready(function() {
  1964. //mSesPlay.rVideoJS.play();
  1965. //var howLoudIsIt = player.volume();
  1966. // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half
  1967. //});
  1968. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  1969. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1970. };
  1971. //mSesPlay.lVideoJS.on("timeupdate", function(){
  1972. // // method will be calledd each 250 msecs
  1973. //});
  1974. mSesPlay.setPosition( 0 );
  1975. } else {
  1976. Ext.Msg.show({
  1977. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1978. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1979. buttons: Ext.Msg.OK,
  1980. icon: Ext.MessageBox.ERROR
  1981. });
  1982. }
  1983. };
  1984. },
  1985. failure: failureAJAXFunction
  1986. });
  1987. }
  1988. action(){
  1989. if( !this.mPaused ){
  1990. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1991. var zz = document.getElementById('hpl_time_mon');
  1992. //debugger;
  1993. if( zz != undefined ){
  1994. zz.innerHTML = ts2dts( this.currentTime );
  1995. };
  1996. //Check videos
  1997. if( this.rVideos.length ){
  1998. var fid = -1;
  1999. for(var i=0; i<this.rVideos.length; i++ ){
  2000. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2001. fid = i;
  2002. break;
  2003. };
  2004. };
  2005. if( fid < 0 ){
  2006. //No Segments for Now;
  2007. this.rVideoJS_playing = false;
  2008. } else {
  2009. if( this.rVideoJS_cid != fid ){
  2010. this.rVideoJS_cid = fid;
  2011. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2012. this.rVideoJS.src( ns );
  2013. };
  2014. this.rVideoJS_playing = true;
  2015. };
  2016. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2017. };
  2018. if( this.lVideos.length ){
  2019. var fid = -1;
  2020. for(var i=0; i<this.lVideos.length; i++ ){
  2021. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2022. fid = i;
  2023. break;
  2024. };
  2025. };
  2026. if( fid < 0 ){
  2027. //No Segments for Now;
  2028. this.lVideoJS_playing = false;
  2029. } else {
  2030. if( this.lVideoJS_cid != fid ){
  2031. this.lVideoJS_cid = fid;
  2032. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2033. this.lVideoJS.src( ns );
  2034. };
  2035. this.lVideoJS_playing = true;
  2036. };
  2037. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2038. };
  2039. if( this.Events.length ){
  2040. var sid = -1;
  2041. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  2042. sid = i;
  2043. break;
  2044. };
  2045. if( sid > -1 ){
  2046. for( var i=0; i< max_grad_levels; i++ ){
  2047. var cid = sid-i;
  2048. var csize = getSize( i );
  2049. //debugger;
  2050. if( typeof this.mSvgElements[i] === 'undefined') {
  2051. if( cid > -1 ){
  2052. var svgns = "http://www.w3.org/2000/svg";
  2053. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  2054. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2055. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2056. this.mSvgElements[i].setAttribute('height', ''+csize);
  2057. this.mSvgElements[i].setAttribute('width', ''+csize);
  2058. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  2059. var tt = document.getElementById('svgTrackMap');
  2060. var zz = document.getElementById('scheme_anch');
  2061. tt.insertBefore( this.mSvgElements[i], zz );
  2062. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  2063. };
  2064. } else {
  2065. if( cid > -1 ){
  2066. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2067. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2068. this.mSvgElements[i].setAttribute('height', ''+csize);
  2069. this.mSvgElements[i].setAttribute('width', ''+csize);
  2070. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  2071. } else {
  2072. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2073. };
  2074. };
  2075. };
  2076. } else
  2077. for( var i=0; i< max_grad_levels; i++ )
  2078. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2079. };
  2080. var tt = Ext.getCmp('hpl_slider');
  2081. if( tt!= undefined ){
  2082. tt.suspendEvents();
  2083. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  2084. tt.resumeEvents();
  2085. };
  2086. this.currentTime += 250;
  2087. if( this.currentTime > this.endTime ) if( this.mLooping ){
  2088. this.currentTime = 0;
  2089. } else {
  2090. //Stop
  2091. this.play();
  2092. };
  2093. };
  2094. }
  2095. play(){
  2096. var zz = Ext.getCmp( 'hpl_pl_btn' );
  2097. if( this.mPaused ){
  2098. this.mPaused = false;
  2099. if( this.rVideoJS_playing ) this.rVideoJS.play();
  2100. if( this.lVideoJS_playing ) this.lVideoJS.play();
  2101. zz.setIconClass( 'plr_op_pause' );
  2102. zz.setText('Pause');
  2103. } else {
  2104. this.mPaused = true;
  2105. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  2106. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  2107. zz.setIconClass( 'plr_op_play' );
  2108. zz.setText('Play');
  2109. };
  2110. if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  2111. }
  2112. pause(){
  2113. this.mPaused = true;
  2114. }
  2115. toggleLoop(){
  2116. this.mLooping = !this.mLooping;
  2117. if( this.mLooping ) if( this.currentTime > this.endTime ){
  2118. this.currentTime = 0;
  2119. // Start
  2120. this.play();
  2121. };
  2122. }
  2123. setPosition( pos_time ){
  2124. this.currentTime = this.startTime + pos_time*1000;
  2125. var zz = document.getElementById('hpl_time_mon');
  2126. zz.innerHTML = ts2dts( this.currentTime );
  2127. }
  2128. onLVideoEnd(){
  2129. }
  2130. onRVideoEnd(){
  2131. }
  2132. dispose(){
  2133. if( this.mTimer != null ) clearInterval( this.mTimer );
  2134. this.mTimer = null;
  2135. if( this.rVideoJS!= null ){
  2136. this.rVideoJS.dispose();
  2137. this.rVideoJS = null;
  2138. };
  2139. if( this.lVideoJS!= null ){
  2140. this.lVideoJS.dispose();
  2141. this.lVideoJS = null;
  2142. };
  2143. }
  2144. }
  2145. var SelectedSessionID = 0;
  2146. function loadHistorySessionView( session_id ){
  2147. autoRiseEvent = false;
  2148. SelectedSessionID = rep_selectedEventId = session_id;
  2149. Ext.Ajax.request({
  2150. url: '/lib/controller/getHistorySessionView.php',
  2151. params: {
  2152. SESSION: rep_selectedEventId,
  2153. UID: <?=$UserID;?>,
  2154. SID: '<?=$Session;?>'
  2155. },
  2156. success: function( response, opts ){
  2157. var data = Ext.decode(response.responseText);
  2158. if( data.status == 'ok' ){
  2159. monitoringViewLevel = 5;
  2160. if( mSesPlay!= null ) {
  2161. mSesPlay.dispose();
  2162. mSesPlay = null;
  2163. };
  2164. Ext.getCmp('main_content').removeAll(true);
  2165. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2166. Ext.getCmp('main_content').doLayout();
  2167. changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId );
  2168. updateUserContent();
  2169. mSesPlay = new argusSessionPlayer( rep_selectedEventId , true );
  2170. fetchStatus();
  2171. };
  2172. },
  2173. failure: failureAJAXFunction
  2174. });
  2175. };
  2176. function deleteSession( session_id ){
  2177. if( session_id == 0 ) return;
  2178. Ext.Msg.show({
  2179. title:'<?=$Labels->GetLabel('_RYS_DEL_SES_');?>',
  2180. msg: '<?=$Labels->GetLabel('_RYS_DEL_SESSION_');?>',
  2181. buttons: Ext.Msg.YESNOCANCEL,
  2182. icon: Ext.MessageBox.QUESTION,
  2183. fn: function(btn, text){
  2184. if( btn == 'yes' ){
  2185. Ext.Ajax.request({
  2186. url: '/lib/controller/doSessionOperations.php',
  2187. params: {
  2188. SESSION: session_id,
  2189. OPID: 1,
  2190. UID: <?=$UserID;?>,
  2191. SID: '<?=$Session;?>'
  2192. },
  2193. success: function( response, opts ){
  2194. Ext.Msg.hide();
  2195. var data = Ext.decode(response.responseText);
  2196. if( data.status == 'ok' ){
  2197. getBackToMap();
  2198. } else {
  2199. Ext.Msg.show({
  2200. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  2201. msg: data.msg,
  2202. buttons: Ext.Msg.OK,
  2203. icon: Ext.MessageBox.ERROR
  2204. });
  2205. };
  2206. },
  2207. failure: failureAJAXFunction
  2208. });
  2209. };
  2210. }
  2211. });
  2212. };
  2213. function loadHistoryStationEvt( e ){
  2214. loadHistoryStation( e.target.options.mycustomid );
  2215. };
  2216. function loadHistoryStation( STT, buba ){
  2217. if( buba == undefined ){
  2218. autoRiseEvent = false;
  2219. } else {
  2220. autoRiseEvent = buba;
  2221. };
  2222. rep_selectedStation = STT;
  2223. changeContent( 2, 1, rep_selectedStation );
  2224. updateUserContent();
  2225. Ext.Ajax.request({
  2226. url: '/lib/controller/getHistoryStationView.php',
  2227. params: {
  2228. STT: rep_selectedStation,
  2229. UID: <?=$UserID;?>,
  2230. SID: '<?=$Session;?>'
  2231. },
  2232. success: function( response, opts ){
  2233. var data = Ext.decode(response.responseText);
  2234. if( data.status == 'ok' ){
  2235. Ext.getCmp('main_content').removeAll(true);
  2236. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2237. Ext.getCmp('main_content').doLayout();
  2238. Ext.getCmp('left_side_menu').removeAll(true);
  2239. Ext.getCmp('left_side_menu').add({
  2240. xtype: 'panel',
  2241. frame: true,
  2242. border: false,
  2243. items: [{
  2244. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  2245. height: PanelH - 30
  2246. }]
  2247. });
  2248. Ext.getCmp('left_side_menu').doLayout();
  2249. } else {
  2250. };
  2251. },
  2252. failure: failureAJAXFunction
  2253. });
  2254. };
  2255. function loadReportDayTree( ts ){
  2256. ReportSelectionMode = 1;//Day Selected
  2257. rep_selectedDateTS = ts;
  2258. //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  2259. //ReportMask.show();
  2260. Ext.Ajax.request({
  2261. url: '/lib/controller/getHistoryDay.php',
  2262. params: {
  2263. UID: <?=$UserID;?>,
  2264. SID: '<?=$Session;?>',
  2265. STT: rep_selectedStation,
  2266. DTS: rep_selectedDateTS
  2267. },
  2268. success: function(response, opts ){
  2269. var data = Ext.decode( response.responseText );
  2270. var sPanel = Ext.getCmp('left_side_menu');
  2271. sPanel.removeAll( true );
  2272. sPanel.add({
  2273. xtype: 'panel',
  2274. layout: 'vbox',
  2275. frame: true,
  2276. border: false,
  2277. items:[{
  2278. xtype: 'spacer',
  2279. height: 3
  2280. },{
  2281. 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>',
  2282. frame: false,
  2283. width: '100%',
  2284. border: false
  2285. },{
  2286. xtype: 'spacer',
  2287. height: 5
  2288. },{
  2289. xtype: 'treepanel',
  2290. autoScroll: true,
  2291. width: '100%',
  2292. height: PanelH-206,
  2293. border: true,
  2294. frame: true,
  2295. loader: new Ext.tree.TreeLoader(),
  2296. rootVisible: false,
  2297. root: new Ext.tree.AsyncTreeNode( data ),
  2298. listeners: {
  2299. click: function(n) {
  2300. if( n.attributes.leaf ){
  2301. Ext.getCmp('chu_adate').show();
  2302. sPanel.doLayout();
  2303. loadHistorySessionView( n.attributes.sid );
  2304. };
  2305. }
  2306. }
  2307. },{
  2308. xtype: 'spacer',
  2309. height: 10
  2310. },{
  2311. xtype: 'button',
  2312. id: 'chu_adate',
  2313. text: 'Show Dates',
  2314. hidden: true,
  2315. width: '100%',
  2316. iconCls: 'reports_dates_btn',
  2317. scale: 'large',
  2318. handler: function(){
  2319. Ext.getCmp('chu_adate').hide();
  2320. loadHistoryStation( rep_selectedStation );
  2321. }
  2322. }]
  2323. });
  2324. sPanel.doLayout();
  2325. changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS );
  2326. updateUserContent();
  2327. //ReportMask.hide();
  2328. }
  2329. });
  2330. };
  2331. function noHistDialog(){
  2332. Ext.Msg.show({
  2333. title:'<?=$Labels->GetLabel('_GEN_MSG_');?>',
  2334. msg: '<?=$Labels->GetLabel('_NO_REPORTS_4_STATION_');?>',
  2335. buttons: Ext.Msg.OK,
  2336. icon: Ext.MessageBox.INFO
  2337. });
  2338. };
  2339. var history_map = null;
  2340. function initHistoryMap( map_id, x, y ){
  2341. if( tlInterval!= null ){
  2342. window.clearTimeout( tlInterval );
  2343. tlInterval = null;
  2344. };
  2345. var mapLayers = [];
  2346. if( history_map != null ){
  2347. history_map.off();
  2348. history_map.remove();
  2349. history_map = null;
  2350. };
  2351. history_map = L.map( map_id,{
  2352. crs: L.CRS.Simple,
  2353. attributionControl: false,
  2354. preferCanvas: true,
  2355. zoomControl: true,
  2356. center: [x,y],
  2357. zoom: 0,
  2358. minZoom: -3,
  2359. maxZoom: 0,
  2360. keyboard: false
  2361. });
  2362. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  2363. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( history_map );
  2364. Ext.Ajax.request({
  2365. url: '/lib/controller/listHistoryStations.php',
  2366. params: {
  2367. UID: <?=$UserID;?>,
  2368. SID: '<?=$Session;?>'
  2369. },
  2370. success: function( response, opts ){
  2371. var data = Ext.decode(response.responseText);
  2372. if( data.status == 'ok' ){
  2373. for( i=0; i < data.stations.length; i++ ){
  2374. if( data.stations[i].status ){
  2375. 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 );
  2376. } else {
  2377. 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 );
  2378. };
  2379. };
  2380. };
  2381. },
  2382. failure: failureAJAXFunction
  2383. });
  2384. };
  2385. function getBackToHistoryMap(){
  2386. autoRiseEvent = false;
  2387. changeContent( 2, 0 );
  2388. updateUserContent();
  2389. var tP = Ext.getCmp('left_side_menu');
  2390. tP.removeAll( true );
  2391. tP.add({
  2392. layout:'vbox',
  2393. frame: false,
  2394. border: false,
  2395. items:[{
  2396. xtype: 'panel',
  2397. frame: true,
  2398. border: false,
  2399. items: [{
  2400. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  2401. height: PanelH - 30
  2402. }]
  2403. }]
  2404. });
  2405. tP.doLayout();
  2406. loadHistoryMapView();
  2407. };
  2408. function loadHistoryMapView(){
  2409. autoRiseEvent = false;
  2410. Ext.Ajax.request({
  2411. url: '/lib/controller/getHistoryMapView.php',
  2412. params: {
  2413. UID: <?=$UserID;?>,
  2414. SID: '<?=$Session;?>'
  2415. },
  2416. success: function( response, opts ){
  2417. var data = Ext.decode(response.responseText);
  2418. if( data.status == 'ok' ){
  2419. monitoringViewLevel = 0;
  2420. Ext.getCmp('main_content').removeAll(true);
  2421. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2422. Ext.getCmp('main_content').doLayout();
  2423. };
  2424. },
  2425. failure: failureAJAXFunction
  2426. });
  2427. return;
  2428. };
  2429. function initReportsView(){
  2430. if( tlInterval!= null ){
  2431. window.clearInterval( tlInterval );
  2432. tlInterval = null;
  2433. timelineObj = null;
  2434. };
  2435. var tP = Ext.getCmp('left_side_menu');
  2436. tP.removeAll( true );
  2437. tP.add({
  2438. layout:'vbox',
  2439. frame: false,
  2440. border: false,
  2441. items:[{
  2442. xtype: 'panel',
  2443. frame: true,
  2444. border: false,
  2445. items: [{
  2446. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel("_PLS_SEL_STA_ONMAP_");?></div>',
  2447. height: PanelH - 30
  2448. }]
  2449. }]
  2450. });
  2451. tP.doLayout();
  2452. monitoringViewLevel = contentView.l[2].v;
  2453. switch( monitoringViewLevel ){
  2454. case 0:{
  2455. loadHistoryMapView();
  2456. break;
  2457. };
  2458. case 1:{
  2459. loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent );
  2460. break;
  2461. };
  2462. case 2:{
  2463. var tA = contentView.l[2].p.split('-');
  2464. rep_selectedStation = parseInt( tA[0] );
  2465. rep_selectedDateTS = parseInt( tA[1] );
  2466. loadHistoryStation( rep_selectedStation, autoRiseEvent );
  2467. loadReportDayTree( rep_selectedDateTS );
  2468. break;
  2469. };
  2470. case 5:{
  2471. var tA = contentView.l[2].p.split('-');
  2472. rep_selectedStation = parseInt( tA[0] );
  2473. rep_selectedDateTS = parseInt( tA[1] );
  2474. rep_selectedEventId = parseInt( tA[2] );
  2475. loadReportDayTree( rep_selectedDateTS );
  2476. loadHistorySessionView( rep_selectedEventId );
  2477. break;
  2478. };
  2479. };
  2480. //Ext.getCmp('main_content').doLayout();
  2481. };