blob: 7d34014a877890fb47bd9647bb6d22dfec60152a [file] [log] [blame]
Felix Meschbergerddf69082008-08-07 19:15:29 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
Felix Meschberger1404ae52010-02-18 13:09:21 +000018// elements cache
19var consoleframe = false;
Felix Meschberger3aff77d2010-03-12 13:25:09 +000020var konsole = false;
Felix Meschberger1404ae52010-02-18 13:09:21 +000021var command = false;
22
23function executeCommand(cmd) {
24 $.post(document.location.href, { 'command' : encodeURIComponent(cmd) },
25 function(result) {
Felix Meschberger3aff77d2010-03-12 13:25:09 +000026 konsole.removeClass('ui-helper-hidden').append(result);
27 consoleframe.attr('scrollTop', konsole.attr('scrollHeight'));
Felix Meschberger1404ae52010-02-18 13:09:21 +000028 command.val('');
29 shellCommandFocus();
30 }, 'html');
Felix Meschbergerddf69082008-08-07 19:15:29 +000031}
32
Felix Meschberger1404ae52010-02-18 13:09:21 +000033function shellCommandFocus() { command.focus() }
Felix Meschbergerddf69082008-08-07 19:15:29 +000034
Felix Meschberger1404ae52010-02-18 13:09:21 +000035// automatically executed on load
36$(document).ready(function(){
Felix Meschberger3aff77d2010-03-12 13:25:09 +000037
38 // disable the shell form if the shell service is not available
39 if (shellDisabled) {
40
41 $('#shell_form').hide();
42
43 } else {
44
45 // init cache
46 consoleframe = $('#consoleframe').click(shellCommandFocus);
47 konsole = $('#console');
48 command = $('#command').focus();
49
50 // attach action handlers
51 $('#clear').click(function() {
52 konsole.addClass('ui-helper-hidden').html('');
53 consoleframe.attr('scrollTop', 0);
54 shellCommandFocus();
55 });
56 $('#help').click(function() {
57 executeCommand('help');
58 });
59 $('form').submit(function() {
60 executeCommand(command.val());
61 return false;
62 });
63
64 }
Felix Meschberger1404ae52010-02-18 13:09:21 +000065});