⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8.html

📁 asterisk 的图形管理界面
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!--
 * Asterisk-GUI	-	an Asterisk configuration interface
 *
 * Setup WIzard/ Incoming Calls
 *
 * Copyright (C) 2006-2007, Digium, Inc.
 *
 * Mark Spencer <markster@digium.com>
 * Pari Nannapaneni <pari@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.
 *
-->
<HTML>
<HEAD>	<TITLE> Asterisk GUI Setup Wizard</TITLE>
	<link href="setup.css" media="all" rel="Stylesheet" type="text/css" />
</HEAD>
<script src="../scripts/prototype.js"></script>
<script src="../scripts/astman.js"></script>
<SCRIPT>

var rawman_url;
var numplan_callbacks = new Object;
var user_callbacks = new Object;
var didtrunks = new Object;
var editstatus ;
var old_incomingrule, old_fromprovider ;
var edit_pattern, edit_DIDtrunk, edit_action, edit_priority ;
var listOfExtensions = [] ;	// to store all the list of extensions to be displayed in the select menu
var focus_fields = new Array('incomingrule','frompattern','fromprovider','toextension');

user_callbacks.format = function(t, x) {
	var tmp = asterisk_guiTDPrefix + t.name ; 
	if ( ( t.fieldbyname['context'] == tmp ) && x == undefined ) {
		didtrunks[tmp] = new Object();
		didtrunks[tmp].trunkname = t.fieldbyname['trunkname'] ; 
		return t.name;
	}
	if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length && x == undefined && t.name != "general" ) {
		listOfExtensions.push( t.name + " -- " + t.fieldbyname['fullname'] );
	}
	return false;
}

user_callbacks.loaded = function(){
	parent.astmanEngine.config2list("extensions.conf", _$('extensions'), new Object(), numplan_callbacks);
}
user_callbacks.eachline = true;
user_callbacks.includecats = true;

// parse all contexts in extensions.conf that look like [DID_trunk_x]
// and show each entry in the table
numplan_callbacks.format = function(t, x) {
	if ((t.name == specialcontext && x != undefined )){
		var p = format_extension( _$('extensions'), t, x)  ;
		if ( p != null ){ listOfExtensions.push(p); }
	}
	if ( ( t.name.substring(0,asterisk_guiTDPrefix.length) == asterisk_guiTDPrefix ) && x == undefined){
		if(typeof didtrunks[t.name] == "undefined"){
			didtrunks[t.name] = new Object();
			didtrunks[t.name].trunkname = t.name;
		}
		return t.name;
	}
	if ( ( t.name.substring(0,asterisk_guiTDPrefix.length) == asterisk_guiTDPrefix ) && t.names[x]=='exten' ){
		//get pattern & action
		var temp = t.fields[x].split(',');
		if( temp[0] == "s" ){return false;}
		didtrunks[t.name][temp[0]] = new Object();
		didtrunks[t.name][temp[0]].priority = temp[1];
		didtrunks[t.name][temp[0]].action = temp[2];
	}
	return false;
}

numplan_callbacks.loaded = function() {
	listOfExtensions.sort();
	for(var a =0; a < listOfExtensions.length ; a++ ){
		var b = listOfExtensions[a].split(' -- ');
		var New_OPTION = document.createElement('option');
		New_OPTION.text = listOfExtensions[a] ;
		New_OPTION.value = b[0] ;
		try {
			_$('toextension').add(New_OPTION, null); // W3C way
		}catch(ex) {
			_$('toextension').add(New_OPTION); // IE way
		}
	}

	// load list of trunks to 'fromprovider'
	var t ;
	for ( t in didtrunks){	if(  didtrunks.hasOwnProperty(t) ){
		var a = document.createElement('option');
		a.text = didtrunks[t].trunkname ;
		a.value = t ;
		var b = document.getElementById('fromprovider');
		try {
			b.add(a, null); 
		}catch(ex) {
			b.add(a); 
		}
	}}
	// load the object didtrunks into the table callingRulesTable
	refreshtable();
}

numplan_callbacks.eachline = true;
numplan_callbacks.includecats = true;

function refreshtable(){
	for( var i=0; i <  _$('callingRulesTable').rows.length; ){
		_$('callingRulesTable').deleteRow(i);
	}
	
	for ( var i in didtrunks ){ // for each trunk
		if( didtrunks.hasOwnProperty(i) ){ 
			for(var j in didtrunks[i]){ // for each pattern of the trunk
				if( didtrunks[i].hasOwnProperty(j) ){ 
					if( j == "trunkname"){ continue;}
					addrowtotable( j, i, didtrunks[i][j].action, didtrunks[i][j].priority);
				}
			}
		}
	}

	if( _$('callingRulesTable').rows.length == 0){
		_$('table_one').style.display="none";
		var newRow = _$('callingRulesTable').insertRow(-1);
		var newCell0 = newRow.insertCell(0);
		newCell0 .align = "center";
		newCell0 .innerHTML = "<BR>An <I>incoming Calling Rule</I> is not defined<BR><BR> Please click on 'Add a Incoming Rule' button<BR> to add a new incoming call rule.<BR><BR>" ;
		return true;
	}

}

