forked from sugarlabs/musicblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (c) 2016-20 Walter Bender | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the The GNU Affero General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 3 of the License, or (at your option) any later version. | ||
// | ||
// You should have received a copy of the GNU Affero General Public | ||
// 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. | ||
|
||
function StatsWindow() { | ||
const BUTTONSIZE = 53; | ||
const ICONSIZE = 32; | ||
|
||
this.init = function(logo) { | ||
this._logo = logo; | ||
this.isOpen = true; | ||
|
||
var w = window.innerWidth; | ||
this._cellScale = w / 1200; | ||
var iconSize = ICONSIZE * this._cellScale; | ||
|
||
var widgetWindow = window.widgetWindows.windowFor( | ||
this, | ||
"stats", | ||
"stats" | ||
); | ||
this.widgetWindow = widgetWindow; | ||
widgetWindow.clear(); | ||
widgetWindow.show(); | ||
|
||
var that = this; | ||
|
||
widgetWindow.onclose = function() { | ||
that.isOpen = false; | ||
blocks.showBlocks(); | ||
this.destroy(); | ||
}; | ||
this.doAnalytics(); | ||
|
||
widgetWindow.sendToCenter(); | ||
}; | ||
|
||
/* | ||
* Renders and carries out analysis | ||
* of the MB project | ||
*/ | ||
this.doAnalytics = function() { | ||
toolbar.closeAuxToolbar(_showHideAuxMenu); | ||
blocks.activeBlock = null; | ||
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) | ||
let data = scoreToChartData(scores); | ||
__callback = () => { | ||
imageData = myRadarChart.toBase64Image(); | ||
img = new Image(); | ||
img.src = imageData; | ||
this.widgetWindow.getWidgetBody().appendChild(img) | ||
blocks.hideBlocks(); | ||
logo.showBlocksAfterRun = false; | ||
document.body.style.cursor = "default"; | ||
}; | ||
options = getChartOptions(__callback); | ||
myRadarChart = new Chart(ctx).Radar(data, options); | ||
|
||
this.jsonObject = document.createElement('p'); | ||
this.widgetWindow.getWidgetBody().appendChild(this.jsonObject) | ||
|
||
}; | ||
|
||
} |