13
13
$ this ->registerJs (
14
14
<<<JS
15
15
jQuery(function($) {
16
- $('#webshell').terminal(
16
+ var webshell = $('#webshell');
17
+
18
+ webshell.terminal(
17
19
function(command, term) {
18
20
if (command.indexOf('yii') === 0 || command.indexOf('yii') === 3) {
19
21
$.jrpc(' {$ endpoint }', 'yii', [command.replace(/^yii ?/, '')], function(json) {
20
22
term.echo(json.result);
23
+ scrollDown();
21
24
});
22
25
} else if (command === 'help') {
23
26
term.echo('Available commands are:');
@@ -26,16 +29,20 @@ function(command, term) {
26
29
term.echo('help \tThis help text');
27
30
term.echo('yii \tyii command');
28
31
term.echo('quit \tQuit web shell');
32
+ scrollDown();
29
33
} else if (command === 'quit') {
30
34
var exitUrl = ' {$ quitUrl }';
31
35
if (exitUrl) {
32
36
term.echo('Bye!');
37
+ scrollDown();
33
38
location.replace(exitUrl);
34
39
} else {
35
40
term.echo('There is no exit.');
41
+ scrollDown();
36
42
}
37
43
} else {
38
44
term.echo('Unknown command.');
45
+ scrollDown();
39
46
}
40
47
},
41
48
{
@@ -45,9 +52,13 @@ function(command, term) {
45
52
}
46
53
);
47
54
48
- $('html').on('keydown', function() {
49
- $('# webshell') .click();
55
+ $('html').on('keydown', function(e) {
56
+ webshell.click();
50
57
});
58
+
59
+ function scrollDown() {
60
+ $('html, body').animate({ scrollTop: webshell.height() }, 'fast');
61
+ }
51
62
});
52
63
JS
53
64
);
0 commit comments