1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Merge pull request #3425 from charlierudolph/compile_errors

Display compile errors - rebase from @jeremybanks
This commit is contained in:
Michael Ficarra 2014-03-18 08:11:29 -05:00
commit e02c8abb1a
2 changed files with 16 additions and 21 deletions

View file

@ -155,22 +155,6 @@ div.code {
#logo img {
margin: 5px 0 0 3px;
}
#error {
position: absolute;
-webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px;
-webkit-border-top-left-radius: 0; -moz-border-radius-topleft: 0; border-top-left-radius: 0;
-webkit-border-bottom-left-radius: 0; -moz-border-radius-bottomleft: 0; border-bottom-left-radius: 0;
right: 0px; top: 0px; left: 726px; bottom: 0;
padding: 0 0 0 15px;
background: #fdcdcc;
background: -webkit-gradient(linear, left top, left bottom, from(#ffedec), to(#ff9a95));
background: -moz-linear-gradient(top, #f8f8f8, #dadada);
color: #862322;
font-size: 10px;
line-height: 50px;
overflow: hidden;
text-transform: uppercase;
}
.navigation {
height: 50px;
font-size: 11px;
@ -322,6 +306,9 @@ div.code {
margin-bottom: 0;
top: 10px; left: 10px; right: 10px; bottom: 15px;
}
#repl_results.error {
color: red
}
#repl_source_wrap {
margin-left: 5px;
width: 47%; right: 50%;
@ -384,3 +371,9 @@ div.code {
background-image: url(../images/button_bg_dark.gif);
text-shadow: none;
}
.minibutton.error {
opacity: 0.5;
color: #600;
cursor: not-allowed;
}

View file

@ -87,7 +87,6 @@
<a href="documentation/docs/sourcemap.html">Source Maps &mdash; src/sourcemap</a>
</div>
</div>
<div id="error" style="display:none;"></div>
</div>
<div class="container">
@ -1926,19 +1925,22 @@ Expressions
# Set up the compilation function, to run when you stop typing.
compileSource = ->
source = $('#repl_source').val()
results = $('#repl_results')
window.compiledJS = ''
try
window.compiledJS = CoffeeScript.compile source, bare: on
el = $('#repl_results')[0]
el = results[0]
if el.innerText
el.innerText = window.compiledJS
else
$(el).text window.compiledJS
$('#error').hide()
results.text(window.compiledJS)
results.removeClass 'error'
$('.minibutton.run').removeClass 'error'
catch {location, message}
if location?
message = "Error on line #{location.first_line + 1}: #{message}"
$('#error').text(message).show()
results.text(message).addClass 'error'
$('.minibutton.run').addClass 'error'
# Update permalink
$('#repl_permalink').attr 'href', "##{sourceFragment}#{encodeURIComponent source}"