2 Asterisk -- An open source telephony toolkit.
4 Copyright (C) 1999 - 2012, Digium, Inc.
6 Mark Spencer <markster@digium.com>
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.
17 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
20 <style type="text/css">
49 border: thin solid black;
55 <title>Asterisk Manager Utility</title>
56 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
58 <script type="text/javascript">
60 $(document).ready(function() {
61 $('#output').height($(document).height() - $('#top').height() - 100);
64 url: "core-en_US.xml",
69 $("#login").submit(function() {
71 submitCommand($(this));
72 $("#command").focus();
76 $("#search_button").click(function() {
77 var command = $("#command").val();
78 $("#command").val("");
81 commands.each(function() {
82 if ($(this).attr("name").toLowerCase() == command.toLowerCase()) {
83 buildCommandForm($(this));
87 $('#output').height($(document).height() - $('#top').height() - 100);
90 $('#command').keyup(function(event) {
91 if (event.keyCode == '13') {
95 var search = $("#command").val().toLowerCase();
97 if (search.length && commands) {
98 commands.each(function() {
99 var com = $(this).attr("name").toLowerCase();
100 if (com.substr(0, search.length) === search) {
105 if (matches.length) {
106 $("#output").append(matches.sort().join("<br/>"));
111 function parseXml(xml) {
112 commands = $(xml).find("manager")
115 function buildCommandForm(command) {
116 var name = command.attr("name");
118 $("#sendcommand").empty();
119 $("#sendcommand").unbind('submit');
120 $("#sendcommand").append('<label>Action: </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+': </label><input name="'+param+'" /><br />');
125 if ($(this).attr("required")) {
126 $('label[for='+param+']').addClass("required");
129 $("input[name="+param+"]").focus();
134 $("#sendcommand").append('<button type="submit" id="commandbutton">Send</button>');
135 $("#sendcommand").submit(function() {
136 $("#output").empty();
137 submitCommand($(this));
138 $("#command").focus();
142 // If we don't have any fields to fill in, go ahead and submit!
144 $("#sendcommand").submit();
148 function submitCommand(form) {
153 data: $(form).serializeArray(),
154 success: displayResponse,
155 failure: function() {alert("Error!");}
160 function displayResponse(data) {
161 data = data.replace(/\r\n/g, "<br />");
162 $("#output").append(data);
172 <form id="login" name="login">
173 <label for="username">Username: </label><input id="username" name="username" />
174 <label for="secret">Secret: </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>
179 <form id="search" name="search">
180 <label for="txt">Action: </label><input name="command" id="command"/>
181 <button id="search_button">Submit</button>
187 <form id="sendcommand" name="sendcommand"></form>
189 <div id="output"></div>