Merge pull request #2 from jeroenvandijk/bookmarklet-fix1

Better error handling for Bookmarklet editor
This commit is contained in:
Michiel Borkent 2021-05-26 17:05:48 +02:00 committed by GitHub
commit c79f2cf22d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,10 +18,21 @@
(defn bookmarklet-href [code] (defn bookmarklet-href [code]
(str "javascript:(function(){" (str "javascript:(function(){"
"var runCode = function() {
try {
scittle.core.eval_string('" code "')
} catch (error) {
console.log('Error in code', error);
alert('Error running code, see console')
}
};"
"if(typeof scittle === 'undefined'){"
(append-tag :script {:src "https://borkdude.github.io/scittle/js/scittle.js" (append-tag :script {:src "https://borkdude.github.io/scittle/js/scittle.js"
:onerror "function(){alert('Error loading ' + this.src)}" :onerror "function(){alert('Error loading ' + this.src)}"
:onload (str "function(){scittle.core.eval_string('" code "')}") :onload (str "runCode")
}) })
"} else {
runCode() }"
"})();")) "})();"))
(defn workspace [] (defn workspace []