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.

3186 lines
105 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.rVideoJS_exists ){
  1810. // if( this.lVideoJS_playing )
  1811. // this.lVideoJS.currentTime( ( nt - this.Videos[this.lVideoJS_cid].sts ) / 1000 );
  1812. //};
  1813. }
  1814. checkVideoTime(){
  1815. if( this.mMainVideo == 0 ){
  1816. const t = this.lVideoJS.currentTime();
  1817. if( t >= this.nextTimestamp ){
  1818. //this.lVideoJS.trigger({ type: 'videotick', timestamp: this.nextTimestamp });
  1819. this.action( parseInt( this.Videos[this.lVideoJS_cid].sts + t*1000 ) );
  1820. this.nextTimestamp += 0.1; // next 100 ms of video time
  1821. };
  1822. } else {
  1823. const t = this.rVideoJS.currentTime();
  1824. if( t >= this.nextTimestamp ){
  1825. //this.rVideoJS.trigger({ type: 'videotick', timestamp: this.nextTimestamp });
  1826. this.action( parseInt( this.Videos[this.rVideoJS_cid].sts + t*1000 ) );
  1827. this.nextTimestamp += 0.1; // next 100 ms of video time
  1828. };
  1829. };
  1830. }
  1831. triggerPlay(){
  1832. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1833. if( this.mPaused ){
  1834. this.mPaused = false;
  1835. zz.setIconClass( 'plr_op_pause' );
  1836. zz.setText('Pause');
  1837. if( this.rVideoJS_exists ){
  1838. this.rVideoJS.play();
  1839. this.rVideoJS_playing = true;
  1840. };
  1841. if( this.lVideoJS_exists ){
  1842. this.lVideoJS.play();
  1843. this.lVideoJS_playing = true;
  1844. };
  1845. } else {
  1846. this.mPaused = true;
  1847. zz.setIconClass( 'plr_op_play' );
  1848. zz.setText('Play');
  1849. if( this.rVideoJS_exists ){
  1850. this.rVideoJS.pause();
  1851. this.rVideoJS_playing = false;
  1852. };
  1853. if( this.lVideoJS_exists ){
  1854. this.rVideoJS.pause();
  1855. this.lVideoJS_playing = false;
  1856. };
  1857. };
  1858. }
  1859. triggerLoop(){
  1860. this.mLooping = !this.mLooping;
  1861. }
  1862. onVideoEnded( side ){
  1863. if( this.mMainVideo == side ){
  1864. var nid = this.getNextVideo( side );
  1865. if( nid > -1 ){
  1866. if( side ){
  1867. this.rVideoJS_cid = nid;
  1868. this.rVideoJS_playing = true;
  1869. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1870. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1871. this.rVideoJS.src( ns );
  1872. this.nextTimestamp = 0.0;
  1873. this.rVideoJS.play();
  1874. } else {
  1875. this.lVideoJS_cid = nid;
  1876. this.lVideoJS_playing = true;
  1877. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1878. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1879. this.lVideoJS.src( ns );
  1880. this.nextTimestamp = 0.0;
  1881. this.lVideoJS.play();
  1882. };
  1883. } else if( this.mLooping ){
  1884. if( side ){
  1885. this.rVideoJS_cid = -1;
  1886. this.rVideoJS_cid = this.getNextVideo( side );
  1887. this.rVideoJS_playing = true;
  1888. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1889. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1890. this.rVideoJS.src( ns );
  1891. this.nextTimestamp = 0.0;
  1892. this.rVideoJS.play();
  1893. } else {
  1894. this.lVideoJS_cid = -1;
  1895. this.lVideoJS_cid = this.getNextVideo( side );
  1896. this.lVideoJS_playing = true;
  1897. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1898. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1899. this.lVideoJS.src( ns );
  1900. this.nextTimestamp = 0.0;
  1901. this.lVideoJS.play();
  1902. };
  1903. };
  1904. };
  1905. }
  1906. action( currentTime = 0 ){
  1907. //console.log( currentTime );
  1908. if( !this.mPaused ){
  1909. this.currentTime = currentTime;
  1910. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1911. var tt = Ext.getCmp('hpl_slider');
  1912. if( tt!= undefined ){
  1913. tt.suspendEvents();
  1914. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1915. tt.resumeEvents();
  1916. };
  1917. var zz = document.getElementById('hpl_time_mon');
  1918. if( zz != undefined ) zz.innerHTML = ts2dts( this.currentTime );
  1919. if( this.Events.length ){
  1920. var sid = -1;
  1921. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1922. sid = i;
  1923. break;
  1924. };
  1925. if( sid > -1 ){
  1926. for( var i=0; i< max_grad_levels; i++ ){
  1927. var cid = sid-i;
  1928. var csize = getSize( i );
  1929. //debugger;
  1930. if( typeof this.mSvgElements[i] === 'undefined') {
  1931. if( cid > -1 ){
  1932. var svgns = "http://www.w3.org/2000/svg";
  1933. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1934. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1935. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1936. this.mSvgElements[i].setAttribute('height', ''+csize);
  1937. this.mSvgElements[i].setAttribute('width', ''+csize);
  1938. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1939. var tt = document.getElementById('svgTrackMap');
  1940. var zz = document.getElementById('scheme_anch');
  1941. tt.insertBefore( this.mSvgElements[i], zz );
  1942. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1943. };
  1944. } else {
  1945. if( cid > -1 ){
  1946. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1947. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1948. this.mSvgElements[i].setAttribute('height', ''+csize);
  1949. this.mSvgElements[i].setAttribute('width', ''+csize);
  1950. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1951. } else {
  1952. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1953. };
  1954. };
  1955. };
  1956. } else
  1957. for( var i=0; i< max_grad_levels; i++ )
  1958. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1959. };
  1960. //this.currentTime += 250;
  1961. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1962. this.currentTime = 0;
  1963. } else {
  1964. //Stop
  1965. //this.play();
  1966. };
  1967. };
  1968. }
  1969. dispose(){
  1970. if( this.rVideoJS_exists ) {
  1971. this.rVideoJS.dispose();
  1972. this.rVideoJS = null;
  1973. };
  1974. if( this.lVideoJS_exists ) {
  1975. this.lVideoJS.dispose();
  1976. this.lVideoJS = null;
  1977. };
  1978. }
  1979. };
  1980. class argusSessionPlayer33{
  1981. sessionId;
  1982. mMapID;
  1983. startTime;
  1984. endTime;
  1985. currentTime;
  1986. rVideoJS = null;
  1987. lVideoJS = null;
  1988. rVideoJS_id = null;
  1989. lVideoJS_id = null;
  1990. rVideoJS_playing = false;
  1991. lVideoJS_playing = false;
  1992. rVideoJS_cid = -1;
  1993. lVideoJS_cid = -1;
  1994. mapLayout;
  1995. lVideos;
  1996. rVideos;
  1997. Events;
  1998. basePath;
  1999. mTimer = null;
  2000. mPaused = true;
  2001. mLooping = true;
  2002. mAutoPlay = false;
  2003. nextRTimestamp = 0.0;
  2004. nextLTimestamp = 0.0;
  2005. mSvgElements;//076.png
  2006. checkLVideoTime(){
  2007. const t = mSesPlay.lVideoJS.currentTime(); // seconds
  2008. while( t >= mSesPlay.nextLTimestamp ){
  2009. mSesPlay.lVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextLTimestamp });
  2010. mSesPlay.nextLTimestamp += 0.1; // next 100 ms of video time
  2011. };
  2012. }
  2013. checkRVideoTime(){
  2014. const t = mSesPlay.rVideoJS.currentTime(); // seconds
  2015. while( t >= mSesPlay.nextRTimestamp ){
  2016. mSesPlay.rVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextRTimestamp });
  2017. mSesPlay.nextRTimestamp += 0.1; // next 100 ms of video time
  2018. };
  2019. }
  2020. constructor( session_id, autoplay ) {
  2021. this.sessionId = session_id;
  2022. this.currentTime = 0;
  2023. this.startTime = 0;
  2024. this.endTime = 0;
  2025. this.lVideos = [];
  2026. this.rVideos = [];
  2027. this.Events = [];
  2028. this.rEvents = [];
  2029. this.lEvents = [];
  2030. this.mSvgElements = [];
  2031. if( autoplay != undefined ) this.mAutoPlay = autoplay;
  2032. Ext.Ajax.request({
  2033. url: '/lib/controller/getSessionData.php',
  2034. params: {
  2035. SESSION: this.sessionId,
  2036. UID: <?=$UserID;?>,
  2037. SID: '<?=$Session;?>'
  2038. },
  2039. success: function( response, opts ){
  2040. var data = Ext.decode( response.responseText );
  2041. //debugger;
  2042. if( data.status == 'ok' ){
  2043. mSesPlay.mapLayout = data.layout;
  2044. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  2045. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  2046. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  2047. if( data.data_ok ){
  2048. mSesPlay.startTime = data.start_ts;
  2049. mSesPlay.endTime = data.start_ts + data.length;
  2050. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  2051. mSesPlay.rVideos = [];
  2052. mSesPlay.lVideos = [];
  2053. mSesPlay.nextRTimestamp = 0.0;
  2054. mSesPlay.nextLTimestamp = 0.0;
  2055. sesVideosListRName = data.r_module_name;
  2056. sesVideosListLName = data.l_module_name;
  2057. if( data.composed_video ){
  2058. if( data.composed_video_status == 'D' ){
  2059. CompositeVideoStatus = 2;
  2060. sesVideosListLExists = data.composed_left_video_exists;
  2061. sesVideosListRExists = data.composed_right_video_exists;
  2062. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  2063. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  2064. } else {
  2065. CompositeVideoStatus = 1;
  2066. CompositeVideoProgress = data.composed_video_progress;
  2067. CompositeVideoLeftInfo = null;
  2068. CompositeVideoRightInfo = null;
  2069. sesVideosListRExists = false;
  2070. sesVideosListLExists = false;
  2071. }
  2072. } else CompositeVideoStatus = 0;
  2073. var tt = Ext.getCmp('hpl_slider');
  2074. tt.setMinValue( 0 );
  2075. tt.setMaxValue( data.length / 1000 );
  2076. if( data.events.length ){
  2077. mSesPlay.Events = data.events;
  2078. for( var i=0; i < data.events.length; i++ ){
  2079. if( data.events[i].side == 'L' ){
  2080. mSesPlay.lEvents.push( data.events[i] );
  2081. } else {
  2082. mSesPlay.rEvents.push( data.events[i] );
  2083. };
  2084. };
  2085. };
  2086. if( data.videos.length ){
  2087. videosListStore.loadData( data, false );
  2088. for( var i=0; i < data.videos.length; i++ ){
  2089. if( mSesPlay.currentTime == 0 ){
  2090. mSesPlay.currentTime = data.videos[i].sts;
  2091. } else {
  2092. if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts;
  2093. };
  2094. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] );
  2095. else mSesPlay.lVideos.push( data.videos[i] );
  2096. };
  2097. sesVideosStartTS = mSesPlay.currentTime;
  2098. } else {
  2099. sesVideosStartTS = 0;
  2100. videosListStore.removeAll();
  2101. };
  2102. if( mSesPlay.rVideos.length ) {
  2103. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  2104. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  2105. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  2106. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  2107. // New imp
  2108. mSesPlay.rVideoJS.on('play', () => {
  2109. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  2110. });
  2111. mSesPlay.rVideoJS.on( 'timeupdate', mSesPlay.checkRVideoTime );
  2112. mSesPlay.rVideoJS.on('seeking', () => {
  2113. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  2114. });
  2115. mSesPlay.rVideoJS.on('videotick', (e) => {
  2116. mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 );
  2117. });
  2118. mSesPlay.rVideoJS.on('ended', function() {
  2119. console.log("Video Ended!");
  2120. if( mSesPlay.rVideoJS_cid < mSesPlay.rVideos.length ){
  2121. mSesPlay.rVideoJS_cid++;
  2122. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.rVideos[mSesPlay.rVideoJS_cid].name };
  2123. mSesPlay.rVideoJS.src( ns );
  2124. mSesPlay.rVideoJS.play();
  2125. mSesPlay.rVideoJS_playing = true;
  2126. };
  2127. });
  2128. };
  2129. if( mSesPlay.lVideos.length ){
  2130. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  2131. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  2132. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  2133. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  2134. // New imp
  2135. mSesPlay.lVideoJS.on('play', () => {
  2136. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  2137. });
  2138. mSesPlay.lVideoJS.on( 'timeupdate', mSesPlay.checkLVideoTime );
  2139. mSesPlay.lVideoJS.on('seeking', () => {
  2140. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  2141. });
  2142. mSesPlay.lVideoJS.on('videotick', (e) => {
  2143. mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 );
  2144. });
  2145. mSesPlay.lVideoJS.on('ended', function() {
  2146. console.log("Video Ended!");
  2147. if( mSesPlay.lVideoJS_cid < mSesPlay.lVideos.length ){
  2148. mSesPlay.lVideoJS_cid++;
  2149. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.lVideos[mSesPlay.lVideoJS_cid].name };
  2150. mSesPlay.lVideoJS.src( ns );
  2151. mSesPlay.lVideoJS.play();
  2152. mSesPlay.lVideoJS_playing = true;
  2153. };
  2154. });
  2155. };
  2156. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  2157. mSesPlay.setPosition( 0 );
  2158. if( mSesPlay.mAutoPlay ) mSesPlay.play();
  2159. } else {
  2160. Ext.Msg.show({
  2161. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  2162. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  2163. buttons: Ext.Msg.OK,
  2164. icon: Ext.MessageBox.ERROR
  2165. });
  2166. }
  2167. };
  2168. },
  2169. failure: failureAJAXFunction
  2170. });
  2171. }
  2172. checkPlayebleTime( ct ){
  2173. if( this.rVideos.length ){
  2174. var fid = -1;
  2175. if( this.rVideoJS_cid < this.rVideos.length - 1 ){
  2176. for(var i=this.rVideoJS_cid+1; i < this.rVideos.length; i++ ){
  2177. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2178. fid = i;
  2179. break;
  2180. };
  2181. };
  2182. if( fid < 0 ){
  2183. //No Segments for Now;
  2184. //this.rVideoJS_playing = false;
  2185. this.rVideoJS_cid = 1;
  2186. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2187. this.rVideoJS.src( ns );
  2188. this.rVideoJS_playing = true;
  2189. } else {
  2190. if( this.rVideoJS_cid != fid ){
  2191. this.rVideoJS_cid = fid;
  2192. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2193. this.rVideoJS.src( ns );
  2194. };
  2195. this.rVideoJS_playing = true;
  2196. };
  2197. };
  2198. };
  2199. if( this.lVideos.length ){
  2200. var fid = -1;
  2201. for(var i=this.lVideos.length-1; i > 0; i-- ){
  2202. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2203. fid = i;
  2204. break;
  2205. };
  2206. };
  2207. if( fid < 0 ){
  2208. //No Segments for Now;
  2209. //this.lVideoJS_playing = false;
  2210. this.lVideoJS_cid = 1;
  2211. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2212. this.lVideoJS.src( ns );
  2213. this.lVideoJS_playing = true;
  2214. } else {
  2215. if( this.lVideoJS_cid != fid ){
  2216. this.lVideoJS_cid = fid;
  2217. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2218. this.lVideoJS.src( ns );
  2219. };
  2220. this.lVideoJS_playing = true;
  2221. };
  2222. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2223. };
  2224. }
  2225. action( currentTime = 0 ){
  2226. if( !this.mPaused ){
  2227. this.currentTime = currentTime;
  2228. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  2229. //debugger;
  2230. this.currentTime = this.checkPlayebleTime( this.currentTime );
  2231. var zz = document.getElementById('hpl_time_mon');
  2232. if( zz != undefined ){
  2233. zz.innerHTML = ts2dts( this.currentTime );
  2234. };
  2235. //Check videos
  2236. if( this.rVideos.length ){
  2237. var fid = -1;
  2238. for(var i=0; i<this.rVideos.length; i++ ){
  2239. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2240. fid = i;
  2241. break;
  2242. };
  2243. };
  2244. if( fid < 0 ){
  2245. //No Segments for Now;
  2246. this.rVideoJS_playing = false;
  2247. } else {
  2248. if( this.rVideoJS_cid != fid ){
  2249. this.rVideoJS_cid = fid;
  2250. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2251. this.rVideoJS.src( ns );
  2252. };
  2253. this.rVideoJS_playing = true;
  2254. };
  2255. //if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2256. };
  2257. if( this.lVideos.length ){
  2258. var fid = -1;
  2259. for(var i=0; i<this.lVideos.length; i++ ){
  2260. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2261. fid = i;
  2262. break;
  2263. };
  2264. };
  2265. if( fid < 0 ){
  2266. //No Segments for Now;
  2267. this.lVideoJS_playing = false;
  2268. } else {
  2269. if( this.lVideoJS_cid != fid ){
  2270. this.lVideoJS_cid = fid;
  2271. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2272. this.lVideoJS.src( ns );
  2273. };
  2274. this.lVideoJS_playing = true;
  2275. };
  2276. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2277. };
  2278. if( this.Events.length ){
  2279. var sid = -1;
  2280. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  2281. sid = i;
  2282. break;
  2283. };
  2284. if( sid > -1 ){
  2285. for( var i=0; i< max_grad_levels; i++ ){
  2286. var cid = sid-i;
  2287. var csize = getSize( i );
  2288. //debugger;
  2289. if( typeof this.mSvgElements[i] === 'undefined') {
  2290. if( cid > -1 ){
  2291. var svgns = "http://www.w3.org/2000/svg";
  2292. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  2293. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2294. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2295. this.mSvgElements[i].setAttribute('height', ''+csize);
  2296. this.mSvgElements[i].setAttribute('width', ''+csize);
  2297. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  2298. var tt = document.getElementById('svgTrackMap');
  2299. var zz = document.getElementById('scheme_anch');
  2300. tt.insertBefore( this.mSvgElements[i], zz );
  2301. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  2302. };
  2303. } else {
  2304. if( cid > -1 ){
  2305. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2306. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2307. this.mSvgElements[i].setAttribute('height', ''+csize);
  2308. this.mSvgElements[i].setAttribute('width', ''+csize);
  2309. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  2310. } else {
  2311. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2312. };
  2313. };
  2314. };
  2315. } else
  2316. for( var i=0; i< max_grad_levels; i++ )
  2317. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2318. };
  2319. var tt = Ext.getCmp('hpl_slider');
  2320. if( tt!= undefined ){
  2321. tt.suspendEvents();
  2322. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  2323. tt.resumeEvents();
  2324. };
  2325. //this.currentTime += 250;
  2326. if( this.currentTime > this.endTime ) if( this.mLooping ){
  2327. this.currentTime = 0;
  2328. } else {
  2329. //Stop
  2330. this.play();
  2331. };
  2332. };
  2333. }
  2334. play(){
  2335. var zz = Ext.getCmp( 'hpl_pl_btn' );
  2336. if( this.mPaused ){
  2337. this.mPaused = false;
  2338. if( this.rVideos.length ){
  2339. if( !this.rVideoJS_playing ) this.rVideoJS.play();
  2340. this.rVideoJS_playing = true;
  2341. };
  2342. if( this.lVideos.length ){
  2343. if( !this.lVideoJS_playing ) this.lVideoJS.play();
  2344. this.lVideoJS_playing = true;
  2345. };
  2346. zz.setIconClass( 'plr_op_pause' );
  2347. zz.setText('Pause');
  2348. } else {
  2349. this.mPaused = true;
  2350. if( this.rVideos.length ){
  2351. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  2352. this.rVideoJS_playing = false;
  2353. };
  2354. if( this.lVideos.length ){
  2355. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  2356. this.lVideoJS_playing = false;
  2357. };
  2358. zz.setIconClass( 'plr_op_play' );
  2359. zz.setText('Play');
  2360. };
  2361. this.action( this.currentTime );
  2362. //if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  2363. }
  2364. pause(){
  2365. this.mPaused = true;
  2366. }
  2367. toggleLoop(){
  2368. this.mLooping = !this.mLooping;
  2369. if( this.mLooping ) if( this.currentTime > this.endTime ){
  2370. this.currentTime = 0;
  2371. // Start
  2372. this.play();
  2373. };
  2374. }
  2375. setPosition( pos_time ){
  2376. //this.currentTime = this.startTime + pos_time*1000;
  2377. var nt = this.startTime + pos_time*1000;
  2378. var zz = document.getElementById('hpl_time_mon');
  2379. zz.innerHTML = ts2dts( nt );
  2380. if( this.rVideoJS_playing )
  2381. this.rVideoJS.currentTime( ( nt - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2382. if( this.lVideoJS_playing )
  2383. this.lVideoJS.currentTime( ( nt - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2384. }
  2385. onLVideoEnd(){
  2386. }
  2387. onRVideoEnd(){
  2388. }
  2389. dispose(){
  2390. if( this.mTimer != null ) clearInterval( this.mTimer );
  2391. this.mTimer = null;
  2392. if( this.rVideoJS!= null ){
  2393. this.rVideoJS.dispose();
  2394. this.rVideoJS = null;
  2395. };
  2396. if( this.lVideoJS!= null ){
  2397. this.lVideoJS.dispose();
  2398. this.lVideoJS = null;
  2399. };
  2400. }
  2401. }
  2402. // canvas aproach ///////////////////////////////////////////
  2403. /*
  2404. const player = videojs('my-video');
  2405. let nextTimestamp = 0;
  2406. let rafId = null;
  2407. function tick() {
  2408. if (player.paused() || player.ended())
  2409. return;
  2410. const t = player.currentTime();
  2411. while (t >= nextTimestamp) {
  2412. player.trigger({
  2413. type: 'videotick',
  2414. timestamp: nextTimestamp
  2415. });
  2416. nextTimestamp += 0.1;
  2417. }
  2418. rafId = requestAnimationFrame(tick);
  2419. }
  2420. player.on('play', () => {
  2421. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  2422. cancelAnimationFrame(rafId);
  2423. rafId = requestAnimationFrame(tick);
  2424. });
  2425. player.on('pause', () => cancelAnimationFrame(rafId));
  2426. player.on('ended', () => cancelAnimationFrame(rafId));
  2427. player.on('seeking', () => {
  2428. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  2429. });
  2430. player.on('videotick', (e) => {
  2431. console.log(e.timestamp);
  2432. });
  2433. */
  2434. class _argusSessionPlayer{
  2435. sessionId;
  2436. mMapID;
  2437. startTime;
  2438. endTime;
  2439. currentTime;
  2440. rVideoJS = null;
  2441. lVideoJS = null;
  2442. rVideoJS_id = null;
  2443. lVideoJS_id = null;
  2444. rVideoJS_playing = false;
  2445. lVideoJS_playing = false;
  2446. rVideoJS_cid = -1;
  2447. lVideoJS_cid = -1;
  2448. mapLayout;
  2449. lVideos;
  2450. rVideos;
  2451. Events;
  2452. basePath;
  2453. mTimer = null;
  2454. mPaused = true;
  2455. mLooping = true;
  2456. mSvgElements;//076.png
  2457. constructor( session_id ) {
  2458. this.sessionId = session_id;
  2459. this.currentTime = 0;
  2460. this.startTime = 0;
  2461. this.endTime = 0;
  2462. this.lVideos = [];
  2463. this.rVideos = [];
  2464. this.Events = [];
  2465. this.mSvgElements = [];
  2466. Ext.Ajax.request({
  2467. url: '/lib/controller/getSessionData.php',
  2468. params: {
  2469. SESSION: this.sessionId,
  2470. UID: <?=$UserID;?>,
  2471. SID: '<?=$Session;?>'
  2472. },
  2473. success: function( response, opts ){
  2474. var data = Ext.decode( response.responseText );
  2475. //debugger;
  2476. if( data.status == 'ok' ){
  2477. mSesPlay.mapLayout = data.layout;
  2478. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  2479. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  2480. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  2481. //debugger;
  2482. if( data.data_ok ){
  2483. if( data.r_module_id ){
  2484. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  2485. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  2486. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  2487. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  2488. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  2489. };
  2490. mSesPlay.startTime = data.start_ts;
  2491. mSesPlay.endTime = data.start_ts + data.length;
  2492. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  2493. mSesPlay.rVideos = [];
  2494. mSesPlay.lVideos = [];
  2495. if( data.videos.length ){
  2496. for( var i=0; i < data.videos.length; i++ )
  2497. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  2498. };
  2499. if( data.events.length ) mSesPlay.Events = data.events;
  2500. var tt = Ext.getCmp('hpl_slider');
  2501. tt.setMinValue( 0 );
  2502. tt.setMaxValue( data.length / 1000 );
  2503. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  2504. //player.on('ended', function() {
  2505. // this.dispose();
  2506. //});
  2507. //alert( data.basepath +'/'+data.videos[0].name );
  2508. //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  2509. //mSesPlay.rVideoJS.ready(function() {
  2510. //mSesPlay.rVideoJS.play();
  2511. //var howLoudIsIt = player.volume();
  2512. //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half
  2513. //});
  2514. //mSesPlay.rVideoJS.on("timeupdate", function(){
  2515. // method will be calledd each 250 msecs
  2516. //});
  2517. if( data.l_module_id ){
  2518. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  2519. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  2520. //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  2521. //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  2522. //mSesPlay.lVideoJS.ready(function() {
  2523. //mSesPlay.rVideoJS.play();
  2524. //var howLoudIsIt = player.volume();
  2525. // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half
  2526. //});
  2527. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  2528. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  2529. };
  2530. //mSesPlay.lVideoJS.on("timeupdate", function(){
  2531. // // method will be calledd each 250 msecs
  2532. //});
  2533. mSesPlay.setPosition( 0 );
  2534. } else {
  2535. Ext.Msg.show({
  2536. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  2537. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  2538. buttons: Ext.Msg.OK,
  2539. icon: Ext.MessageBox.ERROR
  2540. });
  2541. }
  2542. };
  2543. },
  2544. failure: failureAJAXFunction
  2545. });
  2546. }
  2547. action(){
  2548. if( !this.mPaused ){
  2549. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  2550. var zz = document.getElementById('hpl_time_mon');
  2551. //debugger;
  2552. if( zz != undefined ){
  2553. zz.innerHTML = ts2dts( this.currentTime );
  2554. };
  2555. //Check videos
  2556. if( this.rVideos.length ){
  2557. var fid = -1;
  2558. for(var i=0; i<this.rVideos.length; i++ ){
  2559. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2560. fid = i;
  2561. break;
  2562. };
  2563. };
  2564. if( fid < 0 ){
  2565. //No Segments for Now;
  2566. this.rVideoJS_playing = false;
  2567. } else {
  2568. if( this.rVideoJS_cid != fid ){
  2569. this.rVideoJS_cid = fid;
  2570. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2571. this.rVideoJS.src( ns );
  2572. };
  2573. this.rVideoJS_playing = true;
  2574. };
  2575. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2576. };
  2577. if( this.lVideos.length ){
  2578. var fid = -1;
  2579. for(var i=0; i<this.lVideos.length; i++ ){
  2580. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2581. fid = i;
  2582. break;
  2583. };
  2584. };
  2585. if( fid < 0 ){
  2586. //No Segments for Now;
  2587. this.lVideoJS_playing = false;
  2588. } else {
  2589. if( this.lVideoJS_cid != fid ){
  2590. this.lVideoJS_cid = fid;
  2591. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2592. this.lVideoJS.src( ns );
  2593. };
  2594. this.lVideoJS_playing = true;
  2595. };
  2596. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2597. };
  2598. if( this.Events.length ){
  2599. var sid = -1;
  2600. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  2601. sid = i;
  2602. break;
  2603. };
  2604. if( sid > -1 ){
  2605. for( var i=0; i< max_grad_levels; i++ ){
  2606. var cid = sid-i;
  2607. var csize = getSize( i );
  2608. //debugger;
  2609. if( typeof this.mSvgElements[i] === 'undefined') {
  2610. if( cid > -1 ){
  2611. var svgns = "http://www.w3.org/2000/svg";
  2612. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  2613. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2614. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2615. this.mSvgElements[i].setAttribute('height', ''+csize);
  2616. this.mSvgElements[i].setAttribute('width', ''+csize);
  2617. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  2618. var tt = document.getElementById('svgTrackMap');
  2619. var zz = document.getElementById('scheme_anch');
  2620. tt.insertBefore( this.mSvgElements[i], zz );
  2621. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  2622. };
  2623. } else {
  2624. if( cid > -1 ){
  2625. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2626. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2627. this.mSvgElements[i].setAttribute('height', ''+csize);
  2628. this.mSvgElements[i].setAttribute('width', ''+csize);
  2629. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  2630. } else {
  2631. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2632. };
  2633. };
  2634. };
  2635. } else
  2636. for( var i=0; i< max_grad_levels; i++ )
  2637. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2638. };
  2639. var tt = Ext.getCmp('hpl_slider');
  2640. if( tt!= undefined ){
  2641. tt.suspendEvents();
  2642. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  2643. tt.resumeEvents();
  2644. };
  2645. this.currentTime += 250;
  2646. if( this.currentTime > this.endTime ) if( this.mLooping ){
  2647. this.currentTime = 0;
  2648. } else {
  2649. //Stop
  2650. this.play();
  2651. };
  2652. };
  2653. }
  2654. play(){
  2655. var zz = Ext.getCmp( 'hpl_pl_btn' );
  2656. if( this.mPaused ){
  2657. this.mPaused = false;
  2658. if( this.rVideoJS_playing ) this.rVideoJS.play();
  2659. if( this.lVideoJS_playing ) this.lVideoJS.play();
  2660. zz.setIconClass( 'plr_op_pause' );
  2661. zz.setText('Pause');
  2662. } else {
  2663. this.mPaused = true;
  2664. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  2665. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  2666. zz.setIconClass( 'plr_op_play' );
  2667. zz.setText('Play');
  2668. };
  2669. if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  2670. }
  2671. pause(){
  2672. this.mPaused = true;
  2673. }
  2674. toggleLoop(){
  2675. this.mLooping = !this.mLooping;
  2676. if( this.mLooping ) if( this.currentTime > this.endTime ){
  2677. this.currentTime = 0;
  2678. // Start
  2679. this.play();
  2680. };
  2681. }
  2682. setPosition( pos_time ){
  2683. this.currentTime = this.startTime + pos_time*1000;
  2684. var zz = document.getElementById('hpl_time_mon');
  2685. zz.innerHTML = ts2dts( this.currentTime );
  2686. }
  2687. onLVideoEnd(){
  2688. }
  2689. onRVideoEnd(){
  2690. }
  2691. dispose(){
  2692. if( this.mTimer != null ) clearInterval( this.mTimer );
  2693. this.mTimer = null;
  2694. if( this.rVideoJS!= null ){
  2695. this.rVideoJS.dispose();
  2696. this.rVideoJS = null;
  2697. };
  2698. if( this.lVideoJS!= null ){
  2699. this.lVideoJS.dispose();
  2700. this.lVideoJS = null;
  2701. };
  2702. }
  2703. }
  2704. var SelectedSessionID = 0;
  2705. function loadHistorySessionView( session_id ){
  2706. autoRiseEvent = false;
  2707. SelectedSessionID = rep_selectedEventId = session_id;
  2708. Ext.Ajax.request({
  2709. url: '/lib/controller/getHistorySessionView.php',
  2710. params: {
  2711. SESSION: rep_selectedEventId,
  2712. UID: <?=$UserID;?>,
  2713. SID: '<?=$Session;?>'
  2714. },
  2715. success: function( response, opts ){
  2716. var data = Ext.decode(response.responseText);
  2717. if( data.status == 'ok' ){
  2718. monitoringViewLevel = 5;
  2719. if( mSesPlay!= null ) {
  2720. mSesPlay.dispose();
  2721. mSesPlay = null;
  2722. };
  2723. Ext.getCmp('main_content').removeAll(true);
  2724. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2725. Ext.getCmp('main_content').doLayout();
  2726. changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId );
  2727. updateUserContent();
  2728. mSesPlay = new argusSessionPlayer( rep_selectedEventId , true );
  2729. fetchStatus();
  2730. };
  2731. },
  2732. failure: failureAJAXFunction
  2733. });
  2734. };
  2735. function deleteSession( session_id ){
  2736. if( session_id == 0 ) return;
  2737. Ext.Msg.show({
  2738. title:'<?=$Labels->GetLabel('_RYS_DEL_SES_');?>',
  2739. msg: '<?=$Labels->GetLabel('_RYS_DEL_SESSION_');?>',
  2740. buttons: Ext.Msg.YESNOCANCEL,
  2741. icon: Ext.MessageBox.QUESTION,
  2742. fn: function(btn, text){
  2743. if( btn == 'yes' ){
  2744. Ext.Ajax.request({
  2745. url: '/lib/controller/doSessionOperations.php',
  2746. params: {
  2747. SESSION: session_id,
  2748. OPID: 1,
  2749. UID: <?=$UserID;?>,
  2750. SID: '<?=$Session;?>'
  2751. },
  2752. success: function( response, opts ){
  2753. Ext.Msg.hide();
  2754. var data = Ext.decode(response.responseText);
  2755. if( data.status == 'ok' ){
  2756. getBackToMap();
  2757. } else {
  2758. Ext.Msg.show({
  2759. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  2760. msg: data.msg,
  2761. buttons: Ext.Msg.OK,
  2762. icon: Ext.MessageBox.ERROR
  2763. });
  2764. };
  2765. },
  2766. failure: failureAJAXFunction
  2767. });
  2768. };
  2769. }
  2770. });
  2771. };
  2772. function loadHistoryStationEvt( e ){
  2773. loadHistoryStation( e.target.options.mycustomid );
  2774. };
  2775. function loadHistoryStation( STT, buba ){
  2776. if( buba == undefined ){
  2777. autoRiseEvent = false;
  2778. } else {
  2779. autoRiseEvent = buba;
  2780. };
  2781. rep_selectedStation = STT;
  2782. changeContent( 2, 1, rep_selectedStation );
  2783. updateUserContent();
  2784. Ext.Ajax.request({
  2785. url: '/lib/controller/getHistoryStationView.php',
  2786. params: {
  2787. STT: rep_selectedStation,
  2788. UID: <?=$UserID;?>,
  2789. SID: '<?=$Session;?>'
  2790. },
  2791. success: function( response, opts ){
  2792. var data = Ext.decode(response.responseText);
  2793. if( data.status == 'ok' ){
  2794. Ext.getCmp('main_content').removeAll(true);
  2795. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2796. Ext.getCmp('main_content').doLayout();
  2797. Ext.getCmp('left_side_menu').removeAll(true);
  2798. Ext.getCmp('left_side_menu').add({
  2799. xtype: 'panel',
  2800. frame: true,
  2801. border: false,
  2802. items: [{
  2803. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  2804. height: PanelH - 30
  2805. }]
  2806. });
  2807. Ext.getCmp('left_side_menu').doLayout();
  2808. } else {
  2809. };
  2810. },
  2811. failure: failureAJAXFunction
  2812. });
  2813. };
  2814. function loadReportDayTree( ts ){
  2815. ReportSelectionMode = 1;//Day Selected
  2816. rep_selectedDateTS = ts;
  2817. //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  2818. //ReportMask.show();
  2819. Ext.Ajax.request({
  2820. url: '/lib/controller/getHistoryDay.php',
  2821. params: {
  2822. UID: <?=$UserID;?>,
  2823. SID: '<?=$Session;?>',
  2824. STT: rep_selectedStation,
  2825. DTS: rep_selectedDateTS
  2826. },
  2827. success: function(response, opts ){
  2828. var data = Ext.decode( response.responseText );
  2829. var sPanel = Ext.getCmp('left_side_menu');
  2830. sPanel.removeAll( true );
  2831. sPanel.add({
  2832. xtype: 'panel',
  2833. layout: 'vbox',
  2834. frame: true,
  2835. border: false,
  2836. items:[{
  2837. xtype: 'spacer',
  2838. height: 3
  2839. },{
  2840. 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>',
  2841. frame: false,
  2842. width: '100%',
  2843. border: false
  2844. },{
  2845. xtype: 'spacer',
  2846. height: 5
  2847. },{
  2848. xtype: 'treepanel',
  2849. autoScroll: true,
  2850. width: '100%',
  2851. height: PanelH-206,
  2852. border: true,
  2853. frame: true,
  2854. loader: new Ext.tree.TreeLoader(),
  2855. rootVisible: false,
  2856. root: new Ext.tree.AsyncTreeNode( data ),
  2857. listeners: {
  2858. click: function(n) {
  2859. if( n.attributes.leaf ){
  2860. Ext.getCmp('chu_adate').show();
  2861. sPanel.doLayout();
  2862. loadHistorySessionView( n.attributes.sid );
  2863. };
  2864. }
  2865. }
  2866. },{
  2867. xtype: 'spacer',
  2868. height: 10
  2869. },{
  2870. xtype: 'button',
  2871. id: 'chu_adate',
  2872. text: 'Show Dates',
  2873. hidden: true,
  2874. width: '100%',
  2875. iconCls: 'reports_dates_btn',
  2876. scale: 'large',
  2877. handler: function(){
  2878. Ext.getCmp('chu_adate').hide();
  2879. loadHistoryStation( rep_selectedStation );
  2880. }
  2881. }]
  2882. });
  2883. sPanel.doLayout();
  2884. changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS );
  2885. updateUserContent();
  2886. //ReportMask.hide();
  2887. }
  2888. });
  2889. };
  2890. function noHistDialog(){
  2891. Ext.Msg.show({
  2892. title:'<?=$Labels->GetLabel('_GEN_MSG_');?>',
  2893. msg: '<?=$Labels->GetLabel('_NO_REPORTS_4_STATION_');?>',
  2894. buttons: Ext.Msg.OK,
  2895. icon: Ext.MessageBox.INFO
  2896. });
  2897. };
  2898. var history_map = null;
  2899. function initHistoryMap( map_id, x, y ){
  2900. if( tlInterval!= null ){
  2901. window.clearTimeout( tlInterval );
  2902. tlInterval = null;
  2903. };
  2904. var mapLayers = [];
  2905. if( history_map != null ){
  2906. history_map.off();
  2907. history_map.remove();
  2908. history_map = null;
  2909. };
  2910. history_map = L.map( map_id,{
  2911. crs: L.CRS.Simple,
  2912. attributionControl: false,
  2913. preferCanvas: true,
  2914. zoomControl: true,
  2915. center: [x,y],
  2916. zoom: 0,
  2917. minZoom: -3,
  2918. maxZoom: 0,
  2919. keyboard: false
  2920. });
  2921. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  2922. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( history_map );
  2923. Ext.Ajax.request({
  2924. url: '/lib/controller/listHistoryStations.php',
  2925. params: {
  2926. UID: <?=$UserID;?>,
  2927. SID: '<?=$Session;?>'
  2928. },
  2929. success: function( response, opts ){
  2930. var data = Ext.decode(response.responseText);
  2931. if( data.status == 'ok' ){
  2932. for( i=0; i < data.stations.length; i++ ){
  2933. if( data.stations[i].status ){
  2934. 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 );
  2935. } else {
  2936. 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 );
  2937. };
  2938. };
  2939. };
  2940. },
  2941. failure: failureAJAXFunction
  2942. });
  2943. };
  2944. function getBackToHistoryMap(){
  2945. autoRiseEvent = false;
  2946. changeContent( 2, 0 );
  2947. updateUserContent();
  2948. var tP = Ext.getCmp('left_side_menu');
  2949. tP.removeAll( true );
  2950. tP.add({
  2951. layout:'vbox',
  2952. frame: false,
  2953. border: false,
  2954. items:[{
  2955. xtype: 'panel',
  2956. frame: true,
  2957. border: false,
  2958. items: [{
  2959. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  2960. height: PanelH - 30
  2961. }]
  2962. }]
  2963. });
  2964. tP.doLayout();
  2965. loadHistoryMapView();
  2966. };
  2967. function loadHistoryMapView(){
  2968. autoRiseEvent = false;
  2969. Ext.Ajax.request({
  2970. url: '/lib/controller/getHistoryMapView.php',
  2971. params: {
  2972. UID: <?=$UserID;?>,
  2973. SID: '<?=$Session;?>'
  2974. },
  2975. success: function( response, opts ){
  2976. var data = Ext.decode(response.responseText);
  2977. if( data.status == 'ok' ){
  2978. monitoringViewLevel = 0;
  2979. Ext.getCmp('main_content').removeAll(true);
  2980. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2981. Ext.getCmp('main_content').doLayout();
  2982. };
  2983. },
  2984. failure: failureAJAXFunction
  2985. });
  2986. return;
  2987. };
  2988. function initReportsView(){
  2989. if( tlInterval!= null ){
  2990. window.clearInterval( tlInterval );
  2991. tlInterval = null;
  2992. timelineObj = null;
  2993. };
  2994. var tP = Ext.getCmp('left_side_menu');
  2995. tP.removeAll( true );
  2996. tP.add({
  2997. layout:'vbox',
  2998. frame: false,
  2999. border: false,
  3000. items:[{
  3001. xtype: 'panel',
  3002. frame: true,
  3003. border: false,
  3004. items: [{
  3005. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel("_PLS_SEL_STA_ONMAP_");?></div>',
  3006. height: PanelH - 30
  3007. }]
  3008. }]
  3009. });
  3010. tP.doLayout();
  3011. monitoringViewLevel = contentView.l[2].v;
  3012. switch( monitoringViewLevel ){
  3013. case 0:{
  3014. loadHistoryMapView();
  3015. break;
  3016. };
  3017. case 1:{
  3018. loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent );
  3019. break;
  3020. };
  3021. case 2:{
  3022. var tA = contentView.l[2].p.split('-');
  3023. rep_selectedStation = parseInt( tA[0] );
  3024. rep_selectedDateTS = parseInt( tA[1] );
  3025. loadHistoryStation( rep_selectedStation, autoRiseEvent );
  3026. loadReportDayTree( rep_selectedDateTS );
  3027. break;
  3028. };
  3029. case 5:{
  3030. var tA = contentView.l[2].p.split('-');
  3031. rep_selectedStation = parseInt( tA[0] );
  3032. rep_selectedDateTS = parseInt( tA[1] );
  3033. rep_selectedEventId = parseInt( tA[2] );
  3034. loadReportDayTree( rep_selectedDateTS );
  3035. loadHistorySessionView( rep_selectedEventId );
  3036. break;
  3037. };
  3038. };
  3039. //Ext.getCmp('main_content').doLayout();
  3040. };