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

📄 incoming.html.svn-base

📁 asterisk-gui asterisk网关接口编程 控制asterisk的接口
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
<!-- * Asterisk-GUI	-	an Asterisk configuration interface * * Incoming Calling Rules * * 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. *--><script src="scripts/prototype.js"></script><script src="scripts/astman.js"></script><script src="scripts/tooltip.js"></script><link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" /><script>var numplan_callbacks = new Object;var user_callbacks = new Object;var didtrunks = new Object;var old_incomingrule, old_fromprovider ;var editstatus , edit_pattern, edit_DIDtrunk, edit_action, edit_priority ;var sbcid_1 = 's,1,ExecIf($[ "${CALLERID(num)}"="" ],SetCallerPres,unavailable)';var sbcid_2 = 's,2,ExecIf($[ "${CALLERID(num)}"="" ],Set,CALLERID(all)=unknown <0000000>)';function add_toext(a,b){ // a is value, b is text	ASTGUI.selectbox.append(_$('toextension'),b,a);}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'] ; 		didtrunks[tmp].provname = (t.fieldbyname['provider']) ? t.fieldbyname['provider'] : "unknown" ;		didtrunks[tmp].isanalog = 'no';		try{			if( t.fieldbyname['zapchan'] && ( t.fieldbyname['trunkstyle'] == 'analog' ) ){ didtrunks[tmp].isanalog = 'yes'; }		}catch(err){}		return t.name;	}	if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length && x == undefined && t.name != "general" ) {		add_toext("Goto(default|" + t.name + "|1)", t.name + " -- " + t.fieldbyname['fullname'] );	}	return false;}user_callbacks.loaded = function(){	parent.astmanEngine.config2list("extensions.conf", $('extensions'), new Array(), 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 tablenumplan_callbacks.format = function(t, x) {	if((typeof didtrunks[t.name] == "undefined") && t.name.contains('_span_')){ return false; }	if ((t.name == specialcontext && x != undefined )){		var p = format_extension( _$('extensions'), t, x)  ;		if ( p != null ){			add_toext("Goto(default|" + p.split(' -- ')[0] + "|1)", 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 f = ASTGUI.parseContextLine.getExten(t.fields[x]);		if( f == "s" ){return false;}		didtrunks[t.name][f] = new Object();		didtrunks[t.name][f].priority = ASTGUI.parseContextLine.getPriority(t.fields[x]);		didtrunks[t.name][f].action = ASTGUI.parseContextLine.getAction(t.fields[x])	}	if( t.name.match('ringroups-custom-') && (x == undefined) ){		var k = t.fieldbyname['gui_ring_groupname'];		var l = (k)?k:t.name;		add_toext( 'Goto('+t.name+',s,1)', l + ' -- RingGroup' );		return false;	}	if( (t.name == TIMERULES_CATEGORY && x != undefined )) {		return null ; // disable time based rules		if (!t.fields[x].match('NoOp')){ return false; }		var m = t.fields[x].split('NoOp')[1].substr(1);		    m = m.substr(0, m.length-1);		//add_toext("Goto("+TIMERULES_CATEGORY+"|" + t.fields[x].split(',')[0] + "|1)", m + " -- Time Based Rule" );		return false;	}	if(( t.name.substr(0,17) == 'voicemenu-custom-' && x== undefined )){		add_toext( 'Goto(' + t.name + '|s|1)' , t.fieldbyname['comment'] + ' -- VoiceMenu');	}	return false;}numplan_callbacks.loaded = function() {	// load list of trunks to 'fromprovider'	var t ;	for (t in didtrunks){	if(  didtrunks.hasOwnProperty(t) ){		ASTGUI.selectbox.append(_$('fromprovider'),didtrunks[t].trunkname, t);	}}	// load the object didtrunks into the table callingRulesTable	load_mISDNtrunks();}function load_mISDNtrunks(){	var parseUsersConf = function(n){		try{			if( n == "ERROR: CONFIG FILE NOT FOUND"){ } // misdn.conf not found			for( var l in n ){ 				if( n.hasOwnProperty(l) && l.beginsWith('trunk_m') && n[l]['hasmisdn'] =='yes' ){					didtrunks[l] = new Object();					didtrunks[l].trunkname = n[l]['trunkname']; 				}			};		}catch(err){		}finally{			// load the object didtrunks into the table callingRulesTable			refreshtable();			parent.loadscreen(this);		}	};	config2json("misdn.conf", 1, parseUsersConf);}numplan_callbacks.eachline = true;numplan_callbacks.includecats = true;function refreshtable(){	var crt = _$('callingRulesTable') ;	for( var i=0; i <  crt.rows.length; ){ crt.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;}					if(didtrunks[i][j].action){						if(j.substring(0,1) == "+") {continue;}					addrowtotable( j, i, didtrunks[i][j].action, didtrunks[i][j].priority);					}				}			}		}	}	if( crt.rows.length == 0){		_$('table_one').style.display="none";		var newRow = crt.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 an 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 crt = _$('callingRulesTable') ;	var sno = crt.rows.length + 1;	var newRow = crt.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 x;	var y = _$('toextension');	y.selectedIndex = -1 ;	for(var t=0; t < y.length ; t++ ){		if( y.options[t].value == c ){			x = y.options[t].text;			break;		}	}	if( a == "_X." || a == "_+X."){ // handling all unmatched 		return " Route all unmatched incoming calls from provider '" + didtrunks[b].trunkname + "' to '" + x + "'" ; 	}	return " Route incoming calls from provider '" + didtrunks[b].trunkname + "' that match pattern '" + a + "' to '" + x + "'"  ; }function add_incomingrule(){	editstatus = "NEW";	old_incomingrule = "allunmatched";	old_fromprovider = "";	_$('incomingrule').selectedIndex = 0;	_$('fromprovider').selectedIndex = -1;	_$('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." || 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";	}	var q = _$('fromprovider') ;	for(var i=0; i < q.length ; i++){		if(q.options[i].value == b){			q.selectedIndex = i;					old_fromprovider = b;			break;		}	}	var y = _$('toextension');	y.selectedIndex = -1 ;	for(var t=0; t < y.length ; t++ ){		if( y.options[t].value == c ){			y.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	var fp = _$('frompattern') ;	var fpv = _$('fromprovider') ;	var ir = _$('incomingrule').value ;	var te = _$('toextension') ;	if( fpv.selectedIndex == -1 ){		gui_feedback("Please select a service provider !");		fpv.focus();		return false;	}	if( didtrunks[_$('fromprovider').value].isanalog =='yes' && ir != 'allunmatched' ){		gui_feedback("You can not define a custom pattern for Analog trunks!");		_$('incomingrule').focus();		return false;	}	if( ir == "frompattern" && fp.value == "" ){		gui_feedback("Please define an incoming call pattern !");		fp.focus();		fp.select();		return false;	}	if( te.selectedIndex == -1 ){		gui_feedback("Please select an extension to which<BR> an incoming call should be routed to !");		te.focus();		return false;	}	if(ir == "frompattern" && fp.value.substr(0,1) != "_" ){ fp.value = "_" + fp.value ; }	var provname = didtrunks[_$('fromprovider').value].provname ;	// create an entry under the selected trunk	// $('incomingrule') == "allunmatched" or "frompattern" , $('frompattern'), $('fromprovider'), $('toextension')	

⌨️ 快捷键说明

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