Skip to content

Instantly share code, notes, and snippets.

@piperswe
Created November 19, 2015 16:37
Show Gist options
  • Save piperswe/66a5704c415e81aef894 to your computer and use it in GitHub Desktop.
Save piperswe/66a5704c415e81aef894 to your computer and use it in GitHub Desktop.
code-editor Thing
// ==UserScript==
// @name code-editor Preview
// @namespace code-editor-preview
// @include http://ztaylor54.github.io/code-editor/
// @author Zeb McCorkle
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script")
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js")
script.addEventListener('load', function() {
var script = document.createElement("script")
script.textContent = "(" + callback.toString() + ")(jQuery.noConfict(true))"
document.body.appendChild(script)
}, false)
document.body.appendChild(script)
}
function main($) {
var frame = $('<iframe style="width: 100vw; height: 100vh;"></iframe>')
editor.on('keyup', function () {
frame.attr('src', 'data:text/html,' + editor.getValue())
})
$(document.body).append(frame)
}
addJQuery(main);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment