Merge "taskprocessor.c: Tweak high water checks."
[asterisk/asterisk.git] / static-http / mantest.html
1 <!--
2  Asterisk -- An open source telephony toolkit.
3  
4  Copyright (C) 1999 - 2012, Digium, Inc.
5  
6  Mark Spencer <markster@digium.com>
7  
8  See http://www.asterisk.org for more information about
9  the Asterisk project. Please do not directly contact
10  any of the maintainers of this project for assistance;
11  the project provides a web site, mailing lists and IRC
12  channels for your use.
13  This program is free software, distributed under the terms of
14  the GNU General Public License Version 2. See the LICENSE file
15  at the top of the source tree.
16 -->
17 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
18 <html>
19 <head>
20         <style type="text/css">
21                 #container {
22                         margin: 0 auto;
23                         width: 100%;
24                         height: 100%;
25                         background: #fff;
26                 }
27                 #top {
28                         float: left;
29                         width: 100%;
30                         background: #fff;
31                 }
32                 #bottom {
33                         float: left;
34                         width: 100%;
35                         background: #fff;
36                 }
37                 #sender {
38                         clear: left;
39                         float: left;
40                         width: 20%;
41                         display: inline;
42                         overflow: auto;
43                 }
44                 #output {
45                         float: right;
46                         width: 79%;
47                         display: inline;
48                         overflow: auto;
49                         border: thin solid black;
50                 }
51                 .required {
52                         color: red;
53                 }
54         </style>
55         <title>Asterisk Manager Utility</title>
56         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
57
58         <script type="text/javascript">
59
60 $(document).ready(function() {
61         $('#output').height($(document).height() - $('#top').height() - 100);
62         $.ajax({
63                 type: "GET",
64                 url: "core-en_US.xml",
65                 dataType: "xml",
66                 success: parseXml
67         });
68
69         $("#login").submit(function() {
70                 $("#output").empty();
71                 submitCommand($(this));
72                 $("#command").focus();
73                 return false;
74         });
75
76         $("#search_button").click(function() {
77                 var command = $("#command").val();
78                 $("#command").val("");
79                 $("#output").empty();
80                 if (commands) {
81                         commands.each(function() {
82                                 if ($(this).attr("name").toLowerCase() == command.toLowerCase()) {
83                                         buildCommandForm($(this));
84                                 }
85                         });
86                 }
87                 $('#output').height($(document).height() - $('#top').height() - 100);
88                 return false;
89         });
90         $('#command').keyup(function(event) {
91                 if (event.keyCode == '13') {
92                         return;
93                 }
94                 var matches = [];
95                 var search = $("#command").val().toLowerCase();
96                 $("#output").empty();
97                 if (search.length && commands) {
98                         commands.each(function() {
99                                 var com = $(this).attr("name").toLowerCase();
100                                 if (com.substr(0, search.length) === search) {
101                                         matches.push(com);
102                                 }
103                         });
104                 }
105                 if (matches.length) {
106                         $("#output").append(matches.sort().join("<br/>"));
107                 }
108         });
109 });
110
111 function parseXml(xml) {
112         commands = $(xml).find("manager")
113 }
114
115 function buildCommandForm(command) {
116         var name = command.attr("name");
117         var i = 0;
118         $("#sendcommand").empty();
119         $("#sendcommand").unbind('submit');
120         $("#sendcommand").append('<label>Action:&nbsp;</label><input name="action" readonly="readonly" value="'+name+'"/><br />');
121         command.find("parameter").each(function() {
122                 var param = $(this).attr("name");
123                 if (param != "ActionID") {
124                         $("#sendcommand").append('<label for="'+param+'">'+param+':&nbsp;</label><input name="'+param+'" /><br />');
125                         if ($(this).attr("required")) {
126                                 $('label[for='+param+']').addClass("required");
127                         }
128                         if (i == 0) {
129                                 $("input[name="+param+"]").focus();
130                         }
131                         i++;
132                 }
133         });
134         $("#sendcommand").append('<button type="submit" id="commandbutton">Send</button>');
135         $("#sendcommand").submit(function() {
136                 $("#output").empty();
137                 submitCommand($(this));
138                 $("#command").focus();
139                 return false;
140         });
141
142         // If we don't have any fields to fill in, go ahead and submit!
143         if (i == 0) {
144                 $("#sendcommand").submit();
145         }
146 }
147
148 function submitCommand(form) {
149         $.ajax({
150                 type: "GET",
151                 url: "../rawman",
152                 dataType: "text",
153                 data: $(form).serializeArray(),
154                 success: displayResponse,
155                 failure: function() {alert("Error!");}
156         });
157         return false;
158 }
159
160 function displayResponse(data) {
161         data = data.replace(/\r\n/g, "<br />");
162         $("#output").append(data);
163         return false;
164 }
165
166         </script>
167 </head>
168
169 <body>
170         <div id="container">
171                 <div id="top">
172                         <form id="login" name="login">
173                                 <label for="username">Username:&nbsp;</label><input id="username" name="username" />
174                                 <label for="secret">Secret:&nbsp;</label><input id="secret" name="secret" type="password"/>
175                                 <input type="hidden" name="action" value="login" />
176                                 <button id="login_button" type="submit">Submit</button>
177                         </form>
178                         <hr />
179                         <form id="search" name="search">
180                                 <label for="txt">Action:&nbsp;</label><input name="command" id="command"/>
181                                 <button id="search_button">Submit</button>
182                         </form>
183                 </div>
184                 <hr />
185                 <div id="bottom">
186                         <div id="sender">
187                                 <form id="sendcommand" name="sendcommand"></form>
188                         </div>
189                         <div id="output"></div>
190                 </div>
191         </div>
192 </body>
193 </html>