📄 numberplan.html
字号:
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) {
_$('status_message').style.display="none";
delete numberplansdata[ _extv ]['npdata'][a][b] ;
oncomplete();
},
onFailure: function(t) {
gui_alert("Config Error: " + t.status + ": " + t.statusText);
}
};
opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
_$('userscontent').style.display = "none";
_$('bg_transparent').style.display = "none";
_$('status_message').style.display = "";
var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
}
function editcallingrule(a,b){ // a is pattern, b is priority
pattern_beingedited = a ;
pattern_beingedited_priority = b ;
//oldselect = $('trunks').value;
isnewrule = false ;
var _trunks = _$('trunks') ;
var m = numberplansdata[_$('extensions').value]['npdata'];
_$('rulename').value = m[a][b].rulename;
_trunks.selectedIndex = -1 ;
for(var i=0; i < _trunks.length ; i++ ){
if( _trunks.options[i].value == m[a][b].trunk ){
_trunks.selectedIndex = i ;
break;
}
}
_$('pattern').value = a;
_$('strip').value = m[a][b].digits2strip;
_$('prepend').value = m[a][b].prepend;
_$('save_a').disabled = 1;
if( m[a][b].ruledesc == 'custom' || !m[a][b].ruledesc ){
// if this is a custom pattern then donot try to parse the pattern
iscustom = true;
_$('rulename').value = (m[a][b].rulename) ? m[a][b].rulename : "";
m[a][b].ruledesc = 'custom' ;
_$('define_advanced').style.display="";
_$('define_usual').style.display="none";
}else{
// if this is standard pattern then parse the pattern into 'beginswith', 'followedby'
var temp = parsepattern(a,1);
iscustom = false;
_$('define_advanced').style.display="none";
_$('define_usual').style.display="";
}
_$('userscontent').style.display="";
_$('bg_transparent').style.display ='';
_$('addrule').disabled =1;
}
function ruleinanpdata(a,b,c){
this.trunk = a ;
this.digits2strip = b;
this.prepend = c;
}
function numberplan_context(){
this.plancomment = "";
this.nprules = [ ];
this.npcomments = [ ];
this.npdata = { };
}
numplan_callbacks.format = function(t, x) {
if ((t.name.substr(0,11) != 'numberplan-'))
return null;
if( x == undefined ){ // is a new number plan
numberplansdata[t.name] = new numberplan_context ;
try{
return t.fieldbyname['plancomment'] ;
}catch(err){
return t.name;
}
}else if( t.names[x]=='plancomment' ){
numberplansdata[t.name]['plancomment'] = t.fields[x] ;
}else if( t.names[x]=='exten' ){
numberplansdata[t.name]['nprules'].push( t.fields[x] ) ;
}else if( t.names[x]=='comment' ){
var tmp = t.fields[x].split(",");
if( tmp.length > 1 ){
numberplansdata[t.name]['npcomments'].push( t.fields[x] ) ;
}
}
return null;
}
numplan_callbacks.loaded = function() {
var _extns = _$('extensions') ;
add_event( _extns , 'change', select_differentplan );
if( _extns.options.length ==0 ){
parent.loadscreen(this);
addthe_default_callingplan();
}else{
_extns.selectedIndex = 0;
_extns.selectitem(0);
parse_nprulesAndnpcomments();
show_npdata_table(_extns.options[0].value);
parent.loadscreen(this);
}
}
numplan_callbacks.newcategory = function() {
var _extns = _$('extensions') ;
np_oldselect = _extns.selectedIndex ;
_$('include').value = "default";
var c = 1 ;
for(var u =0 ; u < _extns.length ; u++ ){
var tmp = _extns.options[u].value.split("-") ;
if( c < tmp[2] ){ break; }
c++ ;
}
gen = _extns.stored_config.catbyname[_extns.value];
temp = objcopy(gen);
temp.name = "numberplan-custom-" + c ;
temp.fieldbyname['plancomment'] = "DialPlan" + c;
_$('plancomment').value = "DialPlan" + c;
return temp;
}
numplan_callbacks.cancelnewcategory = function(){
var _extns = _$('extensions') ;
_extns.selectedIndex = np_oldselect;
_extns.selectitem(np_oldselect);
_$('npcontent').style.display="none";
_$('bg_transparent').style.display ='none';
}
numplan_callbacks.savechanges = function(){
_$('npcontent').style.display="none";
_$('bg_transparent').style.display ='none';
show_npdata_table( _$('extensions').value );
}
numplan_callbacks.delchanges = function(box, value) {
var _extns = _$('extensions') ;
if( _extns.options.length ==0 ){
addthe_default_callingplan();
}else{
_extns.selectedIndex = 0;
_extns.selectitem(0);
show_npdata_table( _extns.options[0].value );
}
}
numplan_callbacks.eachline = true;
numplan_callbacks.includecats = true;
function localajaxinit(){
showdiv_statusmessage();
setWindowTitle("Calling Rules");
for (var x =0; x < fieldnames.length; x++ ) {
widgets[fieldnames[x]] = _$(fieldnames[x]);
widgets[fieldnames[x]].disabled = true;
}
_$('message_text').innerHTML ="Saving Changes...";
config2json('users.conf', 1, trunks_loaded ) ;
//parent.astmanEngine.config2list("users.conf", $('trunks'), new Array(), trunkcallbacks);
add_event( _$('followedby'), 'change', disable_ormore );
add_event( _$('followedby'), 'keyup', disable_ormore );
}
function disable_ormore(){
if( !parseInt(_$('followedby').value ,10)){
_$('ormore').checked = false;
_$('ormore').disabled = true;
}else{
_$('ormore').disabled = false;
}
}
function trunks_loaded(b){
var c = eval('(' + b + ')');
for( var d in c ){
if ( c.hasOwnProperty(d) && c[d]['context'] && (c[d]['context'] == asterisk_guiTDPrefix + d ) ) {
trunks_desc[d] = new Object();
trunks_desc[d].comment = (c[d]['trunkname']) ? unescape(c[d]['trunkname']) : d ;
var New_OPTION = document.createElement('option');
New_OPTION.text = unescape(trunks_desc[d].comment) ;
New_OPTION.value =d ;
try {
_$('trunks').add(New_OPTION, null); // W3C way
}catch(ex) {
_$('trunks').add(New_OPTION); // IE way
}
}
}
parent.astmanEngine.config2list("extensions.conf", _$('extensions'), widgets , numplan_callbacks);
}
function select_differentplan(){
var _extns = _$('extensions').value ;
if(typeof numberplansdata[_extns] == "undefined"){
numberplansdata[_extns] = new numberplan_context ;
numberplansdata[_extns].plancomment = $("plancomment").value;
}
show_npdata_table(_extns);
}
function newnumberplan(){
_$('npcontent').style.display="";
_$('bg_transparent').style.display ='';
_$('new').click();
}
function delete_numberplan(){ _$('delete').click(); }
function addthe_default_callingplan(a){
if(!a){
_$('message_text').innerHTML = "A default DialPlan is not found !! "
+ "<BR><BR> <A href=\"#\" class=\"splbutton\" onclick=\"addthe_default_callingplan(1)\">click here</A> to create a default DialPlan";
var _bg_s = _$('bg_transparent').style ;
var _sm_s = _$('status_message').style ;
_sm_s.left = 120 ;
_sm_s.zIndex = _bg_s.zIndex + 1;
_bg_s.display = '' ;
_sm_s.display = "" ;
return true;
}
var default_planname = 'numberplan-custom-1' ;
var uri = build_action('newcat', 0, default_planname ,"", "");
uri += build_action('append', 1, default_planname,"plancomment", "DialPlan1");
uri += build_action('append', 2, default_planname,"include", "default");
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) { location.reload(); },
onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); }
};
opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
}
function free_mem( ){
if( navigator.userAgent.indexOf("MSIE") == -1 ){ return true; }
try{
widgets['save'].hostselectbox = null ;
widgets['cancel'].hostselectbox = null ;
widgets['new'].hostselectbox = null ;
widgets['delete'].hostselectbox = null ;
purge( document.body );
}catch(e){ }
}
</script>
<body id="foo" onload="localajaxinit()" bgcolor="EFEFEF" onunload="free_mem()">
<div class="mainscreenTitleBar">
<span style="margin-left: 4px;font-weight:bold;">Calling Rules</span>
<span style="cursor: pointer; cursor: hand;" onclick="window.location.href=window.location.href;" > <img src="images/refresh.png" title=" Refresh " border=0 > </span>
</div>
<div class="mainscreenContentBox" id="mailboxcontent">
<center>
<fieldset style="width: 500px" id="fieldset1">
<legend> List of DialPlans: </legend>
<CENTER><select id="extensions" class="input9" style="z-index:2"></select>
<a href="#" class="splbutton" onclick="newnumberplan()" onmouseover="show_tooltip('en', 'callingrules', 0);">new</a>
<a href="#" class="splbutton" onclick="delete_numberplan()" onmouseover="show_tooltip('en', 'callingrules', 1);">delete</a>
<input id='new' value='New' type="button" style="display:none">
<input id='delete' value='Delete' type="button" style="display:none">
</CENTER>
</fieldset>
</center>
<BR>
<div id="npcontent" STYLE="display:none; position: absolute; left: 110; top: 40; width:320; height:110; background-color:#F4EFE5; border-width: 1px; border-color: #7E5538; border-style: solid; z-index:6">
<table width="100%" cellpadding=0 cellspacing=0 onmousedown="startDrag(event , 'npcontent');">
<TR bgcolor="#7E5538" style="background-image:url('images/title_gradient.gif');">
<TD Height="20" align="center" style="cursor: move">
<font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">Create new Dial Plan </font>
</TD>
<TD Height="20" align="right" style="cursor: move">
<A href="#" onclick="$('cancel').click();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
</TD>
<TD width=4></TD>
</TR>
</table>
<TABLE cellpadding=0 cellspacing=3 border=0 width="100%">
<TR> <TD colspan=2 height=10></TD> </TR>
<TR> <TD align="right">DialPlan Name:</TD>
<TD><input id="name" style="display:none"><input id="plancomment" size=15 class="input9"><input id="include" style="display:none"></TD>
</TR>
<TR> <TD colspan=2 height=10></TD> </TR>
<TR> <TD align="center" colspan=2>
<input id='save' value='Save' type="button">
<input id='cancel' value='Cancel' type="button">
</TD>
</TR>
</TABLE>
</div>
<center>
<fieldset style="height: 390px; " id="fieldset2">
<legend> List of Calling Rules in the selected DialPlan </legend>
<table class="table_blacksm" cellpadding=2 cellspacing=2 border=0 align=center width=500 id="table_one">
<tr> <td width=35>S.No</td>
<td width=90>RuleName</td>
<td>Dial Pattern</td>
<td width=85 align=center>Call Using</td>
<td width=75 align=center>Options</td>
</tr>
</table>
<div id="callingRulesTable_div" style="height:260px;width=100%; overflow :auto; padding : 0px 0px 0px 0px;">
<table id="callingRulesTable" cellpadding=2 cellspacing=1 border=0 align=center width=500></table>
</div>
<BR>
<div STYLE="position: absolute; left:186; top: 460;">
<input type="button" id="addrule" value="Add a Calling Rule" onclick="add_callingrule();" onmouseover="show_tooltip('en', 'callingrules', 4);">
</div>
</fieldset>
</center>
<div id="userscontent" STYLE="display:none; position: absolute; left: 20; top: 144; width:500; height:290; background-color:#F4EFE5; border-width: 1px; border-color: #7E5538; border-style: solid; z-index:5">
<table width="100%" cellpadding=0 cellspacing=0 onmousedown="startDrag(event , 'userscontent');">
<TR bgcolor="#7E5538" style="background-image:url('images/title_gradient.gif');">
<TD Height="20" align="right" style="cursor: move">
<A href="#" onclick="$('cancel_a').click();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
</TD>
<TD width=4></TD>
</TR>
</table>
<TABLE align=center cellpadding=2 cellspacing=2 border=0 width="480">
<TR onmouseover="show_tooltip('en', 'callingrules', 5);">
<TD align="right" width=175>Rule Name:</TD>
<TD><input type="text" id="rulename" size="" onChange="enablesave();" onkeyup="enablesave();" class="input9"></TD>
</TR>
<TR onmouseover="show_tooltip('en', 'callingrules', 6);">
<TD align="right" height=40> Place this call through :</TD>
<TD><select id="trunks" class="input9" onChange="enablesave();"></select></TD>
</TR>
<TR id="define_usual" height=100 onmouseover="show_tooltip('en', 'callingrules', 7);">
<TD valign="top" align=right>Dialing Rules :</TD>
<TD valign="top"> If the number begins with <input id="beginswith" class="input9" type='text' size=6 onChange="enablesave();" onkeyup="enablesave();"> and
followed by <input id="followedby" type='text' class="input9" size=1 onChange="enablesave();" onkeyup="enablesave();"> digits <input type="checkbox" id="ormore" onChange="enablesave();"> or more <BR>
<A href="#" onclick="ownpattern();">(define a custom pattern)</A>
</TD>
</TR>
<TR id="define_advanced" height=100 onmouseover="show_tooltip('en', 'callingrules', 8);">
<TD valign="top" align=right> Custom Pattern: </TD>
<TD valign=top>
<input type="text" id="pattern" size="" onChange="enablesave();" onkeyup="enablesave();" class="input9"><BR>
<A href="#" onclick="basicpattern();">(define a Basic Pattern)</A><BR>
<table align='left' cellpadding=0 cellspacing=0>
<tr> <td class="field_text"><b>N </b></td>
<td class="field_text">Any digit from 2 to 9</td>
</tr>
<tr> <td class="field_text"><b>X </b></td>
<td class="field_text">Any digit from 0 to 9</td>
</tr>
<tr> <td class="field_text"><b>. </b></td>
<td class="field_text">Any number of additional digits</td>
</tr>
</table>
</TD>
</TR>
<TR onmouseover="show_tooltip('en', 'callingrules', 9);">
<TD colspan=2 align=center>
Strip <input type="text" id="strip" class="input9" size="1" onChange="enablesave();" onkeyup="enablesave();">
digits from the front and prepend <input type="text" id="prepend" class="input9" size="3" onChange="enablesave();" onkeyup="enablesave();"> before dialing
</TD>
</TR>
<TR> <TD colspan=2 align=center height=50 valign=middle>
<input type="button" id="save_a" value="Save" onclick="saverule();">
<input type="button" id="cancel_a" value="Cancel" onclick="$('userscontent').style.display='none'; $('bg_transparent').style.display ='none'; $('addrule').disabled =0;">
</TD>
</TR>
</TABLE>
</div>
</div>
<div id="bg_transparent" STYLE="display:none; position: absolute; left: 0; top: 24; width:100%; height:100%; background-color:#EFEFEF; -moz-opacity:.50;opacity:.50; border-width: 1px; border-color: #EFEFEF; border-style: solid; z-index:4">
</div>
</body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -