From 104498dec0228fd01a0971d4cda103c32b51c706 Mon Sep 17 00:00:00 2001 From: Sergey Stepanov Date: Mon, 18 Mar 2024 13:45:01 +0300 Subject: [PATCH] Fix wrong import order of some modules --- web/js/app.js | 24 ++++++------------------ web/js/gui.js | 2 +- web/js/input/touch.js | 16 ++++++++-------- web/js/network/socket.js | 2 +- 4 files changed, 16 insertions(+), 28 deletions(-) diff --git a/web/js/app.js b/web/js/app.js index 5e951d26b..408125dca 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -1,3 +1,9 @@ +import {log} from 'log'; +import {opts, settings} from 'settings'; + +settings.init(); +log.level = settings.loadOr(opts.LOG_LEVEL, log.DEFAULT); + import {api} from 'api'; import { pub, @@ -36,8 +42,6 @@ import { } from 'event'; import {gui} from 'gui'; import {keyboard, KEY, joystick, retropad, touch} from 'input'; -import {log} from 'log'; -import {opts, settings} from 'settings'; import {socket, webrtc} from 'network'; import {debounce} from 'utils'; @@ -512,22 +516,6 @@ sub(SETTINGS_CHANGED, () => { // initial app state setState(app.state.eden); -settings.init(); - -(() => { - let lvl = settings.loadOr(opts.LOG_LEVEL, log.DEFAULT); - // migrate old log level options - // !to remove at some point - if (isNaN(lvl)) { - console.warn( - `The log value [${lvl}] is not supported! ` + - `The default value [debug] will be used instead.`); - settings.set(opts.LOG_LEVEL, `${log.DEFAULT}`) - lvl = log.DEFAULT - } - log.level = lvl -})(); - keyboard.init(); joystick.init(); touch.init(); diff --git a/web/js/gui.js b/web/js/gui.js index 0d295ea17..8be85b190 100644 --- a/web/js/gui.js +++ b/web/js/gui.js @@ -31,7 +31,7 @@ const select = (key = '', callback = () => ({}), values = {values: [], labels: [ }; el.append(select); - select.append(_option('none', current === '')); + select.append(_option(0, current === '', 'none')); values.values.forEach((value, index) => { select.append(_option(value, current === value, values.labels?.[index])); }); diff --git a/web/js/input/touch.js b/web/js/input/touch.js index d60a30b4c..fb2c1ed1d 100644 --- a/web/js/input/touch.js +++ b/web/js/input/touch.js @@ -292,14 +292,6 @@ playerSlider.onkeydown = (e) => { e.preventDefault(); } -// Bind events for menu -// TODO change this flow -pub(MENU_HANDLER_ATTACHED, {event: 'mousedown', handler: handleMenuDown}); -pub(MENU_HANDLER_ATTACHED, {event: 'touchstart', handler: handleMenuDown}); -pub(MENU_HANDLER_ATTACHED, {event: 'touchend', handler: handleMenuUp}); - -sub(DPAD_TOGGLE, (data) => onDpadToggle(data.checked)); - /** * Touch controls. * @@ -311,6 +303,14 @@ sub(DPAD_TOGGLE, (data) => onDpadToggle(data.checked)); */ export const touch = { init: () => { + // Bind events for menu + // TODO change this flow + pub(MENU_HANDLER_ATTACHED, {event: 'mousedown', handler: handleMenuDown}); + pub(MENU_HANDLER_ATTACHED, {event: 'touchstart', handler: handleMenuDown}); + pub(MENU_HANDLER_ATTACHED, {event: 'touchend', handler: handleMenuUp}); + + sub(DPAD_TOGGLE, (data) => onDpadToggle(data.checked)); + // add buttons into the state 🤦 Array.from(document.querySelectorAll('.btn,.btn-big')).forEach((el) => { vpadState[getKey(el)] = false; diff --git a/web/js/network/socket.js b/web/js/network/socket.js index 47314d9d9..e153f4412 100644 --- a/web/js/network/socket.js +++ b/web/js/network/socket.js @@ -20,7 +20,7 @@ const init = (roomId, wid, zone) => { let objParams = {room_id: roomId, zone: zone}; if (wid) objParams.wid = wid; const url = buildUrl(objParams) - console.info(`[ws] connecting to ${url}`); + log.info(`[ws] connecting to ${url}`); conn = new WebSocket(url.toString()); conn.onopen = () => { log.info('[ws] <- open connection');