From e291b3e0ad27bac9cb4c518b7440035db96e15f9 Mon Sep 17 00:00:00 2001 From: Benjamin Landers Date: Sat, 10 May 2014 10:47:39 -0700 Subject: [PATCH 1/2] added loading scripts without the id set --- repl.coffee | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/repl.coffee b/repl.coffee index 1e5d857..1b584df 100644 --- a/repl.coffee +++ b/repl.coffee @@ -6,7 +6,14 @@ if script_element? BASE_PATH = script_element.src.split('/')[...-1].join '/' SANDBOX_SRC = "#{BASE_PATH}/sandbox.html" else - throw new Error 'JSREPL script element cannot be found. Make sure you have the ID "jsrepl-script" on it.' + elements = document.getElementsByTagName 'script' + for script_element in elements + if script_element.src.match /^(.*)\/jsrepl(\-\w+)?\.js(\?|$)/ isnt null + BASE_PATH = script_element.src.split('/')[...-1].join '/' + SANDBOX_SRC = "#{BASE_PATH}/sandbox.html" + break + if BASE_PATH? + throw new Error 'JSREPL script element cannot be found. Make sure you have the ID "jsrepl-script" on it.' class Loader constructor: -> From 74fb3ffe147a27025d06edb9a8ec323123984cf9 Mon Sep 17 00:00:00 2001 From: Benjamin Landers Date: Thu, 15 May 2014 21:16:52 -0700 Subject: [PATCH 2/2] fixed small boolean issue --- repl.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repl.coffee b/repl.coffee index 1b584df..2702ce3 100644 --- a/repl.coffee +++ b/repl.coffee @@ -12,7 +12,7 @@ else BASE_PATH = script_element.src.split('/')[...-1].join '/' SANDBOX_SRC = "#{BASE_PATH}/sandbox.html" break - if BASE_PATH? + if not BASE_PATH? throw new Error 'JSREPL script element cannot be found. Make sure you have the ID "jsrepl-script" on it.' class Loader