From 03ff9427f9014cdca565b6c5688fba1108a48389 Mon Sep 17 00:00:00 2001 From: Anindya Kundu Date: Fri, 29 Jan 2021 16:32:57 +0530 Subject: [PATCH] Move init to top --- js/widgets/pitchdrummatrix.js | 136 +++++++++++++++++----------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/js/widgets/pitchdrummatrix.js b/js/widgets/pitchdrummatrix.js index 35f05cdf5c..c87905dd61 100644 --- a/js/widgets/pitchdrummatrix.js +++ b/js/widgets/pitchdrummatrix.js @@ -62,74 +62,6 @@ class PitchDrumMatrix { this._blockMap = []; } - /** - * @public - * @returns {void} - */ - clearBlocks() { - this._rowBlocks = []; - this._colBlocks = []; - } - - /** - * @public - * @param {number} pitchBlock - * @return {void} - */ - addRowBlock(pitchBlock) { - this._rowBlocks.push(pitchBlock); - } - - /** - * @public - * @param {number} drumBlock - * @return {void} - */ - addColBlock(drumBlock) { - this._colBlocks.push(drumBlock); - } - - /** - * @public - * @param {number} pitchBlock - * @param {number} drumBlock - * @returns {void} - */ - addNode(pitchBlock, drumBlock) { - let obj; - for (let i = 0; i < this._blockMap.length; i++) { - obj = this._blockMap[i]; - if (obj[0] === pitchBlock && obj[1] === drumBlock) { - return; // node is already in the list - } - } - this._blockMap.push([pitchBlock, drumBlock]); - } - - /** - * @public - * @param {number} pitchBlock - * @param {number} drumBlock - * @returns {void} - */ - removeNode(pitchBlock, drumBlock) { - let obj; - for (let i = 0; i < this._blockMap.length; i++) { - obj = this._blockMap[i]; - if (obj[0] === pitchBlock && obj[1] === drumBlock) { - this._blockMap[i] = [-1, -1]; // Mark as removed - } - } - } - - /** - * @private - * @returns {HTMLElement} - */ - _get_save_lock() { - return this._save_lock; - } - /** * Initializes the pitch/drum matrix. First removes the previous matrix and them make another * one in DOM (Document Object Model). @@ -332,6 +264,74 @@ class PitchDrumMatrix { logo.textMsg(_("Click in the grid to map notes to drums.")); } + /** + * @public + * @returns {void} + */ + clearBlocks() { + this._rowBlocks = []; + this._colBlocks = []; + } + + /** + * @public + * @param {number} pitchBlock + * @return {void} + */ + addRowBlock(pitchBlock) { + this._rowBlocks.push(pitchBlock); + } + + /** + * @public + * @param {number} drumBlock + * @return {void} + */ + addColBlock(drumBlock) { + this._colBlocks.push(drumBlock); + } + + /** + * @public + * @param {number} pitchBlock + * @param {number} drumBlock + * @returns {void} + */ + addNode(pitchBlock, drumBlock) { + let obj; + for (let i = 0; i < this._blockMap.length; i++) { + obj = this._blockMap[i]; + if (obj[0] === pitchBlock && obj[1] === drumBlock) { + return; // node is already in the list + } + } + this._blockMap.push([pitchBlock, drumBlock]); + } + + /** + * @public + * @param {number} pitchBlock + * @param {number} drumBlock + * @returns {void} + */ + removeNode(pitchBlock, drumBlock) { + let obj; + for (let i = 0; i < this._blockMap.length; i++) { + obj = this._blockMap[i]; + if (obj[0] === pitchBlock && obj[1] === drumBlock) { + this._blockMap[i] = [-1, -1]; // Mark as removed + } + } + } + + /** + * @private + * @returns {HTMLElement} + */ + _get_save_lock() { + return this._save_lock; + } + /** * @deprecated */