Created
November 19, 2015 16:37
-
-
Save piperswe/66a5704c415e81aef894 to your computer and use it in GitHub Desktop.
code-editor Thing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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