From 78764b539e8e44779f674716bc51bc8b325cc273 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Wed, 6 May 2015 20:17:43 -0400 Subject: [PATCH] Use non-caveman event handlers --- js/scratchx.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/scratchx.js b/js/scratchx.js index 123ede3..f29c232 100644 --- a/js/scratchx.js +++ b/js/scratchx.js @@ -24,7 +24,7 @@ function JSthrowError(e) { function JSeditorReady() { try { handleParameters(); - JSeditorReadyCallback(); + $("#editor").trigger("editorReady"); return true; } catch (error) { console.error(error.message, "\n", error.stack); @@ -107,7 +107,6 @@ swfobject.embedSWF('Scratch.swf', 'editor', '100%', '100%', '11.7.0', 'libs/expr /* File uploads */ -var JSeditorReadyCallback = function(){}; function sendFileToFlash(file) { var fileReader = new FileReader(); fileReader.onload = function (e) { @@ -116,9 +115,10 @@ function sendFileToFlash(file) { if (Scratch.FlashApp.ASobj.ASloadBase64SBX !== undefined) { Scratch.FlashApp.ASobj.ASloadBase64SBX(fileAsB64); } else { - JSeditorReadyCallback = function() { + $(document).on("editorReady", function(e) { Scratch.FlashApp.ASobj.ASloadBase64SBX(fileAsB64); - } + $(this).off(e); + }); } } @@ -133,9 +133,10 @@ function sendURLtoFlash(url) { if (Scratch.FlashApp.ASobj.ASloadGithubURL !== undefined) { Scratch.FlashApp.ASobj.ASloadGithubURL(url); } else { - JSeditorReadyCallback = function() { + $(document).on("editorReady", function(e) { Scratch.FlashApp.ASobj.ASloadGithubURL(url); - } + $(this).off(e); + }); } }