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.

3219 lines
106 KiB

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