<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="enter a command.">
<title>unilogue</title>
<link rel="icon" href="favi.png">
<link rel="stylesheet" href="https://unilogue.github.io/css/style.css">
<script type="text/javascript" src="https://unilogue.github.io/js/jquery-1.11.3.min.js"></script>
</head>
<body>
<header>
<div id="prompt">enter the letter 'g' to load the div, notice how it keeps reloading if you enter the letter 'g' again? i don't want that to happen.</div>
<br>
</header>
<div class="container"><p>> </p><input class="inputs" type="text" placeholder="ENTER COMMAND" /></div>
</body>
</html>
$(document).ready(function() {
$.ajaxSetup ({
cache: false
});
// Check on keydown
$('.inputs').keyup(function (e) {
if (e.keyCode == 13) {
var value = $(this).val();
var ajax_load = "<p>LOADING<span class=\"blink\">_</span></p>";
var loadGlossary = "https://unilogue.github.io/commands/glossary.asp";
var errorLine = $("<p><span class=\"cmd\">> UNKNOWN COMMAND</span></p><br>");
var newLine = $('.inputs').clone(true).val('');
var glossary = $("<div id=\"div3\"></div>");
$.fn.gCmd = function() {
$('.container').append(glossary);
$("#div3").html(ajax_load).load(loadGlossary);
};
$.fn.newLine = function() {
$('.container').append("<p>> </p>").append(newLine);
$(this).prop('disabled', true);
$(this).removeClass('inputs');
$('.inputs').replaceWith(newLine);
$('.inputs:first').focus();
};
// Tiny jQuery Plugin
// by Chris Goodchild
$.fn.exists = function(callback) {
var args = [].slice.call(arguments, 1);
if (this.length) {
callback.call(this, args);
}
return this;
};
/* Usage
$(glossary).exists(function() {
this.append('<p><span class=\"cmd\">> [g]lossary is already open!</span></p><br>');
});*/
if (value == 'g' && !($('#div3').length)) { // If input value is div3
$(this).gCmd();
} else if (value == 'g' && $(glossary).length === 0) {
$(this).append('<p>Look! A Thing!</p>');
} else if (value !== '' && $(glossary).length === 0) { // If input value is wrong
$(this).append(errorLine);
} /*appends to all lines */ $(this).newLine();
}
});
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |