mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-08 03:54:04 -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.
|
// Thread representation tab.
|
||||||
var threadexplorer = document.getElementById('threadexplorer');
|
var threadexplorer = document.getElementById('threadexplorer');
|
||||||
var cachedThreadJSON = '';
|
var cachedThreadJSON = '';
|
||||||
var updateThreadExplorer = function (threads) {
|
var updateThreadExplorer = function (newJSON) {
|
||||||
var newJSON = JSON.stringify(threads, null, 2);
|
|
||||||
if (newJSON != cachedThreadJSON) {
|
if (newJSON != cachedThreadJSON) {
|
||||||
cachedThreadJSON = newJSON;
|
cachedThreadJSON = newJSON;
|
||||||
threadexplorer.innerHTML = cachedThreadJSON;
|
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.
|
* Get data for playground. Data comes back in an emitted event.
|
||||||
*/
|
*/
|
||||||
VirtualMachine.prototype.getPlaygroundData = function () {
|
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', {
|
this.emit('playgroundData', {
|
||||||
blocks: this.editingTarget.blocks,
|
blocks: this.editingTarget.blocks,
|
||||||
threads: this.runtime.threads
|
threads: filteredThreadData
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue