Fix and improve playground threads display ()

This commit is contained in:
Tim Mickel 2016-09-21 16:31:23 -04:00 committed by GitHub
parent aa5e8d2648
commit a687184c3c
2 changed files with 12 additions and 3 deletions

View file

@ -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;

View file

@ -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
});
};