Skip to content

Commit

Permalink
Move init to top
Browse files Browse the repository at this point in the history
  • Loading branch information
meganindya committed Jan 29, 2021
1 parent f834ac0 commit 03ff942
Showing 1 changed file with 68 additions and 68 deletions.
136 changes: 68 additions & 68 deletions js/widgets/pitchdrummatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 03ff942

Please sign in to comment.