WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions examples/coffeeshop.html
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,27 @@ <H3 STYLE="flex-grow:1" ID="title">The CoffeeShop</H3>
els.sample.contentDocument.body.style = "margin:0; padding:0;";
postRun();
els.sample.contentWindow.addEventListener('error', function(e) {
//console.log(e);
var rowOffset = 0;
if (e.filename == "") {
// Figure out line where `Algebra(..., ()=>{...}` starts in ACE Editor (because error is offsetted from there)
var lines = editor.getValue().split("\n");
rowOffset = -1;
for (var line of lines) {
if (line.match(/Algebra\s?\(/)) {
break;
}
rowOffset++;
}
if (rowOffset == -1) {
rowOffset = 0;
}
}
// show error in HTML
els.sample.contentDocument.body.innerHTML+=`<PRE>${e.message}</PRE>`;
// show error in ace editor
var row = e.lineno;
var row = rowOffset + e.lineno;
//console.log("rowOffset", rowOffset, "e.lineno", e.lineno)
// e.lineno is one off in same cases... fixing that, otherwise it looks strange
// Chrome
if (
Expand All @@ -598,9 +615,6 @@ <H3 STYLE="flex-grow:1" ID="title">The CoffeeShop</H3>
) {
row--;
}
if (e.message.includes("ReferenceError:")) {
row++;
}
editor.getSession().setAnnotations([{
row,
column: e.colno,
Expand Down