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.

3179 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. rr.add({
  693. xtype: 'panel',
  694. frame: false,
  695. border: false,
  696. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=2>Compose Videos into one file</td></tr><tr><td colspan=2>&nbsp;</td></tr><tr><td align="center" colspan=2><a class="big_vd_btn" href="javascript:startVideoComposer()">Start Video Composer</a></td></tr><tr><td colspan=2>&nbsp;</td></tr></table></div>'
  697. });
  698. break;
  699. };
  700. case 1:{
  701. rr.add({
  702. border: false,
  703. frame: false,
  704. //layout: 'vbox',
  705. //layoutConfig: {
  706. // align: 'center'
  707. //},
  708. items:[{
  709. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center">Composing Video<br/>You may close this window<br/>and<br/>come back later to download video.</td><td width="100px" align="center"><svg class="donut" width="80" height="100%" viewBox="0 0 42 42"><circle id="status_1_donut0_segment2" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#b1c94e" stroke-width="3" stroke-dasharray="0 100" stroke-dashoffset="25"></circle><circle id="status_1_donut0_segment3" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#aaddff" stroke-width="3" stroke-dasharray="0 100" stroke-dashoffset="25"></circle><circle id="status_1_donut0_segment1" cx="21" cy="21" r="15.91549430918954" fill="transparent" stroke="#ce4b99" stroke-width="3" stroke-dasharray="0 100" stroke-dashoffset="25"></circle><g class="chart-text-black"><text x="50%" y="50%" class="chart-number" id="status_1_totalValue0">0%</text><text x="50%" y="50%" class="chart-label">DONE</text></g></svg></td></tr></table></div>'
  710. }],
  711. listeners:{
  712. afterrender: function(){
  713. setDonatStatus( 1, 0, 29 );
  714. }
  715. }
  716. });
  717. eventVideosStatusUpdater();
  718. break;
  719. };
  720. case 2:{
  721. if( sesVideosListRExists ){
  722. rr.add({
  723. xtype: 'panel',
  724. frame: false,
  725. border: false,
  726. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=3>Composed Video from '+sesVideosListRName+' side</td></tr><tr><td align="right">Duration:</td><td colspan=2>'+CompositeVideoRightInfo.duration+'</td></tr><tr><td align="right">File size:</td><td colspan=2>'+CompositeVideoRightInfo.file_size+'</td></tr><tr><td align="center" colspan=2><div id="r_d_button"></div></td><td align="center"><div id="r_e_button"></div></td></tr><tr><td colspan=3>&nbsp;</td></tr></table></div>'
  727. });
  728. rr.doLayout();
  729. new Ext.Button({
  730. text: 'Download',
  731. width: '80%',
  732. renderTo: 'r_d_button',
  733. handler: function(){
  734. const l = document.createElement('a');
  735. l.style.display = 'none';
  736. l.href = '/lib/controller/getComposedVideo.php?SESSION='+rep_selectedEventId+'&SIDE=L';
  737. document.body.appendChild(l);
  738. l.click();
  739. }
  740. });
  741. new Ext.Button({
  742. text: 'Delete',
  743. width: '80%',
  744. renderTo: 'r_e_button',
  745. handler: function(){
  746. Ext.Ajax.request({
  747. url: '/lib/controller/doSessionOperations.php',
  748. params: {
  749. SESSION: rep_selectedEventId,
  750. OPID: 4,
  751. UID: <?=$UserID;?>,
  752. SID: '<?=$Session;?>'
  753. },
  754. success: function( response, opts ){
  755. var data = Ext.decode(response.responseText);
  756. if( data.status == 'ok' ){
  757. CompositeVideoStatus = 0;
  758. CompositeVideoProgress = 0;
  759. CompositeVideoStatusUpdate();
  760. } else {
  761. Ext.Msg.show({
  762. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  763. msg: data.msg,
  764. buttons: Ext.Msg.OK,
  765. icon: Ext.MessageBox.ERROR
  766. });
  767. };
  768. },
  769. failure: failureAJAXFunction
  770. });
  771. }
  772. });
  773. };
  774. if( sesVideosListLExists ){
  775. rr.add({
  776. xtype: 'panel',
  777. frame: false,
  778. border: false,
  779. html: '<div class="vid_dwc_panel"><table width="100%"><tr><td align="center" colspan=3>Composed Video from '+sesVideosListLName+' side</td></tr><tr><td align="right">Duration:</td><td colspan=2>'+CompositeVideoLeftInfo.duration+'</td></tr><tr><td align="right">File size:</td><td colspan=2>'+CompositeVideoLeftInfo.file_size+'</td></tr><tr><td align="center" colspan=2><div id="l_d_button"></div></td><td align="center"><div id="l_e_button"></div></td></tr><tr><td colspan=3>&nbsp;</td></tr></table></div>'
  780. });
  781. rr.doLayout();
  782. new Ext.Button({
  783. text: 'Download',
  784. width: '80%',
  785. renderTo: 'l_d_button',
  786. handler: function(){
  787. const l = document.createElement('a');
  788. l.style.display = 'none';
  789. l.href = '/lib/controller/getComposedVideo.php?SESSION='+rep_selectedEventId+'&SIDE=L';
  790. document.body.appendChild(l);
  791. l.click();
  792. }
  793. });
  794. new Ext.Button({
  795. text: 'Delete',
  796. width: '80%',
  797. renderTo: 'l_e_button',
  798. handler: function(){
  799. Ext.Ajax.request({
  800. url: '/lib/controller/doSessionOperations.php',
  801. params: {
  802. SESSION: rep_selectedEventId,
  803. OPID: 4,
  804. UID: <?=$UserID;?>,
  805. SID: '<?=$Session;?>'
  806. },
  807. success: function( response, opts ){
  808. var data = Ext.decode(response.responseText);
  809. if( data.status == 'ok' ){
  810. CompositeVideoStatus = 0;
  811. CompositeVideoProgress = 0;
  812. CompositeVideoStatusUpdate();
  813. } else {
  814. Ext.Msg.show({
  815. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  816. msg: data.msg,
  817. buttons: Ext.Msg.OK,
  818. icon: Ext.MessageBox.ERROR
  819. });
  820. };
  821. },
  822. failure: failureAJAXFunction
  823. });
  824. }
  825. });
  826. };
  827. break;
  828. };
  829. };
  830. rr.doLayout();
  831. };
  832. }
  833. function hideEventsVideos(){
  834. if( CompositeVideoStatusTO!= null ) window.clearTimeout( CompositeVideoStatusTO );
  835. CompositeVideoStatusTO = null;
  836. sesVideosListWindow = null;
  837. oldCompositeVideoStatus = -1;
  838. }
  839. function eventVideosStatusUpdater(){
  840. Ext.Ajax.request({
  841. url: '/lib/controller/getComposerStatus.php',
  842. params: {
  843. SESSION: SelectedSessionID,
  844. UID: <?=$UserID;?>,
  845. SID: '<?=$Session;?>'
  846. },
  847. success: function( response, opts ){
  848. var data = Ext.decode(response.responseText);
  849. if( data.status == 'ok' ){
  850. if( data.composed_video_status == 'D'){
  851. CompositeVideoStatus = 2;
  852. sesVideosListRExists = data.composed_right_video_exists;
  853. sesVideosListLExists = data.composed_left_video_exists;
  854. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  855. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  856. CompositeVideoStatusUpdate();
  857. } else {
  858. CompositeVideoStatusUpdate();
  859. CompositeVideoProgress = data.composed_video_progress;
  860. setDonatStatus( 1, 0, CompositeVideoProgress );
  861. CompositeVideoStatusTO = window.setTimeout( eventVideosStatusUpdater, 1000 );
  862. };
  863. }
  864. }
  865. });
  866. }
  867. function showEventsVideos(){
  868. if( sesVideosListWindow == null ){
  869. sesVideosListWindow = new Ext.Window({
  870. title: 'Videos',
  871. modal: true,
  872. width: 510,
  873. height: 560,
  874. closeAction: 'close',
  875. resizable: false,
  876. items:[{
  877. xtype: 'grid',
  878. height: 350,
  879. ds: videosListStore,
  880. cm: new Ext.grid.ColumnModel( videosListColModel_ops ),
  881. sm: new Ext.grid.RowSelectionModel( videosListSelModel_ops ),
  882. },{
  883. xtype: 'panel',
  884. border: false,
  885. frame: false,
  886. id: 'EvtVidCompDownPanel',
  887. autoScroll: true,
  888. items:[]
  889. }],
  890. listeners:{
  891. close: hideEventsVideos
  892. }
  893. });
  894. };
  895. sesVideosListWindow.show();
  896. CompositeVideoStatusUpdate();
  897. };
  898. function LoadMapEventsZ( Mode ){
  899. if( tlLoadLocker ) return;
  900. tlLoadLocker = true;
  901. Ext.Ajax.request({
  902. url: '/lib/controller/getGeoAlerts.php',
  903. params: {
  904. SITE: <?=$SiteID;?>,
  905. UID: <?=$UserID;?>,
  906. SID: '<?=$Session;?>',
  907. MODE: Mode
  908. },
  909. success: function( response, opts ){
  910. if( cevt.length ){
  911. for( i=0; i< cevt.length; i++ ){
  912. if( cevt[i]!= null ){
  913. cevt[i].remove();
  914. delete( cevt[i] );
  915. cevt[i] = null;
  916. };
  917. };
  918. };
  919. if( coz.length ){
  920. for( i=0; i< coz.length; i++ ){
  921. if( coz[i]!= null ){
  922. coz[i].remove();
  923. delete( coz[i] );
  924. coz[i]=null;
  925. };
  926. };
  927. };
  928. var data = Ext.decode( response.responseText );
  929. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  930. for( i=0; i < data.evt.length; i++ ){
  931. cevt[i] = L.circleMarker( [data.evt[i].lat,data.evt[i].lon], {id:data.evt[i].id, color: '#FF0000', radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  932. loadEventProperties( this.options.id );
  933. } );
  934. cevt[i].addTo(map);
  935. };
  936. for( i=0; i < data.other.length; i++ ){
  937. switch( data.other[i].type ){
  938. case 'circle':{
  939. coz[i] = L.circleMarker( data.other[i].loc, {id:data.other[i].id, color: data.other[i].color, radius: 5, stroke: false, fillOpacity: 1.0 } );
  940. coz[i].addTo(map);
  941. break;
  942. };
  943. };
  944. };
  945. //eventsListStore.reload();
  946. tlLoadLocker = false;
  947. },
  948. failure: function( response, opts ) {
  949. //Ext.fly('some_div').update('Fail!');
  950. tlLoadLocker = false;
  951. }
  952. });
  953. };
  954. function loadEventPropertiesByID( id ){
  955. var d = eventsListStore.findExact( 'id', id );
  956. if( d > -1 ) {
  957. var EventRec = eventsListStore.getAt( d );
  958. loadEventProperties( EventRec.data );
  959. };
  960. };
  961. function loadEventProperties( EventRec ){
  962. var tPanel = Ext.getCmp('prop_content');
  963. tPanel.removeAll();// remove( 0 );
  964. var tt = '';
  965. if( selectedMarker!= null ){
  966. selectedMarker.remove();
  967. //map.removeLayer( selectedMarker );
  968. if( EventRec.has_geo ){
  969. tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
  970. selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
  971. selectedMarker.addTo( map );
  972. };
  973. };
  974. tPanel.add( {
  975. title: 'Event Details',
  976. html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
  977. } );
  978. if( EventRec.has_images ){
  979. for( var i=0; i < EventRec.images.length; i++ ){
  980. tPanel.add( {
  981. frame: false,
  982. html: '<img width="100%" src="/lib/controller/getPicture.php?PID='+EventRec.images[i]+'" data-enlargeable000 ondblclick="fullScreen(\'img-'+EventRec.id+'\');" style="cursor: zoom-in" id="img-'+EventRec.id+'"/>'
  983. });
  984. };
  985. };
  986. tPanel.doLayout();
  987. };
  988. function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){
  989. if( tlLoadLocker ) return;
  990. tlLoadLocker = true;
  991. if( Mode == 'arch' ){
  992. Ext.MessageBox.wait("Loading Data","Please Wait",{
  993. width: '100%',
  994. hidden: true,
  995. animate: true,
  996. progress: true,
  997. closable: false
  998. });
  999. };
  1000. Ext.Ajax.request({
  1001. url: '/lib/controller/getEventRecords.php',
  1002. params: {
  1003. SITE: <?=$SiteID;?>,
  1004. UID: <?=$UserID;?>,
  1005. SID: '<?=$Session;?>',
  1006. MODE: Mode,
  1007. FIL: selecredActiveSourceFilter,
  1008. SDA: SD,
  1009. SMO: SMO,
  1010. SYE: SY,
  1011. STM: ST,
  1012. ETM: ET,
  1013. STR: SR,
  1014. DIR: DR
  1015. },
  1016. success: function( response, opts ){
  1017. tlLoadLocker = false;
  1018. var data = Ext.decode(response.responseText);
  1019. if( data.updateFROMTO ){
  1020. Ext.getCmp('STimeFROM').setValue( data.STT );
  1021. Ext.getCmp('STimeTO').setValue( data.ENT );
  1022. if( data.SLD > 0 ){
  1023. SMO = GetMonthNum(data.SLD);
  1024. SY = GetYear(data.SLD);
  1025. SD = GetDay(data.SLD);
  1026. BuildCalendar();
  1027. };
  1028. };
  1029. eventsListStore.loadData( data, false );
  1030. if( Mode == 'arch' ){
  1031. showEventsOnMap( data, true );
  1032. Ext.MessageBox.hide();
  1033. if( DR > 0 ){
  1034. Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
  1035. Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
  1036. };
  1037. if( DR < 0 ){
  1038. Ext.getCmp('evtArchLog').getView().focusRow( 0 );
  1039. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  1040. };
  1041. } else {
  1042. showEventsOnMap( data, false );
  1043. //LoadMapEventsZ( Mode );
  1044. };
  1045. },
  1046. failure: failureAJAXFunction
  1047. });
  1048. };
  1049. function loadArchive(){
  1050. debugger;
  1051. if( tlInterval!= null ){
  1052. window.clearInterval( tlInterval );
  1053. tlInterval = null;
  1054. timelineObj = null;
  1055. };
  1056. stopStatusUpdater();
  1057. setUserContent( 2 );
  1058. var tPanel = Ext.getCmp('main_portal');
  1059. tPanel.removeAll( true );
  1060. Ext.getCmp('main_content').setTitle( 'Events Archive' );
  1061. tPanel.add({
  1062. columnWidth: 0.83,
  1063. frame: false,
  1064. border: false,
  1065. items: [{
  1066. title: 'Site Map',
  1067. frame: false,
  1068. border: false,
  1069. layout: 'vbox',
  1070. layoutConfig: {
  1071. align : 'stretch',
  1072. pack : 'start',
  1073. },
  1074. height: PanelH-300,
  1075. items:[{
  1076. height: PanelH-325,
  1077. flex: 1,
  1078. frame: false,
  1079. border: false,
  1080. layout: 'fit',
  1081. items:{
  1082. id: 'event_map',
  1083. html: '&nbsp;'
  1084. }
  1085. }]
  1086. },{
  1087. frame: false,
  1088. border: false,
  1089. collapsible: false,
  1090. draggable: false,
  1091. layout: 'hbox',
  1092. items:[{
  1093. layout: 'form',
  1094. title: 'Date/Time',
  1095. width: 200,
  1096. frame: true,
  1097. border: false,
  1098. labelAlign: 'right',
  1099. labelWidth: 50,
  1100. defaults: { width: 80},
  1101. items: [{
  1102. xtype: 'combo',
  1103. id: 'STimeFROM',
  1104. fieldLabel: 'From',
  1105. editable: false,
  1106. typeAhead: true,
  1107. triggerAction: 'all',
  1108. width: 120,
  1109. lazyRender:true,
  1110. mode: 'local',
  1111. store: new Ext.data.ArrayStore({
  1112. id: 0,
  1113. fields: ['ss', 'displayText' ],
  1114. data: [<?php
  1115. $zuzu = array();
  1116. for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1117. echo implode( ',', $zuzu ); ?>]
  1118. }),
  1119. valueField: 'ss',
  1120. displayField: 'displayText'
  1121. },{
  1122. xtype: 'combo',
  1123. id: 'STimeTO',
  1124. fieldLabel: 'Till',
  1125. editable: false,
  1126. typeAhead: true,
  1127. triggerAction: 'all',
  1128. width: 120,
  1129. lazyRender:true,
  1130. mode: 'local',
  1131. store: new Ext.data.ArrayStore({
  1132. id: 0,
  1133. fields: ['ss', 'displayText' ],
  1134. data: [<?php
  1135. $zuzu = array();
  1136. for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  1137. echo implode( ',', $zuzu ); ?>]
  1138. }),
  1139. valueField: 'ss',
  1140. displayField: 'displayText'
  1141. }],
  1142. html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
  1143. buttons: [{
  1144. xtype: 'button',
  1145. text: 'Display History',
  1146. handler: function(){
  1147. var STU = Ext.getCmp('STimeFROM').getValue();
  1148. var ETU = Ext.getCmp('STimeTO').getValue();
  1149. getData( 'arch', STU, ETU );
  1150. }
  1151. }]
  1152. },{
  1153. title: 'Event Log',
  1154. frame: false,
  1155. height: 303,
  1156. id: 'evtArchLog',
  1157. xtype: 'grid',
  1158. ds: eventsListStore,
  1159. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1160. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1161. listeners:{
  1162. keydown: function( e ) {
  1163. if( e.getKey() == e.UP ){
  1164. if( SelectedRow == 0 ){
  1165. var id = eventsListStore.getAt( 0 ).id;
  1166. getData( 'arch', 0, 0, id, 1 );
  1167. };
  1168. };
  1169. if( e.getKey() == e.DOWN ){
  1170. if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
  1171. var id = eventsListStore.getAt( SelectedRow ).id;
  1172. getData( 'arch', 0, 0, id, -1 );
  1173. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  1174. Ext.getCmp('evtArchLog').focus( false, true );
  1175. };
  1176. };
  1177. }
  1178. }
  1179. }]
  1180. }]
  1181. });
  1182. tPanel.add({
  1183. columnWidth: 0.17,
  1184. frame: true,
  1185. title: 'Event Information',
  1186. id: 'prop_content',
  1187. border: false,
  1188. items: [{
  1189. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1190. }]
  1191. });
  1192. tPanel.doLayout();
  1193. /*
  1194. Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
  1195. Ext.getCmp('evtLog').getEl().addKeyMap({
  1196. eventName: "keyup",
  1197. binding: [{
  1198. key: Ext.EventObject.SPACE,
  1199. fn: function(){ alert("Space key pressed"); }
  1200. },{
  1201. key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
  1202. shift: true,
  1203. fn: function(){ alert("Left or right pressed while pressing shift"); }
  1204. }]
  1205. });
  1206. */
  1207. //BuildCalendar();
  1208. loadCalendarDates();
  1209. map = L.map('event_map',{
  1210. attributionControl: true,
  1211. //preferCanvas: true,
  1212. zoomControl: true,
  1213. center: [SiteLat, SiteLon],
  1214. /*zoomControl: false,
  1215. zoom: 17,
  1216. minZoom: 17,
  1217. maxZoom: 17,*/
  1218. keyboard: false
  1219. }).setView([SiteLat, SiteLon], 17);
  1220. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1221. var mapLayers = [];
  1222. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1223. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1224. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1225. detectRetina: true
  1226. });*/
  1227. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1228. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1229. maxNativeZoom: 18,
  1230. maxZoom: 24,
  1231. })
  1232. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1233. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1234. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1235. maxZoom: 19
  1236. });
  1237. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1238. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1239. maxZoom: 19
  1240. });
  1241. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1242. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  1243. maxZoom: 24
  1244. });
  1245. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1246. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1247. maxZoom: 19
  1248. });
  1249. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1250. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1251. maxZoom: 19
  1252. });
  1253. /*
  1254. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1255. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1256. maxZoom: 22
  1257. });
  1258. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1259. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1260. maxZoom: 22
  1261. });
  1262. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1263. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1264. maxZoom: 22
  1265. });
  1266. */
  1267. var baseMaps = {
  1268. "MyMap": mapLayers["MyMap"],
  1269. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1270. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1271. "EsriSat": mapLayers["EsriSat"],
  1272. "EsriStreet": mapLayers["EsriStreet"],
  1273. "EsriTopo": mapLayers["EsriTopo"],
  1274. //"Bing": mapLayers["Bing"],
  1275. //"OSM-Cycle": mapLayers["Cycle"],
  1276. //"Landscape": mapLayers["Landscape"],
  1277. //"Outdoor": mapLayers["Outdoor"],
  1278. };
  1279. L.control.layers( baseMaps ).addTo(map);
  1280. mapLayers["MyMap"].addTo(map);
  1281. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1282. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1283. maxNativeZoom: 18,
  1284. maxZoom: 24,
  1285. }).addTo(map); */
  1286. //loadTimeLineGroups( selectedSite );
  1287. loadMapZones( SelectedSite );
  1288. getData( 'arch' );
  1289. //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  1290. };
  1291. function loadMonitoring(){
  1292. if( tlInterval!= null ){
  1293. window.clearInterval( tlInterval );
  1294. tlInterval = null;
  1295. timelineObj = null;
  1296. };
  1297. setUserContent( 1 );
  1298. var tPanel = Ext.getCmp('main_portal');
  1299. tPanel.removeAll( true );
  1300. Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
  1301. tPanel.add({
  1302. columnWidth: 0.83,
  1303. frame: false,
  1304. border: false,
  1305. items: [{
  1306. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  1307. frame: false,
  1308. border: false,
  1309. collapsible: false,
  1310. draggable: false,
  1311. layout: 'vbox',
  1312. layoutConfig: {
  1313. align : 'stretch',
  1314. pack : 'start',
  1315. },
  1316. height: PanelH-300,
  1317. items:[{
  1318. height: PanelH-325,
  1319. flex: 1,
  1320. frame: false,
  1321. border: false,
  1322. layout: 'fit',
  1323. items:{
  1324. id: 'event_map',
  1325. html: '&nbsp;'
  1326. }
  1327. }]
  1328. },{
  1329. frame: false,
  1330. border: true,
  1331. collapsible: false,
  1332. draggable: false,
  1333. layout: 'hbox',
  1334. items:[{
  1335. title: 'Alarm Sources',
  1336. xtype: 'panel',
  1337. border: false,
  1338. frame: false,
  1339. collapsible: false,
  1340. draggable: false,
  1341. id: 'sources_panel',
  1342. width: 160,
  1343. autoScroll: 'auto',
  1344. height: 303
  1345. },{
  1346. title: 'Event Log',
  1347. height: 303,
  1348. xtype: 'grid',
  1349. border: false,
  1350. frame: false,
  1351. collapsible: false,
  1352. draggable: false,
  1353. ds: eventsListStore,
  1354. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1355. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1356. bbar: [{
  1357. text: 'Clear',
  1358. handler: function(){
  1359. Ext.Ajax.request({
  1360. url: '/lib/controller/clearEventCloud.php',
  1361. params: {
  1362. UID: <?=$UserID;?>,
  1363. SID: '<?=$Session;?>'
  1364. },
  1365. success: function( response, opts ){
  1366. },
  1367. failure: function( response, opts ) {
  1368. }
  1369. });
  1370. }
  1371. }]
  1372. }]
  1373. }]
  1374. });
  1375. tPanel.add({
  1376. columnWidth: 0.17,
  1377. title: 'Event Information',
  1378. frame: true,
  1379. id: 'prop_content',
  1380. border: false,
  1381. items: [{
  1382. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1383. }]
  1384. });
  1385. tPanel.doLayout();
  1386. map = L.map('event_map',{
  1387. attributionControl: true,
  1388. //preferCanvas: true,
  1389. zoomControl: true,
  1390. center: [SiteLat, SiteLon],
  1391. /*zoomControl: false,
  1392. zoom: 17,
  1393. minZoom: 17,
  1394. maxZoom: 17,*/
  1395. keyboard: false
  1396. }).setView([SiteLat, SiteLon], 17);
  1397. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1398. var mapLayers = [];
  1399. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1400. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1401. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1402. detectRetina: true
  1403. });*/
  1404. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1405. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1406. maxNativeZoom: 18,
  1407. maxZoom: 24,
  1408. })
  1409. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1410. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1411. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1412. maxZoom: 19
  1413. });
  1414. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1415. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1416. maxZoom: 19
  1417. });
  1418. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1419. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  1420. maxZoom: 24
  1421. });
  1422. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1423. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1424. maxZoom: 19
  1425. });
  1426. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1427. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1428. maxZoom: 19
  1429. });
  1430. /*
  1431. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1432. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1433. maxZoom: 22
  1434. });
  1435. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1436. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1437. maxZoom: 22
  1438. });
  1439. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1440. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1441. maxZoom: 22
  1442. });
  1443. */
  1444. var baseMaps = {
  1445. "MyMap": mapLayers["MyMap"],
  1446. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1447. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1448. "EsriSat": mapLayers["EsriSat"],
  1449. "EsriStreet": mapLayers["EsriStreet"],
  1450. "EsriTopo": mapLayers["EsriTopo"],
  1451. //"Bing": mapLayers["Bing"],
  1452. //"OSM-Cycle": mapLayers["Cycle"],
  1453. //"Landscape": mapLayers["Landscape"],
  1454. //"Outdoor": mapLayers["Outdoor"],
  1455. };
  1456. L.control.layers( baseMaps ).addTo(map);
  1457. mapLayers["MyMap"].addTo(map);
  1458. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1459. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1460. maxNativeZoom: 18,
  1461. maxZoom: 24,
  1462. }).addTo(map); */
  1463. loadMapZones( SelectedSite );
  1464. tlInterval = window.setInterval( getData, 333, 'live' );
  1465. };
  1466. function loadOnlineMonitoring(devID){
  1467. var tPanel = Ext.getCmp('main_content');
  1468. if( tlInterval!= null ){
  1469. window.clearInterval( tlInterval );
  1470. tlInterval = null;
  1471. timelineObj = null;
  1472. };
  1473. tPanel.remove(0);
  1474. tPanel.add({
  1475. html: 'Device Monitoring '+devID
  1476. });
  1477. tPanel.doLayout();
  1478. };
  1479. var mSesPlay = null;
  1480. function ts2dts( b ){
  1481. var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  1482. var a = new Date( b );
  1483. var year = a.getFullYear();
  1484. var month = months[a.getMonth()];
  1485. var date = a.getDate();
  1486. var hour = a.getHours();
  1487. var min = "0" + a.getMinutes();
  1488. var sec = "0" + a.getSeconds();
  1489. return date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) ;
  1490. };
  1491. function drawSessionDataOnSlider( a, b , z, v ){
  1492. var cel = Ext.getCmp("hpl_slider").getEl();
  1493. var c = document.createElement('canvas');
  1494. var ctx = c.getContext('2d');
  1495. c.width = cel.getWidth();
  1496. c.height = cel.getHeight();
  1497. var tK = ( cel.getWidth() - 7 ) / ( b - a );
  1498. var rib = (tK>3)?tK:3;
  1499. ctx.fillStyle='#00000000';
  1500. //ctx.fillStyle='#00FF00';
  1501. ctx.fillRect( 7, 0, cel.getWidth(), cel.getHeight() );
  1502. ctx.fillStyle='#FF0000';
  1503. for( var i=0; i< z.length; i++ ){
  1504. var cX = 7 + Math.round( tK * ( z[i].ts /1000 - a ) );
  1505. ctx.fillRect( cX, 0, rib, 12 );//25
  1506. };
  1507. ctx.fillStyle='#0000FF';
  1508. for( var i=0; i< v.length; i++ ){
  1509. var cX = 7 + Math.round( tK * ( v[i].sts /1000 - a ) );
  1510. var cD = 7 + Math.round( tK * ( v[i].ets /1000 - a ) );
  1511. var cW = cD - cX;
  1512. ctx.fillRect( cX, 13, cW, 25 );
  1513. };
  1514. cel.setStyle('background','url(' + c.toDataURL() + ')');
  1515. };
  1516. var max_grad_levels = 16;
  1517. function getTransperecy( i ){
  1518. if( i == 0 ) return 'FF';
  1519. var k = 128.0 / max_grad_levels;
  1520. var l = parseInt( k*(max_grad_levels-i) ).toString(16);
  1521. if( l.length < 2 ) l = '0'+l;
  1522. return l;
  1523. };
  1524. function getSize( i ){
  1525. var k = 75.0 / max_grad_levels;
  1526. return 25+parseInt( k * i );
  1527. };
  1528. class argusSessionPlayer{
  1529. sessionId;
  1530. mMapID;
  1531. startTime;
  1532. endTime;
  1533. currentTime;
  1534. rVideoJS = null;
  1535. lVideoJS = null;
  1536. rVideoJS_id = null;
  1537. lVideoJS_id = null;
  1538. rVideoJS_playing = false;
  1539. rVideoJS_exists = false;
  1540. lVideoJS_playing = false;
  1541. lVideoJS_exists = false;
  1542. rVideoJS_cid = -1;
  1543. lVideoJS_cid = -1;
  1544. mapLayout;
  1545. Videos;
  1546. Events;
  1547. basePath;
  1548. mTimer = null;
  1549. mPaused = true;
  1550. mLooping = true;
  1551. mAutoPlay = false;
  1552. nextTimestamp = 0.0;
  1553. mSvgElements;//076.png
  1554. mMainVideo = 0;
  1555. constructor( session_id, autoplay ) {
  1556. this.sessionId = session_id;
  1557. this.currentTime = 0;
  1558. this.startTime = 0;
  1559. this.endTime = 0;
  1560. this.Videos = [];
  1561. this.Events = [];
  1562. this.rVideoJS_exists = false;
  1563. this.lVideoJS_exists = false;
  1564. this.rEvents = [];
  1565. this.lEvents = [];
  1566. this.mSvgElements = [];
  1567. if( autoplay != undefined ) this.mAutoPlay = autoplay;
  1568. Ext.Ajax.request({
  1569. url: '/lib/controller/getSessionData.php',
  1570. params: {
  1571. SESSION: this.sessionId,
  1572. UID: <?=$UserID;?>,
  1573. SID: '<?=$Session;?>'
  1574. },
  1575. success: function( response, opts ){
  1576. var data = Ext.decode( response.responseText );
  1577. //debugger;
  1578. if( data.status == 'ok' ){
  1579. mSesPlay.mapLayout = data.layout;
  1580. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1581. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1582. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1583. //debugger;
  1584. if( data.data_ok ){
  1585. // Correct TS will get from Events/Videos
  1586. mSesPlay.startTime = data.start_ts + data.length;//data.start_ts;
  1587. mSesPlay.endTime = 0;//data.start_ts + data.length;
  1588. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1589. mSesPlay.Videos = [];
  1590. mSesPlay.mPaused = true;
  1591. mSesPlay.nextTimestamp = 0.0;
  1592. sesVideosListRName = data.r_module_name;
  1593. sesVideosListLName = data.l_module_name;
  1594. if( data.composed_video ){
  1595. if( data.composed_video_status == 'D' ){
  1596. CompositeVideoStatus = 2;
  1597. sesVideosListRExists = data.composed_right_video_exists;
  1598. sesVideosListLExists = data.composed_left_video_exists;
  1599. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  1600. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  1601. } else {
  1602. CompositeVideoStatus = 1;
  1603. CompositeVideoProgress = data.composed_video_progress;
  1604. CompositeVideoLeftInfo = null;
  1605. CompositeVideoRightInfo = null;
  1606. sesVideosListRExists = false;
  1607. sesVideosListLExists = false;
  1608. }
  1609. } else CompositeVideoStatus = 0;
  1610. if( data.events.length ){
  1611. mSesPlay.Events = data.events;
  1612. for( var i=0; i < data.events.length; i++ ){
  1613. if( data.events[i].side == 'L' ){
  1614. mSesPlay.lEvents.push( data.events[i] );
  1615. } else {
  1616. mSesPlay.rEvents.push( data.events[i] );
  1617. };
  1618. if( data.events[i].ts < mSesPlay.startTime ) mSesPlay.startTime = data.events[i].ts;
  1619. if( data.events[i].ts > mSesPlay.endTime ) mSesPlay.endTime = data.events[i].ts;
  1620. };
  1621. };
  1622. if( data.videos.length ){
  1623. videosListStore.loadData( data, false );
  1624. for( var i=0; i < data.videos.length; i++ ){
  1625. if( mSesPlay.currentTime == 0 ){
  1626. mSesPlay.currentTime = data.videos[i].sts;
  1627. } else {
  1628. if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts;
  1629. };
  1630. if( data.videos[i].side == 'R' ) mSesPlay.rVideoJS_exists = true; else mSesPlay.lVideoJS_exists = true;
  1631. mSesPlay.Videos.push( data.videos[i] );
  1632. if( data.videos[i].sts < mSesPlay.startTime ) mSesPlay.startTime = data.videos[i].sts;
  1633. if( (data.videos[i].sts+60000) > mSesPlay.endTime ) mSesPlay.endTime = data.videos[i].sts + 60000;
  1634. };
  1635. sesVideosStartTS = mSesPlay.currentTime;
  1636. } else {
  1637. sesVideosStartTS = 0;//mSesPlay.currentTime;
  1638. videosListStore.removeAll();
  1639. };
  1640. //Init slider parameters
  1641. var tt = Ext.getCmp('hpl_slider');
  1642. tt.setMinValue( 0 );
  1643. tt.setMaxValue( parseInt( ( mSesPlay.endTime - mSesPlay.startTime ) / 1000 ) );
  1644. tt.suspendEvents();
  1645. tt.setValue( 0, false );
  1646. tt.resumeEvents();
  1647. if( mSesPlay.rVideoJS_exists ) {
  1648. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1649. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1650. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.triggerPlay(); });
  1651. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1652. // New imp
  1653. mSesPlay.rVideoJS.on('play', () => {
  1654. if( mSesPlay.mMainVideo == 1 ){
  1655. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1656. };
  1657. });
  1658. mSesPlay.rVideoJS.on( 'timeupdate', () => {
  1659. //if( mSesPlay.mMainVideo == 1 ){
  1660. mSesPlay.checkVideoTime();
  1661. //};
  1662. });
  1663. mSesPlay.rVideoJS.on('seeking', () => {
  1664. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1665. });
  1666. mSesPlay.rVideoJS.on('videotick', (e) => {
  1667. if( mSesPlay.mMainVideo == 1 ){
  1668. mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 );
  1669. };
  1670. });
  1671. mSesPlay.rVideoJS.on('ended', function() {
  1672. //console.log("Video Ended!");
  1673. mSesPlay.rVideoJS_playing = false;
  1674. mSesPlay.onVideoEnded( 1 );
  1675. });
  1676. };
  1677. if( mSesPlay.lVideoJS_exists ){
  1678. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1679. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1680. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.triggerPlay(); });
  1681. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1682. mSesPlay.lVideoJS.on('play', () => {
  1683. if( mSesPlay.mMainVideo == 0 ){
  1684. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1685. };
  1686. });
  1687. mSesPlay.lVideoJS.on( 'timeupdate', () => {
  1688. //if( mSesPlay.mMainVideo == 0 ){
  1689. mSesPlay.checkVideoTime();
  1690. //};
  1691. });
  1692. mSesPlay.lVideoJS.on('seeking', () => {
  1693. if( mSesPlay.mMainVideo == 0 ){
  1694. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1695. };
  1696. });
  1697. mSesPlay.lVideoJS.on('videotick', (e) => {
  1698. if( mSesPlay.mMainVideo == 0 ){
  1699. mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 );
  1700. };
  1701. });
  1702. mSesPlay.lVideoJS.on('ended', function() {
  1703. console.log("Video Ended!");
  1704. mSesPlay.lVideoJS_playing = false;
  1705. mSesPlay.onVideoEnded( 0 );
  1706. });
  1707. };
  1708. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  1709. //mSesPlay.setPosition( 0 );
  1710. if( mSesPlay.Videos.length ){
  1711. if( mSesPlay.Videos[0].side == 'L' ){
  1712. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.Videos[0].name };
  1713. mSesPlay.lVideoJS.src( ns );
  1714. mSesPlay.lVideoJS_playing = true;
  1715. mSesPlay.lVideoJS_cid = 0;
  1716. mSesPlay.mMainVideo = 0;
  1717. } else {
  1718. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.Videos[0].name };
  1719. mSesPlay.rVideoJS.src( ns );
  1720. mSesPlay.rVideoJS_playing = true;
  1721. mSesPlay.rVideoJS_cid = 0;
  1722. mSesPlay.mMainVideo = 1;
  1723. };
  1724. var zz = document.getElementById('hpl_time_mon');
  1725. zz.innerHTML = ts2dts( mSesPlay.Videos[0].sts );
  1726. };
  1727. if( mSesPlay.mAutoPlay ) mSesPlay.triggerPlay();
  1728. } else {
  1729. Ext.Msg.show({
  1730. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1731. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1732. buttons: Ext.Msg.OK,
  1733. icon: Ext.MessageBox.ERROR
  1734. });
  1735. }
  1736. };
  1737. },
  1738. failure: failureAJAXFunction
  1739. });
  1740. }
  1741. getNextVideo( side ){
  1742. var rv = -1;
  1743. if( this.Videos.length ){
  1744. if( side ){
  1745. for( i= this.rVideoJS_cid+1; i < this.Videos.length; i++ ){
  1746. if( this.Videos[i].side == 'R' ){
  1747. rv = i;
  1748. break;
  1749. };
  1750. };
  1751. } else {
  1752. for( i= this.lVideoJS_cid+1; i < this.Videos.length; i++ ){
  1753. if( this.Videos[i].side == 'L' ){
  1754. rv = i;
  1755. break;
  1756. };
  1757. };
  1758. };
  1759. };
  1760. return rv;
  1761. }
  1762. setPosition( pos_time ){
  1763. var nt = this.startTime + pos_time*1000;
  1764. var zz = document.getElementById('hpl_time_mon');
  1765. zz.innerHTML = ts2dts( nt );
  1766. if( mSesPlay.rVideoJS_exists ){
  1767. var tcid = -1;
  1768. for( var i=0; i < mSesPlay.Videos.length; i++ ){
  1769. if( mSesPlay.Videos[i].side == 'R' ){
  1770. if( ( nt >= mSesPlay.Videos[i].sts ) && ( nt <= ( mSesPlay.Videos[i].sts + 60000 )) ) {
  1771. tcid = i;
  1772. break;
  1773. }
  1774. }
  1775. };
  1776. //debugger;
  1777. if( tcid < 0 ){
  1778. this.rVideoJS_playing = false; // Shut video off
  1779. //var ns = {type: 'image/png', src: '/style/assets/no-signal_h.png' };
  1780. //this.rVideoJS.src( ns );
  1781. //this.src([]);
  1782. //this.rVideoJS.poster( '/style/assets/no-signal_h.png' );
  1783. //this.rVideoJS.posterImage.show();
  1784. this.rVideoJS_cid = -1;
  1785. } else {
  1786. if( /*this.rVideoJS_playing && */ ( tcid == this.rVideoJS_cid ) ) this.rVideoJS.currentTime( ( nt - this.Videos[this.rVideoJS_cid].sts ) / 1000 );
  1787. else {
  1788. // open other video
  1789. this.rVideoJS_cid = tcid;
  1790. this.rVideoJS_playing = true;
  1791. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1792. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1793. this.rVideoJS.src( ns );
  1794. //this.rVideoJS.posterImage.hide();
  1795. this.rVideoJS.play();
  1796. //this.rVideoJS.currentTime( ( nt - this.Videos[this.rVideoJS_cid].sts ) / 1000 );
  1797. };
  1798. };
  1799. };
  1800. //if( mSesPlay.rVideoJS_exists ){
  1801. // if( this.lVideoJS_playing )
  1802. // this.lVideoJS.currentTime( ( nt - this.Videos[this.lVideoJS_cid].sts ) / 1000 );
  1803. //};
  1804. }
  1805. checkVideoTime(){
  1806. if( this.mMainVideo == 0 ){
  1807. const t = this.lVideoJS.currentTime();
  1808. if( t >= this.nextTimestamp ){
  1809. //this.lVideoJS.trigger({ type: 'videotick', timestamp: this.nextTimestamp });
  1810. this.action( parseInt( this.Videos[this.lVideoJS_cid].sts + t*1000 ) );
  1811. this.nextTimestamp += 0.1; // next 100 ms of video time
  1812. };
  1813. } else {
  1814. const t = this.rVideoJS.currentTime();
  1815. if( t >= this.nextTimestamp ){
  1816. //this.rVideoJS.trigger({ type: 'videotick', timestamp: this.nextTimestamp });
  1817. this.action( parseInt( this.Videos[this.rVideoJS_cid].sts + t*1000 ) );
  1818. this.nextTimestamp += 0.1; // next 100 ms of video time
  1819. };
  1820. };
  1821. }
  1822. triggerPlay(){
  1823. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1824. if( this.mPaused ){
  1825. this.mPaused = false;
  1826. zz.setIconClass( 'plr_op_pause' );
  1827. zz.setText('Pause');
  1828. if( this.rVideoJS_exists ){
  1829. this.rVideoJS.play();
  1830. this.rVideoJS_playing = true;
  1831. };
  1832. if( this.lVideoJS_exists ){
  1833. this.lVideoJS.play();
  1834. this.lVideoJS_playing = true;
  1835. };
  1836. } else {
  1837. this.mPaused = true;
  1838. zz.setIconClass( 'plr_op_play' );
  1839. zz.setText('Play');
  1840. if( this.rVideoJS_exists ){
  1841. this.rVideoJS.pause();
  1842. this.rVideoJS_playing = false;
  1843. };
  1844. if( this.lVideoJS_exists ){
  1845. this.rVideoJS.pause();
  1846. this.lVideoJS_playing = false;
  1847. };
  1848. };
  1849. }
  1850. triggerLoop(){
  1851. this.mLooping = !this.mLooping;
  1852. }
  1853. onVideoEnded( side ){
  1854. if( this.mMainVideo == side ){
  1855. var nid = this.getNextVideo( side );
  1856. if( nid > -1 ){
  1857. if( side ){
  1858. this.rVideoJS_cid = nid;
  1859. this.rVideoJS_playing = true;
  1860. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1861. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1862. this.rVideoJS.src( ns );
  1863. this.nextTimestamp = 0.0;
  1864. this.rVideoJS.play();
  1865. } else {
  1866. this.lVideoJS_cid = nid;
  1867. this.lVideoJS_playing = true;
  1868. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1869. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1870. this.lVideoJS.src( ns );
  1871. this.nextTimestamp = 0.0;
  1872. this.lVideoJS.play();
  1873. };
  1874. } else if( this.mLooping ){
  1875. if( side ){
  1876. this.rVideoJS_cid = -1;
  1877. this.rVideoJS_cid = this.getNextVideo( side );
  1878. this.rVideoJS_playing = true;
  1879. //alert( this.basePath + this.Videos[this.rVideoJS_cid].name );
  1880. var ns = {type: 'video/mp4', src: this.basePath + this.Videos[this.rVideoJS_cid].name };
  1881. this.rVideoJS.src( ns );
  1882. this.nextTimestamp = 0.0;
  1883. this.rVideoJS.play();
  1884. } else {
  1885. this.lVideoJS_cid = -1;
  1886. this.lVideoJS_cid = this.getNextVideo( side );
  1887. this.lVideoJS_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.lVideoJS.src( ns );
  1891. this.nextTimestamp = 0.0;
  1892. this.lVideoJS.play();
  1893. };
  1894. };
  1895. };
  1896. }
  1897. action( currentTime = 0 ){
  1898. //console.log( currentTime );
  1899. if( !this.mPaused ){
  1900. this.currentTime = currentTime;
  1901. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1902. var tt = Ext.getCmp('hpl_slider');
  1903. if( tt!= undefined ){
  1904. tt.suspendEvents();
  1905. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1906. tt.resumeEvents();
  1907. };
  1908. var zz = document.getElementById('hpl_time_mon');
  1909. if( zz != undefined ) zz.innerHTML = ts2dts( this.currentTime );
  1910. if( this.Events.length ){
  1911. var sid = -1;
  1912. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1913. sid = i;
  1914. break;
  1915. };
  1916. if( sid > -1 ){
  1917. for( var i=0; i< max_grad_levels; i++ ){
  1918. var cid = sid-i;
  1919. var csize = getSize( i );
  1920. //debugger;
  1921. if( typeof this.mSvgElements[i] === 'undefined') {
  1922. if( cid > -1 ){
  1923. var svgns = "http://www.w3.org/2000/svg";
  1924. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1925. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1926. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1927. this.mSvgElements[i].setAttribute('height', ''+csize);
  1928. this.mSvgElements[i].setAttribute('width', ''+csize);
  1929. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1930. var tt = document.getElementById('svgTrackMap');
  1931. var zz = document.getElementById('scheme_anch');
  1932. tt.insertBefore( this.mSvgElements[i], zz );
  1933. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1934. };
  1935. } else {
  1936. if( cid > -1 ){
  1937. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1938. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1939. this.mSvgElements[i].setAttribute('height', ''+csize);
  1940. this.mSvgElements[i].setAttribute('width', ''+csize);
  1941. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1942. } else {
  1943. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1944. };
  1945. };
  1946. };
  1947. } else
  1948. for( var i=0; i< max_grad_levels; i++ )
  1949. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1950. };
  1951. //this.currentTime += 250;
  1952. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1953. this.currentTime = 0;
  1954. } else {
  1955. //Stop
  1956. //this.play();
  1957. };
  1958. };
  1959. }
  1960. dispose(){
  1961. if( this.rVideoJS_exists ) {
  1962. this.rVideoJS.dispose();
  1963. this.rVideoJS = null;
  1964. };
  1965. if( this.lVideoJS_exists ) {
  1966. this.lVideoJS.dispose();
  1967. this.lVideoJS = null;
  1968. };
  1969. }
  1970. };
  1971. class argusSessionPlayer33{
  1972. sessionId;
  1973. mMapID;
  1974. startTime;
  1975. endTime;
  1976. currentTime;
  1977. rVideoJS = null;
  1978. lVideoJS = null;
  1979. rVideoJS_id = null;
  1980. lVideoJS_id = null;
  1981. rVideoJS_playing = false;
  1982. lVideoJS_playing = false;
  1983. rVideoJS_cid = -1;
  1984. lVideoJS_cid = -1;
  1985. mapLayout;
  1986. lVideos;
  1987. rVideos;
  1988. Events;
  1989. basePath;
  1990. mTimer = null;
  1991. mPaused = true;
  1992. mLooping = true;
  1993. mAutoPlay = false;
  1994. nextRTimestamp = 0.0;
  1995. nextLTimestamp = 0.0;
  1996. mSvgElements;//076.png
  1997. checkLVideoTime(){
  1998. const t = mSesPlay.lVideoJS.currentTime(); // seconds
  1999. while( t >= mSesPlay.nextLTimestamp ){
  2000. mSesPlay.lVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextLTimestamp });
  2001. mSesPlay.nextLTimestamp += 0.1; // next 100 ms of video time
  2002. };
  2003. }
  2004. checkRVideoTime(){
  2005. const t = mSesPlay.rVideoJS.currentTime(); // seconds
  2006. while( t >= mSesPlay.nextRTimestamp ){
  2007. mSesPlay.rVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextRTimestamp });
  2008. mSesPlay.nextRTimestamp += 0.1; // next 100 ms of video time
  2009. };
  2010. }
  2011. constructor( session_id, autoplay ) {
  2012. this.sessionId = session_id;
  2013. this.currentTime = 0;
  2014. this.startTime = 0;
  2015. this.endTime = 0;
  2016. this.lVideos = [];
  2017. this.rVideos = [];
  2018. this.Events = [];
  2019. this.rEvents = [];
  2020. this.lEvents = [];
  2021. this.mSvgElements = [];
  2022. if( autoplay != undefined ) this.mAutoPlay = autoplay;
  2023. Ext.Ajax.request({
  2024. url: '/lib/controller/getSessionData.php',
  2025. params: {
  2026. SESSION: this.sessionId,
  2027. UID: <?=$UserID;?>,
  2028. SID: '<?=$Session;?>'
  2029. },
  2030. success: function( response, opts ){
  2031. var data = Ext.decode( response.responseText );
  2032. //debugger;
  2033. if( data.status == 'ok' ){
  2034. mSesPlay.mapLayout = data.layout;
  2035. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  2036. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  2037. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  2038. //debugger;
  2039. if( data.data_ok ){
  2040. mSesPlay.startTime = data.start_ts;
  2041. mSesPlay.endTime = data.start_ts + data.length;
  2042. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  2043. mSesPlay.rVideos = [];
  2044. mSesPlay.lVideos = [];
  2045. mSesPlay.nextRTimestamp = 0.0;
  2046. mSesPlay.nextLTimestamp = 0.0;
  2047. sesVideosListRName = data.r_module_name;
  2048. sesVideosListLName = data.l_module_name;
  2049. if( data.composed_video ){
  2050. if( data.composed_video_status == 'D' ){
  2051. CompositeVideoStatus = 2;
  2052. sesVideosListRExists = data.composed_right_video_exists;
  2053. sesVideosListLExists = data.composed_left_video_exists;
  2054. if( sesVideosListLExists ) CompositeVideoLeftInfo = data.composed_left_info; else CompositeVideoLeftInfo = null;
  2055. if( sesVideosListRExists ) CompositeVideoRightInfo = data.composed_right_info; else CompositeVideoRightInfo = null;
  2056. } else {
  2057. CompositeVideoStatus = 1;
  2058. CompositeVideoProgress = data.composed_video_progress;
  2059. CompositeVideoLeftInfo = null;
  2060. CompositeVideoRightInfo = null;
  2061. sesVideosListRExists = false;
  2062. sesVideosListLExists = false;
  2063. }
  2064. } else CompositeVideoStatus = 0;
  2065. var tt = Ext.getCmp('hpl_slider');
  2066. tt.setMinValue( 0 );
  2067. tt.setMaxValue( data.length / 1000 );
  2068. if( data.events.length ){
  2069. mSesPlay.Events = data.events;
  2070. for( var i=0; i < data.events.length; i++ ){
  2071. if( data.events[i].side == 'L' ){
  2072. mSesPlay.lEvents.push( data.events[i] );
  2073. } else {
  2074. mSesPlay.rEvents.push( data.events[i] );
  2075. };
  2076. };
  2077. };
  2078. if( data.videos.length ){
  2079. videosListStore.loadData( data, false );
  2080. for( var i=0; i < data.videos.length; i++ ){
  2081. if( mSesPlay.currentTime == 0 ){
  2082. mSesPlay.currentTime = data.videos[i].sts;
  2083. } else {
  2084. if( data.videos[i].sts < mSesPlay.currentTime ) mSesPlay.currentTime = data.videos[i].sts;
  2085. };
  2086. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] );
  2087. else mSesPlay.lVideos.push( data.videos[i] );
  2088. };
  2089. sesVideosStartTS = mSesPlay.currentTime;
  2090. } else {
  2091. sesVideosStartTS = 0;
  2092. videosListStore.removeAll();
  2093. };
  2094. if( mSesPlay.rVideos.length ) {
  2095. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  2096. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  2097. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  2098. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  2099. // New imp
  2100. mSesPlay.rVideoJS.on('play', () => {
  2101. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  2102. });
  2103. mSesPlay.rVideoJS.on( 'timeupdate', mSesPlay.checkRVideoTime );
  2104. mSesPlay.rVideoJS.on('seeking', () => {
  2105. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  2106. });
  2107. mSesPlay.rVideoJS.on('videotick', (e) => {
  2108. mSesPlay.action( mSesPlay.rVideos[mSesPlay.rVideoJS_cid].sts + e.timestamp*1000 );
  2109. });
  2110. mSesPlay.rVideoJS.on('ended', function() {
  2111. console.log("Video Ended!");
  2112. if( mSesPlay.rVideoJS_cid < mSesPlay.rVideos.length ){
  2113. mSesPlay.rVideoJS_cid++;
  2114. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.rVideos[mSesPlay.rVideoJS_cid].name };
  2115. mSesPlay.rVideoJS.src( ns );
  2116. mSesPlay.rVideoJS.play();
  2117. mSesPlay.rVideoJS_playing = true;
  2118. };
  2119. });
  2120. };
  2121. if( mSesPlay.lVideos.length ){
  2122. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  2123. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  2124. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  2125. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  2126. // New imp
  2127. mSesPlay.lVideoJS.on('play', () => {
  2128. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  2129. });
  2130. mSesPlay.lVideoJS.on( 'timeupdate', mSesPlay.checkLVideoTime );
  2131. mSesPlay.lVideoJS.on('seeking', () => {
  2132. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  2133. });
  2134. mSesPlay.lVideoJS.on('videotick', (e) => {
  2135. mSesPlay.action( mSesPlay.lVideos[mSesPlay.lVideoJS_cid].sts + e.timestamp*1000 );
  2136. });
  2137. mSesPlay.lVideoJS.on('ended', function() {
  2138. console.log("Video Ended!");
  2139. if( mSesPlay.lVideoJS_cid < mSesPlay.lVideos.length ){
  2140. mSesPlay.lVideoJS_cid++;
  2141. var ns = {type: 'video/mp4', src: mSesPlay.basePath + mSesPlay.lVideos[mSesPlay.lVideoJS_cid].name };
  2142. mSesPlay.lVideoJS.src( ns );
  2143. mSesPlay.lVideoJS.play();
  2144. mSesPlay.lVideoJS_playing = true;
  2145. };
  2146. });
  2147. };
  2148. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  2149. mSesPlay.setPosition( 0 );
  2150. if( mSesPlay.mAutoPlay ) mSesPlay.play();
  2151. } else {
  2152. Ext.Msg.show({
  2153. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  2154. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  2155. buttons: Ext.Msg.OK,
  2156. icon: Ext.MessageBox.ERROR
  2157. });
  2158. }
  2159. };
  2160. },
  2161. failure: failureAJAXFunction
  2162. });
  2163. }
  2164. checkPlayebleTime( ct ){
  2165. if( this.rVideos.length ){
  2166. var fid = -1;
  2167. if( this.rVideoJS_cid < this.rVideos.length - 1 ){
  2168. for(var i=this.rVideoJS_cid+1; i < this.rVideos.length; i++ ){
  2169. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2170. fid = i;
  2171. break;
  2172. };
  2173. };
  2174. if( fid < 0 ){
  2175. //No Segments for Now;
  2176. //this.rVideoJS_playing = false;
  2177. this.rVideoJS_cid = 1;
  2178. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2179. this.rVideoJS.src( ns );
  2180. this.rVideoJS_playing = true;
  2181. } else {
  2182. if( this.rVideoJS_cid != fid ){
  2183. this.rVideoJS_cid = fid;
  2184. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2185. this.rVideoJS.src( ns );
  2186. };
  2187. this.rVideoJS_playing = true;
  2188. };
  2189. };
  2190. };
  2191. if( this.lVideos.length ){
  2192. var fid = -1;
  2193. for(var i=this.lVideos.length-1; i > 0; i-- ){
  2194. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2195. fid = i;
  2196. break;
  2197. };
  2198. };
  2199. if( fid < 0 ){
  2200. //No Segments for Now;
  2201. //this.lVideoJS_playing = false;
  2202. this.lVideoJS_cid = 1;
  2203. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2204. this.lVideoJS.src( ns );
  2205. this.lVideoJS_playing = true;
  2206. } else {
  2207. if( this.lVideoJS_cid != fid ){
  2208. this.lVideoJS_cid = fid;
  2209. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2210. this.lVideoJS.src( ns );
  2211. };
  2212. this.lVideoJS_playing = true;
  2213. };
  2214. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2215. };
  2216. }
  2217. action( currentTime = 0 ){
  2218. if( !this.mPaused ){
  2219. this.currentTime = currentTime;
  2220. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  2221. //debugger;
  2222. this.currentTime = this.checkPlayebleTime( this.currentTime );
  2223. var zz = document.getElementById('hpl_time_mon');
  2224. if( zz != undefined ){
  2225. zz.innerHTML = ts2dts( this.currentTime );
  2226. };
  2227. //Check videos
  2228. if( this.rVideos.length ){
  2229. var fid = -1;
  2230. for(var i=0; i<this.rVideos.length; i++ ){
  2231. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2232. fid = i;
  2233. break;
  2234. };
  2235. };
  2236. if( fid < 0 ){
  2237. //No Segments for Now;
  2238. this.rVideoJS_playing = false;
  2239. } else {
  2240. if( this.rVideoJS_cid != fid ){
  2241. this.rVideoJS_cid = fid;
  2242. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2243. this.rVideoJS.src( ns );
  2244. };
  2245. this.rVideoJS_playing = true;
  2246. };
  2247. //if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2248. };
  2249. if( this.lVideos.length ){
  2250. var fid = -1;
  2251. for(var i=0; i<this.lVideos.length; i++ ){
  2252. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2253. fid = i;
  2254. break;
  2255. };
  2256. };
  2257. if( fid < 0 ){
  2258. //No Segments for Now;
  2259. this.lVideoJS_playing = false;
  2260. } else {
  2261. if( this.lVideoJS_cid != fid ){
  2262. this.lVideoJS_cid = fid;
  2263. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2264. this.lVideoJS.src( ns );
  2265. };
  2266. this.lVideoJS_playing = true;
  2267. };
  2268. //if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2269. };
  2270. if( this.Events.length ){
  2271. var sid = -1;
  2272. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  2273. sid = i;
  2274. break;
  2275. };
  2276. if( sid > -1 ){
  2277. for( var i=0; i< max_grad_levels; i++ ){
  2278. var cid = sid-i;
  2279. var csize = getSize( i );
  2280. //debugger;
  2281. if( typeof this.mSvgElements[i] === 'undefined') {
  2282. if( cid > -1 ){
  2283. var svgns = "http://www.w3.org/2000/svg";
  2284. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  2285. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2286. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2287. this.mSvgElements[i].setAttribute('height', ''+csize);
  2288. this.mSvgElements[i].setAttribute('width', ''+csize);
  2289. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  2290. var tt = document.getElementById('svgTrackMap');
  2291. var zz = document.getElementById('scheme_anch');
  2292. tt.insertBefore( this.mSvgElements[i], zz );
  2293. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  2294. };
  2295. } else {
  2296. if( cid > -1 ){
  2297. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2298. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2299. this.mSvgElements[i].setAttribute('height', ''+csize);
  2300. this.mSvgElements[i].setAttribute('width', ''+csize);
  2301. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  2302. } else {
  2303. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2304. };
  2305. };
  2306. };
  2307. } else
  2308. for( var i=0; i< max_grad_levels; i++ )
  2309. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2310. };
  2311. var tt = Ext.getCmp('hpl_slider');
  2312. if( tt!= undefined ){
  2313. tt.suspendEvents();
  2314. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  2315. tt.resumeEvents();
  2316. };
  2317. //this.currentTime += 250;
  2318. if( this.currentTime > this.endTime ) if( this.mLooping ){
  2319. this.currentTime = 0;
  2320. } else {
  2321. //Stop
  2322. this.play();
  2323. };
  2324. };
  2325. }
  2326. play(){
  2327. var zz = Ext.getCmp( 'hpl_pl_btn' );
  2328. if( this.mPaused ){
  2329. this.mPaused = false;
  2330. if( this.rVideos.length ){
  2331. if( !this.rVideoJS_playing ) this.rVideoJS.play();
  2332. this.rVideoJS_playing = true;
  2333. };
  2334. if( this.lVideos.length ){
  2335. if( !this.lVideoJS_playing ) this.lVideoJS.play();
  2336. this.lVideoJS_playing = true;
  2337. };
  2338. zz.setIconClass( 'plr_op_pause' );
  2339. zz.setText('Pause');
  2340. } else {
  2341. this.mPaused = true;
  2342. if( this.rVideos.length ){
  2343. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  2344. this.rVideoJS_playing = false;
  2345. };
  2346. if( this.lVideos.length ){
  2347. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  2348. this.lVideoJS_playing = false;
  2349. };
  2350. zz.setIconClass( 'plr_op_play' );
  2351. zz.setText('Play');
  2352. };
  2353. this.action( this.currentTime );
  2354. //if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  2355. }
  2356. pause(){
  2357. this.mPaused = true;
  2358. }
  2359. toggleLoop(){
  2360. this.mLooping = !this.mLooping;
  2361. if( this.mLooping ) if( this.currentTime > this.endTime ){
  2362. this.currentTime = 0;
  2363. // Start
  2364. this.play();
  2365. };
  2366. }
  2367. setPosition( pos_time ){
  2368. //this.currentTime = this.startTime + pos_time*1000;
  2369. var nt = this.startTime + pos_time*1000;
  2370. var zz = document.getElementById('hpl_time_mon');
  2371. zz.innerHTML = ts2dts( nt );
  2372. if( this.rVideoJS_playing )
  2373. this.rVideoJS.currentTime( ( nt - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2374. if( this.lVideoJS_playing )
  2375. this.lVideoJS.currentTime( ( nt - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2376. }
  2377. onLVideoEnd(){
  2378. }
  2379. onRVideoEnd(){
  2380. }
  2381. dispose(){
  2382. if( this.mTimer != null ) clearInterval( this.mTimer );
  2383. this.mTimer = null;
  2384. if( this.rVideoJS!= null ){
  2385. this.rVideoJS.dispose();
  2386. this.rVideoJS = null;
  2387. };
  2388. if( this.lVideoJS!= null ){
  2389. this.lVideoJS.dispose();
  2390. this.lVideoJS = null;
  2391. };
  2392. }
  2393. }
  2394. // canvas aproach ///////////////////////////////////////////
  2395. /*
  2396. const player = videojs('my-video');
  2397. let nextTimestamp = 0;
  2398. let rafId = null;
  2399. function tick() {
  2400. if (player.paused() || player.ended())
  2401. return;
  2402. const t = player.currentTime();
  2403. while (t >= nextTimestamp) {
  2404. player.trigger({
  2405. type: 'videotick',
  2406. timestamp: nextTimestamp
  2407. });
  2408. nextTimestamp += 0.1;
  2409. }
  2410. rafId = requestAnimationFrame(tick);
  2411. }
  2412. player.on('play', () => {
  2413. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  2414. cancelAnimationFrame(rafId);
  2415. rafId = requestAnimationFrame(tick);
  2416. });
  2417. player.on('pause', () => cancelAnimationFrame(rafId));
  2418. player.on('ended', () => cancelAnimationFrame(rafId));
  2419. player.on('seeking', () => {
  2420. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  2421. });
  2422. player.on('videotick', (e) => {
  2423. console.log(e.timestamp);
  2424. });
  2425. */
  2426. class _argusSessionPlayer{
  2427. sessionId;
  2428. mMapID;
  2429. startTime;
  2430. endTime;
  2431. currentTime;
  2432. rVideoJS = null;
  2433. lVideoJS = null;
  2434. rVideoJS_id = null;
  2435. lVideoJS_id = null;
  2436. rVideoJS_playing = false;
  2437. lVideoJS_playing = false;
  2438. rVideoJS_cid = -1;
  2439. lVideoJS_cid = -1;
  2440. mapLayout;
  2441. lVideos;
  2442. rVideos;
  2443. Events;
  2444. basePath;
  2445. mTimer = null;
  2446. mPaused = true;
  2447. mLooping = true;
  2448. mSvgElements;//076.png
  2449. constructor( session_id ) {
  2450. this.sessionId = session_id;
  2451. this.currentTime = 0;
  2452. this.startTime = 0;
  2453. this.endTime = 0;
  2454. this.lVideos = [];
  2455. this.rVideos = [];
  2456. this.Events = [];
  2457. this.mSvgElements = [];
  2458. Ext.Ajax.request({
  2459. url: '/lib/controller/getSessionData.php',
  2460. params: {
  2461. SESSION: this.sessionId,
  2462. UID: <?=$UserID;?>,
  2463. SID: '<?=$Session;?>'
  2464. },
  2465. success: function( response, opts ){
  2466. var data = Ext.decode( response.responseText );
  2467. //debugger;
  2468. if( data.status == 'ok' ){
  2469. mSesPlay.mapLayout = data.layout;
  2470. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  2471. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  2472. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  2473. //debugger;
  2474. if( data.data_ok ){
  2475. if( data.r_module_id ){
  2476. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  2477. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  2478. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  2479. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  2480. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  2481. };
  2482. mSesPlay.startTime = data.start_ts;
  2483. mSesPlay.endTime = data.start_ts + data.length;
  2484. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  2485. mSesPlay.rVideos = [];
  2486. mSesPlay.lVideos = [];
  2487. if( data.videos.length ){
  2488. for( var i=0; i < data.videos.length; i++ )
  2489. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  2490. };
  2491. if( data.events.length ) mSesPlay.Events = data.events;
  2492. var tt = Ext.getCmp('hpl_slider');
  2493. tt.setMinValue( 0 );
  2494. tt.setMaxValue( data.length / 1000 );
  2495. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  2496. //player.on('ended', function() {
  2497. // this.dispose();
  2498. //});
  2499. //alert( data.basepath +'/'+data.videos[0].name );
  2500. //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  2501. //mSesPlay.rVideoJS.ready(function() {
  2502. //mSesPlay.rVideoJS.play();
  2503. //var howLoudIsIt = player.volume();
  2504. //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half
  2505. //});
  2506. //mSesPlay.rVideoJS.on("timeupdate", function(){
  2507. // method will be calledd each 250 msecs
  2508. //});
  2509. if( data.l_module_id ){
  2510. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  2511. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  2512. //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  2513. //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  2514. //mSesPlay.lVideoJS.ready(function() {
  2515. //mSesPlay.rVideoJS.play();
  2516. //var howLoudIsIt = player.volume();
  2517. // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half
  2518. //});
  2519. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  2520. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  2521. };
  2522. //mSesPlay.lVideoJS.on("timeupdate", function(){
  2523. // // method will be calledd each 250 msecs
  2524. //});
  2525. mSesPlay.setPosition( 0 );
  2526. } else {
  2527. Ext.Msg.show({
  2528. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  2529. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  2530. buttons: Ext.Msg.OK,
  2531. icon: Ext.MessageBox.ERROR
  2532. });
  2533. }
  2534. };
  2535. },
  2536. failure: failureAJAXFunction
  2537. });
  2538. }
  2539. action(){
  2540. if( !this.mPaused ){
  2541. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  2542. var zz = document.getElementById('hpl_time_mon');
  2543. //debugger;
  2544. if( zz != undefined ){
  2545. zz.innerHTML = ts2dts( this.currentTime );
  2546. };
  2547. //Check videos
  2548. if( this.rVideos.length ){
  2549. var fid = -1;
  2550. for(var i=0; i<this.rVideos.length; i++ ){
  2551. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  2552. fid = i;
  2553. break;
  2554. };
  2555. };
  2556. if( fid < 0 ){
  2557. //No Segments for Now;
  2558. this.rVideoJS_playing = false;
  2559. } else {
  2560. if( this.rVideoJS_cid != fid ){
  2561. this.rVideoJS_cid = fid;
  2562. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  2563. this.rVideoJS.src( ns );
  2564. };
  2565. this.rVideoJS_playing = true;
  2566. };
  2567. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  2568. };
  2569. if( this.lVideos.length ){
  2570. var fid = -1;
  2571. for(var i=0; i<this.lVideos.length; i++ ){
  2572. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  2573. fid = i;
  2574. break;
  2575. };
  2576. };
  2577. if( fid < 0 ){
  2578. //No Segments for Now;
  2579. this.lVideoJS_playing = false;
  2580. } else {
  2581. if( this.lVideoJS_cid != fid ){
  2582. this.lVideoJS_cid = fid;
  2583. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  2584. this.lVideoJS.src( ns );
  2585. };
  2586. this.lVideoJS_playing = true;
  2587. };
  2588. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  2589. };
  2590. if( this.Events.length ){
  2591. var sid = -1;
  2592. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  2593. sid = i;
  2594. break;
  2595. };
  2596. if( sid > -1 ){
  2597. for( var i=0; i< max_grad_levels; i++ ){
  2598. var cid = sid-i;
  2599. var csize = getSize( i );
  2600. //debugger;
  2601. if( typeof this.mSvgElements[i] === 'undefined') {
  2602. if( cid > -1 ){
  2603. var svgns = "http://www.w3.org/2000/svg";
  2604. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  2605. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2606. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2607. this.mSvgElements[i].setAttribute('height', ''+csize);
  2608. this.mSvgElements[i].setAttribute('width', ''+csize);
  2609. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  2610. var tt = document.getElementById('svgTrackMap');
  2611. var zz = document.getElementById('scheme_anch');
  2612. tt.insertBefore( this.mSvgElements[i], zz );
  2613. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  2614. };
  2615. } else {
  2616. if( cid > -1 ){
  2617. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  2618. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  2619. this.mSvgElements[i].setAttribute('height', ''+csize);
  2620. this.mSvgElements[i].setAttribute('width', ''+csize);
  2621. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  2622. } else {
  2623. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2624. };
  2625. };
  2626. };
  2627. } else
  2628. for( var i=0; i< max_grad_levels; i++ )
  2629. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  2630. };
  2631. var tt = Ext.getCmp('hpl_slider');
  2632. if( tt!= undefined ){
  2633. tt.suspendEvents();
  2634. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  2635. tt.resumeEvents();
  2636. };
  2637. this.currentTime += 250;
  2638. if( this.currentTime > this.endTime ) if( this.mLooping ){
  2639. this.currentTime = 0;
  2640. } else {
  2641. //Stop
  2642. this.play();
  2643. };
  2644. };
  2645. }
  2646. play(){
  2647. var zz = Ext.getCmp( 'hpl_pl_btn' );
  2648. if( this.mPaused ){
  2649. this.mPaused = false;
  2650. if( this.rVideoJS_playing ) this.rVideoJS.play();
  2651. if( this.lVideoJS_playing ) this.lVideoJS.play();
  2652. zz.setIconClass( 'plr_op_pause' );
  2653. zz.setText('Pause');
  2654. } else {
  2655. this.mPaused = true;
  2656. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  2657. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  2658. zz.setIconClass( 'plr_op_play' );
  2659. zz.setText('Play');
  2660. };
  2661. if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  2662. }
  2663. pause(){
  2664. this.mPaused = true;
  2665. }
  2666. toggleLoop(){
  2667. this.mLooping = !this.mLooping;
  2668. if( this.mLooping ) if( this.currentTime > this.endTime ){
  2669. this.currentTime = 0;
  2670. // Start
  2671. this.play();
  2672. };
  2673. }
  2674. setPosition( pos_time ){
  2675. this.currentTime = this.startTime + pos_time*1000;
  2676. var zz = document.getElementById('hpl_time_mon');
  2677. zz.innerHTML = ts2dts( this.currentTime );
  2678. }
  2679. onLVideoEnd(){
  2680. }
  2681. onRVideoEnd(){
  2682. }
  2683. dispose(){
  2684. if( this.mTimer != null ) clearInterval( this.mTimer );
  2685. this.mTimer = null;
  2686. if( this.rVideoJS!= null ){
  2687. this.rVideoJS.dispose();
  2688. this.rVideoJS = null;
  2689. };
  2690. if( this.lVideoJS!= null ){
  2691. this.lVideoJS.dispose();
  2692. this.lVideoJS = null;
  2693. };
  2694. }
  2695. }
  2696. var SelectedSessionID = 0;
  2697. function loadHistorySessionView( session_id ){
  2698. autoRiseEvent = false;
  2699. SelectedSessionID = rep_selectedEventId = session_id;
  2700. Ext.Ajax.request({
  2701. url: '/lib/controller/getHistorySessionView.php',
  2702. params: {
  2703. SESSION: rep_selectedEventId,
  2704. UID: <?=$UserID;?>,
  2705. SID: '<?=$Session;?>'
  2706. },
  2707. success: function( response, opts ){
  2708. var data = Ext.decode(response.responseText);
  2709. if( data.status == 'ok' ){
  2710. monitoringViewLevel = 5;
  2711. if( mSesPlay!= null ) {
  2712. mSesPlay.dispose();
  2713. mSesPlay = null;
  2714. };
  2715. Ext.getCmp('main_content').removeAll(true);
  2716. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2717. Ext.getCmp('main_content').doLayout();
  2718. changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId );
  2719. updateUserContent();
  2720. mSesPlay = new argusSessionPlayer( rep_selectedEventId , true );
  2721. fetchStatus();
  2722. };
  2723. },
  2724. failure: failureAJAXFunction
  2725. });
  2726. };
  2727. function deleteSession( session_id ){
  2728. if( session_id == 0 ) return;
  2729. Ext.Msg.show({
  2730. title:'<?=$Labels->GetLabel('_RYS_DEL_SES_');?>',
  2731. msg: '<?=$Labels->GetLabel('_RYS_DEL_SESSION_');?>',
  2732. buttons: Ext.Msg.YESNOCANCEL,
  2733. icon: Ext.MessageBox.QUESTION,
  2734. fn: function(btn, text){
  2735. if( btn == 'yes' ){
  2736. Ext.Ajax.request({
  2737. url: '/lib/controller/doSessionOperations.php',
  2738. params: {
  2739. SESSION: session_id,
  2740. OPID: 1,
  2741. UID: <?=$UserID;?>,
  2742. SID: '<?=$Session;?>'
  2743. },
  2744. success: function( response, opts ){
  2745. Ext.Msg.hide();
  2746. var data = Ext.decode(response.responseText);
  2747. if( data.status == 'ok' ){
  2748. getBackToMap();
  2749. } else {
  2750. Ext.Msg.show({
  2751. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  2752. msg: data.msg,
  2753. buttons: Ext.Msg.OK,
  2754. icon: Ext.MessageBox.ERROR
  2755. });
  2756. };
  2757. },
  2758. failure: failureAJAXFunction
  2759. });
  2760. };
  2761. }
  2762. });
  2763. };
  2764. function loadHistoryStationEvt( e ){
  2765. loadHistoryStation( e.target.options.mycustomid );
  2766. };
  2767. function loadHistoryStation( STT, buba ){
  2768. if( buba == undefined ){
  2769. autoRiseEvent = false;
  2770. } else {
  2771. autoRiseEvent = buba;
  2772. };
  2773. rep_selectedStation = STT;
  2774. changeContent( 2, 1, rep_selectedStation );
  2775. updateUserContent();
  2776. Ext.Ajax.request({
  2777. url: '/lib/controller/getHistoryStationView.php',
  2778. params: {
  2779. STT: rep_selectedStation,
  2780. UID: <?=$UserID;?>,
  2781. SID: '<?=$Session;?>'
  2782. },
  2783. success: function( response, opts ){
  2784. var data = Ext.decode(response.responseText);
  2785. if( data.status == 'ok' ){
  2786. Ext.getCmp('main_content').removeAll(true);
  2787. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2788. Ext.getCmp('main_content').doLayout();
  2789. Ext.getCmp('left_side_menu').removeAll(true);
  2790. Ext.getCmp('left_side_menu').add({
  2791. xtype: 'panel',
  2792. frame: true,
  2793. border: false,
  2794. items: [{
  2795. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  2796. height: PanelH - 30
  2797. }]
  2798. });
  2799. Ext.getCmp('left_side_menu').doLayout();
  2800. } else {
  2801. };
  2802. },
  2803. failure: failureAJAXFunction
  2804. });
  2805. };
  2806. function loadReportDayTree( ts ){
  2807. ReportSelectionMode = 1;//Day Selected
  2808. rep_selectedDateTS = ts;
  2809. //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  2810. //ReportMask.show();
  2811. Ext.Ajax.request({
  2812. url: '/lib/controller/getHistoryDay.php',
  2813. params: {
  2814. UID: <?=$UserID;?>,
  2815. SID: '<?=$Session;?>',
  2816. STT: rep_selectedStation,
  2817. DTS: rep_selectedDateTS
  2818. },
  2819. success: function(response, opts ){
  2820. var data = Ext.decode( response.responseText );
  2821. var sPanel = Ext.getCmp('left_side_menu');
  2822. sPanel.removeAll( true );
  2823. sPanel.add({
  2824. xtype: 'panel',
  2825. layout: 'vbox',
  2826. frame: true,
  2827. border: false,
  2828. items:[{
  2829. xtype: 'spacer',
  2830. height: 3
  2831. },{
  2832. 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>',
  2833. frame: false,
  2834. width: '100%',
  2835. border: false
  2836. },{
  2837. xtype: 'spacer',
  2838. height: 5
  2839. },{
  2840. xtype: 'treepanel',
  2841. autoScroll: true,
  2842. width: '100%',
  2843. height: PanelH-206,
  2844. border: true,
  2845. frame: true,
  2846. loader: new Ext.tree.TreeLoader(),
  2847. rootVisible: false,
  2848. root: new Ext.tree.AsyncTreeNode( data ),
  2849. listeners: {
  2850. click: function(n) {
  2851. if( n.attributes.leaf ){
  2852. Ext.getCmp('chu_adate').show();
  2853. sPanel.doLayout();
  2854. loadHistorySessionView( n.attributes.sid );
  2855. };
  2856. }
  2857. }
  2858. },{
  2859. xtype: 'spacer',
  2860. height: 10
  2861. },{
  2862. xtype: 'button',
  2863. id: 'chu_adate',
  2864. text: 'Show Dates',
  2865. hidden: true,
  2866. width: '100%',
  2867. iconCls: 'reports_dates_btn',
  2868. scale: 'large',
  2869. handler: function(){
  2870. Ext.getCmp('chu_adate').hide();
  2871. loadHistoryStation( rep_selectedStation );
  2872. }
  2873. }]
  2874. });
  2875. sPanel.doLayout();
  2876. changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS );
  2877. updateUserContent();
  2878. //ReportMask.hide();
  2879. }
  2880. });
  2881. };
  2882. function noHistDialog(){
  2883. Ext.Msg.show({
  2884. title:'<?=$Labels->GetLabel('_GEN_MSG_');?>',
  2885. msg: '<?=$Labels->GetLabel('_NO_REPORTS_4_STATION_');?>',
  2886. buttons: Ext.Msg.OK,
  2887. icon: Ext.MessageBox.INFO
  2888. });
  2889. };
  2890. var history_map = null;
  2891. function initHistoryMap( map_id, x, y ){
  2892. if( tlInterval!= null ){
  2893. window.clearTimeout( tlInterval );
  2894. tlInterval = null;
  2895. };
  2896. var mapLayers = [];
  2897. if( history_map != null ){
  2898. history_map.off();
  2899. history_map.remove();
  2900. history_map = null;
  2901. };
  2902. history_map = L.map( map_id,{
  2903. crs: L.CRS.Simple,
  2904. attributionControl: false,
  2905. preferCanvas: true,
  2906. zoomControl: true,
  2907. center: [x,y],
  2908. zoom: 0,
  2909. minZoom: -3,
  2910. maxZoom: 0,
  2911. keyboard: false
  2912. });
  2913. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  2914. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( history_map );
  2915. Ext.Ajax.request({
  2916. url: '/lib/controller/listHistoryStations.php',
  2917. params: {
  2918. UID: <?=$UserID;?>,
  2919. SID: '<?=$Session;?>'
  2920. },
  2921. success: function( response, opts ){
  2922. var data = Ext.decode(response.responseText);
  2923. if( data.status == 'ok' ){
  2924. for( i=0; i < data.stations.length; i++ ){
  2925. if( data.stations[i].status ){
  2926. 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 );
  2927. } else {
  2928. 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 );
  2929. };
  2930. };
  2931. };
  2932. },
  2933. failure: failureAJAXFunction
  2934. });
  2935. };
  2936. function getBackToHistoryMap(){
  2937. autoRiseEvent = false;
  2938. changeContent( 2, 0 );
  2939. updateUserContent();
  2940. var tP = Ext.getCmp('left_side_menu');
  2941. tP.removeAll( true );
  2942. tP.add({
  2943. layout:'vbox',
  2944. frame: false,
  2945. border: false,
  2946. items:[{
  2947. xtype: 'panel',
  2948. frame: true,
  2949. border: false,
  2950. items: [{
  2951. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  2952. height: PanelH - 30
  2953. }]
  2954. }]
  2955. });
  2956. tP.doLayout();
  2957. loadHistoryMapView();
  2958. };
  2959. function loadHistoryMapView(){
  2960. autoRiseEvent = false;
  2961. Ext.Ajax.request({
  2962. url: '/lib/controller/getHistoryMapView.php',
  2963. params: {
  2964. UID: <?=$UserID;?>,
  2965. SID: '<?=$Session;?>'
  2966. },
  2967. success: function( response, opts ){
  2968. var data = Ext.decode(response.responseText);
  2969. if( data.status == 'ok' ){
  2970. monitoringViewLevel = 0;
  2971. Ext.getCmp('main_content').removeAll(true);
  2972. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2973. Ext.getCmp('main_content').doLayout();
  2974. };
  2975. },
  2976. failure: failureAJAXFunction
  2977. });
  2978. return;
  2979. };
  2980. function initReportsView(){
  2981. if( tlInterval!= null ){
  2982. window.clearInterval( tlInterval );
  2983. tlInterval = null;
  2984. timelineObj = null;
  2985. };
  2986. var tP = Ext.getCmp('left_side_menu');
  2987. tP.removeAll( true );
  2988. tP.add({
  2989. layout:'vbox',
  2990. frame: false,
  2991. border: false,
  2992. items:[{
  2993. xtype: 'panel',
  2994. frame: true,
  2995. border: false,
  2996. items: [{
  2997. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel("_PLS_SEL_STA_ONMAP_");?></div>',
  2998. height: PanelH - 30
  2999. }]
  3000. }]
  3001. });
  3002. tP.doLayout();
  3003. monitoringViewLevel = contentView.l[2].v;
  3004. switch( monitoringViewLevel ){
  3005. case 0:{
  3006. loadHistoryMapView();
  3007. break;
  3008. };
  3009. case 1:{
  3010. loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent );
  3011. break;
  3012. };
  3013. case 2:{
  3014. var tA = contentView.l[2].p.split('-');
  3015. rep_selectedStation = parseInt( tA[0] );
  3016. rep_selectedDateTS = parseInt( tA[1] );
  3017. loadHistoryStation( rep_selectedStation, autoRiseEvent );
  3018. loadReportDayTree( rep_selectedDateTS );
  3019. break;
  3020. };
  3021. case 5:{
  3022. var tA = contentView.l[2].p.split('-');
  3023. rep_selectedStation = parseInt( tA[0] );
  3024. rep_selectedDateTS = parseInt( tA[1] );
  3025. rep_selectedEventId = parseInt( tA[2] );
  3026. loadReportDayTree( rep_selectedDateTS );
  3027. loadHistorySessionView( rep_selectedEventId );
  3028. break;
  3029. };
  3030. };
  3031. //Ext.getCmp('main_content').doLayout();
  3032. };