Skip to content

Instantly share code, notes, and snippets.

@tonyfast
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save tonyfast/59533147ebac39fc0d02 to your computer and use it in GitHub Desktop.

Select an option

Save tonyfast/59533147ebac39fc0d02 to your computer and use it in GitHub Desktop.
Jquery + Jquery.terminal :: A Browser based console in Jquery
<head>
<script src="//cdn.jsdelivr.net/g/jquery,jquery.terminal"></script>
<style>
terminal{
position: fixed;
height: 80%;
right: -550px;
display: block-inline;
width: 650px;
background-color: lightblue;
}
terminal.show{
right: 0px;
}
terminal .console{
margin-left: 40px;
margin-top: 10%;
}
terminal .toggle{
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
float: left;
-webkit-transform: rotate(270deg);
text-align: center;
margin-top: 50%;
margin-bottom: 50%;
width: auto;
}
</style>
</head>
<body>
<link id="terminal" rel="stylesheet" href="http://terminal.jcubic.pl/css/jquery.terminal.css">
<terminal>
<span class="toggle"><b>click to test $.terminal</b></span>
<div class="console"></div>
</terminal>
<script>
$(document).ready(function($, undefined) {
$('.console').terminal(function(command, term) {
if (command !== '') {
try {
var result = window.eval(command);
if (result !== undefined) {
term.echo(new String(result));
}
} catch(e) {
term.error(new String(e));
}
} else {
term.echo('');
}
}, {
greetings: 'Enjoy a browser based Javascript console',
name: 'js_demo',
height: "80%",
prompt: '> '});
$('terminal').first().each( function(){
var t = $(this).find('.toggle');
var p = $(this);
$(t).click( function(){
$(p).toggleClass('show');
})//click
});//each
});//ready
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment