| 
									
										
										
										
											2012-10-11 22:43:52 +00:00
										 |  |  | <!--
 | 
					
						
							|  |  |  |  Asterisk -- An open source telephony toolkit. | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |  Copyright (C) 1999 - 2012, Digium, Inc. | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |  Mark Spencer <markster@digium.com> | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |  See http://www.asterisk.org for more information about | 
					
						
							|  |  |  |  the Asterisk project. Please do not directly contact | 
					
						
							|  |  |  |  any of the maintainers of this project for assistance; | 
					
						
							|  |  |  |  the project provides a web site, mailing lists and IRC | 
					
						
							|  |  |  |  channels for your use. | 
					
						
							|  |  |  |  This program is free software, distributed under the terms of | 
					
						
							|  |  |  |  the GNU General Public License Version 2. See the LICENSE file | 
					
						
							|  |  |  |  at the top of the source tree. | 
					
						
							|  |  |  | --> | 
					
						
							| 
									
										
										
										
											2010-10-13 22:34:32 +00:00
										 |  |  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | 
					
						
							|  |  |  | <html> | 
					
						
							|  |  |  | <head> | 
					
						
							|  |  |  | 	<style type="text/css"> | 
					
						
							|  |  |  | 		#container { | 
					
						
							|  |  |  | 			margin: 0 auto; | 
					
						
							|  |  |  | 			width: 100%; | 
					
						
							|  |  |  | 			height: 100%; | 
					
						
							|  |  |  | 			background: #fff; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		#top { | 
					
						
							|  |  |  | 			float: left; | 
					
						
							|  |  |  | 			width: 100%; | 
					
						
							|  |  |  | 			background: #fff; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		#bottom { | 
					
						
							|  |  |  | 			float: left; | 
					
						
							|  |  |  | 			width: 100%; | 
					
						
							|  |  |  | 			background: #fff; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		#sender { | 
					
						
							|  |  |  | 			clear: left; | 
					
						
							|  |  |  | 			float: left; | 
					
						
							|  |  |  | 			width: 20%; | 
					
						
							|  |  |  | 			display: inline; | 
					
						
							|  |  |  | 			overflow: auto; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		#output { | 
					
						
							|  |  |  | 			float: right; | 
					
						
							|  |  |  | 			width: 79%; | 
					
						
							|  |  |  | 			display: inline; | 
					
						
							|  |  |  | 			overflow: auto; | 
					
						
							|  |  |  | 			border: thin solid black; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		.required { | 
					
						
							|  |  |  | 			color: red; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	</style> | 
					
						
							| 
									
										
										
										
											2012-10-11 22:43:52 +00:00
										 |  |  | 	<title>Asterisk Manager Utility</title> | 
					
						
							|  |  |  | 	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> | 
					
						
							| 
									
										
										
										
											2010-10-13 22:34:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	<script type="text/javascript"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $(document).ready(function() { | 
					
						
							|  |  |  | 	$('#output').height($(document).height() - $('#top').height() - 100); | 
					
						
							|  |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		type: "GET", | 
					
						
							|  |  |  | 		url: "core-en_US.xml", | 
					
						
							|  |  |  | 		dataType: "xml", | 
					
						
							|  |  |  | 		success: parseXml | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$("#login").submit(function() { | 
					
						
							|  |  |  | 		$("#output").empty(); | 
					
						
							|  |  |  | 		submitCommand($(this)); | 
					
						
							|  |  |  | 		$("#command").focus(); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	$("#search_button").click(function() { | 
					
						
							|  |  |  | 		var command = $("#command").val(); | 
					
						
							|  |  |  | 		$("#command").val(""); | 
					
						
							|  |  |  | 		$("#output").empty(); | 
					
						
							|  |  |  | 		if (commands) { | 
					
						
							|  |  |  | 			commands.each(function() { | 
					
						
							|  |  |  | 				if ($(this).attr("name").toLowerCase() == command.toLowerCase()) { | 
					
						
							|  |  |  | 					buildCommandForm($(this)); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		$('#output').height($(document).height() - $('#top').height() - 100); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	$('#command').keyup(function(event) { | 
					
						
							|  |  |  | 		if (event.keyCode == '13') { | 
					
						
							|  |  |  | 			return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		var matches = []; | 
					
						
							|  |  |  | 		var search = $("#command").val().toLowerCase(); | 
					
						
							|  |  |  | 		$("#output").empty(); | 
					
						
							|  |  |  | 		if (search.length && commands) { | 
					
						
							|  |  |  | 			commands.each(function() { | 
					
						
							|  |  |  | 				var com = $(this).attr("name").toLowerCase(); | 
					
						
							|  |  |  | 				if (com.substr(0, search.length) === search) { | 
					
						
							|  |  |  | 					matches.push(com); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (matches.length) { | 
					
						
							|  |  |  | 			$("#output").append(matches.sort().join("<br/>")); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function parseXml(xml) { | 
					
						
							|  |  |  | 	commands = $(xml).find("manager") | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function buildCommandForm(command) { | 
					
						
							|  |  |  | 	var name = command.attr("name"); | 
					
						
							|  |  |  | 	var i = 0; | 
					
						
							|  |  |  | 	$("#sendcommand").empty(); | 
					
						
							|  |  |  | 	$("#sendcommand").unbind('submit'); | 
					
						
							|  |  |  | 	$("#sendcommand").append('<label>Action: </label><input name="action" readonly="readonly" value="'+name+'"/><br />'); | 
					
						
							|  |  |  | 	command.find("parameter").each(function() { | 
					
						
							|  |  |  | 		var param = $(this).attr("name"); | 
					
						
							|  |  |  | 		if (param != "ActionID") { | 
					
						
							|  |  |  | 			$("#sendcommand").append('<label for="'+param+'">'+param+': </label><input name="'+param+'" /><br />'); | 
					
						
							|  |  |  | 			if ($(this).attr("required")) { | 
					
						
							|  |  |  | 				$('label[for='+param+']').addClass("required"); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (i == 0) { | 
					
						
							|  |  |  | 				$("input[name="+param+"]").focus(); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			i++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	$("#sendcommand").append('<button type="submit" id="commandbutton">Send</button>'); | 
					
						
							|  |  |  | 	$("#sendcommand").submit(function() { | 
					
						
							|  |  |  | 		$("#output").empty(); | 
					
						
							|  |  |  | 		submitCommand($(this)); | 
					
						
							|  |  |  | 		$("#command").focus(); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// If we don't have any fields to fill in, go ahead and submit! | 
					
						
							|  |  |  | 	if (i == 0) { | 
					
						
							|  |  |  | 		$("#sendcommand").submit(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function submitCommand(form) { | 
					
						
							|  |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		type: "GET", | 
					
						
							|  |  |  | 		url: "../rawman", | 
					
						
							|  |  |  | 		dataType: "text", | 
					
						
							|  |  |  | 		data: $(form).serializeArray(), | 
					
						
							|  |  |  | 		success: displayResponse, | 
					
						
							|  |  |  | 		failure: function() {alert("Error!");} | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function displayResponse(data) { | 
					
						
							|  |  |  | 	data = data.replace(/\r\n/g, "<br />"); | 
					
						
							|  |  |  | 	$("#output").append(data); | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	</script> | 
					
						
							|  |  |  | </head> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <body> | 
					
						
							|  |  |  | 	<div id="container"> | 
					
						
							|  |  |  | 		<div id="top"> | 
					
						
							|  |  |  | 			<form id="login" name="login"> | 
					
						
							|  |  |  | 				<label for="username">Username: </label><input id="username" name="username" /> | 
					
						
							|  |  |  | 				<label for="secret">Secret: </label><input id="secret" name="secret" type="password"/> | 
					
						
							|  |  |  | 				<input type="hidden" name="action" value="login" /> | 
					
						
							|  |  |  | 				<button id="login_button" type="submit">Submit</button> | 
					
						
							|  |  |  | 			</form> | 
					
						
							|  |  |  | 			<hr /> | 
					
						
							|  |  |  | 			<form id="search" name="search"> | 
					
						
							|  |  |  | 				<label for="txt">Action: </label><input name="command" id="command"/> | 
					
						
							|  |  |  | 				<button id="search_button">Submit</button> | 
					
						
							|  |  |  | 			</form> | 
					
						
							|  |  |  | 		</div> | 
					
						
							|  |  |  | 		<hr /> | 
					
						
							|  |  |  | 		<div id="bottom"> | 
					
						
							|  |  |  | 			<div id="sender"> | 
					
						
							|  |  |  | 				<form id="sendcommand" name="sendcommand"></form> | 
					
						
							|  |  |  | 			</div> | 
					
						
							|  |  |  | 			<div id="output"></div> | 
					
						
							|  |  |  | 		</div> | 
					
						
							|  |  |  | 	</div> | 
					
						
							|  |  |  | </body> | 
					
						
							|  |  |  | </html> |