|
@@ -14,6 +14,47 @@ if(!Array.prototype.indexOf) {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function setMainActive(loc){
|
|
|
|
+ var set = '';
|
|
|
|
+ if (typeof(loc) == 'object') {
|
|
|
|
+ for (var i = 0; i < loc.length; i++){
|
|
|
|
+ if (window.location.pathname == loc[i]){
|
|
|
|
+ set = 'active';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return set;
|
|
|
|
+ } else {
|
|
|
|
+ if (window.location.pathname == loc){
|
|
|
|
+ return 'active';
|
|
|
|
+ } else {
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function createMainNavigation() {
|
|
|
|
+ var nav = [
|
|
|
|
+ {name: 'Параметры', link: 'index.html', child:['/index.html', '/'], access: 2},
|
|
|
|
+ {name: 'Настройки', link: 'settings.html', child: '/settings.html', access: 1},
|
|
|
|
+ // {name: 'Уведомления', link: 'snmp.html', access: 1},
|
|
|
|
+ {name: 'Информация', link: 'info.html', child: '/info.html', access: 2},
|
|
|
|
+ {name: 'Журнал', link: 'history.html', child: ['/history.html', '/ups_history.html'], access: 2}
|
|
|
|
+ ];
|
|
|
|
+ for (var i = 0; i < nav.length; i++) {
|
|
|
|
+ var el = document.createElement('a');
|
|
|
|
+ el.innerHTML = nav[i].name;
|
|
|
|
+ el.href = nav[i].link;
|
|
|
|
+
|
|
|
|
+ el.className = setMainActive(nav[i].child);
|
|
|
|
+ var ls = document.createElement('li');
|
|
|
|
+ ls.appendChild(el);
|
|
|
|
+ if (+getCookie('role') > nav[i].access){
|
|
|
|
+ ls.style.display = 'none';
|
|
|
|
+ }
|
|
|
|
+ $('nav').appendChild(ls);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
function createSubNavigation(){
|
|
function createSubNavigation(){
|
|
var subnav = document.createElement('div');
|
|
var subnav = document.createElement('div');
|
|
subnav.className = 'subnav';
|
|
subnav.className = 'subnav';
|