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.

1051 lines
28 KiB

​
​
​
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
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 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. locationSelectedNode = e.sourceTarget.options.mycustomid;
  446. loadNodeLocationProps( locationSelectedNode );
  447. };
  448. function updateSiteAnchor(){
  449. SiteLat = Ext.getCmp('siteLat').getValue();
  450. SiteLon = Ext.getCmp('siteLon').getValue();
  451. SiteAlt = Ext.getCmp('siteAlt').getValue();
  452. Ext.Ajax.request({
  453. url: '/lib/controller/updateLocation.php',
  454. params: {
  455. SITE: <?=$SiteID;?>,
  456. UID: <?=$UserID;?>,
  457. TYPE: 1,
  458. SID: '<?=$Session;?>',
  459. LAT: SiteLat,
  460. LON: SiteLon,
  461. ALT: SiteAlt
  462. },
  463. failure: function(){
  464. alert( 'Error' );
  465. }
  466. });
  467. };
  468. function updateLocationOrientation(){
  469. var tLat = Ext.getCmp('slat').getValue();
  470. var tLon = Ext.getCmp('slon').getValue();
  471. var tAlt = Ext.getCmp('salt').getValue();
  472. var tRoll = Ext.getCmp('sroll').getValue();
  473. var tPitch = Ext.getCmp('spitch').getValue();
  474. var tYaw = Ext.getCmp('syaw').getValue();
  475. Ext.Ajax.request({
  476. url: '/lib/controller/updateLocation.php',
  477. params: {
  478. NODE: locationSelectedNode,
  479. UID: <?=$UserID;?>,
  480. TYPE: 2,
  481. SID: '<?=$Session;?>',
  482. LAT: tLat,
  483. LON: tLon,
  484. ALT: tAlt,
  485. YAW: tYaw,
  486. ROLL: tRoll,
  487. PITCH: tPitch
  488. },
  489. failure: function(){
  490. alert( 'Error' );
  491. }
  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. //var data = Ext.decode(response.responseText);
  509. loadNodeLocationProps( locationSelectedNode );
  510. }
  511. });
  512. };
  513. function loadLocationNodes(){
  514. Ext.Ajax.request({
  515. url: '/lib/controller/getLocationItems.php',
  516. params: {
  517. SITE: <?=$SiteID;?>,
  518. UID: <?=$UserID;?>,
  519. SID: '<?=$Session;?>'
  520. },
  521. success: function( response, opts ){
  522. var data = Ext.decode(response.responseText);
  523. for( i=0; i < data.length; i++){
  524. switch( data[i].type ){
  525. case 1:{
  526. 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 );
  527. break;
  528. };
  529. case 2:{
  530. 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 );
  531. break;
  532. };
  533. case 3:{
  534. 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 );
  535. break;
  536. };
  537. case 4:{
  538. 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 );
  539. break;
  540. };
  541. case 5:{
  542. 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 );
  543. break;
  544. };
  545. case 6:{
  546. 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 );
  547. break;
  548. };
  549. case 10:
  550. case 12:{
  551. 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 );
  552. break;
  553. };
  554. case 11:
  555. case 13:{
  556. 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 );
  557. break;
  558. };
  559. };
  560. //bindPopup('A pretty CSS3 popup.<br> Easily customizable.');//.openPopup();
  561. };
  562. },
  563. failure: function( response, opts ) {
  564. var tPanel = Ext.getCmp('main_portal');
  565. tPanel.remove(0);
  566. tPanel.add( { html: 'Failed to load dashboard!' } );
  567. tPanel.doLayout();
  568. }
  569. });
  570. };
  571. var orientationEditorWindow = null;
  572. var cubeViewport = null;
  573. var cube = null;
  574. var curX = 0;
  575. var curY = 0;
  576. var curZ = 0;
  577. var bk_upd = false;
  578. function setCubeOrientation( A, B, C ){
  579. if( bk_upd ) return;
  580. bk_upd = true;
  581. curX = A;
  582. curY = B;
  583. curZ = C;
  584. var t = Ext.getCmp('roll_sld');
  585. t.setValue( A );
  586. t = Ext.getCmp('roll');
  587. t.setValue( A );
  588. t = Ext.getCmp('pitch_sld');
  589. t.setValue( B );
  590. t = Ext.getCmp('pitch');
  591. t.setValue( B );
  592. t = Ext.getCmp('yaw_sld');
  593. t.setValue( C );
  594. t = Ext.getCmp('yaw');
  595. t.setValue( C );
  596. if( cube != null ) cube.set( curX, curY, curZ );
  597. bk_upd = false;
  598. };
  599. function orientationEditor(){
  600. if( orientationEditorWindow == null ){
  601. orientationEditorWindow = new Ext.Window({
  602. modal: true,
  603. title: 'Orientation',
  604. closeAction: 'hide',
  605. width: 640,
  606. height: 500,
  607. items:[{
  608. layout: 'table',
  609. defaults: {
  610. bodyStyle:'padding:5px'
  611. },
  612. layoutConfig: {
  613. columns: 3
  614. },
  615. items:[{
  616. html: 'Roll:'
  617. },{
  618. xtype: 'textfield',
  619. id: 'roll',
  620. name: 'roll',
  621. value: 30.0029,
  622. listeners:{
  623. change: function( sl, nv, tt ){
  624. setCubeOrientation( nv / 1.0, curY, curZ );
  625. }
  626. }
  627. },{
  628. xtype: 'slider',
  629. id: 'roll_sld',
  630. width: 200,
  631. value: 30.0029,
  632. minValue: -180.0,
  633. maxValue: 180.0,
  634. listeners:{
  635. change: function( sl, nv, tt ){
  636. setCubeOrientation( nv, curY, curZ );
  637. }
  638. }
  639. },{
  640. html: 'Pitch:'
  641. },{
  642. xtype: 'textfield',
  643. id: 'pitch',
  644. name: 'pitch',
  645. value: 30.0029,
  646. listeners:{
  647. change: function( sl, nv, tt ){
  648. setCubeOrientation( curX, nv / 1.0, curZ );
  649. }
  650. }
  651. },{
  652. xtype: 'slider',
  653. id: 'pitch_sld',
  654. width: 200,
  655. value: 30.0029,
  656. minValue: -180.0,
  657. maxValue: 180.0,
  658. listeners:{
  659. change: function( sl, nv, tt ){
  660. setCubeOrientation( curX, nv, curZ );
  661. }
  662. }
  663. },{
  664. html: 'Yaw:'
  665. },{
  666. xtype: 'textfield',
  667. id: 'yaw',
  668. name: 'yaw',
  669. value: 30.0029,
  670. listeners:{
  671. change: function( sl, nv, tt ){
  672. //alert( nv );
  673. setCubeOrientation( curX, curY, nv / 1.0 );
  674. }
  675. }
  676. },{
  677. xtype: 'slider',
  678. id: 'yaw_sld',
  679. width: 200,
  680. value: 30.0029,
  681. minValue: -180.0,
  682. maxValue: 180.0,
  683. listeners:{
  684. change: function( sl, nv, tt ){
  685. setCubeOrientation( curX, curY, nv );
  686. }
  687. }
  688. }]
  689. },{
  690. 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>'
  691. }],
  692. buttons:[{
  693. text: 'Cancel',
  694. width: 200,
  695. handler: function(){
  696. orientationEditorWindow.hide();
  697. }
  698. },{
  699. text: 'Apply',
  700. width: 200,
  701. handler: function(){
  702. Ext.getCmp('sroll').setValue( Ext.getCmp('roll').getValue() );
  703. Ext.getCmp('spitch').setValue( Ext.getCmp('pitch').getValue() );
  704. Ext.getCmp('syaw').setValue( Ext.getCmp('yaw').getValue() );
  705. orientationEditorWindow.hide();
  706. }
  707. }]
  708. });
  709. orientationEditorWindow.show();
  710. cubeViewport = new Viewport({
  711. element: document.getElementsByClassName('cube')[0],
  712. fps: 20,
  713. sensivity: .1,
  714. sensivityFade: .93,
  715. speed: 2,
  716. touchSensivity: 1.5
  717. });
  718. cube = new Cube({
  719. viewport: cubeViewport,
  720. element: document.getElementsByClassName('cube')[0]
  721. });
  722. } else {
  723. orientationEditorWindow.show();
  724. };
  725. setCubeOrientation( Ext.getCmp('sroll').getValue(), Ext.getCmp('spitch').getValue(), Ext.getCmp('syaw').getValue() );
  726. };
  727. function loadNodeLocationProps( NodeID ){
  728. //alert( 'Node: ' + NodeID );
  729. Ext.Ajax.request({
  730. url: '/lib/controller/getLocationNodeProps.php',
  731. params: {
  732. NID: <?=$SiteID;?>,
  733. UID: <?=$UserID;?>,
  734. SID: '<?=$Session;?>',
  735. NODE: NodeID
  736. },
  737. success: function( response, opts ){
  738. // If the response is JSON, you have to decode it
  739. var data = Ext.decode(response.responseText);
  740. var tPanel = Ext.getCmp('prop_content');
  741. tPanel.remove(0);
  742. tPanel.add( data );
  743. tPanel.doLayout();
  744. },
  745. failure: function( response, opts ) {
  746. //Ext.fly('some_div').update('Fail!');
  747. }/*,
  748. callback: function(options,success,response){
  749. // use this if you need to perform your own success/failure checking
  750. }*/
  751. });
  752. };
  753. function loadLocationEditor(){
  754. if( tlInterval!= null ){
  755. window.clearInterval( tlInterval );
  756. tlInterval = null;
  757. timelineObj = null;
  758. };
  759. var tPanel = Ext.getCmp('main_portal');
  760. tPanel.removeAll( true );
  761. Ext.getCmp('main_content').setTitle( 'Location Map' );
  762. tPanel.add({
  763. columnWidth: 0.83,
  764. frame: false,
  765. border: false,
  766. items: [{
  767. layout: 'fit',
  768. height: PanelH-150,
  769. flex: 1,
  770. //border: true,
  771. items:{
  772. id: 'location_map'
  773. }
  774. },{
  775. layout: 'table',
  776. title: 'Site Properties',
  777. fileUpload: true,
  778. flex: 1,
  779. defaults: {
  780. bodyStyle:'padding:20px'
  781. },
  782. layoutConfig: {
  783. // The total column count must be specified here
  784. columns: 7
  785. },
  786. items:[{
  787. html: 'System Anchor Lat:'
  788. },{
  789. xtype: 'textfield',
  790. id: 'siteLat',
  791. value: SiteLat
  792. },{
  793. html: 'Lon:'
  794. },{
  795. xtype: 'textfield',
  796. id: 'siteLon',
  797. value: SiteLon
  798. },{
  799. html: 'Alt:'
  800. },{
  801. xtype: 'textfield',
  802. id: 'siteAlt',
  803. value: SiteAlt
  804. },{
  805. xtype: 'button',
  806. text: 'Update',
  807. handler: updateSiteAnchor
  808. },{
  809. html: 'Map Type:'
  810. },{
  811. xtype: 'radio',
  812. name: 'map_type',
  813. boxLabel: 'Regular WGS84 Map',
  814. checked: true,
  815. value: 0
  816. },{
  817. xtype: 'radio',
  818. name: 'map_type',
  819. boxLabel: 'Custom Image',
  820. value: 1
  821. },{
  822. xtype: 'combo',
  823. disabled: true,
  824. typeAhead: true,
  825. triggerAction: 'all',
  826. lazyRender:true,
  827. mode: 'local',
  828. store: new Ext.data.ArrayStore({
  829. id: 0,
  830. fields: ['myId', 'displayText' ],
  831. data: [[1, 'item1'], [2, 'item2']]
  832. }),
  833. valueField: 'myId',
  834. displayField: 'displayText'
  835. },{
  836. colspan: 2,
  837. xtype: 'fileuploadfield',
  838. id: 'form-file',
  839. disabled: true,
  840. emptyText: 'Select an image',
  841. fieldLabel: 'Photo',
  842. name: 'photo-path',
  843. buttonText: 'UPLOAD',
  844. buttonCfg: {
  845. iconCls: 'upload-icon'
  846. }
  847. }]
  848. }]
  849. });
  850. tPanel.add({
  851. title: 'Properties',
  852. xtype: 'panel',
  853. flex: 1,
  854. height: 700,
  855. columnWidth: 0.17,
  856. layout: 'fit',
  857. id: 'prop_content',
  858. items:{
  859. html: '<center>Select Item From Map</center>'
  860. }
  861. });
  862. tPanel.doLayout();
  863. map = L.map('location_map').setView([SiteLat, SiteLon], 17);
  864. L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).bindPopup("<b>System Anchor!</b>");//.openPopup();
  865. /*
  866. var map = L.map('map', {
  867. crs: L.CRS.Simple
  868. });
  869. var map = L.map('map', {
  870. crs: L.CRS.Simple,
  871. minZoom: -5
  872. });
  873. var bounds = [[0,0], [1000,1000]];
  874. var image = L.imageOverlay('uqm_map_full.png', bounds).addTo(map);
  875. var bounds = [[-26.5,-25], [1021.5,1023]];
  876. var image = L.imageOverlay('uqm_map_full.png', bounds).addTo(map);
  877. map.fitBounds(bounds);
  878. var sol = L.latLng([ 145, 175.2 ]);
  879. L.marker(sol).addTo(map);
  880. map.setView( [70, 120], 1);
  881. var travel = L.polyline([sol, deneb]).addTo(map);
  882. L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
  883. attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  884. maxZoom: 18,
  885. id: 'mapbox/streets-v11',
  886. tileSize: 512,
  887. zoomOffset: -1,
  888. accessToken: 'your.mapbox.access.token'
  889. }).addTo(mymap);
  890. var circle = L.circle([51.508, -0.11], {
  891. color: 'red',
  892. fillColor: '#f03',
  893. fillOpacity: 0.5,
  894. radius: 500
  895. }).addTo(mymap);
  896. var polygon = L.polygon([
  897. [51.509, -0.08],
  898. [51.503, -0.06],
  899. [51.51, -0.047]
  900. ]).addTo(mymap);
  901. marker.bindPopup("<b>Hello world!</b><br>I am a popup.").openPopup();
  902. circle.bindPopup("I am a circle.");
  903. polygon.bindPopup("I am a polygon.");
  904. function onMapClick(e) {
  905. alert("You clicked the map at " + e.latlng);
  906. }
  907. mymap.on('click', onMapClick);
  908. */
  909. L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  910. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  911. }).addTo(map);
  912. loadLocationNodes();
  913. };