mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
chore(console) remove jquery-terminal
This commit is contained in:
parent
0aff78a638
commit
3c49381ac4
19 changed files with 4 additions and 4185 deletions
|
|
@ -90,6 +90,8 @@ getJSONfromFileTable.
|
|||
|
||||
* feature(socket) if id in use - reconnect
|
||||
|
||||
* chore(console) remove jquery-terminal
|
||||
|
||||
|
||||
2012.04.22, v0.2.0
|
||||
|
||||
|
|
|
|||
|
|
@ -120,12 +120,12 @@ var CloudCmd, Util, DOM, $, jqconsole;
|
|||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jq-console/',
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'console/',
|
||||
lFiles = [
|
||||
lDir + 'jqconsole.js',
|
||||
lDir + 'jqconsole.css',
|
||||
lDir + 'ansi.css',
|
||||
CloudCmd.LIBDIRCLIENT + 'terminal/jquery-terminal/jquery-migrate-1.0.0.js'
|
||||
lDir + 'jquery-migrate-1.0.0.js'
|
||||
];
|
||||
|
||||
DOM.anyLoadInParallel(lFiles, function(){
|
||||
|
|
|
|||
93
lib/client/jquery-console.js
vendored
93
lib/client/jquery-console.js
vendored
|
|
@ -1,93 +0,0 @@
|
|||
var CloudCmd, Util, DOM, $;
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM);
|
||||
|
||||
function ConsoleProto(CloudCmd, Util, DOM){
|
||||
var Name = 'Console',
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
Console = this;
|
||||
|
||||
this.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
Console.show,
|
||||
load,
|
||||
CloudCmd.View,
|
||||
DOM.jqueryLoad,
|
||||
]);
|
||||
|
||||
DOM.Events.addKey(listener);
|
||||
|
||||
delete Console.init;
|
||||
};
|
||||
|
||||
this.show = function(){
|
||||
var lElement;
|
||||
|
||||
Images.showLoad({top:true});
|
||||
|
||||
lElement = DOM.anyload({
|
||||
name : 'div',
|
||||
className : 'console'
|
||||
});
|
||||
|
||||
$(lElement).console({
|
||||
promptLabel: '# ',
|
||||
commandValidate : function(line){
|
||||
var lRet = line !== "";
|
||||
|
||||
return lRet;
|
||||
},
|
||||
commandHandle : function(line){
|
||||
return line;
|
||||
},
|
||||
autofocus : true,
|
||||
animateScroll : false,
|
||||
promptHistory : true,
|
||||
});
|
||||
|
||||
CloudCmd.View.show(lElement);
|
||||
};
|
||||
|
||||
|
||||
this.hide = function(){
|
||||
CloudCmd.View.hide();
|
||||
};
|
||||
|
||||
function load(pCallBack){
|
||||
Util.time(Name + ' load');
|
||||
|
||||
var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jquery-console/',
|
||||
lFiles = [
|
||||
lDir + 'jquery.console.js',
|
||||
lDir + 'jquery.console.css'
|
||||
];
|
||||
|
||||
DOM.anyLoadInParallel(lFiles, function(){
|
||||
console.timeEnd(Name + ' load');
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
}
|
||||
|
||||
function listener(pEvent){
|
||||
var lF10 = Key.F10,
|
||||
lESC = Key.ESC,
|
||||
lIsBind = Key.isBind(),
|
||||
lKey = pEvent.keyCode;
|
||||
|
||||
switch(lKey){
|
||||
case lF10:
|
||||
Console.show();
|
||||
break;
|
||||
case lESC:
|
||||
Console.hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
var CloudCmd, Util, DOM, $;
|
||||
/* object contains terminal jqconsole */
|
||||
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
var Key = CloudCmd.Key,
|
||||
TerminalId,
|
||||
Term,
|
||||
Hidden = false,
|
||||
JqueryTerminal = {};
|
||||
|
||||
CloudCmd.Terminal = {};
|
||||
|
||||
/**
|
||||
* function loads jquery-terminal
|
||||
*/
|
||||
function load(pCallBack){
|
||||
Util.time('terminal load');
|
||||
|
||||
var lDir = '/lib/client/terminal/jquery-terminal/jquery.',
|
||||
lFiles = [
|
||||
lDir + 'terminal.js',
|
||||
lDir + 'mousewheel.js',
|
||||
lDir + 'terminal.css'
|
||||
],
|
||||
lJqueryMigrate = '//code.jquery.com/jquery-migrate-1.0.0.js';
|
||||
/* //github.com/jquery/jquery-migrate/ */
|
||||
|
||||
DOM.anyLoadOnLoad([lFiles, lJqueryMigrate], function(){
|
||||
Util.timeEnd('terminal load');
|
||||
init();
|
||||
$(function($) {
|
||||
Term = JqueryTerminal.Term = $('#terminal').terminal(function(command, term){
|
||||
term.echo('');
|
||||
CloudCmd.Socket.send(command);
|
||||
}, {
|
||||
greetings : '[[;#729FCF;]CloudCmd Terminal]',
|
||||
prompt : '[[;#729FCF;]cloudcmd> ]',
|
||||
color : '#729FCF;'
|
||||
});
|
||||
});
|
||||
/* removing resize function, no need for us */
|
||||
$(window).unbind('resize');
|
||||
|
||||
Util.exec(pCallBack);
|
||||
}).cssSet({id:'terminal-css',
|
||||
inner: '.terminal{' +
|
||||
'height: 720px;' +
|
||||
'};'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function do basic initialization
|
||||
*/
|
||||
function init(){
|
||||
if(!TerminalId)
|
||||
TerminalId = DOM.anyload({
|
||||
name : 'div',
|
||||
id : 'terminal',
|
||||
className : 'panel terminal',
|
||||
parent : DOM.getFM()
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* functin show jquery-terminal
|
||||
*/
|
||||
JqueryTerminal.show = function(){
|
||||
DOM.Images.hideLoad();
|
||||
/* only if panel was hided */
|
||||
if( DOM.hidePanel() ){
|
||||
Hidden = false;
|
||||
DOM.show(TerminalId);
|
||||
Key.unsetBind();
|
||||
Term.resume();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* function hide jquery-terminal
|
||||
*/
|
||||
JqueryTerminal.hide = function(){
|
||||
Hidden = true;
|
||||
|
||||
DOM.hide(TerminalId);
|
||||
DOM.showPanel();
|
||||
Key.setBind();
|
||||
|
||||
Term.pause();
|
||||
};
|
||||
|
||||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
CloudCmd.Terminal.init = function(){
|
||||
Util.loadOnLoad([
|
||||
JqueryTerminal.show,
|
||||
load,
|
||||
DOM.socketLoad,
|
||||
DOM.jqueryLoad,
|
||||
]);
|
||||
|
||||
DOM.Events.addKey(lListener);
|
||||
|
||||
function lListener(pEvent){
|
||||
var lRet = true,
|
||||
lESC = Key.ESC,
|
||||
lTRA = Key.TRA,
|
||||
lKey = pEvent.keyCode,
|
||||
lIsBind = Key.isBind();
|
||||
|
||||
switch(lKey){
|
||||
case lTRA:
|
||||
if(Hidden && lIsBind){
|
||||
JqueryTerminal.show();
|
||||
DOM.preventDefault(pEvent);
|
||||
lRet = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case lESC:
|
||||
if(!Hidden)
|
||||
JqueryTerminal.hide();
|
||||
break;
|
||||
}
|
||||
|
||||
return lRet;
|
||||
}
|
||||
};
|
||||
|
||||
CloudCmd.Terminal.JqueryTerminal = JqueryTerminal;
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
20
lib/client/terminal/jquery-console/.gitignore
vendored
20
lib/client/terminal/jquery-console/.gitignore
vendored
|
|
@ -1,20 +0,0 @@
|
|||
# Compiled source #
|
||||
###################
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
*.pyc
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store*
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
INTRODUCTION
|
||||
|
||||
See demo.html. Or here: http://chrisdone.com/jquery-console/
|
||||
|
||||
Options available:
|
||||
|
||||
autofocus bool Autofocus the terminal, rather than
|
||||
having to click on it.
|
||||
|
||||
promptHistory bool Provide history support (kind of crappy,
|
||||
needs doing properly.)
|
||||
|
||||
historyPreserveColumn bool Preserve the column you were one when
|
||||
switching between history.
|
||||
|
||||
welcomeMessage string Just a first message to display on the
|
||||
terminal.
|
||||
|
||||
promptLabel string Prompt string like 'JavaScript> '.
|
||||
|
||||
cols integer the number of cols, this value is only
|
||||
used by the command completion to format
|
||||
the list of results.
|
||||
|
||||
commandValidate function When user hits return, validate
|
||||
whether to trigger commandHandle and
|
||||
re-prompt.
|
||||
|
||||
commandHandle function Handle the command line, return a
|
||||
string, boolean, or list
|
||||
of {msg:"foo",className:"my-css-class"}.
|
||||
commandHandle(line,report) is
|
||||
called. Report function is for you
|
||||
to report a result of the command
|
||||
asynchronously.
|
||||
|
||||
commandComplete function Handle the command completion when the
|
||||
tab key is pressed. It returns a list
|
||||
of string completion suffixes.
|
||||
|
||||
animateScroll bool Whether to animate the scroll to
|
||||
top. Currently disabled.
|
||||
|
||||
charInsertTrigger function Predicate for whether to allow
|
||||
character insertion.
|
||||
charInsertTrigger(char,line) is called.
|
||||
|
||||
cancelHandle function Handle a user-signaled interrupt.
|
||||
|
||||
LICENSE
|
||||
|
||||
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.
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
.console {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.jquery-console-inner {
|
||||
padding:0.5em;
|
||||
}
|
||||
.jquery-console-prompt-box {
|
||||
color:black;
|
||||
font-family:monospace;
|
||||
}
|
||||
.jquery-console-cursor {
|
||||
color:#333;
|
||||
font-weight:bold;
|
||||
}
|
||||
.jquery-console-message-error {
|
||||
color:#ef0505;
|
||||
font-family:sans-serif;
|
||||
font-weight:bold;
|
||||
padding:0.1em;
|
||||
}
|
||||
.jquery-console-message-value {
|
||||
color:#1ad027;
|
||||
font-family:monospace;
|
||||
padding:0.1em;
|
||||
}
|
||||
.jquery-console-message-type {
|
||||
color:#52666f;
|
||||
font-family:monospace;
|
||||
padding:0.1em;
|
||||
}
|
||||
.jquery-console-prompt-label {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
|
@ -1,716 +0,0 @@
|
|||
// 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 = '<span class="jquery-console-cursor"> </span>';
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Globals
|
||||
var container = $(this);
|
||||
var inner = $('<div class="jquery-console-inner"></div>');
|
||||
// erjiang: changed this from a text input to a textarea so we
|
||||
// can get pasted newlines
|
||||
var typer = $('<textarea class="jquery-console-typer"></textarea>');
|
||||
// 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 = $('<div class="notice"></div>').append($('<div></div>').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 = $('<br/><div class="action"><a href="javascript:">OK</a><div class="clear"></div></div>');
|
||||
n.append(a);
|
||||
focused = false;
|
||||
a.click(function(){ n.fadeOut(function(){ n.remove();inner.css({opacity:1}) }); });
|
||||
}
|
||||
var h = n.height();
|
||||
n.css({height:'0px',visibility:'visible'})
|
||||
.animate({height:h+'px'},function(){
|
||||
if (!focused) inner.css({opacity:0.5});
|
||||
});
|
||||
n.css('cursor','default');
|
||||
return n;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Make a new prompt box
|
||||
function newPromptBox() {
|
||||
column = 0;
|
||||
promptText = '';
|
||||
ringn = 0; // Reset the position of the history ring
|
||||
enableInput();
|
||||
promptBox = $('<div class="jquery-console-prompt-box"></div>');
|
||||
var label = $('<span class="jquery-console-prompt-label"></span>');
|
||||
var labelText = extern.continuedPrompt? continuedPromptLabel : promptLabel;
|
||||
promptBox.append(label.text(labelText).show());
|
||||
label.html(label.html().replace(' ',' '));
|
||||
prompt = $('<span class="jquery-console-prompt"></span>');
|
||||
promptBox.append(prompt);
|
||||
inner.append(promptBox);
|
||||
updatePromptDisplay();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Handle setting focus
|
||||
container.click(function(){
|
||||
inner.addClass('jquery-console-focus');
|
||||
inner.removeClass('jquery-console-nofocus');
|
||||
if (isWebkit) {
|
||||
typer.focusWithoutScrolling();
|
||||
} else {
|
||||
typer.css('position', 'fixed').focus();
|
||||
}
|
||||
scrollToBottom();
|
||||
return false;
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Handle losing focus
|
||||
typer.blur(function(){
|
||||
inner.removeClass('jquery-console-focus');
|
||||
inner.addClass('jquery-console-nofocus');
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Bind to the paste event of the input box so we know when we
|
||||
// get pasted data
|
||||
typer.bind('paste', function(e) {
|
||||
// wipe typer input clean just in case
|
||||
typer.val("");
|
||||
// this timeout is required because the onpaste event is
|
||||
// fired *before* the text is actually pasted
|
||||
setTimeout(function() {
|
||||
typer.consoleInsert(typer.val());
|
||||
typer.val("");
|
||||
}, 0);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Handle key hit before translation
|
||||
// For picking up control characters like up/left/down/right
|
||||
|
||||
typer.keydown(function(e){
|
||||
cancelKeyPress = 0;
|
||||
var keyCode = e.keyCode;
|
||||
// C-c: cancel the execution
|
||||
if(e.ctrlKey && keyCode == 67) {
|
||||
cancelKeyPress = keyCode;
|
||||
cancelExecution();
|
||||
return false;
|
||||
}
|
||||
if (acceptInput) {
|
||||
if (keyCode in keyCodes) {
|
||||
cancelKeyPress = keyCode;
|
||||
(keyCodes[keyCode])();
|
||||
return false;
|
||||
} else if (e.ctrlKey && keyCode in ctrlCodes) {
|
||||
cancelKeyPress = keyCode;
|
||||
(ctrlCodes[keyCode])();
|
||||
return false;
|
||||
} else if (e.altKey && keyCode in altCodes) {
|
||||
cancelKeyPress = keyCode;
|
||||
(altCodes[keyCode])();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Handle key press
|
||||
typer.keypress(function(e){
|
||||
var keyCode = e.keyCode || e.which;
|
||||
if (isIgnorableKey(e)) {
|
||||
return false;
|
||||
}
|
||||
// C-v: don't insert on paste event
|
||||
if ((e.ctrlKey || e.metaKey) && String.fromCharCode(keyCode).toLowerCase() == 'v') {
|
||||
return true;
|
||||
}
|
||||
if (acceptInput && cancelKeyPress != keyCode && keyCode >= 32){
|
||||
if (cancelKeyPress) return false;
|
||||
if (
|
||||
typeof config.charInsertTrigger == 'undefined' || (
|
||||
typeof config.charInsertTrigger == 'function' &&
|
||||
config.charInsertTrigger(keyCode,promptText)
|
||||
)
|
||||
){
|
||||
typer.consoleInsert(keyCode);
|
||||
}
|
||||
}
|
||||
if (isWebkit) return false;
|
||||
});
|
||||
|
||||
function isIgnorableKey(e) {
|
||||
// for now just filter alt+tab that we receive on some platforms when
|
||||
// user switches windows (goes away from the browser)
|
||||
return ((e.keyCode == keyCodes.tab || e.keyCode == 192) && e.altKey);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Rotate through the command history
|
||||
function rotateHistory(n){
|
||||
if (history.length == 0) return;
|
||||
ringn += n;
|
||||
if (ringn < 0) ringn = history.length;
|
||||
else if (ringn > history.length) ringn = 0;
|
||||
var prevText = promptText;
|
||||
if (ringn == 0) {
|
||||
promptText = restoreText;
|
||||
} else {
|
||||
promptText = history[ringn - 1];
|
||||
}
|
||||
if (config.historyPreserveColumn) {
|
||||
if (promptText.length < column + 1) {
|
||||
column = promptText.length;
|
||||
} else if (column == 0) {
|
||||
column = promptText.length;
|
||||
}
|
||||
} else {
|
||||
column = promptText.length;
|
||||
}
|
||||
updatePromptDisplay();
|
||||
};
|
||||
|
||||
function previousHistory() {
|
||||
rotateHistory(-1);
|
||||
};
|
||||
|
||||
function nextHistory() {
|
||||
rotateHistory(1);
|
||||
};
|
||||
|
||||
// Add something to the history ring
|
||||
function addToHistory(line){
|
||||
history.push(line);
|
||||
restoreText = '';
|
||||
};
|
||||
|
||||
// Delete the character at the current position
|
||||
function deleteCharAtPos(){
|
||||
if (column < promptText.length){
|
||||
promptText =
|
||||
promptText.substring(0,column) +
|
||||
promptText.substring(column+1);
|
||||
restoreText = promptText;
|
||||
return true;
|
||||
} else return false;
|
||||
};
|
||||
|
||||
function backDelete() {
|
||||
if (moveColumn(-1)){
|
||||
deleteCharAtPos();
|
||||
updatePromptDisplay();
|
||||
}
|
||||
};
|
||||
|
||||
function forwardDelete() {
|
||||
if (deleteCharAtPos()){
|
||||
updatePromptDisplay();
|
||||
}
|
||||
};
|
||||
|
||||
function deleteUntilEnd() {
|
||||
while(deleteCharAtPos()) {
|
||||
updatePromptDisplay();
|
||||
}
|
||||
};
|
||||
|
||||
function deleteNextWord() {
|
||||
// A word is defined within this context as a series of alphanumeric
|
||||
// characters.
|
||||
// Delete up to the next alphanumeric character
|
||||
while(
|
||||
column < promptText.length &&
|
||||
!isCharAlphanumeric(promptText[column])
|
||||
) {
|
||||
deleteCharAtPos();
|
||||
updatePromptDisplay();
|
||||
}
|
||||
// Then, delete until the next non-alphanumeric character
|
||||
while(
|
||||
column < promptText.length &&
|
||||
isCharAlphanumeric(promptText[column])
|
||||
) {
|
||||
deleteCharAtPos();
|
||||
updatePromptDisplay();
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Validate command and trigger it if valid, or show a validation error
|
||||
function commandTrigger() {
|
||||
var line = promptText;
|
||||
if (typeof config.commandValidate == 'function') {
|
||||
var ret = config.commandValidate(line);
|
||||
if (ret == true || ret == false) {
|
||||
if (ret) {
|
||||
handleCommand();
|
||||
}
|
||||
} else {
|
||||
commandResult(ret,"jquery-console-message-error");
|
||||
}
|
||||
} else {
|
||||
handleCommand();
|
||||
}
|
||||
};
|
||||
|
||||
// Scroll to the bottom of the view
|
||||
function scrollToBottom() {
|
||||
if (jQuery.fn.jquery > "1.6") {
|
||||
inner.prop({ scrollTop: inner.prop("scrollHeight") });
|
||||
}
|
||||
else {
|
||||
inner.attr({ scrollTop: inner.attr("scrollHeight") });
|
||||
}
|
||||
};
|
||||
|
||||
function cancelExecution() {
|
||||
if(typeof config.cancelHandle == 'function') {
|
||||
config.cancelHandle();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Handle a command
|
||||
function handleCommand() {
|
||||
if (typeof config.commandHandle == 'function') {
|
||||
disableInput();
|
||||
addToHistory(promptText);
|
||||
var text = promptText;
|
||||
if (extern.continuedPrompt) {
|
||||
if (continuedText)
|
||||
continuedText += '\n' + promptText;
|
||||
else continuedText = promptText;
|
||||
} else continuedText = undefined;
|
||||
if (continuedText) text = continuedText;
|
||||
var ret = config.commandHandle(text,function(msgs){
|
||||
commandResult(msgs);
|
||||
});
|
||||
if (extern.continuedPrompt && !continuedText)
|
||||
continuedText = promptText;
|
||||
if (typeof ret == 'boolean') {
|
||||
if (ret) {
|
||||
// Command succeeded without a result.
|
||||
commandResult();
|
||||
} else {
|
||||
commandResult(
|
||||
'Command failed.',
|
||||
"jquery-console-message-error"
|
||||
);
|
||||
}
|
||||
} else if (typeof ret == "string") {
|
||||
commandResult(ret,"jquery-console-message-success");
|
||||
} else if (typeof ret == 'object' && ret.length) {
|
||||
commandResult(ret);
|
||||
} else if (extern.continuedPrompt) {
|
||||
commandResult();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Disable input
|
||||
function disableInput() {
|
||||
acceptInput = false;
|
||||
};
|
||||
|
||||
// Enable input
|
||||
function enableInput() {
|
||||
acceptInput = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Reset the prompt in invalid command
|
||||
function commandResult(msg,className) {
|
||||
column = -1;
|
||||
updatePromptDisplay();
|
||||
if (typeof msg == 'string') {
|
||||
message(msg,className);
|
||||
} else if ($.isArray(msg)) {
|
||||
for (var x in msg) {
|
||||
var ret = msg[x];
|
||||
message(ret.msg,ret.className);
|
||||
}
|
||||
} else { // Assume it's a DOM node or jQuery object.
|
||||
inner.append(msg);
|
||||
}
|
||||
newPromptBox();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Display a message
|
||||
function message(msg,className) {
|
||||
var mesg = $('<div class="jquery-console-message"></div>');
|
||||
if (className) mesg.addClass(className);
|
||||
mesg.filledText(msg).hide();
|
||||
inner.append(mesg);
|
||||
mesg.show();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Handle normal character insertion
|
||||
// data can either be a number, which will be interpreted as the
|
||||
// numeric value of a single character, or a string
|
||||
typer.consoleInsert = function(data){
|
||||
// TODO: remove redundant indirection
|
||||
var text = isNaN(data) ? data : String.fromCharCode(data);
|
||||
var before = promptText.substring(0,column);
|
||||
var after = promptText.substring(column);
|
||||
promptText = before + text + after;
|
||||
moveColumn(text.length);
|
||||
restoreText = promptText;
|
||||
updatePromptDisplay();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Move to another column relative to this one
|
||||
// Negative means go back, positive means go forward.
|
||||
function moveColumn(n){
|
||||
if (column + n >= 0 && column + n <= promptText.length){
|
||||
column += n;
|
||||
return true;
|
||||
} else return false;
|
||||
};
|
||||
|
||||
function moveForward() {
|
||||
if(moveColumn(1)) {
|
||||
updatePromptDisplay();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function moveBackward() {
|
||||
if(moveColumn(-1)) {
|
||||
updatePromptDisplay();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function moveToStart() {
|
||||
if (moveColumn(-column))
|
||||
updatePromptDisplay();
|
||||
};
|
||||
|
||||
function moveToEnd() {
|
||||
if (moveColumn(promptText.length-column))
|
||||
updatePromptDisplay();
|
||||
};
|
||||
|
||||
function moveToNextWord() {
|
||||
while(
|
||||
column < promptText.length &&
|
||||
!isCharAlphanumeric(promptText[column]) &&
|
||||
moveForward()
|
||||
) {}
|
||||
while(
|
||||
column < promptText.length &&
|
||||
isCharAlphanumeric(promptText[column]) &&
|
||||
moveForward()
|
||||
) {}
|
||||
};
|
||||
|
||||
function moveToPreviousWord() {
|
||||
// Move backward until we find the first alphanumeric
|
||||
while(
|
||||
column -1 >= 0 &&
|
||||
!isCharAlphanumeric(promptText[column-1]) &&
|
||||
moveBackward()
|
||||
) {}
|
||||
// Move until we find the first non-alphanumeric
|
||||
while(
|
||||
column -1 >= 0 &&
|
||||
isCharAlphanumeric(promptText[column-1]) &&
|
||||
moveBackward()
|
||||
) {}
|
||||
};
|
||||
|
||||
function isCharAlphanumeric(charToTest) {
|
||||
if(typeof charToTest == 'string') {
|
||||
var code = charToTest.charCodeAt();
|
||||
return (code >= 'A'.charCodeAt() && code <= 'Z'.charCodeAt()) ||
|
||||
(code >= 'a'.charCodeAt() && code <= 'z'.charCodeAt()) ||
|
||||
(code >= '0'.charCodeAt() && code <= '9'.charCodeAt());
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
function doComplete() {
|
||||
if(typeof config.completeHandle == 'function') {
|
||||
var completions = config.completeHandle(promptText);
|
||||
var len = completions.length;
|
||||
if (len === 1) {
|
||||
extern.promptText(promptText + completions[0]);
|
||||
} else if (len > 1 && config.cols) {
|
||||
var prompt = promptText;
|
||||
// Compute the number of rows that will fit in the width
|
||||
var max = 0;
|
||||
for (var i = 0;i < len;i++) {
|
||||
max = Math.max(max, completions[i].length);
|
||||
}
|
||||
max += 2;
|
||||
var n = Math.floor(config.cols / max);
|
||||
var buffer = "";
|
||||
var col = 0;
|
||||
for (i = 0;i < len;i++) {
|
||||
var completion = completions[i];
|
||||
buffer += completions[i];
|
||||
for (var j = completion.length;j < max;j++) {
|
||||
buffer += " ";
|
||||
}
|
||||
if (++col >= n) {
|
||||
buffer += "\n";
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
commandResult(buffer,"jquery-console-message-value");
|
||||
extern.promptText(prompt);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function doNothing() {};
|
||||
|
||||
extern.promptText = function(text){
|
||||
if (typeof text === 'string') {
|
||||
promptText = text;
|
||||
column = promptText.length;
|
||||
updatePromptDisplay();
|
||||
}
|
||||
return promptText;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Update the prompt display
|
||||
function updatePromptDisplay(){
|
||||
var line = promptText;
|
||||
var html = '';
|
||||
if (column > 0 && line == ''){
|
||||
// When we have an empty line just display a cursor.
|
||||
html = cursor;
|
||||
} else if (column == promptText.length){
|
||||
// We're at the end of the line, so we need to display
|
||||
// the text *and* cursor.
|
||||
html = htmlEncode(line) + cursor;
|
||||
} else {
|
||||
// Grab the current character, if there is one, and
|
||||
// make it the current cursor.
|
||||
var before = line.substring(0, column);
|
||||
var current = line.substring(column,column+1);
|
||||
if (current){
|
||||
current =
|
||||
'<span class="jquery-console-cursor">' +
|
||||
htmlEncode(current) +
|
||||
'</span>';
|
||||
}
|
||||
var after = line.substring(column+1);
|
||||
html = htmlEncode(before) + current + htmlEncode(after);
|
||||
}
|
||||
prompt.html(html);
|
||||
scrollToBottom();
|
||||
};
|
||||
|
||||
// Simple HTML encoding
|
||||
// Simply replace '<', '>' and '&'
|
||||
// TODO: Use jQuery's .html() trick, or grab a proper, fast
|
||||
// HTML encoder.
|
||||
function htmlEncode(text){
|
||||
return (
|
||||
text.replace(/&/g,'&')
|
||||
.replace(/</g,'<')
|
||||
.replace(/</g,'<')
|
||||
.replace(/ /g,' ')
|
||||
.replace(/\n/g,'<br />')
|
||||
);
|
||||
};
|
||||
|
||||
return extern;
|
||||
};
|
||||
// Simple utility for printing messages
|
||||
$.fn.filledText = function(txt){
|
||||
$(this).text(txt);
|
||||
$(this).html($(this).html().replace(/\n/g,'<br/>'));
|
||||
return this;
|
||||
};
|
||||
|
||||
// Alternative method for focus without scrolling
|
||||
$.fn.focusWithoutScrolling = function(){
|
||||
var x = window.scrollX, y = window.scrollY;
|
||||
$(this).focus();
|
||||
window.scrollTo(x, y);
|
||||
};
|
||||
})(jQuery);
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
0.4.20 Add exec, greetings, onClear, onBlur, onFocus, onTerminalChange
|
||||
0.4.19 add support for ANSI terminal formatting, fix cancelable ajax on
|
||||
CTRL+D, replace emails with link mailto, remove formatting processing
|
||||
from command line, add text glow option to formatting
|
||||
0.4.18 fix scrollbar, better exceptions in chrome, replace urls with links
|
||||
one style for font and color in root .terminal class
|
||||
0.4.17 fix IE formatting issue by adding cross-browser split
|
||||
0.4.16 add reverse history search on CTRL+R
|
||||
|
||||
fix cancel ajax call on CTRL+D
|
||||
0.4.15 only one command from multiply commands is added to history
|
||||
CTRL+D is handled even if exit is false
|
||||
0.4.14 terminal don't add space after prompt (prompt need to add this space)
|
||||
fix historyFilter
|
||||
remove livequery
|
||||
0.4.12 history return history object
|
||||
add historyFilter
|
||||
new event onCommandChange that execute scroll_to_bottom
|
||||
add event onBeforeLogin
|
||||
0.4.11 fix blank lines when echo longer strings
|
||||
0.4.10 fix long line formatting and linebreak in the middle of formatting
|
||||
0.4.9 fix wrap first line when prompt contain formatting
|
||||
0.4.8 fix alt+d and ctrl+u
|
||||
0.4.7 fix inserting special characters in Webkit on Windows
|
||||
0.4.6 remove undocumented pipe operator
|
||||
refreash prompt on resume
|
||||
0.4.5 fix line wrapping when text contains tabulations
|
||||
0.4.4 fix line wrapping with scrollbars
|
||||
0.4.3 fix JSON-RPC when use without login
|
||||
0.4.2 fix formatting when text contain empty lines
|
||||
0.4.1 fix formatting when text contains newline characters
|
||||
0.4 fix text formating when text splited into more then one line
|
||||
you can pass nested objects as first argument
|
||||
add tab completion with object passed as first argument
|
||||
0.3.8 fix cursor manipulation when command contain new line characters
|
||||
0.3.7 fix function terminal.login_name
|
||||
0.3.6 fix switch between terminals - when terminal is not visible scroll to current terminal
|
||||
0.3.5 fix scrolling in jQuery 1.6
|
||||
0.3.3 fixing PAGE UP/DOWN
|
||||
0.3.2 fixing cursor in long lines
|
||||
0.3.1 fixing small bugs, speed up resizing
|
||||
0.3 fix resizing on start and issue with greetings
|
||||
add formating strings to set style of text.
|
||||
add to echo a function which will be called when terminal
|
||||
is resized
|
||||
0.3-RC2 fix manipulation of long line commands
|
||||
0.3-RC1 add callbacks and new functions
|
||||
you can now overwrite keyboard shortcuts
|
||||
resizing recalculates lines lenght and redraw content
|
||||
if you create plugin for elements that are not in the DOM
|
||||
and then append it to DOM it's display corectly
|
||||
put all dependencies in one file
|
||||
Default greetings show terminal signature depending on
|
||||
width of terminal
|
||||
use Local Sorage for command line history if posible
|
||||
remove access to command line (cmd plugin) and add interface
|
||||
to allow interact with it
|
||||
|
||||
0.2.3.9 fix append enter character (0x0D) to the command (thanks to marat
|
||||
for reporting the bug)
|
||||
|
||||
0.2.3.8 update mousewheel plugin which fix scrolling in Opera (Thanks for
|
||||
Alexey Dubovtsev for reporting the bug)
|
||||
|
||||
0.2.3.7 fix cursor in IE in tilda example
|
||||
|
||||
0.2.3.6 fix json serialization in IE
|
||||
|
||||
0.2.3.5 fix demos and clipboard textarea transparency in IE
|
||||
|
||||
0.2.3.4 fix long lines in command line issue
|
||||
|
||||
0.2.3.3 fix Terminal in Internet Exporer
|
||||
|
||||
0.2.3.2 fix blank line issue (thanks to Chris Janicki for finding the
|
||||
bug) and fix CTRL + Arrows scroll on CTRL+V
|
||||
|
||||
0.2.3.1 allow CTRL+W CTRL+T
|
||||
|
||||
0.2.3 fix for "(#$%.{" characters on Opera/Chrome, add cursor move
|
||||
with CTRL+P, CTRL+N, CTRL+F, CTRL+B which also work in Chrome.
|
||||
Fix Arrow Keys on Chrome (for cursor move and command line
|
||||
history). Change License to LGPL3.
|
||||
|
||||
0.2.2 fix down-arrow/open parentises issue in Opera and Chrome
|
||||
|
||||
0.2.1 add support for paste from clipboard with CTRL+V (Copy to
|
||||
clipboard is alway enabled on websites)
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
__ _____ ________ __
|
||||
/ // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /
|
||||
__ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ /
|
||||
/ / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__
|
||||
\___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
|
||||
\/ /____/ version 0.4.22
|
||||
|
||||
|
||||
http://terminal.jcubic.pl
|
||||
|
||||
Licensed under GNU LGPL Version 3 license http://www.gnu.org/licenses/lgpl.html
|
||||
Copyright (c) 2011-2012 Jakub Jankiewicz <http://jcubic.pl>
|
||||
|
||||
JQuery Terminal Emulator is a plugin for creating command line interpreters in
|
||||
your applications. It can automatically call JSON-RPC service when user type
|
||||
commands or you can provide you own function in which you can parse user
|
||||
command. It's ideal if you want to provide additional functionality for power
|
||||
users. It can also be used to debug your aplication.
|
||||
|
||||
Features:
|
||||
|
||||
* You can create interpreter for your JSON-RPC service with one line
|
||||
of code.
|
||||
|
||||
* Support for authentication (you can provide function when user enter
|
||||
login and password or if you use JSON-RPC it can automatically call
|
||||
login function on the server and pass token to all functions)
|
||||
|
||||
* Stack of interpreters - you can create commands that trigger additional
|
||||
interpreters (eg. you can use couple of JSON-RPC service and run them
|
||||
when user type command)
|
||||
|
||||
* Command Tree - you can use nested objects. Each command will invoke a
|
||||
function, if the value is an object it will create new interpreter and
|
||||
use function from that object as commands. You can use as much nested
|
||||
object/commands as you like. If the value is a string it will create
|
||||
JSON-RPC service.
|
||||
|
||||
* Support for command line history it use Local Storage if posible
|
||||
|
||||
* Support for tab completion if you create terminal from an object
|
||||
|
||||
* Include keyboard shortcut from bash like CTRL+A, CTRL+D, CTRL+E etc.
|
||||
|
||||
* Multiply terminals on one page (every terminal can have different
|
||||
command, it's own authentication function and it's own command history)
|
||||
|
||||
* It catch all exceptions and display error messages in terminal
|
||||
(you can see errors in your javascript and php code in terminal if they
|
||||
are in interpreter function)
|
||||
|
||||
|
||||
Example of usage (javascript interpreter)
|
||||
|
||||
jQuery(function($, undefined) {
|
||||
$('#term_demo').terminal(function(command, term) {
|
||||
if (command !== '') {
|
||||
var result = window.eval(command);
|
||||
if (result != undefined) {
|
||||
term.echo(String(result));
|
||||
}
|
||||
}
|
||||
}, {
|
||||
greetings: 'Javascript Interpreter',
|
||||
name: 'js_demo',
|
||||
height: 200,
|
||||
width: 450,
|
||||
prompt: 'js> '});
|
||||
});
|
||||
63
lib/client/terminal/jquery-terminal/dterm.js
vendored
63
lib/client/terminal/jquery-terminal/dterm.js
vendored
|
|
@ -1,63 +0,0 @@
|
|||
/*!
|
||||
* Example plugin using JQuery Terminal Emulator
|
||||
* Copyright (C) 2010 Jakub Jankiewicz <http://jcubic.pl>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
(function($) {
|
||||
$.extend_if_has = function(desc, source, array) {
|
||||
for (var i=array.length;i--;) {
|
||||
if (typeof source[array[i]] != 'undefined') {
|
||||
desc[array[i]] = source[array[i]];
|
||||
}
|
||||
}
|
||||
return desc;
|
||||
};
|
||||
$.fn.dterm = function(eval, options) {
|
||||
var op = $.extend_if_has({}, options,
|
||||
['greetings', 'prompt', 'onInit',
|
||||
'onExit', 'clear',
|
||||
'login', 'name', 'exit']);
|
||||
op.enabled = false;
|
||||
var terminal = this.terminal(eval, op).css('overflow', 'hidden');
|
||||
if (!options.title) {
|
||||
options.title = 'JQuery Terminal Emulator';
|
||||
}
|
||||
if (options.logoutOnClose) {
|
||||
options.close = function(e, ui) {
|
||||
terminal.logout();
|
||||
terminal.clear();
|
||||
};
|
||||
} else {
|
||||
options.close = function(e, ui) {
|
||||
terminal.disable();
|
||||
};
|
||||
}
|
||||
var self = this;
|
||||
var dialog = this.dialog($.extend(options, {
|
||||
resizeStop: function(e, ui) {
|
||||
var content = self.find('.ui-dialog-content');
|
||||
terminal.resize(content.width(), content.height());
|
||||
},
|
||||
open: function(e, ui) {
|
||||
terminal.focus();
|
||||
terminal.resize();
|
||||
},
|
||||
show: 'fade',
|
||||
closeOnEscape: false
|
||||
}));
|
||||
self.terminal = terminal;
|
||||
return self;
|
||||
};
|
||||
})(jQuery);
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<script src="/lib/client/jquery.js"></script>
|
||||
<script src="jquery.mousewheel.js"></script>
|
||||
<script src="http://terminal.jcubic.pl/js/jquery.terminal-0.4.17.js"></script>
|
||||
<link href="jquery.terminal.css" rel="stylesheet">
|
||||
|
||||
<div id='terminal'></div>
|
||||
<script>
|
||||
jQuery(function($, undefined) {
|
||||
$('#terminal').terminal(function(command, term) {
|
||||
term.echo('');
|
||||
}, {
|
||||
greetings: 'Javascript Interpreter',
|
||||
name: 'js_demo',
|
||||
height: 200,
|
||||
prompt: 'js>'});
|
||||
});
|
||||
</script>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
||||
*
|
||||
* Version: 3.0.6
|
||||
*
|
||||
* Requires: 1.2.2+
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
var types = ['DOMMouseScroll', 'mousewheel'];
|
||||
|
||||
if ($.event.fixHooks) {
|
||||
for ( var i=types.length; i; ) {
|
||||
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
|
||||
}
|
||||
}
|
||||
|
||||
$.event.special.mousewheel = {
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.addEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.removeEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind("mousewheel", fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = "mousewheel";
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
|
||||
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
|
||||
|
||||
// New school multidimensional scroll (touchpads) deltas
|
||||
deltaY = delta;
|
||||
|
||||
// Gecko
|
||||
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaY = 0;
|
||||
deltaX = -1*delta;
|
||||
}
|
||||
|
||||
// Webkit
|
||||
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
|
||||
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
return ($.event.dispatch || $.event.handle).apply(this, args);
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
.terminal .clipboard {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
opacity: 0.01;
|
||||
filter: alpha(opacity = 0.01);
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.01);
|
||||
width: 2px;
|
||||
}
|
||||
.cmd > .clipboard {
|
||||
position: fixed;
|
||||
}
|
||||
.terminal {
|
||||
padding: 10px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.cmd {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
height: 1.3em;
|
||||
}
|
||||
.terminal .terminal-output div div, .terminal .prompt {
|
||||
display: block;
|
||||
/* line-height: 9px; */
|
||||
height: 14px;
|
||||
}
|
||||
.terminal {
|
||||
font-family: FreeMono, monospace;
|
||||
color: #aaa;
|
||||
background-color: #000;
|
||||
/* font-size: 12px; */
|
||||
/* line-height: 14px; */
|
||||
line-height: 16px;
|
||||
/* removing breaking the lines */
|
||||
}
|
||||
.terminal .terminal-output div span {
|
||||
display: inline-block;
|
||||
}
|
||||
.terminal .cmd span {
|
||||
display: inline-block;
|
||||
}
|
||||
.terminal .cmd span.inverted {
|
||||
background-color: #aaa;
|
||||
color: #000;
|
||||
}
|
||||
.terminal .terminal-output div div::-moz-selection, .terminal .terminal-output div span::-moz-selection {
|
||||
background-color: #aaa;
|
||||
color: #000;
|
||||
}
|
||||
.terminal .terminal-output div div::selection, .terminal .terminal-output div span::selection,
|
||||
.terminal .cmd > span::selection, .terminal .prompt span::selection {
|
||||
background-color: #aaa;
|
||||
color: #000;
|
||||
}
|
||||
.terminal .terminal-output div.error, .terminal .terminal-output div.error div {
|
||||
color: red;
|
||||
}
|
||||
.tilda {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 1100;
|
||||
}
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
.terminal a {
|
||||
color: #0F60FF;
|
||||
}
|
||||
.terminal a:hover {
|
||||
color: red;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue