From 5e33f1c50ae46c5951b3690aaa02f918136311e0 Mon Sep 17 00:00:00 2001 From: pbellec Date: Sun, 17 Feb 2019 10:31:44 -0500 Subject: [PATCH] Finished linting brainsprite.js. Also switche no-unused-vars to a warning, because I don't seem to manage to declare brainsprite as a global. --- .eslintrc.js | 5 ++++- brainsprite.js | 20 +++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 311c133..c6b4928 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,11 +6,14 @@ module.exports = { 'extends': 'standard', 'globals': { 'Atomics': 'readonly', - 'SharedArrayBuffer': 'readonly' + 'SharedArrayBuffer': 'readonly', + 'brainsprite': 'readonly' }, 'parserOptions': { 'ecmaVersion': 2018 }, 'rules': { + 'no-unused-vars': ['warn', { 'vars': 'local', 'args': 'after-used', + 'ignoreRestSiblings': false }] } } diff --git a/brainsprite.js b/brainsprite.js index be9d641..8c7667e 100644 --- a/brainsprite.js +++ b/brainsprite.js @@ -134,8 +134,7 @@ function initColorMap (colorMap) { return colorMap } -/* exported brainsprite */ -function brainsprite (params) { +var brainsprite = function (params) { // Create and activate a brainsprite viewer object // // Parameters @@ -497,8 +496,8 @@ function brainsprite (params) { coord = 'y = ' + Math.round(brain.coordinatesSlice.Y) coordWidth = brain.context.measureText(coord).width brain.context.fillText(coord, brain.widthCanvas.X + - (brain.widthCanvas.Y / 2) - coordWidth / 2, - Math.round(brain.canvas.height - (brain.sizeFontPixels / 2))) + (brain.widthCanvas.Y / 2) - coordWidth / 2, + Math.round(brain.canvas.height - (brain.sizeFontPixels / 2))) } break @@ -528,8 +527,7 @@ function brainsprite (params) { brain.context.drawImage(brain.planes.canvasZ, 0, 0, brain.nbSlice.X, brain.nbSlice.Y, brain.widthCanvas.X + brain.widthCanvas.Y, (brain.heightCanvas.max - - brain.heightCanvas.Z) / 2, brain.widthCanvas.Z, - brain.heightCanvas.Z) + brain.heightCanvas.Z) / 2, brain.widthCanvas.Z, brain.heightCanvas.Z) // Add Z coordinates on the slice if (brain.flagCoordinates) { @@ -537,8 +535,8 @@ function brainsprite (params) { coordWidth = brain.context.measureText(coord).width brain.context.fillStyle = brain.colorFont brain.context.fillText(coord, brain.widthCanvas.X + - brain.widthCanvas.Y + (brain.widthCanvas.Z / 2) - coordWidth / 2, - Math.round(brain.canvas.height - (brain.sizeFontPixels / 2))) + brain.widthCanvas.Y + (brain.widthCanvas.Z / 2) - coordWidth / 2, + Math.round(brain.canvas.height - (brain.sizeFontPixels / 2))) } } } @@ -594,12 +592,12 @@ function brainsprite (params) { brain.canvas.addEventListener('click', brain.clickBrain, false) // Attach a listener on mouse down - brain.canvas.addEventListener('mousedown', function (e) { + brain.canvas.addEventListener('mousedown', function () { brain.canvas.addEventListener('mousemove', brain.clickBrain, false) }, false) // Detach the listener on mouse up - brain.canvas.addEventListener('mouseup', function (e) { + brain.canvas.addEventListener('mouseup', function () { brain.canvas.removeEventListener('mousemove', brain.clickBrain, false) }, false) @@ -622,4 +620,4 @@ function brainsprite (params) { brain.drawAll() return brain -}; +}