Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7eaa9b31db
Fetching contributors…

Cannot retrieve contributors at this time

121 lines (107 sloc) 3.386 kb
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="coffee-script.js"></script>
<style>
#cc-editor {
position: fixed;
top: 0;
bottom: 0;
right: 50%;
left: 0;
z-index: 1;
background-color:#EEE;
font-style: Monaco, Menlo, monospace;
font-size: 10pt;
}
#cc-results {
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 50%;
z-index: 1;
font-style: Monaco, Menlo, monospace;
font-size: 10pt;
}
#runcc {
position: fixed;
right: 10px;
bottom: 5px;
z-index: 3;
}
#error {
position: fixed;
bottom: 0;
right: 0;
padding: 8px 60px 8px 15px;
background-color: #DDD;
color: #900;
font-family: Arial, Helvetica, sans-serif;
font-size: .8em;
text-align: right;
z-index: 2;
opacity: .8;
-webkit-transition: opacity .2s linear;
}
#error.is-hidden {
opacity: 0;
}
</style>
</head>
<body>
<div id="cc-editor"></div>
<div id="cc-results"></div>
<div id="error"></div>
<button id="runcc">Run</button>
<script src="ace/ace-noconflict.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/mode-coffee-noconflict.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/mode-javascript-noconflict.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/theme-twilight-noconflict.js" type="text/javascript" charset="utf-8"></script>
<script>
var tabId = chrome.devtools.inspectedWindow.tabId;
var err = document.getElementById('error');
var editor = ace.edit("cc-editor");
editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/coffee");
editor.setShowPrintMargin(false);
var compiled = ace.edit("cc-results");
compiled.setTheme("ace/theme/twilight");
compiled.session.setMode("ace/mode/javascript");
compiled.setShowPrintMargin(false);
function compileIt(){
chrome.devtools.inspectedWindow.eval( compiled.session.getValue(), function(result, isException) {});
}
function update(){
try {
var compiledSource = CoffeeScript.compile( editor.session.getValue(), {bare:true});
compiled.session.setValue(compiledSource);
err.className = 'is-hidden';
} catch (error) {
err.className = '';
err.innerHTML = error.message;
}
localStorage.setItem("state" + tabId, editor.session.getValue());
}
schedule = function(fn, timeout) {
if (fn.$timer) return;
fn.$timer = setTimeout(function() {fn.$timer = null; fn()}, timeout || 10);
}
editor.on("change", function(e){
schedule(update, 20);
});
var compileOptions = {
name: "compileIt",
exec: compileIt,
bindKey: "Ctrl-Return|Command-Return|Shift-Return"
};
editor.commands.addCommand(compileOptions);
compiled.commands.addCommand(compileOptions);
document.getElementById('runcc').addEventListener('click', compileIt);
editor.session.setValue(localStorage.getItem("state" + tabId));
schedule(function(){ editor.focus() }, 20);
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.