Skip to content

Instantly share code, notes, and snippets.

@wizard04wsu
Last active August 29, 2015 13:56
Show Gist options
  • Save wizard04wsu/8963578 to your computer and use it in GitHub Desktop.
Save wizard04wsu/8963578 to your computer and use it in GitHub Desktop.
Template for an on-page JavaScript log
<html>
<head>
<title>Log</title>
<style type="text/css" media="all">
#log {
padding:0.5em;
overflow:auto;
font-family:"Envy Code R", "Consolas", "DejaVu Sans Mono", "Anonymous Pro", "Courier New", monospace;
font-size:80%;
background-color:#EEE;
color:#000;
}
#log div {
transition-property:background-color, color;
transition-duration:0.75s, 0.25s;
transition-delay:0.01s, 0.2s;
}
#log div:hover {
background-color:#AAA;
color:#FFF;
}
</style>
<script type="text/javascript">
function log(entry, appendToTop){
var log = document.getElementById("log"),
existing = log.innerHTML;
log.innerHTML = appendToTop ? "<div>"+entry+"</div>"+existing : existing+"<div>"+entry+"</div>";
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment