blob: 8a79c8ef5f3236f7987cf57e8c91e08187e4c5e1 [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;
20var console = false;
21var command = false;
22
23function executeCommand(cmd) {
24 $.post(document.location.href, { 'command' : encodeURIComponent(cmd) },
25 function(result) {
26 console.removeClass('ui-helper-hidden').append(result);
27 consoleframe.attr('scrollTop', console.attr('scrollHeight'));
28 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(){
37 // init cache
38 consoleframe = $('#consoleframe').click(shellCommandFocus);
39 console = $('#console');
40 command = $('#command').focus();
Felix Meschbergerddf69082008-08-07 19:15:29 +000041
Felix Meschberger1404ae52010-02-18 13:09:21 +000042 // attach action handlers
43 $('#clear').click(function() {
44 console.addClass('ui-helper-hidden').html('');
45 consoleframe.attr('scrollTop', 0);
46 shellCommandFocus();
47 });
48 $('#help').click(function() {
49 executeCommand('help');
50 });
51 $('form').submit(function() {
52 executeCommand(command.val());
53 return false;
54 });
55});