summaryrefslogtreecommitdiff
path: root/web/js
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-11-14 02:52:00 +0300
committerDevaev Maxim <[email protected]>2018-11-14 02:57:47 +0300
commit2916c7fe067ee8093edfda62d2a0bd51b70e4090 (patch)
treef76bde4fadd84c5dd0a3121cc8f8d0f820d7bc15 /web/js
parent49a09a6ba168ada706999e9955b531b975edbd5f (diff)
refactoring
Diffstat (limited to 'web/js')
-rw-r--r--web/js/kvm/atx.js (renamed from web/js/atx.js)0
-rw-r--r--web/js/kvm/hid.js (renamed from web/js/hid.js)0
-rw-r--r--web/js/kvm/keyboard.js (renamed from web/js/keyboard.js)0
-rw-r--r--web/js/kvm/main.js23
-rw-r--r--web/js/kvm/mouse.js (renamed from web/js/mouse.js)0
-rw-r--r--web/js/kvm/msd.js (renamed from web/js/msd.js)0
-rw-r--r--web/js/kvm/session.js (renamed from web/js/session.js)27
-rw-r--r--web/js/kvm/stream.js (renamed from web/js/stream.js)0
-rw-r--r--web/js/main.js15
-rw-r--r--web/js/ui.js35
10 files changed, 53 insertions, 47 deletions
diff --git a/web/js/atx.js b/web/js/kvm/atx.js
index b75b901b..b75b901b 100644
--- a/web/js/atx.js
+++ b/web/js/kvm/atx.js
diff --git a/web/js/hid.js b/web/js/kvm/hid.js
index 5b13480f..5b13480f 100644
--- a/web/js/hid.js
+++ b/web/js/kvm/hid.js
diff --git a/web/js/keyboard.js b/web/js/kvm/keyboard.js
index ee9a7ba1..ee9a7ba1 100644
--- a/web/js/keyboard.js
+++ b/web/js/kvm/keyboard.js
diff --git a/web/js/kvm/main.js b/web/js/kvm/main.js
new file mode 100644
index 00000000..3cb65402
--- /dev/null
+++ b/web/js/kvm/main.js
@@ -0,0 +1,23 @@
+var ui;
+
+function main() {
+ if (
+ !window.navigator
+ || window.navigator.userAgent.indexOf("MSIE ") > 0
+ || window.navigator.userAgent.indexOf("Trident/") > 0
+ || window.navigator.userAgent.indexOf("Edge/") > 0
+ ) {
+ $("bad-browser-modal").style.visibility = "visible";
+ } else {
+ ui = new Ui();
+
+ tools.setOnClick($("show-about-button"), () => ui.showWindow($("about-window")));
+ tools.setOnClick($("show-keyboard-button"), () => ui.showWindow($("keyboard-window")));
+ tools.setOnClick($("show-stream-button"), () => ui.showWindow($("stream-window")));
+ tools.setOnClick($("open-log-button"), () => ui.open("kvmd/log?seek=3600&follow=1", "_blank"));
+
+ ui.showWindow($("stream-window"));
+
+ new Session();
+ }
+}
diff --git a/web/js/mouse.js b/web/js/kvm/mouse.js
index 9f93a659..9f93a659 100644
--- a/web/js/mouse.js
+++ b/web/js/kvm/mouse.js
diff --git a/web/js/msd.js b/web/js/kvm/msd.js
index bbc86370..bbc86370 100644
--- a/web/js/msd.js
+++ b/web/js/kvm/msd.js
diff --git a/web/js/session.js b/web/js/kvm/session.js
index 9f726a1d..5a89813a 100644
--- a/web/js/session.js
+++ b/web/js/kvm/session.js
@@ -1,4 +1,4 @@
-function Session(hid, atx, msd, streamer) {
+function Session() {
// var self = this;
/********************************************************************************/
@@ -8,6 +8,11 @@ function Session(hid, atx, msd, streamer) {
var __ping_timer = null;
var __missed_heartbeats = 0;
+ var __hid = new Hid();
+ var __atx = new Atx();
+ var __msd = new Msd();
+ var __streamer = new Streamer();
+
var __init__ = function() {
$("link-led").title = "Not connected yet...";
__loadKvmdVersion();
@@ -53,10 +58,10 @@ function Session(hid, atx, msd, streamer) {
$("link-led").className = "led-green";
$("link-led").title = "Connected";
tools.debug("Session: socket opened:", event);
- streamer.loadInitialState();
- atx.loadInitialState();
- msd.loadInitialState();
- hid.setSocket(__ws);
+ __streamer.loadInitialState();
+ __atx.loadInitialState();
+ __msd.loadInitialState();
+ __hid.setSocket(__ws);
__missed_heartbeats = 0;
__ping_timer = setInterval(__pingServer, 1000);
};
@@ -68,11 +73,11 @@ function Session(hid, atx, msd, streamer) {
__missed_heartbeats = 0;
} else if (event.msg_type === "event") {
if (event.msg.event === "streamer_state") {
- streamer.setState(event.msg.event_attrs);
+ __streamer.setState(event.msg.event_attrs);
} else if (event.msg.event === "atx_state") {
- atx.setState(event.msg.event_attrs);
+ __atx.setState(event.msg.event_attrs);
} else if (event.msg.event === "msd_state") {
- msd.setState(event.msg.event_attrs);
+ __msd.setState(event.msg.event_attrs);
}
}
};
@@ -93,9 +98,9 @@ function Session(hid, atx, msd, streamer) {
clearInterval(__ping_timer);
__ping_timer = null;
}
- streamer.clearState();
- atx.clearState();
- hid.setSocket(null);
+ __streamer.clearState();
+ __atx.clearState();
+ __hid.setSocket(null);
__ws = null;
setTimeout(function() {
$("link-led").className = "led-yellow";
diff --git a/web/js/stream.js b/web/js/kvm/stream.js
index 630eaa25..630eaa25 100644
--- a/web/js/stream.js
+++ b/web/js/kvm/stream.js
diff --git a/web/js/main.js b/web/js/main.js
deleted file mode 100644
index d82939c9..00000000
--- a/web/js/main.js
+++ /dev/null
@@ -1,15 +0,0 @@
-var ui;
-
-function main() {
- if (
- !window.navigator
- || window.navigator.userAgent.indexOf("MSIE ") > 0
- || window.navigator.userAgent.indexOf("Trident/") > 0
- || window.navigator.userAgent.indexOf("Edge/") > 0
- ) {
- $("bad-browser-modal").style.visibility = "visible";
- } else {
- ui = new Ui();
- new Session(new Hid(), new Atx(), new Msd(), new Streamer());
- }
-}
diff --git a/web/js/ui.js b/web/js/ui.js
index 0c5d5888..754e80b0 100644
--- a/web/js/ui.js
+++ b/web/js/ui.js
@@ -5,7 +5,7 @@ function Ui() {
var __top_z_index = 0;
var __windows = [];
- var __ctl_items = [];
+ var __menu_items = [];
var __init__ = function() {
Array.prototype.forEach.call(document.querySelectorAll("button"), function(el_button) {
@@ -14,9 +14,9 @@ function Ui() {
el_button.ontouchstart = function() {};
});
- Array.prototype.forEach.call($$("ctl-item"), function(el_item) {
+ Array.prototype.forEach.call($$("menu-item"), function(el_item) {
tools.setOnClick(el_item, () => __toggleMenu(el_item));
- __ctl_items.push(el_item);
+ __menu_items.push(el_item);
});
Array.prototype.forEach.call($$("window"), function(el_window) {
@@ -37,13 +37,6 @@ function Ui() {
window.addEventListener("resize", () => __organizeWindowsOnResize(false));
window.addEventListener("orientationchange", () => __organizeWindowsOnResize(true));
-
- tools.setOnClick($("show-about-button"), () => self.showWindow($("about-window")));
- tools.setOnClick($("show-keyboard-button"), () => self.showWindow($("keyboard-window")));
- tools.setOnClick($("show-stream-button"), () => self.showWindow($("stream-window")));
- tools.setOnClick($("open-log-button"), () => window.open("kvmd/log?seek=3600&follow=1", "_blank"));
-
- self.showWindow($("stream-window"));
};
/********************************************************************************/
@@ -127,7 +120,7 @@ function Ui() {
if (!__isWindowOnPage(el_window) || el_window.hasAttribute("data-centered") || center) {
var view = self.getViewGeometry();
var rect = el_window.getBoundingClientRect();
- el_window.style.top = Math.max($("ctl").clientHeight, Math.round((view.bottom - rect.height) / 2)) + "px";
+ el_window.style.top = Math.max($("menu").clientHeight, Math.round((view.bottom - rect.height) / 2)) + "px";
el_window.style.left = Math.round((view.right - rect.width) / 2) + "px";
el_window.setAttribute("data-centered", "");
}
@@ -139,7 +132,7 @@ function Ui() {
self.getViewGeometry = function() {
return {
- top: $("ctl").clientHeight,
+ top: $("menu").clientHeight,
bottom: Math.max(document.documentElement.clientHeight, window.innerHeight || 0),
left: 0,
right: Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
@@ -161,15 +154,15 @@ function Ui() {
var __toggleMenu = function(el_a) {
var all_hidden = true;
- __ctl_items.forEach(function(el_item) {
- var el_menu = el_item.parentElement.querySelector(".ctl-dropdown-content");
+ __menu_items.forEach(function(el_item) {
+ var el_menu = el_item.parentElement.querySelector(".menu-dropdown-content");
if (el_item === el_a && window.getComputedStyle(el_menu, null).visibility === "hidden") {
el_item.focus();
- el_item.classList.add("ctl-item-selected");
+ el_item.classList.add("menu-item-selected");
el_menu.style.visibility = "visible";
all_hidden &= false;
} else {
- el_item.classList.remove("ctl-item-selected");
+ el_item.classList.remove("menu-item-selected");
el_menu.style.visibility = "hidden";
}
});
@@ -190,15 +183,15 @@ function Ui() {
var __closeAllMenues = function() {
document.onkeyup = null;
- __ctl_items.forEach(function(el_item) {
- var el_menu = el_item.parentElement.querySelector(".ctl-dropdown-content");
- el_item.classList.remove("ctl-item-selected");
+ __menu_items.forEach(function(el_item) {
+ var el_menu = el_item.parentElement.querySelector(".menu-dropdown-content");
+ el_item.classList.remove("menu-item-selected");
el_menu.style.visibility = "hidden";
});
};
var __globalMouseButtonHandler = function(event) {
- if (!event.target.matches(".ctl-item")) {
+ if (!event.target.matches(".menu-item")) {
for (var el_item = event.target; el_item && el_item !== document; el_item = el_item.parentNode) {
if (el_item.hasAttribute("data-force-hide-menu")) {
break;
@@ -216,7 +209,7 @@ function Ui() {
Array.prototype.forEach.call($$("window"), function(el_window) {
if (el_window.style.visibility === "visible" && (orientation || el_window.hasAttribute("data-centered"))) {
var rect = el_window.getBoundingClientRect();
- el_window.style.top = Math.max($("ctl").clientHeight, Math.round((view.bottom - rect.height) / 2)) + "px";
+ el_window.style.top = Math.max($("menu").clientHeight, Math.round((view.bottom - rect.height) / 2)) + "px";
el_window.style.left = Math.round((view.right - rect.width) / 2) + "px";
el_window.setAttribute("data-centered", "");
}