Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa78f4e

Browse filesBrowse files
committed
demo ready
1 parent fc476bd commit aa78f4e
Copy full SHA for aa78f4e

File tree

Expand file treeCollapse file tree

4 files changed

+24
-13
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+24
-13
lines changed

‎.gitignore

Copy file name to clipboard
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea/workspace.xml
2-
.idea/tasks.xml
2+
.idea/tasks.xml
3+
.DS_Store

‎js/mtshell.js

Copy file name to clipboardExpand all lines: js/mtshell.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
shellConfig.history = config.history;
77
}
88
var _shell = new Shell(shellConfig);
9-
var _commandList = _.sortBy(['go', 'ls', 'cd', 'show', 'pwd', 'help'], function(x) {
9+
var _commandList = _.sortBy(['go', 'ls', 'cd', 'show', 'pwd', 'help','clear'], function(x) {
1010
return x;
1111
});
1212
var _namespaces = {
@@ -96,6 +96,10 @@
9696
cmd = "show";
9797
}
9898
switch(cmd) {
99+
case "clear":
100+
$(input_id).siblings().remove();
101+
callback();
102+
return;
99103
case "help":
100104
var content = $('<div><div><strong>Commands:</strong></div></div>');
101105
_.each(_commandList, function(command) {

‎js/shell.js

Copy file name to clipboardExpand all lines: js/shell.js
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
config = config || {};
44
// instance fields
55
var _prompt = config.prompt || 'jsh$';
6-
var _shell_id = config.shell_id || '#shell';
6+
var _shell_view_id = config.shell_view_id || '#shell-view';
7+
var _shell_panel_id = config.shell_panel_id || '#shell-panel';
78
var _input_id = config.input_id || '#shell-cli';
89
var _input_html = config.input_html || '<div id="shell-cli"><strong class="prompt"></strong>&nbsp;<span class="input"><span class="left"/><span class="cursor"/><span class="right"/></span></div>';
910
var _suggest_html = config.suggest_html || '<div id="shell-suggest"></div>';
@@ -19,7 +20,7 @@
1920
text:'',
2021
cursor:0
2122
};
22-
var shell;
23+
var _view, _panel;
2324

2425
// public methods
2526
var self = {
@@ -104,7 +105,7 @@
104105
},
105106
scrollToBottom:function () {
106107
//_shell.scrollTop(_shell.height());
107-
_shell.animate({scrollTop:_shell.height()}, 1000);
108+
_panel.animate({scrollTop:_view.height()}, 1000);
108109
}
109110
};
110111

@@ -127,15 +128,15 @@
127128
}
128129

129130
function init() {
130-
if ($(_shell_id).length == 0) {
131+
if ($(_shell_view_id).length == 0) {
131132
_active = false;
132133
return;
133134
}
134135
if ($(_input_id).length == 0) {
135-
$(_shell_id).append(_input_html);
136+
$(_shell_view_id).append(_input_html);
136137
}
137-
_shell = $(_shell_id);
138-
_shell.css('overflow', 'scroll');
138+
_view = $(_shell_view_id);
139+
_panel = $(_shell_panel_id);
139140
}
140141

141142
// init
@@ -148,7 +149,7 @@
148149
if (_onCmd) {
149150
_onCmd(cmd, _input_id, function (prompt) {
150151
$(_input_id).removeAttr('id');
151-
$(_shell_id).append(_input_html);
152+
$(_shell_view_id).append(_input_html);
152153
if (prompt) {
153154
self.setPrompt(prompt);
154155
}

‎js/shellinit.js

Copy file name to clipboardExpand all lines: js/shellinit.js
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
shell = new MtShell({history: new ReadLine.History({storage: localStorage})});
22
(function($) {
33
$(document).ready(function() {
4-
var mtConsole = $('#shell');
4+
var mtConsole = $('#shell-panel');
55

66
function showConsole() {
77
mtConsole.slideDown();
88
mtConsole.focus();
99
}
1010

1111
function hideConsole() {
12-
mtConsole.slideUp();
13-
mtConsole.blur();
12+
console.log("slideup");
13+
mtConsole.slideUp(1000, function() {
14+
console.log("blur");
15+
mtConsole.blur();
16+
});
1417
}
1518

1619
mtConsole.focus(function() {
@@ -20,6 +23,7 @@ shell = new MtShell({history: new ReadLine.History({storage: localStorage})});
2023
}
2124
});
2225
mtConsole.blur(function() {
26+
console.log("deactivating");
2327
shell.deactivate();
2428
if(localStorage) {
2529
localStorage.setItem('mtShell.visible', false);
@@ -40,6 +44,7 @@ shell = new MtShell({history: new ReadLine.History({storage: localStorage})});
4044
if(e.keyCode && e.keyCode === 192 && e.shiftKey) {
4145
showConsole();
4246
} else if(e.keyCode && e.keyCode === 27) {
47+
console.log("hiding console");
4348
hideConsole();
4449
}
4550
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.