From e79037098accdc462f5ff167de54c087c51d798f Mon Sep 17 00:00:00 2001 From: cammyj1122 Date: Tue, 25 Oct 2022 15:30:44 -0400 Subject: [PATCH] Added flag for when all blocks have finished to Thread.js. Replaced code that cause variable errors in custom-dialog.js --- Thread.js | 18 +++++++++++++++++- custom-dialog.js | 6 ++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Thread.js b/Thread.js index f67c93e..3b646c3 100644 --- a/Thread.js +++ b/Thread.js @@ -37,10 +37,17 @@ class Thread { step() { console.log(`Stepping thread: ${this.id}`); var hasMore = this.interpreter.run(); - if (!hasMore) this.die(); + // if (!hasMore) this.die(); + if (!hasMore) { + this.die(); + } } die() { + let thread = this; + Thread.FinishedAll({ + targetID: thread.target.id, + }); this.target.removeThread(this.id); } @@ -107,5 +114,14 @@ class Thread { 'data': data, })); + } + + static FinishedAll(data) { + console.log('Finished All!', data); + window.socket.send(JSON.stringify({ + 'type': 'FinishedAll', + 'data': data, + })); + } } \ No newline at end of file diff --git a/custom-dialog.js b/custom-dialog.js index 168e167..1a2e7fe 100644 --- a/custom-dialog.js +++ b/custom-dialog.js @@ -117,12 +117,14 @@ .appendChild(document.createTextNode(message)); var onOkay = function(event) { - CustomDialog.hide(); + dialogDiv.style.display = 'none'; + backdropDiv.style.display = 'none'; options.onOkay && options.onOkay(); event && event.stopPropagation(); }; var onCancel = function(event) { - CustomDialog.hide(); + dialogDiv.style.display = 'none'; + backdropDiv.style.display = 'none'; options.onCancel && options.onCancel(); event && event.stopPropagation(); };