Created
June 18, 2014 12:52
-
-
Save kitroed/8dbc82171934a6136d39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<head> | |
</head> | |
<body> | |
<div> | |
<h1>Input</h1> | |
</div> | |
<div> | |
<h1>Output</h1> | |
<textarea type="text" id="outputTextArea" style="width:100%" rows=25></textarea> | |
</div> | |
<script> | |
//create a reference that adds functions clear, write, writeLine | |
// that createa a closure over the outputTextArea reference | |
var pageConsole = (function() { | |
var output = document.getElementById("outputTextArea"); | |
return { | |
clear: function(){ | |
output.value = ""; | |
}, | |
write: function( text){ | |
output.value += text; | |
}, | |
writeLine: function( text){ | |
output.value += text + '\n'; | |
} | |
}; | |
})(); | |
pageConsole.clear(); | |
pageConsole.write("first"); | |
pageConsole.write("second"); | |
pageConsole.writeLine("third"); | |
pageConsole.writeLine("fourth"); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment