Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix version number

  • Loading branch information...
commit 42b5385166de964052ca61b3896ab499ec837a05 1 parent ff4ed38
@jcubic jcubic authored
Showing with 150 additions and 132 deletions.
  1. +102 −84 js/jquery.terminal-0.4.9.js
  2. +48 −48 js/jquery.terminal-0.4.9.min.js
View
186 js/jquery.terminal-0.4.9.js
@@ -14,14 +14,14 @@
*
* Storage plugin Distributed under the MIT License
* Copyright (c) 2010 Dave Schindler
- *
+ *
* LiveQuery plugin Dual MIT and GPL
* Copyright (c) 2008 Brandon Aaron (http://brandonaaron.net)
*
* jQuery Timers licenced with the WTFPL
* <http://jquery.offput.ca/every/>
*
- * Date: Thu, 01 Mar 2012 13:45:02 +0000
+ * Date: Fri, 02 Mar 2012 13:25:06 +0000
*/
/*
@@ -70,21 +70,21 @@ function get_stack(caller) {
}
(function($, undefined) {
-
+
// ----------------------------------------
// START Live Query plugin
// ----------------------------------------
$.extend($.fn, {
livequery: function(type, fn, fn2) {
var self = this, q;
-
+
// Handle different call patterns
if ($.isFunction(type)) {
fn2 = fn;
fn = type;
type = undefined;
}
-
+
// See if Live Query already exists
$.each($.livequery.queries, function(i, query) {
if (self.selector == query.selector && self.context == query.context &&
@@ -93,22 +93,22 @@ function get_stack(caller) {
return (q = query) && false;
}
});
-
+
// Create new Live Query if it wasn't found
q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
-
+
// Make sure it is running
q.stopped = false;
-
+
// Run it immediately for the first time
q.run();
-
+
// Contnue the chain
return this;
},
expire: function(type, fn, fn2) {
var self = this, x =10;
-
+
// Handle different call patterns
if ($.isFunction(type)) {
fn2 = fn;
@@ -125,7 +125,7 @@ function get_stack(caller) {
$.livequery.stop(query.id);
}
});
-
+
// Continue the chain
return this;
}
@@ -139,10 +139,10 @@ function get_stack(caller) {
this.fn2 = fn2;
this.elements = [];
this.stopped = false;
-
+
// The id is the index of the Live Query in $.livequery.queries
this.id = $.livequery.queries.push(this)-1;
-
+
// Mark the functions for matching later on
fn.$lqguid = fn.$lqguid || $.livequery.guid++;
if (fn2) {
@@ -155,7 +155,7 @@ function get_stack(caller) {
$.livequery.prototype = {
stop: function() {
var query = this;
-
+
if (this.type) {
// Unbind all bound events
this.elements.unbind(this.type, this.fn);
@@ -167,29 +167,29 @@ function get_stack(caller) {
}
// Clear out matched elements
this.elements = [];
-
+
// Stop the Live Query from running until restarted
this.stopped = true;
},
-
+
run: function() {
// Short-circuit if stopped
if (this.stopped) {
return;
}
var query = this;
-
+
var oEls = this.elements,
els = $(this.selector, this.context),
nEls = els.not(oEls);
-
+
// Set elements to the latest set of matched elements
this.elements = els;
-
+
if (this.type) {
// Bind events to newly matched elements
nEls.bind(this.type, this.fn);
-
+
// Unbind events to elements no longer matched
if (oEls.length > 0) {
$.each(oEls, function(i, el) {
@@ -203,7 +203,7 @@ function get_stack(caller) {
nEls.each(function() {
query.fn.apply(this);
});
-
+
// Call the second function for elements no longer matched
if (this.fn2 && oEls.length > 0) {
$.each(oEls, function(i, el) {
@@ -222,7 +222,7 @@ function get_stack(caller) {
queue: [],
running: false,
timeout: null,
-
+
checkQueue: function() {
if ($.livequery.running && $.livequery.queue.length) {
var length = $.livequery.queue.length;
@@ -232,43 +232,43 @@ function get_stack(caller) {
}
}
},
-
+
pause: function() {
// Don't run anymore Live Queries until restarted
$.livequery.running = false;
},
-
+
play: function() {
// Restart Live Queries
$.livequery.running = true;
// Request a run of the Live Queries
$.livequery.run();
},
-
+
registerPlugin: function() {
$.each(arguments, function(i,n) {
// Short-circuit if the method doesn't exist
if (!$.fn[n]) {
return;
}
-
+
// Save a reference to the original method
var old = $.fn[n];
-
+
// Create a new method
$.fn[n] = function() {
// Call the original method
var r = old.apply(this, arguments);
-
+
// Request a run of the Live Queries
$.livequery.run();
-
+
// Return the original methods result
return r;
};
});
},
-
+
run: function(id) {
if (id != undefined) {
// Put the particular Live Query in the queue if it doesn't already exist
@@ -290,7 +290,7 @@ function get_stack(caller) {
// Create a timeout to check the queue and actually run the Live Queries
$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
},
-
+
stop: function(id) {
if (id != undefined) {
// Stop are particular Live Query
@@ -320,7 +320,7 @@ function get_stack(caller) {
$.prototype.init = function(a,c) {
// Call the original init and save the result
var r = init.apply(this, arguments);
-
+
// Copy over properties if they exist already
if (a && a.selector) {
r.context = a.context;
@@ -337,7 +337,7 @@ function get_stack(caller) {
// Give the init function the jQuery prototype for later instantiation
// (needed after Rev 4091)
- $.prototype.init.prototype = $.prototype;
+ $.prototype.init.prototype = $.prototype;
// ----------------------------------------
// START Storage plugin
// ----------------------------------------
@@ -604,11 +604,11 @@ function get_stack(caller) {
}
return result;
}
-
-
+
+
// -----------------------------------------------------------------------
- var format_split_re = /(\[\[[biu]*;[^;]*;[^\]]*\][^\]\[]*\])/g;
- var format_re = /\[\[([biu]*);([^;]*);([^\]]*)\]([^\]\[]*)\]/g;
+ var format_split_re = /(\[\[[bius]*;[^;]*;[^\]]*\][^\]\[]*\])/g;
+ var format_re = /\[\[([bius]*);([^;]*);([^\]]*)\]([^\]\[]*)\]/g;
var color_hex_re = /#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})/;
function encodeHTML(str) {
if (typeof str == 'string') {
@@ -632,15 +632,24 @@ function get_stack(caller) {
background,
text) {
if (text === '') {
- return '<span>&nbsp;</span>';
+ return '<span></span>';
}
var style_str = '';
+
if (style.indexOf('b') != -1) {
style_str += 'font-weight:bold;';
}
+ var text_decoration = 'text-decoration:';
if (style.indexOf('u') != -1) {
- style_str += 'text-decoration:underline;';
+ text_decoration += 'underline ';
+ }
+ if (style.indexOf('s') != -1) {
+ text_decoration += 'line-through';
}
+ if (style.indexOf('s') != -1 ||
+ style.indexOf('u') != -1) {
+ style_str += text_decoration + ';';
+ }
if (style.indexOf('i') != -1) {
style_str += 'font-style:italic; ';
}
@@ -902,17 +911,17 @@ function get_stack(caller) {
var enabled = options.enabled;
var name, history;
var cursor = self.find('.cursor');
-
+
function blink(i) {
cursor.toggleClass('inverted');
}
-
+
function change_num_chars() {
var W = self.width();
var w = cursor.innerWidth();
num_chars = Math.floor(W / w);
}
-
+
function get_splited_command_line(string) {
var first = string.substring(0, num_chars - prompt_len - 1);
var rest = string.substring(num_chars - prompt_len - 1);
@@ -1267,7 +1276,7 @@ function get_stack(caller) {
}
return false;
} /*else {
- if ((e.altKey && e.which == 68) ||
+ if ((e.altKey && e.which == 68) ||
(e.ctrlKey && [65, 66, 68, 69, 80, 78, 70].has(e.which)) ||
// 68 == D
[35, 36, 37, 38, 39, 40].has(e.which)) {
@@ -1388,7 +1397,6 @@ function get_stack(caller) {
}
}
});
-
// INIT
self.name(options.name || '');
prompt = options.prompt || '>';
@@ -1436,7 +1444,6 @@ function get_stack(caller) {
// -----------------------------------------------------------------------
// JSON-RPC CALL
// -----------------------------------------------------------------------
-
$.jrpc = function(url, id, method, params, success, error) {
var request = $.json_stringify({
'jsonrpc': '2.0', 'method': method,
@@ -1453,11 +1460,11 @@ function get_stack(caller) {
//timeout: 1,
type: 'POST'});
};
-
+
// -----------------------------------------------------------------------
// :: TERMINAL PLUGIN CODE
// -----------------------------------------------------------------------
- var version = '{{VERSION}}';
+ var version = '0.4.9';
var copyright = 'Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>';
var version_string = 'version ' + version;
//regex is for placing version string aligned to the right
@@ -1542,18 +1549,18 @@ function get_stack(caller) {
var cur_width = cursor.width()
var result = Math.floor(self.width() / cur_width);
if (haveScrollbars()) {
- // assume that scrollbars are 20px - in my Laptop with
+ // assume that scrollbars are 20px - in my Laptop with
// Linux/Chrome they are 16px
var margins = self.innerWidth() - self.width();
result -= Math.ceil((20 - margins / 2) / (cur_width-1));
}
return result;
}
-
+
function escape_brackets(string) {
return string.replace(/\[/g, '&#91;').replace(/\]/g, '&#93;');
}
-
+
// display Exception on terminal
function display_exception(e, label) {
var message;
@@ -1595,21 +1602,23 @@ function get_stack(caller) {
}
return true;
}
-
-
+
+
function scroll_to_bottom() {
- var scrollHeight = self.prop ? self.prop('scrollHeight') :
+ var scrollHeight = self.prop ? self.prop('scrollHeight') :
self.attr('scrollHeight');
self.scrollTop(scrollHeight);
}
-
+
//split string to array of strings with the same length and keep formatting
function get_formatted_lines(str, length) {
var result = [];
- var re_full = /(\[\[[biu]*;[^;]*;\][^\]\[]*\]?)/g;
- var re_begin = /(\[\[[biu]*;[^;]*;\])/;
+ var re_full = /(\[\[[bius]*;[^;]*;\][^\]\[]*\]?)/g;
+ var re_begin = /(\[\[[bius]*;[^;]*;\])/;
var array = str.split(/\n/g);
var prev_format = ''; // string from previous unclosed formating
+ var prev_partial = '';
+ // split by newlines
for (var i = 0, len = array.length; i < len; ++i) {
if (prev_format !== '') {
if (array[i] === '') {
@@ -1620,23 +1629,27 @@ function get_stack(caller) {
prev_format = '';
}
}
+ // iterate long lines
for (var j = 0, jlen = array[i].length; j < jlen; j += length) {
var line = array[i].substring(j, j + length);
if (prev_format !== '') {
line = prev_format + line;
}
+
var format = line.match(re_full);
//shorter lines if tabs are present
var tabs = line.match(/\t/g);
var num_tabs = tabs ? tabs.length : 0;
if (num_tabs > 0) {
var remove_chars = num_tabs*3;
- line = array[i].substring(j, j+length-remove_chars);
+ line = array[i].substring(j, j+length-remove_chars);
j -= remove_chars;
//console.log(remove_chars);
}
// TODO: this don't work on checker box
- //
+ //
+
+ //if (format && format.length > 0
if (format && format.length > 0) {
var format_count = 0;
//calculate number of characters that belong to formating
@@ -1657,8 +1670,18 @@ function get_stack(caller) {
j += format_count;
if (last[last.length-1] != "]") {
//last formating string string is not closed
- line += "]";
prev_format = last.match(re_begin)[1];
+ //end = j + prev_format.length;
+ var prev_len = prev_format.length;
+ var ending = array[i].substring(end, end+prev_len);
+ line += ending;
+ // formating ended if added new characters
+ if (!ending.match(/\]/)) {
+ line += ']';
+ } else {
+ prev_format = '';
+ }
+ j += prev_len;
} else {
prev_format = '';
}
@@ -1680,7 +1703,7 @@ function get_stack(caller) {
}
return result;
}
-
+
function draw_line(string) {
string = typeof string == 'string' ? string : String(string);
var div, i, len;
@@ -1689,7 +1712,7 @@ function get_stack(caller) {
//var array = string.split('\n');
// TODO: the way it should work
var array = get_formatted_lines(string, num_chars);
-
+
div = $('<div></div>');
for (i = 0, len = array.length; i < len; ++i) {
if (array[i] === '' || array[i] == '\r') {
@@ -1706,7 +1729,7 @@ function get_stack(caller) {
scroll_to_bottom();
return div;
}
-
+
function show_greetings() {
if (options.greetings === undefined) {
self.echo(self.signature);
@@ -1714,11 +1737,11 @@ function get_stack(caller) {
self.echo(options.greetings);
}
}
-
+
function is_scrolled_into_view(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
-
+
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
@@ -1728,7 +1751,7 @@ function get_stack(caller) {
// ----------------------------------------------------------
// TERMINAL METHODS
// ----------------------------------------------------------
-
+
$.extend(self, {
clear: function() {
output.html('');
@@ -1748,12 +1771,12 @@ function get_stack(caller) {
return self;
},
resume: function() {
- //console.log('resume on ' + options.prompt + '\n' +
+ //console.log('resume on ' + options.prompt + '\n' +
// get_stack(arguments.callee.caller).join(''));
if (command_line) {
self.enable();
command_line.show();
-
+
scroll_to_bottom();
}
return self;
@@ -1788,7 +1811,7 @@ function get_stack(caller) {
}
},
focus: function(toggle) {
- //console.log('focus on ' + options.prompt + '\n' +
+ //console.log('focus on ' + options.prompt + '\n' +
// get_stack(arguments.callee.caller).join(''));
self.oneTime(1, function() {
if (terminals.length() == 1) {
@@ -1811,7 +1834,7 @@ function get_stack(caller) {
return self;
},
enable: function() {
- //console.log('enable: ' + options.prompt + '\n' +
+ //console.log('enable: ' + options.prompt + '\n' +
// get_stack(arguments.callee.caller).join(''));
if (num_chars === undefined) {
//enabling first time
@@ -1966,10 +1989,10 @@ function get_stack(caller) {
}
}
return self;
-
+
}
});
-
+
//function constructor for eval
function make_json_rpc_eval_fun(url, terminal) {
var id = 1;
@@ -2028,7 +2051,6 @@ function get_stack(caller) {
}
};
}
-
//display prompt and last command
function echo_command(command) {
@@ -2050,7 +2072,7 @@ function get_stack(caller) {
function commands(command) {
try {
var interpreter = interpreters.top();
-
+
if (command == 'exit' && settings.exit) {
if (interpreters.size() == 1) {
if (settings.login) {
@@ -2070,14 +2092,14 @@ function get_stack(caller) {
interpreter['eval'](command, self);
}
}
-
+
} catch (e) {
display_exception(e, 'USER');
self.resume();
throw e;
}
}
-
+
// functions change prompt of command line to login to password
// and call user login function with callback that set token
// if user call it with value that is true
@@ -2101,7 +2123,7 @@ function get_stack(caller) {
if (typeof settings.login != 'function') {
throw "Value of login property must be a function";
}
- var passwd = command;
+ var passwd = command;
settings.login(user, passwd, function(token) {
if (token) {
var name = settings.name;
@@ -2163,7 +2185,7 @@ function get_stack(caller) {
interpreter.onStart(self);
}
}
-
+
function initialize() {
prepare_top_interpreter();
show_greetings();
@@ -2177,13 +2199,13 @@ function get_stack(caller) {
// after text pasted into textarea in cmd plugin
self.oneTime(5, function() {
if (scrollBars != haveScrollbars()) {
- // if scollbars appearance change we will have different
+ // if scollbars appearance change we will have different
// number of chars
self.resize();
scrollBars = haveScrollbars();
}
});
-
+
if (!self.paused()) {
if (settings.keydown && settings.keydown(e, self) === false) {
return false;
@@ -2264,7 +2286,6 @@ function get_stack(caller) {
}
}*/
}
-
// INIT CODE
var url;
if (init_eval.constructor == String) {
@@ -2278,7 +2299,6 @@ function get_stack(caller) {
command_list.push(i);
}
init_eval = (function make_eval(object) {
- //
// function that maps commands to object methods
// it keeps terminal context
return function(command, terminal) {
@@ -2315,7 +2335,7 @@ function get_stack(caller) {
} else {
throw 'Unknow object "' + String(init_eval) + '" passed as eval';
}
-
+
// create json-rpc authentication function
if (url && (typeof settings.login == 'string' || settings.login)) {
settings.login = (function(method) {
@@ -2327,7 +2347,6 @@ function get_stack(caller) {
method,
[user, passwd],
function(response) {
-
self.resume();
if (!response.error && response.result) {
callback(response.result);
@@ -2344,7 +2363,6 @@ function get_stack(caller) {
//default name is login so you can pass true
})(typeof settings.login == 'boolean' ? 'login' : settings.login);
}
-
if (valid('prompt', settings.prompt)) {
var interpreters = new Stack({
name: settings.name,
View
96 js/jquery.terminal-0.4.9.min.js
@@ -22,57 +22,57 @@
jQuery Timers licenced with the WTFPL
<http://jquery.offput.ca/every/>
- Date: Thu, 01 Mar 2012 13:45:02 +0000
+ Date: Fri, 02 Mar 2012 13:25:06 +0000
*/
Array.prototype.has=function(g){for(var A=this.length;A--;)if(this[A]==g)return true;return false};function get_stack(g){return g?[g.toString().match(/.*\n.*\n/)].concat(get_stack(g.caller)):[]}
-(function(g,A){function ca(a,c){var e;if(typeof a==="string"&&typeof c==="string"){localStorage[a]=c;return true}else if(typeof a==="object"&&typeof c==="undefined"){for(e in a)if(a.hasOwnProperty(e))localStorage[e]=a[e];return true}return false}function $(a,c){var e,i;e=new Date;e.setTime(e.getTime()+31536E6);e="; expires="+e.toGMTString();if(typeof a==="string"&&typeof c==="string"){document.cookie=a+"="+c+e+"; path=/";return true}else if(typeof a==="object"&&typeof c==="undefined"){for(i in a)if(a.hasOwnProperty(i))document.cookie=
-i+"="+a[i]+e+"; path=/";return true}return false}function da(a){return localStorage[a]}function ea(a){var c,e,i;a+="=";c=document.cookie.split(";");for(e=0;e<c.length;e++){for(i=c[e];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(a)===0)return i.substring(a.length,i.length)}return null}function fa(a){return delete localStorage[a]}function ga(a){return $(a,"",-1)}function X(a,c){var e=[],i=a.length;if(i<c)return[a];for(var h=0;h<i;h+=c)e.push(a.substring(h,h+c));return e}function F(a){if(typeof a==
-"string"){a=a.replace(/&(?!#[0-9]+;|[a-zA-Z]+;)/g,"&amp;");a=a.replace(/</g,"&lt;").replace(/>/g,"&gt;");a=a.replace(/\n/g,"<br/>");a=a.replace(/ /g,"&nbsp;");a=a.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");var c=a.split(ha);if(c.length>1)a=g.map(c,function(e){return e===""?e:e[0]=="["?e.replace(Y,function(i,h,u,x,D){if(D==="")return"<span>&nbsp;</span>";i="";if(h.indexOf("b")!=-1)i+="font-weight:bold;";if(h.indexOf("u")!=-1)i+="text-decoration:underline;";if(h.indexOf("i")!=-1)i+="font-style:italic; ";
-if(u.match(aa))i+="color:"+u+";";if(x.match(aa))i+="background-color:"+x;return a='<span style="'+i+'">'+D+"</span>"}):"<span>"+e+"</span>"}).join("");return a}else return""}function ba(a){var c=a instanceof Array?a:a?[a]:[],e=0;g.extend(this,{left:function(){if(e===0)e=c.length-1;else--e;return c[e]},right:function(){if(e==c.length-1)e=0;else++e;return c[e]},current:function(){return c[e]},data:function(){return c},length:function(){return c.length},reset:function(){e=0},append:function(i){c.push(i);
-this.reset()}})}function ia(a){var c=a?[a]:[];g.extend(this,{size:function(){return c.length},pop:function(){if(c.length===0)return null;else{var e=c[c.length-1];c=c.slice(0,c.length-1);return e}},push:function(e){c=c.concat([e]);return e},top:function(){return c.length>0?c[c.length-1]:null}})}function ja(a){var c=true;if(typeof a==="string"&&a!=="")a+="_";var e=g.Storage.get(a+"commands"),i=new ba(e?eval("("+e+")"):[""]);g.extend(this,{append:function(h){if(c&&i.current()!=h){i.append(h);g.Storage.set(a+
-"commands",g.json_stringify(i.data()))}},data:function(){return i.data()},next:function(){return i.right()},last:function(){i.reset()},previous:function(){return i.left()},clear:function(){i=new ba;g.Storage.remove(a+"commands")},enable:function(){c=true},disable:function(){c=false}})}g.extend(g.fn,{livequery:function(a,c,e){var i=this,h;if(g.isFunction(a)){e=c;c=a;a=A}g.each(g.livequery.queries,function(u,x){if(i.selector==x.selector&&i.context==x.context&&a==x.type&&(!c||c.$lqguid==x.fn.$lqguid)&&
-(!e||e.$lqguid==x.fn2.$lqguid))return(h=x)&&false});h=h||new g.livequery(this.selector,this.context,a,c,e);h.stopped=false;h.run();return this},expire:function(a,c,e){var i=this;if(g.isFunction(a)){e=c;c=a;a=A}g.each(g.livequery.queries,function(h,u){if(i.selector==u.selector&&i.context==u.context&&(!a||a==u.type)&&(!c||c.$lqguid==u.fn.$lqguid)&&(!e||e.$lqguid==u.fn2.$lqguid)&&!this.stopped)g.livequery.stop(u.id)});return this}});g.livequery=function(a,c,e,i,h){this.selector=a;this.context=c||document;
-this.type=e;this.fn=i;this.fn2=h;this.elements=[];this.stopped=false;this.id=g.livequery.queries.push(this)-1;i.$lqguid=i.$lqguid||g.livequery.guid++;if(h)h.$lqguid=h.$lqguid||g.livequery.guid++;return this};g.livequery.prototype={stop:function(){var a=this;if(this.type)this.elements.unbind(this.type,this.fn);else this.fn2&&this.elements.each(function(c,e){a.fn2.apply(e)});this.elements=[];this.stopped=true},run:function(){if(!this.stopped){var a=this,c=this.elements,e=g(this.selector,this.context),
-i=e.not(c);this.elements=e;if(this.type){i.bind(this.type,this.fn);c.length>0&&g.each(c,function(h,u){g.inArray(u,e)<0&&g.event.remove(u,a.type,a.fn)})}else{i.each(function(){a.fn.apply(this)});this.fn2&&c.length>0&&g.each(c,function(h,u){g.inArray(u,e)<0&&a.fn2.apply(u)})}}}};g.extend(g.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if(g.livequery.running&&g.livequery.queue.length)for(var a=g.livequery.queue.length;a--;)g.livequery.queries[g.livequery.queue.shift()].run()},
+(function(g,A){function da(a,c){var e;if(typeof a==="string"&&typeof c==="string"){localStorage[a]=c;return true}else if(typeof a==="object"&&typeof c==="undefined"){for(e in a)if(a.hasOwnProperty(e))localStorage[e]=a[e];return true}return false}function aa(a,c){var e,i;e=new Date;e.setTime(e.getTime()+31536E6);e="; expires="+e.toGMTString();if(typeof a==="string"&&typeof c==="string"){document.cookie=a+"="+c+e+"; path=/";return true}else if(typeof a==="object"&&typeof c==="undefined"){for(i in a)if(a.hasOwnProperty(i))document.cookie=
+i+"="+a[i]+e+"; path=/";return true}return false}function ea(a){return localStorage[a]}function fa(a){var c,e,i;a+="=";c=document.cookie.split(";");for(e=0;e<c.length;e++){for(i=c[e];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(a)===0)return i.substring(a.length,i.length)}return null}function ga(a){return delete localStorage[a]}function ha(a){return aa(a,"",-1)}function Y(a,c){var e=[],i=a.length;if(i<c)return[a];for(var h=0;h<i;h+=c)e.push(a.substring(h,h+c));return e}function I(a){if(typeof a==
+"string"){a=a.replace(/&(?!#[0-9]+;|[a-zA-Z]+;)/g,"&amp;");a=a.replace(/</g,"&lt;").replace(/>/g,"&gt;");a=a.replace(/\n/g,"<br/>");a=a.replace(/ /g,"&nbsp;");a=a.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");var c=a.split(ia);if(c.length>1)a=g.map(c,function(e){return e===""?e:e[0]=="["?e.replace(Z,function(i,h,u,x,E){if(E==="")return"<span></span>";i="";if(h.indexOf("b")!=-1)i+="font-weight:bold;";var P="text-decoration:";if(h.indexOf("u")!=-1)P+="underline ";if(h.indexOf("s")!=-1)P+="line-through";
+if(h.indexOf("s")!=-1||h.indexOf("u")!=-1)i+=P+";";if(h.indexOf("i")!=-1)i+="font-style:italic; ";if(u.match(ba))i+="color:"+u+";";if(x.match(ba))i+="background-color:"+x;return a='<span style="'+i+'">'+E+"</span>"}):"<span>"+e+"</span>"}).join("");return a}else return""}function ca(a){var c=a instanceof Array?a:a?[a]:[],e=0;g.extend(this,{left:function(){if(e===0)e=c.length-1;else--e;return c[e]},right:function(){if(e==c.length-1)e=0;else++e;return c[e]},current:function(){return c[e]},data:function(){return c},
+length:function(){return c.length},reset:function(){e=0},append:function(i){c.push(i);this.reset()}})}function ja(a){var c=a?[a]:[];g.extend(this,{size:function(){return c.length},pop:function(){if(c.length===0)return null;else{var e=c[c.length-1];c=c.slice(0,c.length-1);return e}},push:function(e){c=c.concat([e]);return e},top:function(){return c.length>0?c[c.length-1]:null}})}function ka(a){var c=true;if(typeof a==="string"&&a!=="")a+="_";var e=g.Storage.get(a+"commands"),i=new ca(e?eval("("+e+
+")"):[""]);g.extend(this,{append:function(h){if(c&&i.current()!=h){i.append(h);g.Storage.set(a+"commands",g.json_stringify(i.data()))}},data:function(){return i.data()},next:function(){return i.right()},last:function(){i.reset()},previous:function(){return i.left()},clear:function(){i=new ca;g.Storage.remove(a+"commands")},enable:function(){c=true},disable:function(){c=false}})}g.extend(g.fn,{livequery:function(a,c,e){var i=this,h;if(g.isFunction(a)){e=c;c=a;a=A}g.each(g.livequery.queries,function(u,
+x){if(i.selector==x.selector&&i.context==x.context&&a==x.type&&(!c||c.$lqguid==x.fn.$lqguid)&&(!e||e.$lqguid==x.fn2.$lqguid))return(h=x)&&false});h=h||new g.livequery(this.selector,this.context,a,c,e);h.stopped=false;h.run();return this},expire:function(a,c,e){var i=this;if(g.isFunction(a)){e=c;c=a;a=A}g.each(g.livequery.queries,function(h,u){if(i.selector==u.selector&&i.context==u.context&&(!a||a==u.type)&&(!c||c.$lqguid==u.fn.$lqguid)&&(!e||e.$lqguid==u.fn2.$lqguid)&&!this.stopped)g.livequery.stop(u.id)});
+return this}});g.livequery=function(a,c,e,i,h){this.selector=a;this.context=c||document;this.type=e;this.fn=i;this.fn2=h;this.elements=[];this.stopped=false;this.id=g.livequery.queries.push(this)-1;i.$lqguid=i.$lqguid||g.livequery.guid++;if(h)h.$lqguid=h.$lqguid||g.livequery.guid++;return this};g.livequery.prototype={stop:function(){var a=this;if(this.type)this.elements.unbind(this.type,this.fn);else this.fn2&&this.elements.each(function(c,e){a.fn2.apply(e)});this.elements=[];this.stopped=true},run:function(){if(!this.stopped){var a=
+this,c=this.elements,e=g(this.selector,this.context),i=e.not(c);this.elements=e;if(this.type){i.bind(this.type,this.fn);c.length>0&&g.each(c,function(h,u){g.inArray(u,e)<0&&g.event.remove(u,a.type,a.fn)})}else{i.each(function(){a.fn.apply(this)});this.fn2&&c.length>0&&g.each(c,function(h,u){g.inArray(u,e)<0&&a.fn2.apply(u)})}}}};g.extend(g.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if(g.livequery.running&&g.livequery.queue.length)for(var a=g.livequery.queue.length;a--;)g.livequery.queries[g.livequery.queue.shift()].run()},
pause:function(){g.livequery.running=false},play:function(){g.livequery.running=true;g.livequery.run()},registerPlugin:function(){g.each(arguments,function(a,c){if(g.fn[c]){var e=g.fn[c];g.fn[c]=function(){var i=e.apply(this,arguments);g.livequery.run();return i}}})},run:function(a){if(a!=A)g.inArray(a,g.livequery.queue)<0&&g.livequery.queue.push(a);else g.each(g.livequery.queries,function(c){g.inArray(c,g.livequery.queue)<0&&g.livequery.queue.push(c)});g.livequery.timeout&&clearTimeout(g.livequery.timeout);
-g.livequery.timeout=setTimeout(g.livequery.checkQueue,20)},stop:function(a){a!=A?g.livequery.queries[a].stop():g.each(g.livequery.queries,function(c){g.livequery.queries[c].stop()})}});g.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");g(function(){g.livequery.play()});var ka=g.prototype.init;g.prototype.init=function(a,c){var e=ka.apply(this,arguments);if(a&&a.selector){e.context=a.context;e.selector=
-a.selector}if(typeof a=="string"){e.context=c||document;e.selector=a}return e};g.prototype.init.prototype=g.prototype;var S=typeof window.localStorage!=="undefined";g.extend({Storage:{set:S?ca:$,get:S?da:ea,remove:S?fa:ga}});jQuery.fn.extend({everyTime:function(a,c,e,i,h){return this.each(function(){jQuery.timer.add(this,a,c,e,i,h)})},oneTime:function(a,c,e){return this.each(function(){jQuery.timer.add(this,a,c,e,1)})},stopTime:function(a,c){return this.each(function(){jQuery.timer.remove(this,a,
+g.livequery.timeout=setTimeout(g.livequery.checkQueue,20)},stop:function(a){a!=A?g.livequery.queries[a].stop():g.each(g.livequery.queries,function(c){g.livequery.queries[c].stop()})}});g.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove");g(function(){g.livequery.play()});var la=g.prototype.init;g.prototype.init=function(a,c){var e=la.apply(this,arguments);if(a&&a.selector){e.context=a.context;e.selector=
+a.selector}if(typeof a=="string"){e.context=c||document;e.selector=a}return e};g.prototype.init.prototype=g.prototype;var T=typeof window.localStorage!=="undefined";g.extend({Storage:{set:T?da:aa,get:T?ea:fa,remove:T?ga:ha}});jQuery.fn.extend({everyTime:function(a,c,e,i,h){return this.each(function(){jQuery.timer.add(this,a,c,e,i,h)})},oneTime:function(a,c,e){return this.each(function(){jQuery.timer.add(this,a,c,e,1)})},stopTime:function(a,c){return this.each(function(){jQuery.timer.remove(this,a,
c)})}});jQuery.extend({timer:{guid:1,global:{},regex:/^([0-9]+)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1E3,das:1E4,hs:1E5,ks:1E6},timeParse:function(a){if(a==A||a===null)return null;var c=this.regex.exec(jQuery.trim(a.toString()));return c[2]?parseInt(c[1],10)*(this.powers[c[2]]||1):a},add:function(a,c,e,i,h,u){var x=0;if(jQuery.isFunction(e)){h||(h=i);i=e;e=c}c=jQuery.timer.timeParse(c);if(!(typeof c!="number"||isNaN(c)||c<=0)){if(h&&h.constructor!=Number){u=!!h;h=0}h=h||0;u=u||false;if(!a.$timers)a.$timers=
-{};a.$timers[e]||(a.$timers[e]={});i.$timerID=i.$timerID||this.guid++;var D=function(){if(!(u&&this.inProgress)){this.inProgress=true;if(++x>h&&h!==0||i.call(a,x)===false)jQuery.timer.remove(a,e,i);this.inProgress=false}};D.$timerID=i.$timerID;a.$timers[e][i.$timerID]||(a.$timers[e][i.$timerID]=window.setInterval(D,c));this.global[e]||(this.global[e]=[]);this.global[e].push(a)}},remove:function(a,c,e){var i=a.$timers,h;if(i){if(c){if(i[c]){if(e){if(e.$timerID){window.clearInterval(i[c][e.$timerID]);
-delete i[c][e.$timerID]}}else for(e in i[c]){window.clearInterval(i[c][e]);delete i[c][e]}for(h in i[c])break;if(!h){h=null;delete i[c]}}}else for(c in i)this.remove(a,c,e);for(h in i)break;if(!h)a.$timers=null}}}});if(jQuery.browser.msie)jQuery(window).one("unload",function(){var a=jQuery.timer.global,c;for(c in a)for(var e=a[c],i=e.length;--i;)jQuery.timer.remove(e[i],c)});var ha=/(\[\[[biu]*;[^;]*;[^\]]*\][^\]\[]*\])/g,Y=/\[\[([biu]*);([^;]*);([^\]]*)\]([^\]\[]*)\]/g,aa=/#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})/;
+{};a.$timers[e]||(a.$timers[e]={});i.$timerID=i.$timerID||this.guid++;var E=function(){if(!(u&&this.inProgress)){this.inProgress=true;if(++x>h&&h!==0||i.call(a,x)===false)jQuery.timer.remove(a,e,i);this.inProgress=false}};E.$timerID=i.$timerID;a.$timers[e][i.$timerID]||(a.$timers[e][i.$timerID]=window.setInterval(E,c));this.global[e]||(this.global[e]=[]);this.global[e].push(a)}},remove:function(a,c,e){var i=a.$timers,h;if(i){if(c){if(i[c]){if(e){if(e.$timerID){window.clearInterval(i[c][e.$timerID]);
+delete i[c][e.$timerID]}}else for(e in i[c]){window.clearInterval(i[c][e]);delete i[c][e]}for(h in i[c])break;if(!h){h=null;delete i[c]}}}else for(c in i)this.remove(a,c,e);for(h in i)break;if(!h)a.$timers=null}}}});if(jQuery.browser.msie)jQuery(window).one("unload",function(){var a=jQuery.timer.global,c;for(c in a)for(var e=a[c],i=e.length;--i;)jQuery.timer.remove(e[i],c)});var ia=/(\[\[[bius]*;[^;]*;[^\]]*\][^\]\[]*\])/g,Z=/\[\[([bius]*);([^;]*);([^\]]*)\]([^\]\[]*)\]/g,ba=/#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})/;
g.json_stringify=function(a,c){var e="",i;c=c===A?1:c;switch(typeof a){case "function":e+=a;break;case "boolean":e+=a?"true":"false";break;case "object":if(a===null)e+="null";else if(a instanceof Array){e+="[";var h=a.length;for(i=0;i<h-1;++i)e+=g.json_stringify(a[i],c+1);e+=g.json_stringify(a[h-1],c+1)+"]"}else{e+="{";for(h in a)if(a.hasOwnProperty(h))e+='"'+h+'":'+g.json_stringify(a[h],c+1);e+="}"}break;case "string":h=a;var u={"\\\\":"\\\\",'"':'\\"',"/":"\\/","\\n":"\\n","\\r":"\\r","\\t":"\\t"};
-for(i in u)if(u.hasOwnProperty(i))h=h.replace(RegExp(i,"g"),u[i]);e+='"'+h+'"';break;case "number":e+=String(a)}e+=c>1?",":"";if(c==1)e=e.replace(/,([\]}])/g,"$1");return e.replace(/([\[{]),/g,"$1")};g.fn.cmd=function(a){function c(){M.toggleClass("inverted")}function e(f){var q=f.substring(0,x-D-1);f=f.substring(x-D-1);return[q].concat(X(f,x))}function i(){u.focus();h.oneTime(1,function(){h.insert(u.val());u.blur().val("")})}var h=this;h.addClass("cmd");h.append('<span class="prompt"></span><span></span><span class="cursor">&nbsp;</span><span></span>');
-var u=g("<textarea/>").addClass("clipboard").appendTo(h);a.width&&h.width(a.width);var x,D,T=a.mask||false,o="",m=0,N,P=a.enabled,U,G,M=h.find(".cursor"),E=function(f){function q(r,v){if(v==r.length){k.html(F(r));M.html("&nbsp;");H.html("")}else if(v===0){k.html("");M.html(F(r.slice(0,1)));H.html(F(r.slice(1)))}else{var p=F(r.slice(0,v));k.html(p);p=r.slice(v,v+1);M.html(p==" "?"&nbsp;":F(p));v==r.lenght-1?H.html(""):H.html(F(r.slice(v+1)))}}function V(r){return"<div>"+F(r)+"</div>"}function L(r){var v=
-H;g.each(r,function(p,I){v=g(V(I)).insertAfter(v).addClass("clear")})}function W(r){g.each(r,function(v,p){k.before(V(p))})}var k=M.prev(),H=M.next();return function(){var r=T?o.replace(/./g,"*"):o,v;f.find("div").remove();k.html("");if(r.length>x-D-1||r.match(/\n/)){var p,I=r.match(/\t/g),C=I?I.length*3:0;if(I)r=r.replace(/\t/g,"\u0000\u0000\u0000\u0000");if(r.match(/\n/)){var l=r.split("\n"),b=x-D-1;for(v=0;v<l.length-1;++v)l[v]+=" ";if(l[0].length>b){p=[l[0].substring(0,b)];p=p.concat(X(l[0].substring(b),
-x))}else p=[l[0]];for(v=1;v<l.length;++v)if(l[v].length>x)p=p.concat(X(l[v],x));else p.push(l[v])}else p=e(r);if(I)p=g.map(p,function(j){return j.replace(/\x00\x00\x00\x00/g,"\t")});b=p[0].length;if(m<b){q(p[0],m);L(p.slice(1))}else if(m==b){k.before(V(p[0]));q(p[1],0);L(p.slice(2))}else{v=p.length;if(m<b){q(p[0],m);L(p.slice(1))}else if(m==b){k.before(V(p[0]));q(p[1],0);L(p.slice(2))}else{I=p.slice(-1)[0];l=r.length-m;r=0;if(l<=I.length){W(p.slice(0,-1));r=I.length==l?0:I.length-l;q(I,r+C)}else if(v==
-3){k.before("<div>"+F(p[0])+"</div>");q(p[1],m-b-1);H.after('<div class="clear">'+F(p[2])+"</div>")}else{r=m;for(v=0;v<p.length;++v)if(r>p[v].length)r-=p[v].length;else break;C=p[v];b=v;if(r==C.length){r=0;C=p[++b]}q(C,r);W(p.slice(0,b));L(p.slice(b+1))}}}}else if(r===""){k.html("");M.html("&nbsp;");H.html("")}else q(r,m)}}(h),d=function(){var f=h.find(".prompt");return function(){if(typeof N=="string"){D=N.replace(Y,"$4").length;f.html(F(N)+"&nbsp;")}else N(function(q){D=q.replace(Y,"$4").length;
-f.html(F(q)+"&nbsp;")})}}();g.extend(h,{name:function(f){if(f!==A){U=f;G=new ja(f)}else return U},history:function(){return G},set:function(f,q){if(f!==A){o=f;if(!q)m=o.length;E()}},insert:function(f,q){if(m==o.length)o+=f;else o=m===0?f+o:o.slice(0,m)+f+o.slice(m);q||(m+=f.length);E()},get:function(){return o},commands:function(f){if(f)a.commands=f;else return f},destroy:function(){g(document.documentElement).unbind(".commandline");h.find(".prompt").remove()},prompt:function(f){if(f===A)return N;
-else{if(typeof f=="string"||typeof f=="function")N=f;else throw"prompt must be a function or string";d();E()}},position:function(f){if(typeof f=="number"){m=f<0?0:f>o.length?o.length:f;E()}else return m},show:function(){var f=h.show;return function(){f.apply(h,[]);E();d()}}(),resize:function(f){if(f)x=f;else{f=h.width();var q=M.innerWidth();x=Math.floor(f/q)}E()},enable:function(){if(!P){h.everyTime(500,"blink",c);P=true}},isenabled:function(){return P},disable:function(){if(P){h.stopTime("blink",
-c);h.find(".cursor").removeClass("inverted");P=false}},mask:function(f){if(typeof f=="boolean"){T=f;E()}else return T}});h.name(a.name||"");N=a.prompt||">";d();if(a.enabled===A||a.enabled===true)h.enable();g(g.browser.msie?document.documentElement:window).keypress(function(f){var q;if(f.ctrlKey&&f.which==99)return true;if(a.keypress)q=a.keypress(f);if(q===A||q){if(P)if([38,32,13,0,8].has(f.which)&&f.keyCode!=123&&!(f.which==38&&f.shiftKey))return false;else if(!f.ctrlKey&&!(f.altKey&&f.which==100)){h.insert(String.fromCharCode(f.which));
-return false}else f.altKey&&h.insert(String.fromCharCode(f.which))}else return q}).keydown(function(f){if(P){if(a.keydown&&a.keydown(f)===false)return false;var q;if(f.altKey){if(f.which==68){h.set(o.slice(0,m)+o.slice(m).replace(/[^ ]+ |[^ ]+$/,""),true);return false}return true}else if(f.keyCode==13){G&&o&&G.append(o);G.last();f=o;h.set("");a.commands&&a.commands(f);typeof N=="function"&&d()}else if(f.which==32)h.insert(" ");else if(f.which==8){if(o!==""&&m>0){o=o.slice(0,m-1)+o.slice(m,o.length);
---m;E()}}else if(f.which==9&&!(f.ctrlKey||f.altKey))h.insert("\t");else if(f.which==46){if(o!==""&&m<o.length){o=o.slice(0,m)+o.slice(m+1,o.length);E()}return true}else if(G&&f.which==38||f.which==80&&f.ctrlKey)h.set(G.previous());else if(G&&f.which==40||f.which==78&&f.ctrlKey)h.set(G.next());else if(f.which==37||f.which==66&&f.ctrlKey)if(f.ctrlKey&&f.which!=66){q=m-1;f=0;for(o[q]==" "&&--q;q>0;--q)if(o[q]==" "&&o[q+1]!=" "){f=q+1;break}else if(o[q]=="\n"&&o[q+1]!="\n"){f=q;break}h.position(f)}else{if(m>
-0){--m;E()}}else if(f.which==39||f.which==70&&f.ctrlKey)if(f.ctrlKey&&f.which!=70){o[m]==" "&&++m;f=o.slice(m).match(/\S[\n\s]{2,}|[\n\s]+\S?/);if(!f||f[0].match(/^\s+$/))m=o.length;else if(f[0][0]!=" ")m+=f.index+1;else{m+=f.index+f[0].length-1;f[0][f[0].length-1]!=" "&&--m}E()}else{if(m<o.length){++m;E()}}else if(f.which==123)return true;else if(f.which==36)h.position(0);else if(f.which==35)h.position(o.length);else if(f.ctrlKey||f.metaKey)if(f.shiftKey){if(f.which==84)return true}else if(f.which==
+for(i in u)if(u.hasOwnProperty(i))h=h.replace(RegExp(i,"g"),u[i]);e+='"'+h+'"';break;case "number":e+=String(a)}e+=c>1?",":"";if(c==1)e=e.replace(/,([\]}])/g,"$1");return e.replace(/([\[{]),/g,"$1")};g.fn.cmd=function(a){function c(){N.toggleClass("inverted")}function e(f){var q=f.substring(0,x-E-1);f=f.substring(x-E-1);return[q].concat(Y(f,x))}function i(){u.focus();h.oneTime(1,function(){h.insert(u.val());u.blur().val("")})}var h=this;h.addClass("cmd");h.append('<span class="prompt"></span><span></span><span class="cursor">&nbsp;</span><span></span>');
+var u=g("<textarea/>").addClass("clipboard").appendTo(h);a.width&&h.width(a.width);var x,E,P=a.mask||false,o="",m=0,O,Q=a.enabled,U,J,N=h.find(".cursor"),F=function(f){function q(s,v){if(v==s.length){k.html(I(s));N.html("&nbsp;");K.html("")}else if(v===0){k.html("");N.html(I(s.slice(0,1)));K.html(I(s.slice(1)))}else{var p=I(s.slice(0,v));k.html(p);p=s.slice(v,v+1);N.html(p==" "?"&nbsp;":I(p));v==s.lenght-1?K.html(""):K.html(I(s.slice(v+1)))}}function V(s){return"<div>"+I(s)+"</div>"}function M(s){var v=
+K;g.each(s,function(p,L){v=g(V(L)).insertAfter(v).addClass("clear")})}function W(s){g.each(s,function(v,p){k.before(V(p))})}var k=N.prev(),K=N.next();return function(){var s=P?o.replace(/./g,"*"):o,v;f.find("div").remove();k.html("");if(s.length>x-E-1||s.match(/\n/)){var p,L=s.match(/\t/g),C=L?L.length*3:0;if(L)s=s.replace(/\t/g,"\u0000\u0000\u0000\u0000");if(s.match(/\n/)){var l=s.split("\n"),b=x-E-1;for(v=0;v<l.length-1;++v)l[v]+=" ";if(l[0].length>b){p=[l[0].substring(0,b)];p=p.concat(Y(l[0].substring(b),
+x))}else p=[l[0]];for(v=1;v<l.length;++v)if(l[v].length>x)p=p.concat(Y(l[v],x));else p.push(l[v])}else p=e(s);if(L)p=g.map(p,function(j){return j.replace(/\x00\x00\x00\x00/g,"\t")});b=p[0].length;if(m<b){q(p[0],m);M(p.slice(1))}else if(m==b){k.before(V(p[0]));q(p[1],0);M(p.slice(2))}else{v=p.length;if(m<b){q(p[0],m);M(p.slice(1))}else if(m==b){k.before(V(p[0]));q(p[1],0);M(p.slice(2))}else{L=p.slice(-1)[0];l=s.length-m;s=0;if(l<=L.length){W(p.slice(0,-1));s=L.length==l?0:L.length-l;q(L,s+C)}else if(v==
+3){k.before("<div>"+I(p[0])+"</div>");q(p[1],m-b-1);K.after('<div class="clear">'+I(p[2])+"</div>")}else{s=m;for(v=0;v<p.length;++v)if(s>p[v].length)s-=p[v].length;else break;C=p[v];b=v;if(s==C.length){s=0;C=p[++b]}q(C,s);W(p.slice(0,b));M(p.slice(b+1))}}}}else if(s===""){k.html("");N.html("&nbsp;");K.html("")}else q(s,m)}}(h),d=function(){var f=h.find(".prompt");return function(){if(typeof O=="string"){E=O.replace(Z,"$4").length;f.html(I(O)+"&nbsp;")}else O(function(q){E=q.replace(Z,"$4").length;
+f.html(I(q)+"&nbsp;")})}}();g.extend(h,{name:function(f){if(f!==A){U=f;J=new ka(f)}else return U},history:function(){return J},set:function(f,q){if(f!==A){o=f;if(!q)m=o.length;F()}},insert:function(f,q){if(m==o.length)o+=f;else o=m===0?f+o:o.slice(0,m)+f+o.slice(m);q||(m+=f.length);F()},get:function(){return o},commands:function(f){if(f)a.commands=f;else return f},destroy:function(){g(document.documentElement).unbind(".commandline");h.find(".prompt").remove()},prompt:function(f){if(f===A)return O;
+else{if(typeof f=="string"||typeof f=="function")O=f;else throw"prompt must be a function or string";d();F()}},position:function(f){if(typeof f=="number"){m=f<0?0:f>o.length?o.length:f;F()}else return m},show:function(){var f=h.show;return function(){f.apply(h,[]);F();d()}}(),resize:function(f){if(f)x=f;else{f=h.width();var q=N.innerWidth();x=Math.floor(f/q)}F()},enable:function(){if(!Q){h.everyTime(500,"blink",c);Q=true}},isenabled:function(){return Q},disable:function(){if(Q){h.stopTime("blink",
+c);h.find(".cursor").removeClass("inverted");Q=false}},mask:function(f){if(typeof f=="boolean"){P=f;F()}else return P}});h.name(a.name||"");O=a.prompt||">";d();if(a.enabled===A||a.enabled===true)h.enable();g(g.browser.msie?document.documentElement:window).keypress(function(f){var q;if(f.ctrlKey&&f.which==99)return true;if(a.keypress)q=a.keypress(f);if(q===A||q){if(Q)if([38,32,13,0,8].has(f.which)&&f.keyCode!=123&&!(f.which==38&&f.shiftKey))return false;else if(!f.ctrlKey&&!(f.altKey&&f.which==100)){h.insert(String.fromCharCode(f.which));
+return false}else f.altKey&&h.insert(String.fromCharCode(f.which))}else return q}).keydown(function(f){if(Q){if(a.keydown&&a.keydown(f)===false)return false;var q;if(f.altKey){if(f.which==68){h.set(o.slice(0,m)+o.slice(m).replace(/[^ ]+ |[^ ]+$/,""),true);return false}return true}else if(f.keyCode==13){J&&o&&J.append(o);J.last();f=o;h.set("");a.commands&&a.commands(f);typeof O=="function"&&d()}else if(f.which==32)h.insert(" ");else if(f.which==8){if(o!==""&&m>0){o=o.slice(0,m-1)+o.slice(m,o.length);
+--m;F()}}else if(f.which==9&&!(f.ctrlKey||f.altKey))h.insert("\t");else if(f.which==46){if(o!==""&&m<o.length){o=o.slice(0,m)+o.slice(m+1,o.length);F()}return true}else if(J&&f.which==38||f.which==80&&f.ctrlKey)h.set(J.previous());else if(J&&f.which==40||f.which==78&&f.ctrlKey)h.set(J.next());else if(f.which==37||f.which==66&&f.ctrlKey)if(f.ctrlKey&&f.which!=66){q=m-1;f=0;for(o[q]==" "&&--q;q>0;--q)if(o[q]==" "&&o[q+1]!=" "){f=q+1;break}else if(o[q]=="\n"&&o[q+1]!="\n"){f=q;break}h.position(f)}else{if(m>
+0){--m;F()}}else if(f.which==39||f.which==70&&f.ctrlKey)if(f.ctrlKey&&f.which!=70){o[m]==" "&&++m;f=o.slice(m).match(/\S[\n\s]{2,}|[\n\s]+\S?/);if(!f||f[0].match(/^\s+$/))m=o.length;else if(f[0][0]!=" ")m+=f.index+1;else{m+=f.index+f[0].length-1;f[0][f[0].length-1]!=" "&&--m}F()}else{if(m<o.length){++m;F()}}else if(f.which==123)return true;else if(f.which==36)h.position(0);else if(f.which==35)h.position(o.length);else if(f.ctrlKey||f.metaKey)if(f.shiftKey){if(f.which==84)return true}else if(f.which==
65)h.position(0);else if(f.which==69)h.position(o.length);else if(f.which==88||f.which==67||f.which==87||f.which==84)return true;else if(f.which==86){i();return true}else if(f.which==75)if(m===0)h.set("");else m!=o.length&&h.set(o.slice(0,m));else if(f.which==85){h.set(o.slice(m,o.length));h.position(0)}else{if(f.which==17)return true}else return true;return false}});return h};g.jrpc=function(a,c,e,i,h,u){c=g.json_stringify({jsonrpc:"2.0",method:e,params:i,id:c});return g.ajax({url:a,data:c,success:h,
-error:u,contentType:"application/json",dataType:"json",async:true,cache:false,type:"POST"})};S=/ {19}$/;var la=[["jQuery Terminal","(c) 2011 jcubic"],["JQuery Terminal Emulator v. {{VERSION}}","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>".replace(/ *<.*>/,"")],["JQuery Terminal Emulator version version {{VERSION}}","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>"],[" _______ ________ __"," / / _ /_ ____________ _/__ ___/______________ _____ / /",
-" __ / / // / // / _ / _/ // / / / _ / _/ / / \\/ / _ \\/ /","/ / / // / // / ___/ // // / / / ___/ // / / / / /\\ / // / /__","\\___/____ \\\\__/____/_/ \\__ / /_/____/_//_/ /_/ /_/ \\/\\__\\_\\___/"," \\/ /____/ ".replace(S,"")+"version {{VERSION}}","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>"],[" __ _____ ________ __"," / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /",
-" __ / // // // // // _ // _// // / / // _ // _// // // \\/ // _ \\/ /","/ / // // // // // ___// / / // / / // ___// / / / / // // /\\ // // / /__","\\___//____ \\\\___//____//_/ _\\_ / /_//____//_/ /_/ /_//_//_/ /_/ \\__\\_\\___/"," \\/ /____/ ".replace(S,"")+"version {{VERSION}}","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>"]],ma=[],Q=new function(a){var c=a?[a]:[],e=0;g.extend(this,{rotate:function(){if(c.length==
-1)return c[0];else{if(e==c.length-1)e=0;else++e;return c[e]}},length:function(){return c.length},set:function(i){for(var h=c.length;h--;)if(c[h]===i){e=h;return}this.append(i)},front:function(){return c[e]},append:function(i){c.push(i)}})};g.fn.terminal=function(a,c){function e(){return d.get(0).scrollHeight>d.innerHeight()}function i(){var b=d.find(".cursor").width(),j=Math.floor(d.width()/b);if(e()){var n=d.innerWidth()-d.width();j-=Math.ceil((20-n/2)/(b-1))}return j}function h(b,j){d.error("&#91;"+
-j+"&#93;: "+(typeof b=="string"?b:b.fileName+": "+b.message));d.pause();typeof b.fileName=="string"&&g.get(b.fileName,function(n){d.resume();var w=b.lineNumber-1;(n=n.split("\n")[w])&&d.error("&#91;"+b.lineNumber+"&#93;: "+n)})}function u(b,j){try{if(typeof j=="function")j(function(){});else if(typeof j!="string")throw b+" must be string or function";}catch(n){h(n,b.toUpperCase());return false}return true}function x(){var b=d.prop?d.prop("scrollHeight"):d.attr("scrollHeight");d.scrollTop(b)}function D(b,
-j){for(var n=[],w=/(\[\[[biu]*;[^;]*;\][^\]\[]*\]?)/g,t=/(\[\[[biu]*;[^;]*;\])/,y=b.split(/\n/g),s="",z=0,R=y.length;z<R;++z){if(s!=="")if(y[z]===""){n.push(s+"]");continue}else{y[z]=s+y[z];s=""}for(var J=0,na=y[z].length;J<na;J+=j){var B=y[z].substring(J,J+j);if(s!=="")B=s+B;var O=B.match(w),K=B.match(/\t/g);K=K?K.length:0;if(K>0){K*=3;B=y[z].substring(J,J+j-K);J-=K}if(O&&O.length>0){B=K=0;for(var oa=O.length;B<oa;++B){K+=O[B].match(t)[1].length;if(O[B][O[B].length-1]=="]")K+=1}if(s!=="")K-=s.length;
-B=s+y[z].substring(J,J+j+K);O=B.match(w);s=O[O.length-1];J+=K;if(s[s.length-1]!="]"){B+="]";s=s.match(t)[1]}else s=""}else s="";if(O=B.match(/(&(?:#[0-9]+|[A-Za-z]+);)/g)){var Z=0;g.each(O,function(qa,pa){Z+=pa.length-1});B=y[z].substring(J,J+j-Z);J-=Z}n.push(B)}}return n}function T(b){b=typeof b=="string"?b:String(b);var j,n;if(b.length>L){var w=D(b,L);b=g("<div></div>");j=0;for(n=w.length;j<n;++j)w[j]===""||w[j]=="\r"?b.append("<div>&nbsp;</div>"):g("<div/>").html(F(w[j])).appendTo(b)}else b=g("<div/>").html(F(b));
-q.append(b);b.width("100%");x();return b}function o(b,j){var n=1,w=function(t,y){j.pause();g.jrpc(b,n++,t,y,function(s){if(s.error)j.error("&#91;RPC&#93; "+s.error.message);else if(typeof s.result=="string")j.echo(s.result);else if(s.result instanceof Array)j.echo(s.result.join(" "));else if(typeof s.result=="object"){var z="",R;for(R in s.result)if(s.result.hasOwnProperty(R))z+=R+": "+s.result[R]+"\n";j.echo(z)}j.resume()},function(s,z){j.error("&#91;AJAX&#93; "+z+" - Server reponse is: \n"+s.responseText);
-j.resume()})};return function(t,y){if(t!==""){var s,z;if(t.match(/[^ ]* /)){t=t.split(/ +/);s=t[0];z=t.slice(1)}else{s=t;z=[]}if(!k.login||s=="help")w(s,z);else{var R=y.token();R?w(s,[R].concat(z)):y.error("&#91;AUTH&#93; Access denied (no token)")}}}}function m(b){var j=l.prompt();if(l.mask())b=b.replace(/./g,"*");typeof j=="function"?j(function(n){d.echo(n+" "+b)}):d.echo(j+" "+b)}function N(b){try{var j=C.top();if(b=="exit"&&k.exit)if(C.size()==1)k.login?U():d.echo("You can exit from main interpeter");
-else d.pop("exit");else{m(b);b=="clear"&&k.clear?d.clear():j.eval(b,d)}}catch(n){h(n,"USER");d.resume();throw n;}}function P(){var b=null;l.prompt("login:");k.history&&l.history().disable();l.commands(function(j){try{m(j);if(b){l.mask(false);d.pause();if(typeof k.login!="function")throw"Value of login property must be a function";k.login(b,j,function(w){if(w){var t=k.name;t=t?"_"+t:"";g.Storage.set("token"+t,w);g.Storage.set("login"+t,b);l.commands(N);M()}else{d.error("Wrong password try again");
-l.prompt("login:");b=null}d.resume();k.history&&l.history().enable()})}else{b=j;l.prompt("password:");l.mask(true)}}catch(n){h(n,"LOGIN",d);throw n;}})}function U(){var b=k.name;b=b?"_"+b:"";g.Storage.remove("token"+b,null);g.Storage.remove("login"+b,null);k.history&&l.history().disable();P()}function G(){var b=C.top(),j="";if(b.name!==A&&b.name!=="")j+=b.name+"_";j+=V;l.name(j);l.prompt(b.prompt);k.history&&l.history().enable();l.set("");if(typeof b.onStart=="function")b.onStart(d)}function M(){G();
-if(c.greetings===A)d.echo(d.signature);else c.greetings&&d.echo(c.greetings);if(typeof k.onInit=="function")k.onInit(d)}function E(b){d.oneTime(5,function(){if(v!=e()){d.resize();v=e()}});if(!d.paused()){if(k.keydown&&k.keydown(b,d)===false)return false;if(b.which!=9)r=0;if(b.which==68&&b.ctrlKey){if(k.exit)if(l.get()==="")if(C.size()>1||k.login!==A)d.pop("");else{d.resume();d.echo("")}else d.set_command("");b.preventDefault()}else if(k.tabcompletion&&b.which==9){++r;b=l.get();if(!b.match(" ")){for(var j=
-RegExp("^"+b),n=C.top().command_list,w=[],t=n.length;t--;)j.test(n[t])&&w.push(n[t]);if(w.length==1)d.set_command(w[0]);else if(w.length>1)if(r>=2){m(b);d.echo(w.join("\t"));r=0}}return false}else if(b.which==86&&b.ctrlKey){d.oneTime(1,function(){x()});return true}else if(b.which==9&&b.ctrlKey){Q.length()>1&&d.focus(false);b.preventDefault()}else if(b.which==34)d.scroll(d.height());else b.which==33?d.scroll(-d.height()):d.attr({scrollTop:d.attr("scrollHeight")})}}var d=this,f=[],q,V=Q.length(),L,
-W=[],k={name:"",prompt:">",history:true,exit:true,clear:true,enabled:true,login:null,tabcompletion:false,onInit:null,onExit:null,keypress:null,keydown:null};if(c){c.width&&d.width(c.width);c.height&&d.height(c.height);g.extend(k,c)}var H=!k.enabled;if(d.length===0)throw'Sorry, but terminal said that "'+d.selector+'" is not valid selector!';d.ajaxSend(function(b,j){ma.push(j)});if(d.data("terminal"))return d.data("terminal");q=g("<div>").addClass("terminal-output").appendTo(d);d.addClass("terminal").append("<div/>");
-g.extend(d,{clear:function(){q.html("");l.set("");f=[];d.attr({scrollTop:0});return d},paused:function(){return H},pause:function(){if(l){d.disable();l.hide()}return d},resume:function(){if(l){d.enable();l.show();x()}return d},cols:function(){return L},rows:function(){return f.length},history:function(){return l.history().data()},next:function(){if(Q.length()==1)return d;else{var b=d.offset().top;d.height();d.scrollTop();var j=d,n=g(window).scrollTop(),w=n+g(window).height(),t=g(j).offset().top;if(t+
-g(j).height()>=n&&t<=w){Q.front().disable();b=Q.rotate().enable();j=b.offset().top-50;g("html,body").animate({scrollTop:j},500);return b}else{d.enable();g("html,body").animate({scrollTop:b-50},500);return d}}},focus:function(b){d.oneTime(1,function(){if(Q.length()==1)b===false?d.disable():d.enable();else if(b===false)d.next();else{Q.front().disable();Q.set(d);d.enable()}});return d},enable:function(){L===A&&d.resize();if(H)if(l){l.enable();H=false}return d},disable:function(){if(l){H=true;l.disable()}return d},
-enabled:function(){return H},signature:function(){var b=d.cols();b=b<15?null:b<35?0:b<55?1:b<64?2:b<75?3:4;return b!==null?la[b].join("\n")+"\n":""},version:function(){return"{{VERSION}}"},get_command:function(){return l.get()},insert:function(b){l.insert(b);return d},set_prompt:function(b){u("prompt",b)&&l.prompt(b);return d},set_command:function(b){l.set(b);return d},set_mask:function(b){l.mask(b);return d},get_output:function(){return g.map(f,function(b,j){return typeof j=="function"?j():j}).get().join("\n")},
-resize:function(b,j){if(b&&j){d.width(b);d.height(j)}L=i();l.resize(L);var n=q.detach();q.html("");g.each(f,function(w,t){T(typeof t=="function"?t():t)});d.prepend(n);x();return d},echo:function(b){f.push(b);return T(typeof b=="function"?b():b)},error:function(b){d.echo("[[;#f00;]"+b.replace(/\[/g,"&#91;").replace(/\]/g,"&#93;")+"]")},scroll:function(b){var j;if(d.prop){b>d.prop("scrollTop")&&b>0&&d.prop("scrollTop",0);j=d.prop("scrollTop");d.prop("scrollTop",j+b)}else{b>d.attr("scrollTop")&&b>0&&
-d.attr("scrollTop",0);j=d.attr("scrollTop");d.attr("scrollTop",j+b)}return d},logout:k.login?function(){for(;C.size()>1;)C.pop();U();return d}:function(){throw"You don't have login function";},token:k.login?function(){var b=k.name;return g.Storage.get("token"+(b?"_"+b:""))}:null,login_name:k.login?function(){var b=k.name;return g.Storage.get("login"+(b?"_"+b:""))}:null,name:function(){return k.name},push:function(b,j){if(!j.prompt||u("prompt",j.prompt)){if(typeof b=="string")b=o(j.eval,d);C.push(g.extend({eval:b},
-j));G()}return d},pop:function(b){b!==A&&m(b);if(C.top().name===k.name){if(k.login){U();if(typeof k.onExit=="function")k.onExit(d)}}else{b=C.pop();G();if(typeof b.onExit=="function")b.onExit(d)}return d}});var r=0,v=e(),p;if(a.constructor==String){p=a;a=o(a,d)}else if(a.constructor==Array)throw"You can't use array as eval";else if(typeof a=="object"){for(var I in a)W.push(I);a=function b(j){return function(n){if(n!==""){n=n.split(/ +/);var w=n[0],t=n.slice(1);n=j[w];var y=typeof n;if(y=="function")n.apply(d,
-t);else if(y=="object"||y=="string"){t=[];if(y=="object"){for(var s in n)t.push(s);n=b(n)}d.push(n,{prompt:w+">",name:w,command_list:t})}else d.error("Command '"+w+"' Not Found")}}}(a)}else if(typeof a!="function")throw'Unknow object "'+String(a)+'" passed as eval';if(p&&(typeof k.login=="string"||k.login))k.login=function(b){var j=1;return function(n,w,t){d.pause();g.jrpc(p,j++,b,[n,w],function(y){d.resume();!y.error&&y.result?t(y.result):t(null)},function(y,s){d.resume();d.error("&#91;AJAX&#92; Response: "+
-s+"\n"+y.responseText)})}}(typeof k.login=="boolean"?"login":k.login);if(u("prompt",k.prompt)){var C=new ia({name:k.name,eval:a,prompt:k.prompt,command_list:W,greetings:k.greetings}),l=d.find(".terminal-output").next().cmd({prompt:k.prompt,history:k.history,width:"100%",keydown:E,keypress:k.keypress?function(b){return k.keypress(b,d)}:null,commands:N});d.livequery(function(){d.resize()});Q.append(d);k.enabled===true?d.focus():d.disable();g(window).resize(d.resize);d.click(function(){d.focus()});d.token&&
-!d.token()&&d.login_name&&!d.login_name()?P():M();typeof g.fn.init.prototype.mousewheel==="function"&&d.mousewheel(function(b,j){j>0?d.scroll(-40):d.scroll(40);return false},true)}d.data("terminal",d);return d}})(jQuery);
+error:u,contentType:"application/json",dataType:"json",async:true,cache:false,type:"POST"})};T=/ {13}$/;var ma=[["jQuery Terminal","(c) 2011 jcubic"],["JQuery Terminal Emulator v. 0.4.9","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>".replace(/ *<.*>/,"")],["JQuery Terminal Emulator version version 0.4.9","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>"],[" _______ ________ __"," / / _ /_ ____________ _/__ ___/______________ _____ / /",
+" __ / / // / // / _ / _/ // / / / _ / _/ / / \\/ / _ \\/ /","/ / / // / // / ___/ // // / / / ___/ // / / / / /\\ / // / /__","\\___/____ \\\\__/____/_/ \\__ / /_/____/_//_/ /_/ /_/ \\/\\__\\_\\___/"," \\/ /____/ ".replace(T,"")+"version 0.4.9","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>"],[" __ _____ ________ __"," / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / /",
+" __ / // // // // // _ // _// // / / // _ // _// // // \\/ // _ \\/ /","/ / // // // // // ___// / / // / / // ___// / / / / // // /\\ // // / /__","\\___//____ \\\\___//____//_/ _\\_ / /_//____//_/ /_/ /_//_//_/ /_/ \\__\\_\\___/"," \\/ /____/ ".replace(T,"")+"version 0.4.9","Copyright (c) 2011 Jakub Jankiewicz <http://jcubic.pl>"]],na=[],R=new function(a){var c=a?[a]:[],e=0;g.extend(this,{rotate:function(){if(c.length==1)return c[0];
+else{if(e==c.length-1)e=0;else++e;return c[e]}},length:function(){return c.length},set:function(i){for(var h=c.length;h--;)if(c[h]===i){e=h;return}this.append(i)},front:function(){return c[e]},append:function(i){c.push(i)}})};g.fn.terminal=function(a,c){function e(){return d.get(0).scrollHeight>d.innerHeight()}function i(){var b=d.find(".cursor").width(),j=Math.floor(d.width()/b);if(e()){var n=d.innerWidth()-d.width();j-=Math.ceil((20-n/2)/(b-1))}return j}function h(b,j){d.error("&#91;"+j+"&#93;: "+
+(typeof b=="string"?b:b.fileName+": "+b.message));d.pause();typeof b.fileName=="string"&&g.get(b.fileName,function(n){d.resume();var w=b.lineNumber-1;(n=n.split("\n")[w])&&d.error("&#91;"+b.lineNumber+"&#93;: "+n)})}function u(b,j){try{if(typeof j=="function")j(function(){});else if(typeof j!="string")throw b+" must be string or function";}catch(n){h(n,b.toUpperCase());return false}return true}function x(){var b=d.prop?d.prop("scrollHeight"):d.attr("scrollHeight");d.scrollTop(b)}function E(b,j){for(var n=
+[],w=/(\[\[[bius]*;[^;]*;\][^\]\[]*\]?)/g,t=/(\[\[[bius]*;[^;]*;\])/,y=b.split(/\n/g),r="",z=0,S=y.length;z<S;++z){if(r!=="")if(y[z]===""){n.push(r+"]");continue}else{y[z]=r+y[z];r=""}for(var G=0,oa=y[z].length;G<oa;G+=j){var B=y[z].substring(G,G+j);if(r!=="")B=r+B;var H=B.match(w),D=B.match(/\t/g);D=D?D.length:0;if(D>0){D*=3;B=y[z].substring(G,G+j-D);G-=D}if(H&&H.length>0){B=D=0;for(var X=H.length;B<X;++B){D+=H[B].match(t)[1].length;if(H[B][H[B].length-1]=="]")D+=1}if(r!=="")D-=r.length;X=G+j+D;
+B=r+y[z].substring(G,X);H=B.match(w);r=H[H.length-1];G+=D;if(r[r.length-1]!="]"){r=r.match(t)[1];H=r.length;D=y[z].substring(X,X+H);B+=D;if(D.match(/\]/))r="";else B+="]";G+=H}else r=""}else r="";if(H=B.match(/(&(?:#[0-9]+|[A-Za-z]+);)/g)){var $=0;g.each(H,function(qa,pa){$+=pa.length-1});B=y[z].substring(G,G+j-$);G-=$}n.push(B)}}return n}function P(b){b=typeof b=="string"?b:String(b);var j,n;if(b.length>M){var w=E(b,M);b=g("<div></div>");j=0;for(n=w.length;j<n;++j)w[j]===""||w[j]=="\r"?b.append("<div>&nbsp;</div>"):
+g("<div/>").html(I(w[j])).appendTo(b)}else b=g("<div/>").html(I(b));q.append(b);b.width("100%");x();return b}function o(b,j){var n=1,w=function(t,y){j.pause();g.jrpc(b,n++,t,y,function(r){if(r.error)j.error("&#91;RPC&#93; "+r.error.message);else if(typeof r.result=="string")j.echo(r.result);else if(r.result instanceof Array)j.echo(r.result.join(" "));else if(typeof r.result=="object"){var z="",S;for(S in r.result)if(r.result.hasOwnProperty(S))z+=S+": "+r.result[S]+"\n";j.echo(z)}j.resume()},function(r,
+z){j.error("&#91;AJAX&#93; "+z+" - Server reponse is: \n"+r.responseText);j.resume()})};return function(t,y){if(t!==""){var r,z;if(t.match(/[^ ]* /)){t=t.split(/ +/);r=t[0];z=t.slice(1)}else{r=t;z=[]}if(!k.login||r=="help")w(r,z);else{var S=y.token();S?w(r,[S].concat(z)):y.error("&#91;AUTH&#93; Access denied (no token)")}}}}function m(b){var j=l.prompt();if(l.mask())b=b.replace(/./g,"*");typeof j=="function"?j(function(n){d.echo(n+" "+b)}):d.echo(j+" "+b)}function O(b){try{var j=C.top();if(b=="exit"&&
+k.exit)if(C.size()==1)k.login?U():d.echo("You can exit from main interpeter");else d.pop("exit");else{m(b);b=="clear"&&k.clear?d.clear():j.eval(b,d)}}catch(n){h(n,"USER");d.resume();throw n;}}function Q(){var b=null;l.prompt("login:");k.history&&l.history().disable();l.commands(function(j){try{m(j);if(b){l.mask(false);d.pause();if(typeof k.login!="function")throw"Value of login property must be a function";k.login(b,j,function(w){if(w){var t=k.name;t=t?"_"+t:"";g.Storage.set("token"+t,w);g.Storage.set("login"+
+t,b);l.commands(O);N()}else{d.error("Wrong password try again");l.prompt("login:");b=null}d.resume();k.history&&l.history().enable()})}else{b=j;l.prompt("password:");l.mask(true)}}catch(n){h(n,"LOGIN",d);throw n;}})}function U(){var b=k.name;b=b?"_"+b:"";g.Storage.remove("token"+b,null);g.Storage.remove("login"+b,null);k.history&&l.history().disable();Q()}function J(){var b=C.top(),j="";if(b.name!==A&&b.name!=="")j+=b.name+"_";j+=V;l.name(j);l.prompt(b.prompt);k.history&&l.history().enable();l.set("");
+if(typeof b.onStart=="function")b.onStart(d)}function N(){J();if(c.greetings===A)d.echo(d.signature);else c.greetings&&d.echo(c.greetings);if(typeof k.onInit=="function")k.onInit(d)}function F(b){d.oneTime(5,function(){if(v!=e()){d.resize();v=e()}});if(!d.paused()){if(k.keydown&&k.keydown(b,d)===false)return false;if(b.which!=9)s=0;if(b.which==68&&b.ctrlKey){if(k.exit)if(l.get()==="")if(C.size()>1||k.login!==A)d.pop("");else{d.resume();d.echo("")}else d.set_command("");b.preventDefault()}else if(k.tabcompletion&&
+b.which==9){++s;b=l.get();if(!b.match(" ")){for(var j=RegExp("^"+b),n=C.top().command_list,w=[],t=n.length;t--;)j.test(n[t])&&w.push(n[t]);if(w.length==1)d.set_command(w[0]);else if(w.length>1)if(s>=2){m(b);d.echo(w.join("\t"));s=0}}return false}else if(b.which==86&&b.ctrlKey){d.oneTime(1,function(){x()});return true}else if(b.which==9&&b.ctrlKey){R.length()>1&&d.focus(false);b.preventDefault()}else if(b.which==34)d.scroll(d.height());else b.which==33?d.scroll(-d.height()):d.attr({scrollTop:d.attr("scrollHeight")})}}
+var d=this,f=[],q,V=R.length(),M,W=[],k={name:"",prompt:">",history:true,exit:true,clear:true,enabled:true,login:null,tabcompletion:false,onInit:null,onExit:null,keypress:null,keydown:null};if(c){c.width&&d.width(c.width);c.height&&d.height(c.height);g.extend(k,c)}var K=!k.enabled;if(d.length===0)throw'Sorry, but terminal said that "'+d.selector+'" is not valid selector!';d.ajaxSend(function(b,j){na.push(j)});if(d.data("terminal"))return d.data("terminal");q=g("<div>").addClass("terminal-output").appendTo(d);
+d.addClass("terminal").append("<div/>");g.extend(d,{clear:function(){q.html("");l.set("");f=[];d.attr({scrollTop:0});return d},paused:function(){return K},pause:function(){if(l){d.disable();l.hide()}return d},resume:function(){if(l){d.enable();l.show();x()}return d},cols:function(){return M},rows:function(){return f.length},history:function(){return l.history().data()},next:function(){if(R.length()==1)return d;else{var b=d.offset().top;d.height();d.scrollTop();var j=d,n=g(window).scrollTop(),w=n+
+g(window).height(),t=g(j).offset().top;if(t+g(j).height()>=n&&t<=w){R.front().disable();b=R.rotate().enable();j=b.offset().top-50;g("html,body").animate({scrollTop:j},500);return b}else{d.enable();g("html,body").animate({scrollTop:b-50},500);return d}}},focus:function(b){d.oneTime(1,function(){if(R.length()==1)b===false?d.disable():d.enable();else if(b===false)d.next();else{R.front().disable();R.set(d);d.enable()}});return d},enable:function(){M===A&&d.resize();if(K)if(l){l.enable();K=false}return d},
+disable:function(){if(l){K=true;l.disable()}return d},enabled:function(){return K},signature:function(){var b=d.cols();b=b<15?null:b<35?0:b<55?1:b<64?2:b<75?3:4;return b!==null?ma[b].join("\n")+"\n":""},version:function(){return"0.4.9"},get_command:function(){return l.get()},insert:function(b){l.insert(b);return d},set_prompt:function(b){u("prompt",b)&&l.prompt(b);return d},set_command:function(b){l.set(b);return d},set_mask:function(b){l.mask(b);return d},get_output:function(){return g.map(f,function(b,
+j){return typeof j=="function"?j():j}).get().join("\n")},resize:function(b,j){if(b&&j){d.width(b);d.height(j)}M=i();l.resize(M);var n=q.detach();q.html("");g.each(f,function(w,t){P(typeof t=="function"?t():t)});d.prepend(n);x();return d},echo:function(b){f.push(b);return P(typeof b=="function"?b():b)},error:function(b){d.echo("[[;#f00;]"+b.replace(/\[/g,"&#91;").replace(/\]/g,"&#93;")+"]")},scroll:function(b){var j;if(d.prop){b>d.prop("scrollTop")&&b>0&&d.prop("scrollTop",0);j=d.prop("scrollTop");
+d.prop("scrollTop",j+b)}else{b>d.attr("scrollTop")&&b>0&&d.attr("scrollTop",0);j=d.attr("scrollTop");d.attr("scrollTop",j+b)}return d},logout:k.login?function(){for(;C.size()>1;)C.pop();U();return d}:function(){throw"You don't have login function";},token:k.login?function(){var b=k.name;return g.Storage.get("token"+(b?"_"+b:""))}:null,login_name:k.login?function(){var b=k.name;return g.Storage.get("login"+(b?"_"+b:""))}:null,name:function(){return k.name},push:function(b,j){if(!j.prompt||u("prompt",
+j.prompt)){if(typeof b=="string")b=o(j.eval,d);C.push(g.extend({eval:b},j));J()}return d},pop:function(b){b!==A&&m(b);if(C.top().name===k.name){if(k.login){U();if(typeof k.onExit=="function")k.onExit(d)}}else{b=C.pop();J();if(typeof b.onExit=="function")b.onExit(d)}return d}});var s=0,v=e(),p;if(a.constructor==String){p=a;a=o(a,d)}else if(a.constructor==Array)throw"You can't use array as eval";else if(typeof a=="object"){for(var L in a)W.push(L);a=function b(j){return function(n){if(n!==""){n=n.split(/ +/);
+var w=n[0],t=n.slice(1);n=j[w];var y=typeof n;if(y=="function")n.apply(d,t);else if(y=="object"||y=="string"){t=[];if(y=="object"){for(var r in n)t.push(r);n=b(n)}d.push(n,{prompt:w+">",name:w,command_list:t})}else d.error("Command '"+w+"' Not Found")}}}(a)}else if(typeof a!="function")throw'Unknow object "'+String(a)+'" passed as eval';if(p&&(typeof k.login=="string"||k.login))k.login=function(b){var j=1;return function(n,w,t){d.pause();g.jrpc(p,j++,b,[n,w],function(y){d.resume();!y.error&&y.result?
+t(y.result):t(null)},function(y,r){d.resume();d.error("&#91;AJAX&#92; Response: "+r+"\n"+y.responseText)})}}(typeof k.login=="boolean"?"login":k.login);if(u("prompt",k.prompt)){var C=new ja({name:k.name,eval:a,prompt:k.prompt,command_list:W,greetings:k.greetings}),l=d.find(".terminal-output").next().cmd({prompt:k.prompt,history:k.history,width:"100%",keydown:F,keypress:k.keypress?function(b){return k.keypress(b,d)}:null,commands:O});d.livequery(function(){d.resize()});R.append(d);k.enabled===true?
+d.focus():d.disable();g(window).resize(d.resize);d.click(function(){d.focus()});d.token&&!d.token()&&d.login_name&&!d.login_name()?Q():N();typeof g.fn.init.prototype.mousewheel==="function"&&d.mousewheel(function(b,j){j>0?d.scroll(-40):d.scroll(40);return false},true)}d.data("terminal",d);return d}})(jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.