Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

little highlight of runtime error #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
40 changes: 39 additions & 1 deletion src/js/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ __$__.Update = {

// this function is called when ace editor is edited.
PositionUpdate: function(__arg__) {

//adding portion start

window.onload = function(){
var cell_highlight = document.getElementsByClassName("ace_gutter-cell");
for(i=0;i<cell_highlight.length;i++)
cell_highlight[i].style.backgroundColor = '#F0F0F0';
}
var cell_highlight = document.getElementsByClassName("ace_gutter-cell");
for(i=0;i<cell_highlight.length;i++){
cell_highlight[i].style.backgroundColor = '#F0F0F0';
}

// adding portion end

try {
window.localStorage.setItem('Kanon-Code', __$__.editor.getValue());
} catch (e) {
Expand Down Expand Up @@ -62,7 +77,30 @@ __$__.Update = {
try {
eval(__$__.editor.getValue());
} catch (e) {
document.getElementById('console').textContent = 'Runtime Error: ' + e.message;

//adding portion start

if(e.lineNumber){
var lnum = e.lineNumber //firefox
}
else{
if(e.line){
var lnum = e.line; //safari
}else{
lnum = e.stack.toString().split(/\n/)[1].split(/,/)[1].split(/:/)[1]; //chrome
}
}
document.getElementById('console').textContent = 'Runtime Error: Line ' + lnum + ": " + e.message;

window.onload = function(){
var opinion = document.getElementsByClassName("ace_gutter-cell");
opinion[lnum - 1].style.backgroundColor = 'yellow';
}
var opinion = document.getElementsByClassName("ace_gutter-cell");
opinion[lnum - 1].style.backgroundColor = 'yellow';

//adding portion end

}
}
}
Expand Down