Skip to content

Instantly share code, notes, and snippets.

@esironal
Created October 26, 2015 04:50
Show Gist options
  • Select an option

  • Save esironal/e4388b91634921a987d0 to your computer and use it in GitHub Desktop.

Select an option

Save esironal/e4388b91634921a987d0 to your computer and use it in GitHub Desktop.
Auto Updating Code Editor
form(class="codeEditingContainer" id="codeEditingContainer")
textarea(class="codeEditor" id="codeEditor" placeholder="Type your code here and see it update live over there ––>")
div(class="liveUpdate" id="liveUpdate")
$(document).ready(function() {
var update = setInterval(updateLive, 1);
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
function updateLive() {
var codeEditor = $("#codeEditor");
var liveUpdate = $("#liveUpdate");
var words = codeEditor.val();
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
codeEditor.on("keyup", function() {
liveUpdate.html(words);
});
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
@import "nib"
.liveUpdate
position fixed
right 0
top 0
bottom 0
height 100vh
width 50%
.codeEditingContainer
position fixed
left 0
top 0
bottom 0
height 100vh
width 49.5%
.codeEditor
background #222
color white
border none
resize none // gets rid of resize icon
height 100%
width 100%
.codeEditor:focus
outline none // gets rid of that nasty glow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment