Web UI for ARGUS server
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.

1126 lines
31 KiB

​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
6 years ago
​
6 years ago
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
6 years ago
​
6 years ago
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
6 years ago
  1. //<?php require_once('../../js_asm.php');
  2. $QS="SELECT * FROM sites WHERE id={$SiteID}";
  3. $RV = $DATABASE->Query( $QS );
  4. ?>
  5. var SiteLat=<?=$RV[0]['anchor_lat'];?>;
  6. var SiteLon=<?=$RV[0]['anchor_lon'];?>;
  7. var SiteAlt=<?=$RV[0]['anchor_alt'];?>;
  8. var map = null;
  9. function Events() {
  10. this.events = { };
  11. }
  12. Events.prototype.on = function(name, fn) {
  13. var events = this.events[name];
  14. if (events == undefined) {
  15. this.events[name] = [ fn ];
  16. this.emit('event:on', fn);
  17. } else {
  18. if (events.indexOf(fn) == -1) {
  19. events.push(fn);
  20. this.emit('event:on', fn);
  21. }
  22. }
  23. return this;
  24. }
  25. Events.prototype.once = function(name, fn) {
  26. var events = this.events[name];
  27. fn.once = true;
  28. if (!events) {
  29. this.events[name] = [ fn ];
  30. this.emit('event:once', fn);
  31. } else {
  32. if (events.indexOf(fn) == -1) {
  33. events.push(fn);
  34. this.emit('event:once', fn);
  35. }
  36. }
  37. return this;
  38. }
  39. Events.prototype.emit = function(name, args) {
  40. var events = this.events[name];
  41. if (events) {
  42. var i = events.length;
  43. while(i--) {
  44. if (events[i]) {
  45. events[i].call(this, args);
  46. if (events[i].once) {
  47. delete events[i];
  48. }
  49. }
  50. }
  51. }
  52. return this;
  53. }
  54. Events.prototype.unbind = function(name, fn) {
  55. if (name) {
  56. var events = this.events[name];
  57. if (events) {
  58. if (fn) {
  59. var i = events.indexOf(fn);
  60. if (i != -1) {
  61. delete events[i];
  62. }
  63. } else {
  64. delete this.events[name];
  65. }
  66. }
  67. } else {
  68. delete this.events;
  69. this.events = { };
  70. }
  71. return this;
  72. }
  73. var userPrefix;
  74. var prefix = (function () {
  75. var styles = window.getComputedStyle(document.documentElement, ''),
  76. pre = (Array.prototype.slice
  77. .call(styles)
  78. .join('')
  79. .match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
  80. )[1],
  81. dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
  82. userPrefix = {
  83. dom: dom,
  84. lowercase: pre,
  85. css: '-' + pre + '-',
  86. js: pre[0].toUpperCase() + pre.substr(1)
  87. };
  88. })();
  89. function bindEvent(element, type, handler) {
  90. if(element.addEventListener) {
  91. element.addEventListener(type, handler, false);
  92. } else {
  93. element.attachEvent('on' + type, handler);
  94. }
  95. }
  96. function Viewport(data) {
  97. events.add( this );
  98. var self = this;
  99. this.element = data.element;
  100. this.fps = data.fps;
  101. this.sensivity = data.sensivity;
  102. this.sensivityFade = data.sensivityFade;
  103. this.touchSensivity = data.touchSensivity;
  104. this.speed = data.speed;
  105. this.lastX = 0;
  106. this.lastY = 0;
  107. this.mouseX = 0;
  108. this.mouseY = 0;
  109. this.distanceX = 0;
  110. this.distanceY = 0;
  111. this.positionX = 0;
  112. this.positionY = 0;
  113. this.positionZ = 0;
  114. this.torqueX = 0;
  115. this.torqueY = 0;
  116. this.down = false;
  117. this.upsideDown = false;
  118. this.previousPositionX = 0;
  119. this.previousPositionY = 0;
  120. this.previousPositionZ = 0;
  121. this.currentSide = 0;
  122. this.calculatedSide = 0;
  123. bindEvent(data.element /*document*/, 'mousedown', function() { self.down = true; });
  124. bindEvent(data.element, 'mouseup', function() { self.down = false; });
  125. bindEvent(data.element, 'keyup', function() { self.down = false; });
  126. bindEvent(data.element, 'mousemove', function(e) { self.mouseX = e.pageX; self.mouseY = e.pageY; });
  127. bindEvent(data.element, 'touchstart', function(e) {
  128. self.down = true;
  129. e.touches ? e = e.touches[0] : null;
  130. self.mouseX = e.pageX / self.touchSensivity;
  131. self.mouseY = e.pageY / self.touchSensivity;
  132. self.lastX = self.mouseX;
  133. self.lastY = self.mouseY;
  134. });
  135. bindEvent(data.element, 'touchmove', function(e) {
  136. if(e.preventDefault) {
  137. e.preventDefault();
  138. }
  139. if(e.touches.length == 1) {
  140. e.touches ? e = e.touches[0] : null;
  141. self.mouseX = e.pageX / self.touchSensivity;
  142. self.mouseY = e.pageY / self.touchSensivity;
  143. }
  144. });
  145. bindEvent(data.element, 'touchend', function(e) {
  146. self.down = false;
  147. });
  148. setInterval(this.animate.bind(this), this.fps);
  149. }
  150. var events = new Events();
  151. events.add = function(obj) {
  152. obj.events = { };
  153. }
  154. events.implement = function(fn) {
  155. fn.prototype = Object.create(Events.prototype);
  156. }
  157. events.implement(Viewport);
  158. Viewport.prototype.animate = function() {
  159. this.distanceX = (this.mouseX - this.lastX);
  160. this.distanceY = (this.mouseY - this.lastY);
  161. this.lastX = this.mouseX;
  162. this.lastY = this.mouseY;
  163. if(this.down) {
  164. this.torqueX = this.torqueX * this.sensivityFade + (this.distanceX * this.speed - this.torqueX) * this.sensivity;
  165. this.torqueY = this.torqueY * this.sensivityFade + (this.distanceY * this.speed - this.torqueY) * this.sensivity;
  166. }
  167. if(Math.abs(this.torqueX) > 1.0 || Math.abs(this.torqueY) > 1.0) {
  168. if(!this.down) {
  169. this.torqueX *= this.sensivityFade;
  170. this.torqueY *= this.sensivityFade;
  171. }
  172. this.positionY -= this.torqueY;
  173. if(this.positionY > 360) {
  174. this.positionY -= 360;
  175. } else if(this.positionY < 0) {
  176. this.positionY += 360;
  177. }
  178. if(this.positionY > 90 && this.positionY < 270) {
  179. this.positionX -= this.torqueX;
  180. if(!this.upsideDown) {
  181. this.upsideDown = true;
  182. this.emit('upsideDown', { upsideDown: this.upsideDown });
  183. }
  184. } else {
  185. this.positionX += this.torqueX;
  186. if(this.upsideDown) {
  187. this.upsideDown = false;
  188. this.emit('upsideDown', { upsideDown: this.upsideDown });
  189. }
  190. }
  191. if(this.positionX > 360) {
  192. this.positionX -= 360;
  193. } else if(this.positionX < 0) {
  194. this.positionX += 360;
  195. }
  196. if(!(this.positionY >= 46 && this.positionY <= 130) && !(this.positionY >= 220 && this.positionY <= 308)) {
  197. if(this.upsideDown) {
  198. if(this.positionX >= 42 && this.positionX <= 130) {
  199. this.calculatedSide = 3;
  200. } else if(this.positionX >= 131 && this.positionX <= 223) {
  201. this.calculatedSide = 2;
  202. } else if(this.positionX >= 224 && this.positionX <= 314) {
  203. this.calculatedSide = 5;
  204. } else {
  205. this.calculatedSide = 4;
  206. }
  207. } else {
  208. if(this.positionX >= 42 && this.positionX <= 130) {
  209. this.calculatedSide = 5;
  210. } else if(this.positionX >= 131 && this.positionX <= 223) {
  211. this.calculatedSide = 4;
  212. } else if(this.positionX >= 224 && this.positionX <= 314) {
  213. this.calculatedSide = 3;
  214. } else {
  215. this.calculatedSide = 2;
  216. }
  217. }
  218. } else {
  219. if(this.positionY >= 46 && this.positionY <= 130) {
  220. this.calculatedSide = 6;
  221. }
  222. if(this.positionY >= 220 && this.positionY <= 308) {
  223. this.calculatedSide = 1;
  224. }
  225. }
  226. if(this.calculatedSide !== this.currentSide) {
  227. this.currentSide = this.calculatedSide;
  228. this.emit('sideChange');
  229. }
  230. }
  231. this.element.style[userPrefix.js + 'Transform'] = 'rotateX(' + this.positionY + 'deg) rotateY(' + this.positionX + 'deg) rotateZ('+this.positionZ + 'deg)';
  232. if(this.positionY != this.previousPositionY || this.positionX != this.previousPositionX || this.positionZ != this.previousPositionZ ) {
  233. this.previousPositionY = this.positionY;
  234. this.previousPositionX = this.positionX;
  235. this.previousPositionZ = this.positionZ;
  236. this.emit('rotate');
  237. }
  238. }
  239. Viewport.prototype.setDirect = function( A, B, C ) {
  240. if( 1 ) {
  241. this.positionX = A;
  242. this.positionY = B;
  243. this.positionZ = C;
  244. if(this.positionY > 360) {
  245. this.positionY -= 360;
  246. } else if(this.positionY < 0) {
  247. this.positionY += 360;
  248. }
  249. if(this.positionY > 90 && this.positionY < 270) {
  250. if(!this.upsideDown) {
  251. this.upsideDown = true;
  252. this.emit('upsideDown', { upsideDown: this.upsideDown });
  253. }
  254. } else {
  255. if(this.upsideDown) {
  256. this.upsideDown = false;
  257. this.emit('upsideDown', { upsideDown: this.upsideDown });
  258. }
  259. }
  260. if(this.positionX > 360) {
  261. this.positionX -= 360;
  262. } else if(this.positionX < 0) {
  263. this.positionX += 360;
  264. }
  265. if(!(this.positionY >= 46 && this.positionY <= 130) && !(this.positionY >= 220 && this.positionY <= 308)) {
  266. if(this.upsideDown) {
  267. if(this.positionX >= 42 && this.positionX <= 130) {
  268. this.calculatedSide = 3;
  269. } else if(this.positionX >= 131 && this.positionX <= 223) {
  270. this.calculatedSide = 2;
  271. } else if(this.positionX >= 224 && this.positionX <= 314) {
  272. this.calculatedSide = 5;
  273. } else {
  274. this.calculatedSide = 4;
  275. }
  276. } else {
  277. if(this.positionX >= 42 && this.positionX <= 130) {
  278. this.calculatedSide = 5;
  279. } else if(this.positionX >= 131 && this.positionX <= 223) {
  280. this.calculatedSide = 4;
  281. } else if(this.positionX >= 224 && this.positionX <= 314) {
  282. this.calculatedSide = 3;
  283. } else {
  284. this.calculatedSide = 2;
  285. }
  286. }
  287. } else {
  288. if(this.positionY >= 46 && this.positionY <= 130) {
  289. this.calculatedSide = 6;
  290. }
  291. if(this.positionY >= 220 && this.positionY <= 308) {
  292. this.calculatedSide = 1;
  293. }
  294. }
  295. if(this.calculatedSide !== this.currentSide) {
  296. this.currentSide = this.calculatedSide;
  297. this.emit('sideChange');
  298. }
  299. }
  300. this.element.style[userPrefix.js + 'Transform'] = 'rotateX(' + this.positionY + 'deg) rotateY(' + this.positionX + 'deg) rotateZ('+this.positionZ + 'deg)';
  301. if(this.positionY != this.previousPositionY || this.positionX != this.previousPositionX || this.positionZ != this.previousPositionZ ) {
  302. this.previousPositionY = this.positionY;
  303. this.previousPositionX = this.positionX;
  304. this.previousPositionZ = this.positionZ;
  305. this.emit('rotate');
  306. }
  307. }
  308. function Cube(data) {
  309. var self = this;
  310. this.element = data.element;
  311. this.sides = this.element.getElementsByClassName('side');
  312. this.viewport = data.viewport;
  313. this.viewport.on('rotate', function() {
  314. self.rotateSides();
  315. });
  316. this.viewport.on('upsideDown', function(obj) {
  317. self.upsideDown(obj);
  318. });
  319. this.viewport.on('sideChange', function() {
  320. self.sideChange();
  321. });
  322. }
  323. Cube.prototype.rotateSides = function() {
  324. var viewport = this.viewport;
  325. if(viewport.positionY > 90 && viewport.positionY < 270) {
  326. this.sides[0].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + (viewport.positionX + viewport.torqueX) + 'deg)';
  327. this.sides[5].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + -(viewport.positionX + 180 + viewport.torqueX) + 'deg)';
  328. } else {
  329. this.sides[0].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + (viewport.positionX - viewport.torqueX) + 'deg)';
  330. this.sides[5].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + -(viewport.positionX + 180 - viewport.torqueX) + 'deg)';
  331. }
  332. }
  333. Cube.prototype.upsideDown = function(obj) {
  334. var deg = (obj.upsideDown == true) ? '180deg' : '0deg';
  335. var i = 5;
  336. while(i > 0 && --i) {
  337. this.sides[i].getElementsByClassName('cube-image')[0].style[userPrefix.js + 'Transform'] = 'rotate(' + deg + ')';
  338. }
  339. }
  340. Cube.prototype.sideChange = function() {
  341. for(var i = 0; i < this.sides.length; ++i) {
  342. this.sides[i].getElementsByClassName('cube-image')[0].className = 'cube-image';
  343. }
  344. this.sides[this.viewport.currentSide - 1].getElementsByClassName('cube-image')[0].className = 'cube-image active';
  345. }
  346. Cube.prototype.set = function( A, B, C ) {
  347. //C = C + 90.0;
  348. this.viewport.setDirect( A, B, C );
  349. }
  350. //var viewport = new Viewport({
  351. // element: document.getElementsByClassName('cube')[0],
  352. // fps: 20,
  353. // sensivity: .1,
  354. // sensivityFade: .93,
  355. // speed: 2,
  356. // touchSensivity: 1.5
  357. //});
  358. //new Cube({
  359. // viewport: viewport,
  360. // element: document.getElementsByClassName('cube')[0]
  361. //});
  362. var LRF3D_Icon = L.icon({
  363. iconUrl: '/style/assets/5_node.png',
  364. //shadowUrl: 'leaf-shadow.png',
  365. iconSize: [64, 64], // size of the icon
  366. //shadowSize: [50, 64], // size of the shadow
  367. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  368. //shadowAnchor: [4, 62], // the same for the shadow
  369. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  370. });
  371. var LFS_Icon = L.icon({
  372. iconUrl: '/style/assets/2_node.png',
  373. //shadowUrl: 'leaf-shadow.png',
  374. iconSize: [64, 64], // size of the icon
  375. //shadowSize: [50, 64], // size of the shadow
  376. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  377. //shadowAnchor: [4, 62], // the same for the shadow
  378. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  379. });
  380. var PLS200_Icon = L.icon({
  381. iconUrl: '/style/assets/3_node.png',
  382. //shadowUrl: 'leaf-shadow.png',
  383. iconSize: [64, 64], // size of the icon
  384. //shadowSize: [50, 64], // size of the shadow
  385. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  386. //shadowAnchor: [4, 62], // the same for the shadow
  387. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  388. });
  389. var PLSNET200_Icon = L.icon({
  390. iconUrl: '/style/assets/6_node.png',
  391. //shadowUrl: 'leaf-shadow.png',
  392. iconSize: [64, 64], // size of the icon
  393. //shadowSize: [50, 64], // size of the shadow
  394. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  395. //shadowAnchor: [4, 62], // the same for the shadow
  396. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  397. });
  398. var PLS360_Icon = L.icon({
  399. iconUrl: '/style/assets/4_node.png',
  400. //shadowUrl: 'leaf-shadow.png',
  401. iconSize: [64, 64], // size of the icon
  402. //shadowSize: [50, 64], // size of the shadow
  403. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  404. //shadowAnchor: [4, 62], // the same for the shadow
  405. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  406. });
  407. var ALS_Icon = L.icon({
  408. iconUrl: '/style/assets/1_node.png',
  409. //shadowUrl: 'leaf-shadow.png',
  410. iconSize: [64, 64], // size of the icon
  411. //shadowSize: [50, 64], // size of the shadow
  412. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  413. //shadowAnchor: [4, 62], // the same for the shadow
  414. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  415. });
  416. var PTZCAM_Icon = L.icon({
  417. iconUrl: '/style/assets/12_node.png',
  418. //shadowUrl: 'leaf-shadow.png',
  419. iconSize: [64, 64], // size of the icon
  420. //shadowSize: [50, 64], // size of the shadow
  421. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  422. //shadowAnchor: [4, 62], // the same for the shadow
  423. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  424. });
  425. var FIXCAM_Icon = L.icon({
  426. iconUrl: '/style/assets/11_node.png',
  427. //shadowUrl: 'leaf-shadow.png',
  428. iconSize: [64, 64], // size of the icon
  429. //shadowSize: [50, 64], // size of the shadow
  430. iconAnchor: [32, 32], // point of the icon which will correspond to marker's location
  431. //shadowAnchor: [4, 62], // the same for the shadow
  432. popupAnchor: [0, -30] // point from which the popup should open relative to the iconAnchor
  433. });
  434. var SITEZ_Icon = L.icon({
  435. iconUrl: '/style/assets/centre_1.png',
  436. //shadowUrl: 'leaf-shadow.png',
  437. iconSize: [32, 32], // size of the icon
  438. //shadowSize: [50, 64], // size of the shadow
  439. iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
  440. //shadowAnchor: [4, 62], // the same for the shadow
  441. popupAnchor: [0, -15] // point from which the popup should open relative to the iconAnchor
  442. });
  443. var locationSelectedNode = 0;
  444. function loadLoactionProps( e ){
  445. if( typeof e == 'number' ){
  446. locationSelectedNode = e;
  447. } else {
  448. locationSelectedNode = e.sourceTarget.options.mycustomid;
  449. }
  450. loadNodeLocationProps( locationSelectedNode );
  451. };
  452. function updateSiteAnchor(){
  453. SiteLat = Ext.getCmp('siteLat').getValue();
  454. SiteLon = Ext.getCmp('siteLon').getValue();
  455. SiteAlt = Ext.getCmp('siteAlt').getValue();
  456. Ext.Ajax.request({
  457. url: '/lib/controller/updateLocation.php',
  458. params: {
  459. SITE: <?=$SiteID;?>,
  460. UID: <?=$UserID;?>,
  461. TYPE: 1,
  462. SID: '<?=$Session;?>',
  463. LAT: SiteLat,
  464. LON: SiteLon,
  465. ALT: SiteAlt
  466. },
  467. failure: failureAJAXFunction
  468. });
  469. };
  470. function updateLocationOrientation(){
  471. var tLat = Ext.getCmp('slat').getValue();
  472. var tLon = Ext.getCmp('slon').getValue();
  473. var tAlt = Ext.getCmp('salt').getValue();
  474. var tRoll = Ext.getCmp('sroll').getValue();
  475. var tPitch = Ext.getCmp('spitch').getValue();
  476. var tYaw = Ext.getCmp('syaw').getValue();
  477. Ext.Ajax.request({
  478. url: '/lib/controller/updateLocation.php',
  479. params: {
  480. NODE: locationSelectedNode,
  481. UID: <?=$UserID;?>,
  482. TYPE: 2,
  483. SID: '<?=$Session;?>',
  484. LAT: tLat,
  485. LON: tLon,
  486. ALT: tAlt,
  487. YAW: tYaw,
  488. ROLL: tRoll,
  489. PITCH: tPitch
  490. },
  491. failure: failureAJAXFunction
  492. });
  493. };
  494. function updateLocation( e ){
  495. locationSelectedNode = e.target.options.mycustomid;
  496. Ext.Ajax.request({
  497. url: '/lib/controller/updateLocation.php',
  498. params: {
  499. NODE: locationSelectedNode,
  500. SITE: <?=$SiteID;?>,
  501. UID: <?=$UserID;?>,
  502. TYPE: 0,
  503. SID: '<?=$Session;?>',
  504. LAT: e.target._latlng.lat,
  505. LON: e.target._latlng.lng
  506. },
  507. success: function( response, opts ){
  508. loadNodeLocationProps( locationSelectedNode );
  509. },
  510. failure: failureAJAXFunction
  511. });
  512. };
  513. function setNodeLocationToAnchor(){
  514. Ext.Ajax.request({
  515. url: '/lib/controller/updateLocation.php',
  516. params: {
  517. NODE: locationSelectedNode,
  518. SITE: <?=$SiteID;?>,
  519. UID: <?=$UserID;?>,
  520. TYPE: 0,
  521. SID: '<?=$Session;?>',
  522. LAT: SiteLat,
  523. LON: SiteLon,
  524. ALT: SiteAlt
  525. },
  526. success: function( response, opts ){
  527. loadLocationEditor();
  528. },
  529. failure: failureAJAXFunction
  530. });
  531. };
  532. function loadLocationNodes(){
  533. Ext.Ajax.request({
  534. url: '/lib/controller/getLocationItems.php',
  535. params: {
  536. SITE: <?=$SiteID;?>,
  537. UID: <?=$UserID;?>,
  538. SID: '<?=$Session;?>'
  539. },
  540. success: function( response, opts ){
  541. var data = Ext.decode(response.responseText);
  542. for( i=0; i < data.length; i++){
  543. switch( data[i].type ){
  544. case 1:{
  545. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: ALS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  546. break;
  547. };
  548. case 2:{
  549. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LFS_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  550. break;
  551. };
  552. case 3:{
  553. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  554. break;
  555. };
  556. case 4:{
  557. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLS360_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  558. break;
  559. };
  560. case 5:{
  561. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: LRF3D_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  562. break;
  563. };
  564. case 6:{
  565. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PLSNET200_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  566. break;
  567. };
  568. case 10:
  569. case 12:{
  570. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: FIXCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  571. break;
  572. };
  573. case 11:
  574. case 13:{
  575. L.marker([data[i].lat, data[i].lon], {draggable: true,icon: PTZCAM_Icon, mycustomid:data[i].id } ).addTo(map).on('click', loadLoactionProps ).on('dragend', updateLocation );
  576. break;
  577. };
  578. };
  579. //bindPopup('A pretty CSS3 popup.<br> Easily customizable.');//.openPopup();
  580. };
  581. },
  582. failure: function( response, opts ) {
  583. var tPanel = Ext.getCmp('main_portal');
  584. tPanel.remove(0);
  585. tPanel.add( { html: 'Failed to load dashboard!' } );
  586. tPanel.doLayout();
  587. }
  588. });
  589. };
  590. var orientationEditorWindow = null;
  591. var cubeViewport = null;
  592. var cube = null;
  593. var curX = 0;
  594. var curY = 0;
  595. var curZ = 0;
  596. var bk_upd = false;
  597. function setCubeOrientation( A, B, C ){
  598. if( bk_upd ) return;
  599. bk_upd = true;
  600. curX = A;
  601. curY = B;
  602. curZ = C;
  603. var t = Ext.getCmp('roll_sld');
  604. t.setValue( A );
  605. t = Ext.getCmp('roll');
  606. t.setValue( A );
  607. t = Ext.getCmp('pitch_sld');
  608. t.setValue( B );
  609. t = Ext.getCmp('pitch');
  610. t.setValue( B );
  611. t = Ext.getCmp('yaw_sld');
  612. t.setValue( C );
  613. t = Ext.getCmp('yaw');
  614. t.setValue( C );
  615. if( cube != null ) cube.set( curX, curY, curZ );
  616. bk_upd = false;
  617. };
  618. function orientationEditor(){
  619. if( orientationEditorWindow == null ){
  620. orientationEditorWindow = new Ext.Window({
  621. modal: true,
  622. title: 'Orientation',
  623. closeAction: 'hide',
  624. width: 640,
  625. height: 500,
  626. items:[{
  627. layout: 'table',
  628. defaults: {
  629. bodyStyle:'padding:5px'
  630. },
  631. layoutConfig: {
  632. columns: 3
  633. },
  634. items:[{
  635. html: 'Roll:'
  636. },{
  637. xtype: 'textfield',
  638. id: 'roll',
  639. name: 'roll',
  640. value: 30.0029,
  641. listeners:{
  642. change: function( sl, nv, tt ){
  643. setCubeOrientation( nv / 1.0, curY, curZ );
  644. }
  645. }
  646. },{
  647. xtype: 'slider',
  648. id: 'roll_sld',
  649. width: 200,
  650. value: 30.0029,
  651. minValue: -180.0,
  652. maxValue: 180.0,
  653. listeners:{
  654. change: function( sl, nv, tt ){
  655. setCubeOrientation( nv, curY, curZ );
  656. }
  657. }
  658. },{
  659. html: 'Pitch:'
  660. },{
  661. xtype: 'textfield',
  662. id: 'pitch',
  663. name: 'pitch',
  664. value: 30.0029,
  665. listeners:{
  666. change: function( sl, nv, tt ){
  667. setCubeOrientation( curX, nv / 1.0, curZ );
  668. }
  669. }
  670. },{
  671. xtype: 'slider',
  672. id: 'pitch_sld',
  673. width: 200,
  674. value: 30.0029,
  675. minValue: -180.0,
  676. maxValue: 180.0,
  677. listeners:{
  678. change: function( sl, nv, tt ){
  679. setCubeOrientation( curX, nv, curZ );
  680. }
  681. }
  682. },{
  683. html: 'Yaw:'
  684. },{
  685. xtype: 'textfield',
  686. id: 'yaw',
  687. name: 'yaw',
  688. value: 30.0029,
  689. listeners:{
  690. change: function( sl, nv, tt ){
  691. //alert( nv );
  692. setCubeOrientation( curX, curY, nv / 1.0 );
  693. }
  694. }
  695. },{
  696. xtype: 'slider',
  697. id: 'yaw_sld',
  698. width: 200,
  699. value: 30.0029,
  700. minValue: -180.0,
  701. maxValue: 180.0,
  702. listeners:{
  703. change: function( sl, nv, tt ){
  704. setCubeOrientation( curX, curY, nv );
  705. }
  706. }
  707. }]
  708. },{
  709. html: '<div id="wrapper"><div class="viewport"><div class="cube"><div class="side"><div class="cube-image top">FRONT</div></div><div class="side"><div class="cube-image">TOP</div></div><div class="side"><div class="cube-image">RIGHT</div></div><div class="side"><div class="cube-image">BOTTOM</div></div><div class="side"><div class="cube-image">LEFT</div></div><div class="side"><div class="cube-image active">BACK</div></div></div></div></div>'
  710. }],
  711. buttons:[{
  712. text: 'Cancel',
  713. width: 200,
  714. handler: function(){
  715. orientationEditorWindow.hide();
  716. }
  717. },{
  718. text: 'Apply',
  719. width: 200,
  720. handler: function(){
  721. Ext.getCmp('sroll').setValue( Ext.getCmp('roll').getValue() );
  722. Ext.getCmp('spitch').setValue( Ext.getCmp('pitch').getValue() );
  723. Ext.getCmp('syaw').setValue( Ext.getCmp('yaw').getValue() );
  724. orientationEditorWindow.hide();
  725. }
  726. }]
  727. });
  728. orientationEditorWindow.show();
  729. cubeViewport = new Viewport({
  730. element: document.getElementsByClassName('cube')[0],
  731. fps: 20,
  732. sensivity: .1,
  733. sensivityFade: .93,
  734. speed: 2,
  735. touchSensivity: 1.5
  736. });
  737. cube = new Cube({
  738. viewport: cubeViewport,
  739. element: document.getElementsByClassName('cube')[0]
  740. });
  741. } else {
  742. orientationEditorWindow.show();
  743. };
  744. setCubeOrientation( Ext.getCmp('sroll').getValue(), Ext.getCmp('spitch').getValue(), Ext.getCmp('syaw').getValue() );
  745. };
  746. function loadNodeLocationProps( NodeID ){
  747. //alert( 'Node: ' + NodeID );
  748. Ext.Ajax.request({
  749. url: '/lib/controller/getLocationNodeProps.php',
  750. params: {
  751. NID: <?=$SiteID;?>,
  752. UID: <?=$UserID;?>,
  753. SID: '<?=$Session;?>',
  754. NODE: NodeID
  755. },
  756. success: function( response, opts ){
  757. // If the response is JSON, you have to decode it
  758. var data = Ext.decode(response.responseText);
  759. var tPanel = Ext.getCmp('prop_content');
  760. tPanel.remove(0);
  761. tPanel.add( data );
  762. tPanel.doLayout();
  763. },
  764. failure: failureAJAXFunction
  765. });
  766. };
  767. function LoadNodesList(){
  768. Ext.Ajax.request({
  769. url: '/lib/controller/getLocationNodes.php',
  770. params: {
  771. SITE: <?=$SiteID;?>,
  772. UID: <?=$UserID;?>,
  773. SID: '<?=$Session;?>'
  774. },
  775. success: function( response, opts ){
  776. // If the response is JSON, you have to decode it
  777. var data = Ext.decode(response.responseText);
  778. var tPanel = Ext.getCmp('prop_content');
  779. tPanel.remove(0);
  780. tPanel.add( data );
  781. tPanel.doLayout();
  782. },
  783. failure: failureAJAXFunction
  784. });
  785. };
  786. function loadLocationEditor(){
  787. if( tlInterval!= null ){
  788. window.clearInterval( tlInterval );
  789. tlInterval = null;
  790. timelineObj = null;
  791. };
  792. var tPanel = Ext.getCmp('main_portal');
  793. tPanel.removeAll( true );
  794. Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_LOC_MAP_LBL_');?>' );
  795. tPanel.add({
  796. columnWidth: 0.83,
  797. frame: false,
  798. border: false,
  799. items: [{
  800. layout: 'fit',
  801. height: PanelH-150,
  802. flex: 1,
  803. //border: true,
  804. items:{
  805. id: 'location_map'
  806. }
  807. },{
  808. layout: 'table',
  809. title: '<?=$Labels->GetLabel('_SITE_PROP_LBL_');?>',
  810. flex: 1,
  811. defaults: {
  812. bodyStyle:'padding:20px'
  813. },
  814. layoutConfig: {
  815. // The total column count must be specified here
  816. columns: 7,
  817. textAlign: 'center'
  818. },
  819. items:[{
  820. html: '<?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?> <?=$Labels->GetLabel('_LAT_SHORT_LBL_');?>:'
  821. },{
  822. xtype: 'textfield',
  823. id: 'siteLat',
  824. value: SiteLat
  825. },{
  826. html: '<?=$Labels->GetLabel('_LON_SHORT_LBL_');?>:'
  827. },{
  828. xtype: 'textfield',
  829. id: 'siteLon',
  830. value: SiteLon
  831. },{
  832. html: '<?=$Labels->GetLabel('_ALT_SHORT_LBL_');?>:'
  833. },{
  834. xtype: 'textfield',
  835. id: 'siteAlt',
  836. value: SiteAlt
  837. },{
  838. xtype: 'button',
  839. text: '<?=$Labels->GetLabel('_UPDATE_LBL_');?>',
  840. handler: updateSiteAnchor
  841. },{
  842. html: '<?=$Labels->GetLabel('_MAP_TYP_LBL_');?>:'
  843. },{
  844. xtype: 'radio',
  845. name: 'map_type',
  846. boxLabel: '<?=$Labels->GetLabel('_MAP_REG_LBL_');?>',
  847. checked: true,
  848. value: 0
  849. },{
  850. xtype: 'radio',
  851. name: 'map_type',
  852. boxLabel: '<?=$Labels->GetLabel('_MAP_CUST_LBL_');?>',
  853. colspan: 2,
  854. value: 1
  855. },{
  856. xtype: 'combo',
  857. disabled: true,
  858. typeAhead: true,
  859. triggerAction: 'all',
  860. lazyRender:true,
  861. colspan: 2,
  862. mode: 'local',
  863. store: new Ext.data.ArrayStore({
  864. id: 0,
  865. fields: ['myId', 'displayText' ],
  866. data: [[1, 'item1'], [2, 'item2']]
  867. }),
  868. valueField: 'myId',
  869. displayField: 'displayText'
  870. },{
  871. xtype: 'button',
  872. id: 'add-c_map-btn',
  873. disabled: true,
  874. text: '<?=$Labels->GetLabel('_CREATE_NEW_LBL_');?>'
  875. }]
  876. }]
  877. });
  878. tPanel.add({
  879. title: 'Properties',
  880. xtype: 'panel',
  881. flex: 1,
  882. height: 700,
  883. columnWidth: 0.17,
  884. layout: 'fit',
  885. id: 'prop_content',
  886. items:{
  887. html: '<center>Select Item From Map</center>'
  888. }
  889. });
  890. tPanel.doLayout();
  891. map = L.map('location_map',{
  892. attributionControl: true,
  893. //preferCanvas: true,
  894. zoomControl: true,
  895. center: [SiteLat, SiteLon],
  896. /*zoomControl: false,
  897. zoom: 17,
  898. minZoom: 17,
  899. maxZoom: 17,*/
  900. keyboard: false
  901. }).setView([SiteLat, SiteLon], 17);
  902. L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
  903. /*
  904. Ext.Ajax.request({
  905. url: '/lib/controller/getNetwork.php',
  906. params: {
  907. NID: selectedSite,
  908. UID: <?=$UserID;?>,
  909. SID: '<?=$Session;?>'
  910. },
  911. success: function( response, opts ){
  912. /*
  913. layout: { improvedLayout: false }
  914. physics: { enabled: true}
  915. For the node, set a property called fixed:
  916. fixed: { x: true , y: true }
  917. Here is the son of the node:
  918. {id: 1, value: 2, label: 'xx' , x: 320, y:170 , fixed: { x: true , y: true } }
  919. // If the response is JSON, you have to decode it
  920. var data = Ext.decode(response.responseText);
  921. netwodkData.nodes = new vis.DataSet( data.nodes );
  922. netwodkData.edges = new vis.DataSet( data.edges );
  923. //map.createPane( 'my_network' );
  924. //map.getPane('my_network').style.zIndex = 1650;
  925. //map.getPane('my_network').style.pointerEvents = 'none';
  926. //map.getPane('my_network').innerHTML = "<div id=\"net_cont\" style=\"width: 640px; height: 500px;\"></div>";
  927. //var container = document.getElementById(Ext.getCmp('net_cont').body.id);
  928. //var container = document.getElementById( 'net_cont' );
  929. var container =map.getPane('markerPane');
  930. networkObj = new vis.Network( container, netwodkData, networkOpts );
  931. },
  932. failure: function( response, opts ) {
  933. //Ext.fly('some_div').update('Fail!');
  934. }
  935. });
  936. */
  937. /*
  938. var map = L.map('map', {
  939. crs: L.CRS.Simple
  940. });
  941. var map = L.map('map', {
  942. crs: L.CRS.Simple,
  943. minZoom: -5
  944. });
  945. var bounds = [[0,0], [1000,1000]];
  946. var image = L.imageOverlay('uqm_map_full.png', bounds).addTo(map);
  947. var bounds = [[-26.5,-25], [1021.5,1023]];
  948. var image = L.imageOverlay('uqm_map_full.png', bounds).addTo(map);
  949. map.fitBounds(bounds);
  950. var sol = L.latLng([ 145, 175.2 ]);
  951. L.marker(sol).addTo(map);
  952. map.setView( [70, 120], 1);
  953. var travel = L.polyline([sol, deneb]).addTo(map);
  954. L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
  955. attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  956. maxZoom: 18,
  957. id: 'mapbox/streets-v11',
  958. tileSize: 512,
  959. zoomOffset: -1,
  960. accessToken: 'your.mapbox.access.token'
  961. }).addTo(mymap);
  962. var circle = L.circle([51.508, -0.11], {
  963. color: 'red',
  964. fillColor: '#f03',
  965. fillOpacity: 0.5,
  966. radius: 500
  967. }).addTo(mymap);
  968. var polygon = L.polygon([
  969. [51.509, -0.08],
  970. [51.503, -0.06],
  971. [51.51, -0.047]
  972. ]).addTo(mymap);
  973. marker.bindPopup("<b>Hello world!</b><br>I am a popup.").openPopup();
  974. circle.bindPopup("I am a circle.");
  975. polygon.bindPopup("I am a polygon.");
  976. function onMapClick(e) {
  977. alert("You clicked the map at " + e.latlng);
  978. }
  979. mymap.on('click', onMapClick);
  980. */
  981. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  982. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  983. }).addTo(map);
  984. loadLocationNodes();
  985. };