diff options
author | Devaev Maxim <[email protected]> | 2019-07-13 06:38:55 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-07-13 06:38:55 +0300 |
commit | 98468bfa3069e76862be8e0a19bbe8e3fc6748fa (patch) | |
tree | 8a2cf0083532b2d7058b194410bd32386a7f07d3 /web | |
parent | ad97aecaf4d043c59d018310b4d8f4852d30b6e0 (diff) |
using js modules
Diffstat (limited to 'web')
-rw-r--r-- | web/index.html | 10 | ||||
-rw-r--r-- | web/ipmi/index.html | 6 | ||||
-rw-r--r-- | web/kvm/index.html | 18 | ||||
-rw-r--r-- | web/login/index.html | 10 | ||||
-rw-r--r-- | web/share/js/bb.js | 2 | ||||
-rw-r--r-- | web/share/js/index/main.js | 9 | ||||
-rw-r--r-- | web/share/js/ipmi/main.js | 5 | ||||
-rw-r--r-- | web/share/js/keypad.js | 5 | ||||
-rw-r--r-- | web/share/js/kvm/atx.js | 6 | ||||
-rw-r--r-- | web/share/js/kvm/hid.js | 9 | ||||
-rw-r--r-- | web/share/js/kvm/keyboard.js | 6 | ||||
-rw-r--r-- | web/share/js/kvm/main.js | 11 | ||||
-rw-r--r-- | web/share/js/kvm/mouse.js | 6 | ||||
-rw-r--r-- | web/share/js/kvm/msd.js | 6 | ||||
-rw-r--r-- | web/share/js/kvm/session.js | 11 | ||||
-rw-r--r-- | web/share/js/kvm/stream.js | 8 | ||||
-rw-r--r-- | web/share/js/login/main.js | 9 | ||||
-rw-r--r-- | web/share/js/tools.js | 8 | ||||
-rw-r--r-- | web/share/js/wm.js | 11 |
19 files changed, 103 insertions, 53 deletions
diff --git a/web/index.html b/web/index.html index f6a75f3e..72c13d34 100644 --- a/web/index.html +++ b/web/index.html @@ -41,12 +41,10 @@ <link rel="stylesheet" href="share/css/start.css"> <link rel="stylesheet" href="share/css/index/index.css"> - <script src="share/js/bb.js"></script> - <script src="share/js/tools.js"></script> - <script src="share/js/wm.js"></script> - <script src="share/js/index/main.js"></script> - - <script>window.onload = main;</script> + <script type="module"> + import {main} from "./share/js/index/main.js"; + main(); + </script> </head> <body> diff --git a/web/ipmi/index.html b/web/ipmi/index.html index 3471706e..5a13234a 100644 --- a/web/ipmi/index.html +++ b/web/ipmi/index.html @@ -38,10 +38,12 @@ <link rel="stylesheet" href="../share/css/main.css"> <link rel="stylesheet" href="../share/css/start.css"> - <script src="../share/js/tools.js"></script> <script src="../share/js/ipmi/main.js"></script> - <script>window.onload = main;</script> + <script type="module"> + import {main} from "/share/js/ipmi/main.js"; + main(); + </script> </head> <body> diff --git a/web/kvm/index.html b/web/kvm/index.html index 56279005..3150a2f6 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -50,20 +50,10 @@ <link rel="stylesheet" href="../share/css/kvm/keyboard.css"> <link rel="stylesheet" href="../share/css/kvm/about.css"> - <script src="../share/js/bb.js"></script> - <script src="../share/js/tools.js"></script> - <script src="../share/js/wm.js"></script> - <script src="../share/js/keypad.js"></script> - <script src="../share/js/kvm/stream.js"></script> - <script src="../share/js/kvm/atx.js"></script> - <script src="../share/js/kvm/keyboard.js"></script> - <script src="../share/js/kvm/mouse.js"></script> - <script src="../share/js/kvm/hid.js"></script> - <script src="../share/js/kvm/msd.js"></script> - <script src="../share/js/kvm/session.js"></script> - <script src="../share/js/kvm/main.js"></script> - - <script>window.onload = main;</script> + <script type="module"> + import {main} from "/share/js/kvm/main.js"; + main(); + </script> </head> <body class="body-no-select"> diff --git a/web/login/index.html b/web/login/index.html index 248f877c..d5394c9d 100644 --- a/web/login/index.html +++ b/web/login/index.html @@ -40,12 +40,10 @@ <link rel="stylesheet" href="../share/css/modals.css"> <link rel="stylesheet" href="../share/css/login/login.css"> - <script src="../share/js/bb.js"></script> - <script src="../share/js/tools.js"></script> - <script src="../share/js/wm.js"></script> - <script src="../share/js/login/main.js"></script> - - <script>window.onload = main;</script> + <script type="module"> + import {main} from "/share/js/login/main.js"; + main(); + </script> </head> <body> diff --git a/web/share/js/bb.js b/web/share/js/bb.js index f5083df9..858517f2 100644 --- a/web/share/js/bb.js +++ b/web/share/js/bb.js @@ -20,7 +20,7 @@ *****************************************************************************/ -function checkBrowser() { +export function checkBrowser() { if ( !window.navigator || window.navigator.userAgent.indexOf("MSIE ") > 0 diff --git a/web/share/js/index/main.js b/web/share/js/index/main.js index 1173558c..fb4bdc71 100644 --- a/web/share/js/index/main.js +++ b/web/share/js/index/main.js @@ -20,10 +20,13 @@ *****************************************************************************/ -var wm; +import {tools, $} from "../tools.js"; +import {checkBrowser} from "../bb.js"; +import {wm, initWindowManager} from "../wm.js"; -function main() { - wm = new WindowManager(); + +export function main() { + initWindowManager(); if (checkBrowser()) { __setAppText(); diff --git a/web/share/js/ipmi/main.js b/web/share/js/ipmi/main.js index 243b46a2..7aa8b0cb 100644 --- a/web/share/js/ipmi/main.js +++ b/web/share/js/ipmi/main.js @@ -20,7 +20,10 @@ *****************************************************************************/ -function main() { +import {$} from "../tools.js"; + + +export function main() { let host = window.location.hostname; let site = window.location.protocol + "//" + window.location.host; $("ipmi-text").innerHTML = ` diff --git a/web/share/js/keypad.js b/web/share/js/keypad.js index bbc4ccb2..58bcef86 100644 --- a/web/share/js/keypad.js +++ b/web/share/js/keypad.js @@ -20,7 +20,10 @@ *****************************************************************************/ -function Keypad(keys_parent, key_callback) { +import {tools, $$$} from "./tools.js"; + + +export function Keypad(keys_parent, key_callback) { var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/atx.js b/web/share/js/kvm/atx.js index b718b99c..e95998f1 100644 --- a/web/share/js/kvm/atx.js +++ b/web/share/js/kvm/atx.js @@ -20,7 +20,11 @@ *****************************************************************************/ -function Atx() { +import {tools, $} from "../tools.js"; +import {wm} from "../wm.js"; + + +export function Atx() { var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/hid.js b/web/share/js/kvm/hid.js index 345b28eb..0e0adbea 100644 --- a/web/share/js/kvm/hid.js +++ b/web/share/js/kvm/hid.js @@ -20,7 +20,14 @@ *****************************************************************************/ -function Hid() { +import {tools, $, $$$} from "../tools.js"; +import {wm} from "../wm.js"; + +import {Keyboard} from "./keyboard.js"; +import {Mouse} from "./mouse.js"; + + +export function Hid() { var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/keyboard.js b/web/share/js/kvm/keyboard.js index 1a4563af..d573d924 100644 --- a/web/share/js/kvm/keyboard.js +++ b/web/share/js/kvm/keyboard.js @@ -20,7 +20,11 @@ *****************************************************************************/ -function Keyboard() { +import {tools, $} from "../tools.js"; +import {Keypad} from "../keypad.js"; + + +export function Keyboard() { var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/main.js b/web/share/js/kvm/main.js index dcbb1eeb..3059457b 100644 --- a/web/share/js/kvm/main.js +++ b/web/share/js/kvm/main.js @@ -20,9 +20,14 @@ *****************************************************************************/ -var wm; +import {tools, $} from "../tools.js"; +import {checkBrowser} from "../bb.js"; +import {wm, initWindowManager} from "../wm.js"; -function main() { +import {Session} from "./session.js"; + + +export function main() { if (checkBrowser()) { window.onbeforeunload = function(event) { let text = "Are you sure you want to close Pi-KVM session?"; @@ -30,7 +35,7 @@ function main() { return text; }; - wm = new WindowManager(); + initWindowManager(); tools.setOnClick($("show-about-button"), () => wm.showWindow($("about-window"))); tools.setOnClick($("show-keyboard-button"), () => wm.showWindow($("keyboard-window"))); diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index c2d961e6..5ec79444 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -20,7 +20,11 @@ *****************************************************************************/ -function Mouse() { +import {tools, $} from "../tools.js"; +import {Keypad} from "../keypad.js"; + + +export function Mouse() { var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/msd.js b/web/share/js/kvm/msd.js index 68cb3fb7..3b414376 100644 --- a/web/share/js/kvm/msd.js +++ b/web/share/js/kvm/msd.js @@ -20,7 +20,11 @@ *****************************************************************************/ -function Msd() { +import {tools, $} from "../tools.js"; +import {wm} from "../wm.js"; + + +export function Msd() { var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/session.js b/web/share/js/kvm/session.js index b01fbe34..d76e75ae 100644 --- a/web/share/js/kvm/session.js +++ b/web/share/js/kvm/session.js @@ -20,7 +20,16 @@ *****************************************************************************/ -function Session() { +import {tools, $} from "../tools.js"; +import {wm} from "../wm.js"; + +import {Hid} from "./hid.js"; +import {Atx} from "./atx.js"; +import {Msd} from "./msd.js"; +import {Streamer} from "./stream.js"; + + +export function Session() { // var self = this; /************************************************************************/ diff --git a/web/share/js/kvm/stream.js b/web/share/js/kvm/stream.js index a73d0d2d..8a664454 100644 --- a/web/share/js/kvm/stream.js +++ b/web/share/js/kvm/stream.js @@ -20,7 +20,11 @@ *****************************************************************************/ -function Streamer() { +import {tools, $} from "../tools.js"; +import {wm} from "../wm.js"; + + +export function Streamer() { var self = this; /************************************************************************/ @@ -103,7 +107,7 @@ function Streamer() { __client_id = stream_client.slice(stream_client.indexOf("/") + 1); } - if (stream.clients_stat.hasOwnProperty(__client_id)) { + if (Object.prototype.hasOwnProperty.call(stream.clients_stat, __client_id)) { __client_fps = stream.clients_stat[__client_id].fps; } else { __clearState(); diff --git a/web/share/js/login/main.js b/web/share/js/login/main.js index cd0746fc..3de2bf41 100644 --- a/web/share/js/login/main.js +++ b/web/share/js/login/main.js @@ -20,11 +20,14 @@ *****************************************************************************/ -var wm; +import {tools, $} from "../tools.js"; +import {checkBrowser} from "../bb.js"; +import {wm, initWindowManager} from "../wm.js"; -function main() { + +export function main() { if (checkBrowser()) { - wm = new WindowManager(); + initWindowManager(); tools.setOnClick($("login-button"), __login); $("user-input").onkeyup = $("passwd-input").onkeyup = function(event) { diff --git a/web/share/js/tools.js b/web/share/js/tools.js index 240fdc29..0498927c 100644 --- a/web/share/js/tools.js +++ b/web/share/js/tools.js @@ -20,7 +20,7 @@ *****************************************************************************/ -var tools = new function() { +export var tools = new function() { let __debug = (new URL(window.location.href)).searchParams.get("debug"); this.setDefault = function(dict, key, value) { @@ -160,6 +160,6 @@ var tools = new function() { this.info("Browser:", this.browser); }; -var $ = (id) => document.getElementById(id); -var $$ = (cls) => document.getElementsByClassName(cls); -var $$$ = (selector) => document.querySelectorAll(selector); +export var $ = (id) => document.getElementById(id); +export var $$ = (cls) => document.getElementsByClassName(cls); +export var $$$ = (selector) => document.querySelectorAll(selector); diff --git a/web/share/js/wm.js b/web/share/js/wm.js index 1732934f..586bceca 100644 --- a/web/share/js/wm.js +++ b/web/share/js/wm.js @@ -20,7 +20,16 @@ *****************************************************************************/ -function WindowManager() { +import {tools, $, $$, $$$} from "./tools.js"; + + +export var wm; + +export function initWindowManager() { + wm = new __WindowManager(); +} + +function __WindowManager() { var self = this; /************************************************************************/ |