mantest.html 4.6 KB

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