mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
using js modules
This commit is contained in:
parent
ad97aecaf4
commit
98468bfa30
@ -1,20 +1,3 @@
|
|||||||
globals:
|
|
||||||
Atx: true
|
|
||||||
Hid: true
|
|
||||||
Keyboard: true
|
|
||||||
Mouse: true
|
|
||||||
Msd: true
|
|
||||||
Session: true
|
|
||||||
Streamer: true
|
|
||||||
Keypad: true
|
|
||||||
WindowManager: true
|
|
||||||
wm: true
|
|
||||||
tools: true
|
|
||||||
checkBrowser: true
|
|
||||||
"$": true
|
|
||||||
"$$": true
|
|
||||||
"$$$": true
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
browser: true
|
browser: true
|
||||||
es6: true
|
es6: true
|
||||||
@ -23,6 +6,7 @@ extends: "eslint:recommended"
|
|||||||
|
|
||||||
parserOptions:
|
parserOptions:
|
||||||
ecmaVersion: 6
|
ecmaVersion: 6
|
||||||
|
sourceType: module
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
indent:
|
indent:
|
||||||
|
|||||||
@ -41,12 +41,10 @@
|
|||||||
<link rel="stylesheet" href="share/css/start.css">
|
<link rel="stylesheet" href="share/css/start.css">
|
||||||
<link rel="stylesheet" href="share/css/index/index.css">
|
<link rel="stylesheet" href="share/css/index/index.css">
|
||||||
|
|
||||||
<script src="share/js/bb.js"></script>
|
<script type="module">
|
||||||
<script src="share/js/tools.js"></script>
|
import {main} from "./share/js/index/main.js";
|
||||||
<script src="share/js/wm.js"></script>
|
main();
|
||||||
<script src="share/js/index/main.js"></script>
|
</script>
|
||||||
|
|
||||||
<script>window.onload = main;</script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -38,10 +38,12 @@
|
|||||||
<link rel="stylesheet" href="../share/css/main.css">
|
<link rel="stylesheet" href="../share/css/main.css">
|
||||||
<link rel="stylesheet" href="../share/css/start.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 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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -50,20 +50,10 @@
|
|||||||
<link rel="stylesheet" href="../share/css/kvm/keyboard.css">
|
<link rel="stylesheet" href="../share/css/kvm/keyboard.css">
|
||||||
<link rel="stylesheet" href="../share/css/kvm/about.css">
|
<link rel="stylesheet" href="../share/css/kvm/about.css">
|
||||||
|
|
||||||
<script src="../share/js/bb.js"></script>
|
<script type="module">
|
||||||
<script src="../share/js/tools.js"></script>
|
import {main} from "/share/js/kvm/main.js";
|
||||||
<script src="../share/js/wm.js"></script>
|
main();
|
||||||
<script src="../share/js/keypad.js"></script>
|
</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>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="body-no-select">
|
<body class="body-no-select">
|
||||||
|
|||||||
@ -40,12 +40,10 @@
|
|||||||
<link rel="stylesheet" href="../share/css/modals.css">
|
<link rel="stylesheet" href="../share/css/modals.css">
|
||||||
<link rel="stylesheet" href="../share/css/login/login.css">
|
<link rel="stylesheet" href="../share/css/login/login.css">
|
||||||
|
|
||||||
<script src="../share/js/bb.js"></script>
|
<script type="module">
|
||||||
<script src="../share/js/tools.js"></script>
|
import {main} from "/share/js/login/main.js";
|
||||||
<script src="../share/js/wm.js"></script>
|
main();
|
||||||
<script src="../share/js/login/main.js"></script>
|
</script>
|
||||||
|
|
||||||
<script>window.onload = main;</script>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function checkBrowser() {
|
export function checkBrowser() {
|
||||||
if (
|
if (
|
||||||
!window.navigator
|
!window.navigator
|
||||||
|| window.navigator.userAgent.indexOf("MSIE ") > 0
|
|| window.navigator.userAgent.indexOf("MSIE ") > 0
|
||||||
|
|||||||
@ -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()) {
|
if (checkBrowser()) {
|
||||||
__setAppText();
|
__setAppText();
|
||||||
|
|||||||
@ -20,7 +20,10 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function main() {
|
import {$} from "../tools.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function main() {
|
||||||
let host = window.location.hostname;
|
let host = window.location.hostname;
|
||||||
let site = window.location.protocol + "//" + window.location.host;
|
let site = window.location.protocol + "//" + window.location.host;
|
||||||
$("ipmi-text").innerHTML = `
|
$("ipmi-text").innerHTML = `
|
||||||
|
|||||||
@ -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;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -20,7 +20,11 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function Atx() {
|
import {tools, $} from "../tools.js";
|
||||||
|
import {wm} from "../wm.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function Atx() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -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;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -20,7 +20,11 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function Keyboard() {
|
import {tools, $} from "../tools.js";
|
||||||
|
import {Keypad} from "../keypad.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function Keyboard() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -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()) {
|
if (checkBrowser()) {
|
||||||
window.onbeforeunload = function(event) {
|
window.onbeforeunload = function(event) {
|
||||||
let text = "Are you sure you want to close Pi-KVM session?";
|
let text = "Are you sure you want to close Pi-KVM session?";
|
||||||
@ -30,7 +35,7 @@ function main() {
|
|||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
wm = new WindowManager();
|
initWindowManager();
|
||||||
|
|
||||||
tools.setOnClick($("show-about-button"), () => wm.showWindow($("about-window")));
|
tools.setOnClick($("show-about-button"), () => wm.showWindow($("about-window")));
|
||||||
tools.setOnClick($("show-keyboard-button"), () => wm.showWindow($("keyboard-window")));
|
tools.setOnClick($("show-keyboard-button"), () => wm.showWindow($("keyboard-window")));
|
||||||
|
|||||||
@ -20,7 +20,11 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function Mouse() {
|
import {tools, $} from "../tools.js";
|
||||||
|
import {Keypad} from "../keypad.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function Mouse() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -20,7 +20,11 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function Msd() {
|
import {tools, $} from "../tools.js";
|
||||||
|
import {wm} from "../wm.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function Msd() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -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;
|
// var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
@ -20,7 +20,11 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
function Streamer() {
|
import {tools, $} from "../tools.js";
|
||||||
|
import {wm} from "../wm.js";
|
||||||
|
|
||||||
|
|
||||||
|
export function Streamer() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
@ -103,7 +107,7 @@ function Streamer() {
|
|||||||
__client_id = stream_client.slice(stream_client.indexOf("/") + 1);
|
__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;
|
__client_fps = stream.clients_stat[__client_id].fps;
|
||||||
} else {
|
} else {
|
||||||
__clearState();
|
__clearState();
|
||||||
|
|||||||
@ -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()) {
|
if (checkBrowser()) {
|
||||||
wm = new WindowManager();
|
initWindowManager();
|
||||||
|
|
||||||
tools.setOnClick($("login-button"), __login);
|
tools.setOnClick($("login-button"), __login);
|
||||||
$("user-input").onkeyup = $("passwd-input").onkeyup = function(event) {
|
$("user-input").onkeyup = $("passwd-input").onkeyup = function(event) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
var tools = new function() {
|
export var tools = new function() {
|
||||||
let __debug = (new URL(window.location.href)).searchParams.get("debug");
|
let __debug = (new URL(window.location.href)).searchParams.get("debug");
|
||||||
|
|
||||||
this.setDefault = function(dict, key, value) {
|
this.setDefault = function(dict, key, value) {
|
||||||
@ -160,6 +160,6 @@ var tools = new function() {
|
|||||||
this.info("Browser:", this.browser);
|
this.info("Browser:", this.browser);
|
||||||
};
|
};
|
||||||
|
|
||||||
var $ = (id) => document.getElementById(id);
|
export var $ = (id) => document.getElementById(id);
|
||||||
var $$ = (cls) => document.getElementsByClassName(cls);
|
export var $$ = (cls) => document.getElementsByClassName(cls);
|
||||||
var $$$ = (selector) => document.querySelectorAll(selector);
|
export var $$$ = (selector) => document.querySelectorAll(selector);
|
||||||
|
|||||||
@ -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;
|
var self = this;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user