function addrowtotable(a,b,c,d){	// a is pattern, b is DID_trunk, c is action, d is priority
	var sno = _$('callingRulesTable').rows.length + 1;
	var newRow = _$('callingRulesTable').insertRow(-1);
	newRow.id = "row" + sno; 
	
	var newCell0 = newRow.insertCell(0);
	newCell0.innerHTML = sno ;
	newCell0.align="center";
	newCell0.width=35;

	var newCell1 = newRow.insertCell(1);
	newCell1.innerHTML =  convert_tohuman(a,b,c) ; 

	var newCell2 = newRow.insertCell(2);
	newCell2.innerHTML = "<A href=\"#\" onclick=\"edit_incomingrule('"+ a +"', '"+ b +"', '" + c + "','" + d+"')\">Edit</A>&nbsp;&nbsp;<A href=\"#\" onclick=\"delete_incomingrule('"+ a +"', '"+ b +"', '" + c + "','" + d+"')\">Delete</A>";
	newCell2.width=75;
	newCell2.align="center";
	return true;
}


function convert_tohuman(a,b,c) { // a is pattern, b is DID_trunk, c is action, 
	var trunk = b.substr(4) ;
	if( c.match("Goto") && !c.match("voicemenu-")  ){ 
		var tmp = c.split('(');
		var exten = tmp[1].split('|'); // extension is exten[1]
	}

	if( a == "_X."){ // handling all unmatched 
		return " Route all unmatched incoming calls from provider '" + trunk + "' to extension '" + exten[1] + "'" ; 
	}
	return " Route incoming calls from provider '" + trunk + "' that macth pattern '" + a + "' to extension '" + exten[1] + "'"  ; 
}


function add_incomingrule(){
	editstatus = "NEW";
	_$('incomingrule').selectedIndex = 0;
	_$('fromprovider').selectedIndex = -1;
	old_incomingrule = "allunmatched";
	old_fromprovider = "";
	_$('toextension').selectedIndex = -1;
	_$('frompattern').value = "";
	_$('save_a').disabled = true;
	_$('thatmatch').style.display = "none" ;
	_$('userscontent').style.display = "";
	_$('bg_transparent').style.display = "";
}

function edit_incomingrule(a,b,c,d){// a is pattern, b is DID_trunk, c is action, d is priority
	edit_pattern = a; 
	edit_DIDtrunk = b;
	edit_action = c; 
	edit_priority=d ;

	editstatus = "EDIT";
	if(a == "_X."){
		_$('incomingrule').selectedIndex = 0;
		_$('thatmatch').style.display = "none" ;
		old_incomingrule = "allunmatched";
	}else{
		_$('frompattern').value = a ;
		_$('incomingrule').selectedIndex = 1;
		_$('thatmatch').style.display = "" ;
		old_incomingrule = "frompattern";
	}

	for(var i=0; i < _$('fromprovider').length ; i++){
		if( _$('fromprovider').options[i].value == b){
			_$('fromprovider').selectedIndex = i;		
			old_fromprovider = b;
			break;
		}
	}

	if( c.match("Goto") && !c.match("voicemenu-")  ){ 
		var tmp = c.split('(');
		var exten = tmp[1].split('|'); // extension is exten[1]
		_$('toextension').selectedIndex = -1 ;
		for(var t=0; t < _$('toextension').length ; t++ ){
			if( _$('toextension').options[t].value == exten[1] ){
				_$('toextension').selectedIndex = t;
				break;
			}
		}
	}

	_$('userscontent').style.display = "";
	_$('bg_transparent').style.display ='';
}


function save_incomingrule(){
	if(	editstatus == "NEW"){
		save_new_incomingrule();
	}else if ( editstatus == "EDIT" ){
		update_incomingrule();
	}
}


function save_new_incomingrule(){
	// field validation 
	if(_$('incomingrule').value == "frompattern" && _$('frompattern').value == "" ){
		alert("Please define an incoming call pattern !");
		_$('frompattern').focus();
		_$('frompattern').select();
		return false;
	}
	if( _$('fromprovider').selectedIndex == -1 ){
		alert("Please select a service provider !");
		_$('fromprovider').focus();
		return false;
	}
	if( _$('toextension').selectedIndex == -1 ){
		alert("Please select an extension to which an incoming call should be routed to !");
		_$('toextension').focus();
		return false;
	}

	if(_$('incomingrule').value == "frompattern" && _$('frompattern').value.substr(0,1) != "_" ){
				$('frompattern').value = "_" + _$('frompattern').value ;
	}

	// create an entry under the selected trunk
	// $('incomingrule') == "allunmatched" or "frompattern" , $('frompattern'), $('fromprovider'), $('toextension')
	if (_$('incomingrule').value == "allunmatched" ){
		var newpattern = "_X." ;
		var temp_provider = _$('fromprovider').value;
		var temp_priority = "1";
		var temp_action = "Goto(default|" + _$('toextension').value + "|1)";
		var new_exten = newpattern  + "," + temp_priority + "," + temp_action;
		var new_exten2 = "s,1," + temp_action;
		var uri = build_action('append', 0, temp_provider ,"exten", new_exten);
		uri += build_action('append', 1, temp_provider ,"exten", new_exten2);
	}else{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -