mantest.html 4.1 KB

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