{I" class:ETI"BundledAsset; FI"logical_path; TI"jquery.console.js; TI" pathname; TI"V/Users/genadi/Development/web-console/vendor/assets/javascripts/jquery.console.js; FI"content_type; TI"application/javascript; TI" mtime; Tl+Ä®|SI"length; TiÃOI"digest; TI"%5fc63303102fb6f5326282b22df695d5; FI"source; TI"ÃO// JQuery Console 1.0 // Sun Feb 21 20:28:47 GMT 2010 // // Copyright 2010 Chris Done, Simon David Pratt. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above // copyright notice, this list of conditions and the following // disclaimer. // // 2. Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials // provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // TESTED ON // Internet Explorer 6 // Opera 10.01 // Chromium 4.0.237.0 (Ubuntu build 31094) // Firefox 3.5.8, 3.6.2 (Mac) // Safari 4.0.5 (6531.22.7) (Mac) // Google Chrome 5.0.375.55 (Mac) (function($){ var isWebkit = !!~navigator.userAgent.indexOf(' AppleWebKit/'); $.fn.console = function(config){ //////////////////////////////////////////////////////////////////////// // Constants // Some are enums, data types, others just for optimisation var keyCodes = { // left 37: moveBackward, // right 39: moveForward, // up 38: previousHistory, // down 40: nextHistory, // backspace 8: backDelete, // delete 46: forwardDelete, // end 35: moveToEnd, // start 36: moveToStart, // return 13: commandTrigger, // tab 18: doNothing, // tab 9: doComplete }; var ctrlCodes = { // C-a 65: moveToStart, // C-e 69: moveToEnd, // C-d 68: forwardDelete, // C-n 78: nextHistory, // C-p 80: previousHistory, // C-b 66: moveBackward, // C-f 70: moveForward, // C-k 75: deleteUntilEnd }; if(config.ctrlCodes) { $.extend(ctrlCodes, config.ctrlCodes); } var altCodes = { // M-f 70: moveToNextWord, // M-b 66: moveToPreviousWord, // M-d 68: deleteNextWord }; var cursor = ' '; //////////////////////////////////////////////////////////////////////// // Globals var container = $(this); var inner = $('
'); // erjiang: changed this from a text input to a textarea so we // can get pasted newlines var typer = $(''); // Prompt var promptBox; var prompt; var promptLabel = config && config.promptLabel? config.promptLabel : "> "; var continuedPromptLabel = config && config.continuedPromptLabel? config.continuedPromptLabel : "> "; var column = 0; var promptText = ''; var restoreText = ''; var continuedText = ''; // Prompt history stack var history = []; var ringn = 0; // For reasons unknown to The Sword of Michael himself, Opera // triggers and sends a key character when you hit various // keys like PgUp, End, etc. So there is no way of knowing // when a user has typed '#' or End. My solution is in the // typer.keydown and typer.keypress functions; I use the // variable below to ignore the keypress event if the keydown // event succeeds. var cancelKeyPress = 0; // When this value is false, the prompt will not respond to input var acceptInput = true; // When this value is true, the command has been canceled var cancelCommand = false; // External exports object var extern = {}; //////////////////////////////////////////////////////////////////////// // Main entry point (function(){ container.append(inner); inner.append(typer); typer.css({position:'absolute',top:0,left:'-9999px'}); if (config.welcomeMessage) message(config.welcomeMessage,'jquery-console-welcome'); newPromptBox(); if (config.autofocus) { inner.addClass('jquery-console-focus'); typer.focus(); setTimeout(function(){ inner.addClass('jquery-console-focus'); typer.focus(); },100); } extern.inner = inner; extern.typer = typer; extern.scrollToBottom = scrollToBottom; })(); //////////////////////////////////////////////////////////////////////// // Reset terminal extern.reset = function(){ var welcome = (typeof config.welcomeMessage != 'undefined'); inner.parent().fadeOut(function(){ inner.find('div').each(function(){ if (!welcome) { $(this).remove(); } else { welcome = false; } }); newPromptBox(); inner.parent().fadeIn(function(){ inner.addClass('jquery-console-focus'); typer.focus(); }); }); }; //////////////////////////////////////////////////////////////////////// // Reset terminal extern.notice = function(msg,style){ var n = $('').append($('').text(msg)) .css({visibility:'hidden'}); container.append(n); var focused = true; if (style=='fadeout') setTimeout(function(){ n.fadeOut(function(){ n.remove(); }); },4000); else if (style=='prompt') { var a = $('