public
Last active — forked from minikomi/editor.html

Javascript editor in your browser

  • Download Gist
editor.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
data:text/html,
<style type="text/css">
#e {
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
font-size:16px;
}
</style>
<div id="e"></div>
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
var myKey="SecretKeyz";
$(document).ready(function(){
var e = ace.edit("e");
e.setTheme("ace/theme/tomorrow_night_eighties");
e.getSession().setMode("ace/mode/javascript");
var url = "http://api.openkeyval.org/"+myKey;
$.ajax({
url: url,
dataType: "jsonp",
success: function(data){
e.setValue(data);
}
});
 
$("#e").on("keydown", function (b) {
if (b.ctrlKey && 83 == b.which) {
// Save to OpenKeyVal
b.preventDefault();
var data = myKey+"="+encodeURIComponent(e.getValue());
$.ajax({
data: data,
url: "http://api.openkeyval.org/store/",
dataType: "jsonp",
success: function(data){
alert("Saved.");
}
});
} else if (b.ctrlKey && 74 == b.which) {
// Execute Current Buffer
b.preventDefault();
eval(e.getValue());
}
});
});
</script>

Use Ace editor, set to JavaScript mode and use ctrl+j to execute current buffer.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.