From 21e17a294e3345097b42db55d1110a6a1389fd8e Mon Sep 17 00:00:00 2001 From: caribaud Date: Sun, 11 Jun 2023 09:51:47 +0200 Subject: [PATCH] more corrections --- eslint/eslintrc.json | 3 ++- melpomene.js | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/eslint/eslintrc.json b/eslint/eslintrc.json index 77aaba5..445108f 100644 --- a/eslint/eslintrc.json +++ b/eslint/eslintrc.json @@ -34,6 +34,7 @@ "no-unused-vars": ["error", {"argsIgnorePattern": "^_"}], "max-len" : ["warn", {"code": 88}], "capitalized-comments": "off", - "operator-linebreak": ["warn", "before"] + "operator-linebreak": ["warn", "before"], + "max-lines": "off" } } diff --git a/melpomene.js b/melpomene.js index 8572c8c..567b92e 100644 --- a/melpomene.js +++ b/melpomene.js @@ -39,26 +39,36 @@ const PROGRESS_BAR = document.getElementById("melpomene-progress-bar"); const PROGRESS_BAR_PAGES = document.getElementById("melpomene-progress-sections"); const VERSION_DISPLAY = document.getElementById("melpomene-version"); +// ==================== +// INDEX CONSTANTS +// ==================== + +const ZOOM_PAGE_INDEX = 0; +const ZOOM_WIDTH_INDEX = 1; +const ZOOM_HEIGHT_INDEX = 2; +const ZOOM_X_INDEX = 3; +const ZOOM_Y_INDEX = 4; + // =========================== // STATES GLOBAL VARIABLES // =========================== -var PAGES_ZOOMS; +let PAGES_ZOOMS; // The variable ZOOMS can either be defined by another JS file or contructed at init if (typeof PAGES_ZOOMS === "undefined") { PAGES_ZOOMS = null; } -var CURRENT_ZOOM = 0; -var CURRENT_PAGE = 1; -var CURRENT_WIDTH = 0; -var CURRENT_HEIGHT = 0; -var CURRENT_X = 0; -var CURRENT_Y = 0; +let CURRENT_ZOOM = 0; +let CURRENT_PAGE = 1; +let CURRENT_WIDTH = 0; +let CURRENT_HEIGHT = 0; +let CURRENT_X = 0; +let CURRENT_Y = 0; -var IS_PAGE_MODE = false; -var MOUSEWHELL_WAIT = false; +let IS_PAGE_MODE = false; +let MOUSEWHELL_WAIT = false; // ============= // UTILITIES @@ -360,17 +370,17 @@ function moveReaderDisplayToPage(pageNumber) moveReaderDisplayToArea(pageNumber, 0, 0, 0, 0); } -function moveReaderDisplayToZoom(index) +function moveReaderDisplayToZoom(zoomIdx) { moveReaderDisplayToArea( - PAGES_ZOOMS[index][0], - PAGES_ZOOMS[index][1], - PAGES_ZOOMS[index][2], - PAGES_ZOOMS[index][3], - PAGES_ZOOMS[index][4] + PAGES_ZOOMS[zoomIdx][ZOOM_PAGE_INDEX], + PAGES_ZOOMS[zoomIdx][ZOOM_WIDTH_INDEX], + PAGES_ZOOMS[zoomIdx][ZOOM_HEIGHT_INDEX], + PAGES_ZOOMS[zoomIdx][ZOOM_X_INDEX], + PAGES_ZOOMS[zoomIdx][ZOOM_Y_INDEX] ); - CURRENT_ZOOM = index; + CURRENT_ZOOM = zoomIdx; } function toggleViewMode()