mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-09 03:54:44 -04:00
Fix and improve playground threads display (#198)
This commit is contained in:
parent
aa5e8d2648
commit
a687184c3c
2 changed files with 12 additions and 3 deletions
|
@ -87,8 +87,7 @@ window.onload = function() {
|
|||
// Thread representation tab.
|
||||
var threadexplorer = document.getElementById('threadexplorer');
|
||||
var cachedThreadJSON = '';
|
||||
var updateThreadExplorer = function (threads) {
|
||||
var newJSON = JSON.stringify(threads, null, 2);
|
||||
var updateThreadExplorer = function (newJSON) {
|
||||
if (newJSON != cachedThreadJSON) {
|
||||
cachedThreadJSON = newJSON;
|
||||
threadexplorer.innerHTML = cachedThreadJSON;
|
||||
|
|
12
src/index.js
12
src/index.js
|
@ -76,9 +76,19 @@ VirtualMachine.prototype.stopAll = function () {
|
|||
* Get data for playground. Data comes back in an emitted event.
|
||||
*/
|
||||
VirtualMachine.prototype.getPlaygroundData = function () {
|
||||
var instance = this;
|
||||
// Only send back thread data for the current editingTarget.
|
||||
var threadData = this.runtime.threads.filter(function(thread) {
|
||||
return thread.target == instance.editingTarget;
|
||||
});
|
||||
// Remove the target key, since it's a circular reference.
|
||||
var filteredThreadData = JSON.stringify(threadData, function(key, value) {
|
||||
if (key == 'target') return undefined;
|
||||
return value;
|
||||
}, 2);
|
||||
this.emit('playgroundData', {
|
||||
blocks: this.editingTarget.blocks,
|
||||
threads: this.runtime.threads
|
||||
threads: filteredThreadData
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue