📄 incoming.html
字号:
<!--
* 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/rico.js"></script>
<script src="scripts/astman.js"></script>
<script src="scripts/tooltip.js"></script>
<link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
<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 listOfExtensions = [] ; // to store all the list of extensions to be displayed in the select menu
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 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 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(' -- ');
//$('toextension').innerHTML = $('toextension').innerHTML + "<option value='" + b[0] + "'>" + listOfExtensions[a] + "</option>";
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();
parent.loadscreen(this);
}
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;}
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 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 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> <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 '" + didtrunks[b].trunkname + "' to extension '" + exten[1] + "'" ;
}
return " Route incoming calls from provider '" + didtrunks[b].trunkname + "' that macth pattern '" + a + "' to extension '" + exten[1] + "'" ;
}
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."){
_$('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;
}
}
if( c.match("Goto") && !c.match("voicemenu-") ){
var tmp = c.split('(');
var exten = tmp[1].split('|'); // extension is exten[1]
var y = _$('toextension');
y.selectedIndex = -1 ;
for(var t=0; t < y.length ; t++ ){
if( y.options[t].value == exten[1] ){
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( ir == "frompattern" && fp.value == "" ){
gui_feedback("Please define an incoming call pattern !");
fp.focus();
fp.select();
return false;
}
if( fpv.selectedIndex == -1 ){
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -