Pulled Try CoffeeScript fragment prefix into a variable, other minor improvements.
This commit is contained in:
parent
80f9a20bfd
commit
2c43a9d209
|
@ -84,7 +84,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="repl_results_wrap"><pre id="repl_results"></pre></div>
|
<div id="repl_results_wrap"><pre id="repl_results"></pre></div>
|
||||||
<div class="minibutton dark run" title="Ctrl-Enter">Run</div>
|
<div class="minibutton dark run" title="Ctrl-Enter">Run</div>
|
||||||
<a class="minibutton permalink" id="repl_permalink" style="display: block; top: 38px;" href="#src:">Link</a>
|
<a class="minibutton permalink" id="repl_permalink" style="display: block; top: 38px;">Link</a>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1578,6 +1578,7 @@ Expressions
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/coffeescript">
|
<script type="text/coffeescript">
|
||||||
|
source_fragment_prefix = "try_src:"
|
||||||
|
|
||||||
# Set up the compilation function, to run when you stop typing.
|
# Set up the compilation function, to run when you stop typing.
|
||||||
compileSource = ->
|
compileSource = ->
|
||||||
|
@ -1595,7 +1596,7 @@ Expressions
|
||||||
$('#error').text(error.message).show()
|
$('#error').text(error.message).show()
|
||||||
|
|
||||||
# Update permalink
|
# Update permalink
|
||||||
$('#repl_permalink').attr 'href', "#src:#{encodeURIComponent source}"
|
$('#repl_permalink').attr 'href', "##{source_fragment_prefix}#{encodeURIComponent source}"
|
||||||
|
|
||||||
# Listen for keypresses and recompile.
|
# Listen for keypresses and recompile.
|
||||||
$('#repl_source').keyup -> compileSource()
|
$('#repl_source').keyup -> compileSource()
|
||||||
|
@ -1645,12 +1646,12 @@ Expressions
|
||||||
|
|
||||||
$("#repl_permalink").click (e) ->
|
$("#repl_permalink").click (e) ->
|
||||||
window.location = $(this).attr("href")
|
window.location = $(this).attr("href")
|
||||||
return false
|
false
|
||||||
|
|
||||||
# If source code is included in location.hash, display it.
|
# If source code is included in location.hash, display it.
|
||||||
hash = decodeURIComponent location.hash.replace(/^#/, '')
|
hash = decodeURIComponent location.hash.replace(/^#/, '')
|
||||||
if matches = /^src:/.exec(hash)
|
if hash.indexOf(source_fragment_prefix) == 0
|
||||||
src = hash.substr "src:".length
|
src = hash.substr source_fragment_prefix.length
|
||||||
loadConsole src
|
loadConsole src
|
||||||
|
|
||||||
compileSource()
|
compileSource()
|
||||||
|
|
11
index.html
11
index.html
|
@ -62,7 +62,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="repl_results_wrap"><pre id="repl_results"></pre></div>
|
<div id="repl_results_wrap"><pre id="repl_results"></pre></div>
|
||||||
<div class="minibutton dark run" title="Ctrl-Enter">Run</div>
|
<div class="minibutton dark run" title="Ctrl-Enter">Run</div>
|
||||||
<a class="minibutton permalink" id="repl_permalink" style="display: block; top: 38px;" href="#src:">Link</a>
|
<a class="minibutton permalink" id="repl_permalink" style="display: block; top: 38px;">Link</a>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2463,6 +2463,7 @@ task(<span class="String"><span class="String">'</span>build:parser<span class="
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/coffeescript">
|
<script type="text/coffeescript">
|
||||||
|
source_fragment_prefix = "try_src:"
|
||||||
|
|
||||||
# Set up the compilation function, to run when you stop typing.
|
# Set up the compilation function, to run when you stop typing.
|
||||||
compileSource = ->
|
compileSource = ->
|
||||||
|
@ -2480,7 +2481,7 @@ task(<span class="String"><span class="String">'</span>build:parser<span class="
|
||||||
$('#error').text(error.message).show()
|
$('#error').text(error.message).show()
|
||||||
|
|
||||||
# Update permalink
|
# Update permalink
|
||||||
$('#repl_permalink').attr 'href', "#src:#{encodeURIComponent source}"
|
$('#repl_permalink').attr 'href', "##{source_fragment_prefix}#{encodeURIComponent source}"
|
||||||
|
|
||||||
# Listen for keypresses and recompile.
|
# Listen for keypresses and recompile.
|
||||||
$('#repl_source').keyup -> compileSource()
|
$('#repl_source').keyup -> compileSource()
|
||||||
|
@ -2530,12 +2531,12 @@ task(<span class="String"><span class="String">'</span>build:parser<span class="
|
||||||
|
|
||||||
$("#repl_permalink").click (e) ->
|
$("#repl_permalink").click (e) ->
|
||||||
window.location = $(this).attr("href")
|
window.location = $(this).attr("href")
|
||||||
return false
|
false
|
||||||
|
|
||||||
# If source code is included in location.hash, display it.
|
# If source code is included in location.hash, display it.
|
||||||
hash = decodeURIComponent location.hash.replace(/^#/, '')
|
hash = decodeURIComponent location.hash.replace(/^#/, '')
|
||||||
if matches = /^src:/.exec(hash)
|
if hash.indexOf(source_fragment_prefix) == 0
|
||||||
src = hash.substr "src:".length
|
src = hash.substr source_fragment_prefix.length
|
||||||
loadConsole src
|
loadConsole src
|
||||||
|
|
||||||
compileSource()
|
compileSource()
|
||||||
|
|
Loading…
Reference in New Issue