From f04f5668f1c8d1063067e8bd202545a96ec0ab69 Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Wed, 25 Jul 2018 15:02:37 +0300 Subject: [PATCH] refactoring --- kvmd/web/index.html | 6 +++--- kvmd/web/js/ui.js | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kvmd/web/index.html b/kvmd/web/index.html index 05507b07..db1d5e06 100644 --- a/kvmd/web/index.html +++ b/kvmd/web/index.html @@ -37,7 +37,7 @@
  • - + Mass Storage ↴ diff --git a/kvmd/web/js/ui.js b/kvmd/web/js/ui.js index e6b3de33..dd7d7a4d 100644 --- a/kvmd/web/js/ui.js +++ b/kvmd/web/js/ui.js @@ -1,5 +1,9 @@ var ui = new function() { this.init = function() { + Array.prototype.forEach.call(document.getElementsByClassName("ctl-item"), function(el_item) { + el_item.onclick = function() { __toggleMenu(el_item); }; + }); + window.onclick = __windowClickHandler; Array.prototype.forEach.call(document.getElementsByClassName("window"), function(el_window) { @@ -8,7 +12,7 @@ var ui = new function() { }); }; - this.toggleMenu = function(el_a) { + var __toggleMenu = function(el_a) { Array.prototype.forEach.call(document.getElementsByClassName("ctl-item"), function(el_item) { var el_menu = el_item.parentElement.querySelector(".ctl-dropdown-content"); if (el_item === el_a && el_menu.style.display === "none") { @@ -31,7 +35,7 @@ var ui = new function() { return; } } - ui.toggleMenu(null); + __toggleMenu(null); } };