summaryrefslogtreecommitdiff
path: root/web/kbn_assets/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/kbn_assets/app.js')
-rw-r--r--web/kbn_assets/app.js79
1 files changed, 56 insertions, 23 deletions
diff --git a/web/kbn_assets/app.js b/web/kbn_assets/app.js
index d575a5a..6081681 100644
--- a/web/kbn_assets/app.js
+++ b/web/kbn_assets/app.js
@@ -1,7 +1,6 @@
-(function() {
var RE_WHITESPACE = /[\t\r\n\f]/g
-window.ajax = {
+var ajax = {
get: function(url, data) {
if (typeof data == 'object') {
var index = 0;
@@ -38,35 +37,37 @@ window.ajax = {
}
};
-window.extend = function(a, b) {
+function extend(a, b) {
return Object.assign(a, b);
}
-window.ge = function(id) {
+function ge(id) {
return document.getElementById(id);
}
-var ua = navigator.userAgent.toLowerCase();
-window.browserInfo = {
- version: (ua.match(/.+(?:me|ox|on|rv|it|ra|ie)[\/: ]([\d.]+)/) || [0,'0'])[1],
- //opera: /opera/i.test(ua),
- msie: (/msie/i.test(ua) && !/opera/i.test(ua)) || /trident/i.test(ua),
- mozilla: /firefox/i.test(ua),
- android: /android/i.test(ua),
- mac: /mac/i.test(ua),
- samsungBrowser: /samsungbrowser/i.test(ua),
- chrome: /chrome/i.test(ua),
- safari: /safari/i.test(ua),
- mobile: /iphone|ipod|ipad|opera mini|opera mobi|iemobile|android/i.test(ua),
- operaMini: /opera mini/i.test(ua),
- ios: /iphone|ipod|ipad|watchos/i.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1),
-};
+(function() {
+ var ua = navigator.userAgent.toLowerCase();
+ window.browserInfo = {
+ version: (ua.match(/.+(?:me|ox|on|rv|it|ra|ie)[\/: ]([\d.]+)/) || [0,'0'])[1],
+ //opera: /opera/i.test(ua),
+ msie: (/msie/i.test(ua) && !/opera/i.test(ua)) || /trident/i.test(ua),
+ mozilla: /firefox/i.test(ua),
+ android: /android/i.test(ua),
+ mac: /mac/i.test(ua),
+ samsungBrowser: /samsungbrowser/i.test(ua),
+ chrome: /chrome/i.test(ua),
+ safari: /safari/i.test(ua),
+ mobile: /iphone|ipod|ipad|opera mini|opera mobi|iemobile|android/i.test(ua),
+ operaMini: /opera mini/i.test(ua),
+ ios: /iphone|ipod|ipad|watchos/i.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1),
+ };
+})();
-window.isTouchDevice = function() {
+function isTouchDevice() {
return 'ontouchstart' in window || navigator.msMaxTouchPoints;
}
-window.hasClass = function(el, name) {
+function hasClass(el, name) {
if (!el)
throw new Error('hasClass: invalid element')
@@ -80,7 +81,7 @@ window.hasClass = function(el, name) {
}
}
-window.addClass = function(el, name) {
+function addClass(el, name) {
if (!hasClass(el, name)) {
el.className = (el.className ? el.className + ' ' : '') + name;
return true
@@ -88,6 +89,39 @@ window.addClass = function(el, name) {
return false
}
+function removeClass(el, name) {
+ if (!el)
+ throw new Error('removeClass: invalid element')
+
+ if (Array.isArray(name)) {
+ for (var i = 0; i < name.length; i++)
+ removeClass(el, name[i]);
+ return;
+ }
+ el.className = ((el.className || '').replace((new RegExp('(\\s|^)' + name + '(\\s|$)')), ' ')).trim()
+}
+
+function indexInit() {
+ var blocks = ['zones', 'all'];
+ for (var i = 0; i < blocks.length; i++) {
+ var button = ge('cam_'+blocks[i]+'_btn');
+ button.addEventListener('click', function(e) {
+ var selected = e.target.getAttribute('data-id');
+ for (var j = 0; j < blocks.length; j++) {
+ var button = ge('cam_'+blocks[j]+'_btn');
+ var content = ge('cam_'+blocks[j]);
+ if (blocks[j] === selected) {
+ addClass(button, 'active');
+ content.style.display = '';
+ } else {
+ removeClass(button, 'active');
+ content.style.display = 'none';
+ }
+ }
+ });
+ }
+}
+
window.Cameras = {
hlsOptions: null,
h265webjsOptions: null,
@@ -316,7 +350,6 @@ window.Cameras = {
return video.canPlayType('application/vnd.apple.mpegurl');
},
};
-})();
class ModemStatusUpdater {