Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
meganindya committed Dec 10, 2020
1 parent b384bee commit 8c59919
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions js/widgets/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,84 +9,67 @@
// License along with this library; if not, write to the Free Software
// Foundation, 51 Franklin Street, Suite 500 Boston, MA 02110-1335 USA

// This widget makes displays the status of selected parameters and
// notes as they are being played.

const BUTTONSIZE = 53;
const ICONSIZE = 32;

/**
* This widget makes displays the status of selected parameters and notes as they are being played.
*/
class StatsWindow {

constructor(logo) {
this._logo = logo;
constructor() {
this.isOpen = true;

let w = window.innerWidth;
this._cellScale = w / 1200;
let iconSize = ICONSIZE * this._cellScale;

let widgetWindow = window.widgetWindows.windowFor(
this,
"stats",
"stats"
);
this.widgetWindow = widgetWindow;
widgetWindow.clear();
widgetWindow.show();

widgetWindow.onclose = ()=>{
this.widgetWindow = window.widgetWindows.windowFor(this, "stats", "stats");
this.widgetWindow.clear();
this.widgetWindow.show();
this.widgetWindow.onclose = () => {
this.isOpen = false;
blocks.showBlocks();
widgetWindow.destroy();
this.widgetWindow.destroy();
};
this.doAnalytics();

widgetWindow.sendToCenter();
this.widgetWindow.sendToCenter();
};

/*
* Renders and carries out analysis
* of the MB project
/**
* Renders and carries out analysis of the MB project.
*/
doAnalytics() {
toolbar.closeAuxToolbar(_showHideAuxMenu);
blocks.activeBlock = null;
let myChart = docById("myChart");

// if (_isCanvasBlank(myChart) === false) {
// return;
// }

let ctx = myChart.getContext("2d");
loading = true;
document.body.style.cursor = "wait";

let myRadarChart = null;
let scores = analyzeProject(blocks);
runAnalytics(logo)
runAnalytics(logo);
let data = scoreToChartData(scores);
let __callback = () => {
const __callback = () => {
let imageData = myRadarChart.toBase64Image();
let img = new Image();
img.src = imageData;
img.width = 200;
this.widgetWindow.getWidgetBody().appendChild(img)
img.width = 200;
this.widgetWindow.getWidgetBody().appendChild(img);
blocks.hideBlocks();
logo.showBlocksAfterRun = false;
document.body.style.cursor = "default";
};
let options = getChartOptions(__callback);
myRadarChart = new Chart(ctx).Radar(data, options);

this.jsonObject = document.createElement('ul');
this.jsonObject.style.float = 'left';
this.widgetWindow.getWidgetBody().appendChild(this.jsonObject)

this.jsonObject = document.createElement("ul");
this.jsonObject.style.float = "left";
this.widgetWindow.getWidgetBody().appendChild(this.jsonObject);
};

displayInfo(stats) {
let lowHertz = stats["lowestNote"][2] + 0.5;
let highHertz = stats["highestNote"][2] + 0.5;
this.jsonObject.innerHTML =
this.jsonObject.innerHTML =
'<li>duples: ' + stats["duples"] + '</li>' +
'<li>triplets: ' + stats["triplets"] + '</li>' +
'<li>quintuplets: ' + stats["quintuplets"] + '</li>' +
Expand All @@ -97,5 +80,4 @@ class StatsWindow {
'<li>rests used: ' + stats["rests"] + '</li>' +
'<li>ornaments used: ' + stats["ornaments"] + '</li>'
}

}

0 comments on commit 8c59919

Please sign in to comment.