From a7f603264a41783968810ce845863062b908e6ff Mon Sep 17 00:00:00 2001 From: Paul Ye Date: Sun, 23 Aug 2020 13:06:56 +0200 Subject: [PATCH 1/3] Remove some globally exposed methods. --- web/js/codeworld.js | 6 +----- web/js/codeworld_shared.js | 2 +- web/js/funblocks.js | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/web/js/codeworld.js b/web/js/codeworld.js index 74c7708b1..e2b9e55fd 100644 --- a/web/js/codeworld.js +++ b/web/js/codeworld.js @@ -70,7 +70,7 @@ function attachEventListeners() { $('#startRecButton').on('click', captureStart); $('#stopRecButton').on('click', stopRecording); - $('#shareButton').on('click', share); + $('#shareButton').on('click', () => share(compile)); $('#inspectButton').on('click', inspect); $('#runButton').on('click', compile); @@ -1277,7 +1277,3 @@ function downloadProject() { document.body.removeChild(elem); } } - -// TEMP: required by setCode in codeworld_shared.js -window.compile = compile; -window.stopRun = stopRun; diff --git a/web/js/codeworld_shared.js b/web/js/codeworld_shared.js index 046a478eb..803113969 100644 --- a/web/js/codeworld_shared.js +++ b/web/js/codeworld_shared.js @@ -1174,7 +1174,7 @@ function loadProject(name, path, buildMode, successFunc) { }); } -function share() { +function share(compile) { let offerSource = true; function go() { diff --git a/web/js/funblocks.js b/web/js/funblocks.js index 73bcfae00..410d9681e 100644 --- a/web/js/funblocks.js +++ b/web/js/funblocks.js @@ -66,7 +66,7 @@ function attachEventListeners() { $('#deleteButton').on('click', deleteProject); $('#docButton').on('click', help); $('#shareFolderButton').on('click', () => shareFolder_(window.projectEnv)); - $('#shareButton').on('click', share); + $('#shareButton').on('click', () => share(compile)); $('#runner').on('load', toggleObsoleteCodeAlert); } From fa1a79c36b0c4fa3610151b4ee7c7625f8d9f212 Mon Sep 17 00:00:00 2001 From: Paul Ye Date: Sun, 6 Sep 2020 15:27:06 +0200 Subject: [PATCH 2/3] Add partialRight utility function --- web/js/utils/functional.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 web/js/utils/functional.js diff --git a/web/js/utils/functional.js b/web/js/utils/functional.js new file mode 100644 index 000000000..4ae0f9045 --- /dev/null +++ b/web/js/utils/functional.js @@ -0,0 +1,4 @@ +const partialRight = (fn, presetArgs) => (...laterArgs) => + fn(...laterArgs, ...presetArgs); + +export { partialRight }; From feb4b74e65587b698835b6a8e96480b83fec18e3 Mon Sep 17 00:00:00 2001 From: Paul Ye Date: Thu, 27 Aug 2020 10:02:56 +0200 Subject: [PATCH 3/3] Always show share button + warn about potential errors --- web/blocks.html | 26 +++---- web/css/codeworld.css | 11 ++- web/env.html | 28 +++---- web/js/codeworld.js | 10 ++- web/js/codeworld_shared.js | 152 +++++++++++++++++++++++-------------- web/js/funblocks.js | 6 +- 6 files changed, 142 insertions(+), 91 deletions(-) diff --git a/web/blocks.html b/web/blocks.html index 580eb44eb..92719dcb1 100644 --- a/web/blocks.html +++ b/web/blocks.html @@ -43,13 +43,13 @@   New -   Save As - @@ -59,10 +59,10 @@
- @@ -75,7 +71,7 @@ -