gun/web/editor.html
2015-07-24 04:30:44 -07:00

67 lines
1.9 KiB
HTML

<html>
<body>
<link rel="stylesheet" href="./dep/codemirror/codemirror.css">
<link rel="stylesheet" href="./dep/codemirror/colorforth.css">
<style>
.edit {
border: 1px dashed;
overflow: hidden;
}
.CodeMirror {
float: left;
padding: .5em;
height: auto;
width: 49%;
}
iframe {
float: left;
width: 49%;
border: none;
}
</style>
<textarea style="height: 15em"></textarea>
<iframe></iframe>
<script src="./dep/jquery.js"></script>
<script src="./dep/jsquery.js"></script>
<script src="./dep/codemirror/codemirror.js"></script>
<script src="./dep/codemirror/xml.js"></script>
<script src="./dep/codemirror/javascript.js"></script>
<script src="./dep/codemirror/css.js"></script>
<script src="./dep/codemirror/htmlmixed.js"></script>
<script src="./dep/codemirror/matchbrackets.js"></script>
<script src="./dep/beautify/beautify.js"></script>
<script src="./dep/beautify/beautify-css.js"></script>
<script src="./dep/beautify/beautify-html.js"></script>
<script src="./dep/beautify/unpackers/javascriptobfuscator_unpacker.js"></script>
<script src="./dep/beautify/unpackers/urlencode_unpacker.js"></script>
<script src="./dep/beautify/unpackers/p_a_c_k_e_r_unpacker.js"></script>
<script src="./dep/beautify/unpackers/myobfuscate_unpacker.js"></script>
<script>
var editor = CodeMirror.fromTextArea($('textarea')[0], {
theme: 'colorforth',
//lineNumbers: true,
matchBrackets: true,
mode: "text/html",
tabSize: 2
});
editor.live = function(cb){ editor.cb = cb || editor.cb }
editor.on("change", function change() {
clearTimeout(change.throttle);
change.throttle = setTimeout(live, 100);
});
function live() {
var frame = $('iframe').height($('.CodeMirror').height() * .95)[0];
frame = frame.contentDocument || frame.contentWindow.document;
frame.open();
frame.write(editor.getValue());
(editor.cb || function(){})(frame);
frame.close();
}
setTimeout(live, 100);
</script>
</html>
</body>