📄 5.html
字号:
<!--
* Asterisk-GUI - an Asterisk configuration interface
*
* Setup WIzard/ Dialing 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.
*
-->
<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 trunks_desc = new Object;
var trunkcallbacks = new Object;
var numplan_callbacks = new Object;
var default_numberplan = 0;
var default_np_rules = new Array;
var default_np_comments = new Array;
var default_np_data = new Object;
var isnewrule ;
var iscustom ;
var pattern_beingedited ;
var pattern_beingedited_priority ;
var oldselect;
function localinit(){
showdiv_statusmessage();
//parent.$('next').disabled = true;
parent._$('next').onclick = function(){ window.location.href="6.html"; };
parent._$('back').disabled = false;
parent._$('back').onclick = function(){ window.location.href="4.html"; };
rawman_url = parent.rawman_url ;
parent.astmanEngine.setURL(rawman_url);
ping();
}
function ping(){
var opt = {
method: 'get',
asynchronous: true,
onComplete: isloggedin
};
opt.parameters="action=ping" ;
var tmp = new Ajax.Request(rawman_url , opt);
}
function isloggedin(originalRequest){
if ( originalRequest.responseText.match("Error") ) {
// User is not logged in , show him the login screen
parent.window.location.href = parent.window.location.href ;
}
if ( originalRequest.responseText.match("Pong") ) {
_$('message_text').innerHTML ="Saving Changes...";
parent.astmanEngine.config2list("users.conf", _$('trunks'), new Object(), trunkcallbacks);
}
}
function addthe_default_callingplan(){
t=confirm("A default Dial Plan is not found. \n" + " Do you want to create a default Dial Plan ");
if(t == false){
_$('status').innerHTML = "A default DialPlan is not found !! "
+ "<BR> <A href=\"#\" onclick=\"addthe_default_callingplan()\">click here</A> to create a default Dial plan";
_$('addrule').disabled = 1;
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) {
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(rawman_url, opt);
}
trunkcallbacks.format = function(t) {
if ( t.fieldbyname['context'] != asterisk_guiTDPrefix + t.name ) {
return null;
}
if (t.fieldbyname['trunkname'] && t.fieldbyname['trunkname'].length) {
trunks_desc[t.name] = new Object();
trunks_desc[t.name].comment = t.fieldbyname['trunkname'] ;
return t.fieldbyname['trunkname'];
} else{
trunks_desc[t.name] = new Object();
trunks_desc[t.name].comment = t.name ;
return t.name;
}
}
trunkcallbacks.loaded = function(){
_$('trunks').addEventListener('click',hackenablesave,false);
parent.astmanEngine.config2list("extensions.conf", _$('extensions'), new Object(), numplan_callbacks);
}
function hackenablesave(){
if( oldselect != _$('trunks').value ){
enablesave();
}
}
numplan_callbacks.format = function(t, x) {
var exten_fields;
if(t.name == "numberplan-custom-1" && x == undefined ){
default_numberplan = 1;
}else if(t.name == "numberplan-custom-1" && t.names[x]=='exten' ){
default_np_rules.push( t.fields[x] );
}else if(t.name == "numberplan-custom-1" && t.names[x]=='comment' ){
var tmp = t.fields[x].split(",");
if( tmp.length > 1 ){
default_np_comments.push( t.fields[x] );
}
}
return false;
}
numplan_callbacks.loaded = function() {
parent.astmanEngine.pollEvents();
if(!default_numberplan){
// Redirect To creating a default Number Plan
addthe_default_callingplan();
return true;
}
for( var i=0; i < default_np_rules.length; i++){
var temp = default_np_rules[i].split(","); // temp[0] is the pattern, temp[1] is the priority,temp[2] is 'Macro(trunkdial', temp[3] is ${trunkname}/${EXTEN:1})
var temp1 = temp[3].split("{");
var temp2 = temp1[1].split("}");
var temp3 = temp1[2].split("}");
var temp4 = temp3[0].split(":");
temp[4] = temp2[0] ; // temp[4] is trunkname
temp[5] = temp4[1] ; // temp[5] is the #digits to strip in the front
if ( typeof default_np_data[temp[0]] == 'undefined' ) {
default_np_data[temp[0]] = new Object();
}
default_np_data[temp[0]][temp[1]] = new Object();
default_np_data[temp[0]][temp[1]].trunk = temp[4] ;
default_np_data[temp[0]][temp[1]].digits2strip = temp[5] ;
}
for ( var i =0; i < default_np_comments.length ; i++){
var temp = default_np_comments[i].split(",");
default_np_data[temp[0]][temp[1]].rulename = temp[2] ;
if(temp[3] !="custom"){
default_np_data[temp[0]][temp[1]].ruledesc = parsepattern(temp[0],0) ;
}else{
default_np_data[temp[0]][temp[1]].ruledesc = "custom" ;
}
}
// now show this object in a table.
for( var x in default_np_data ){ // x is the pattern
// sort the priorities
if( !default_np_data.hasOwnProperty(x) ){ continue; }
var sorted_priorities = [];
for ( var y in default_np_data[x] ){
if( default_np_data[x].hasOwnProperty(y) ){
sorted_priorities.push(y);
}
}
sorted_priorities.sort();
// done sorting priorities
// show fields in a table in the order of sorted priorities
for( var z=0; z < sorted_priorities.length ; z++ ){
//check if the trunk defined is actually an existing trunk
var trunk_exists = 0;
for(var i=0; i < _$('trunks').length ; i++ ){
if( _$('trunks').options[i].value == default_np_data[x][sorted_priorities[z]].trunk ){
trunk_exists = 1;
break;
}
}
if ( default_np_data[x][sorted_priorities[z]].trunk == "" ){
_$('trunks').selectedIndex = -1;
addrowtotable( x , sorted_priorities[z] , "undefined" , default_np_data[x][sorted_priorities[z]].digits2strip );
}else if(trunk_exists == 0){
_$('trunks').selectedIndex = -1;
addrowtotable( x , sorted_priorities[z] , "invalid" , default_np_data[x][sorted_priorities[z]].digits2strip );
}else{
addrowtotable( x , sorted_priorities[z] , default_np_data[x][sorted_priorities[z]].trunk , default_np_data[x][sorted_priorities[z]].digits2strip );
}
}
}
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>A <I>Calling Rule</I> is not defined<BR><BR> Please click on the 'Add a Calling Rule' button<BR> to add a Calling Rule<BR><BR>" ;
return true;
}
}
numplan_callbacks.eachline = true;
numplan_callbacks.includecats = true;
function addrowtotable(a,b,c,d){ // a is pattern, b is priority, c is trunk, d is digits2strip
var sno = _$('callingRulesTable').rows.length + 1;
var newRow = _$('callingRulesTable').insertRow(-1);
newRow.id = "row" + sno;
var newCell0 = newRow.insertCell(0);
newCell0.innerHTML = sno ;
newCell0.width=35;
newCell0.align="center";
var newCell1 = newRow.insertCell(1);
newCell1.innerHTML = default_np_data[a][b].rulename ;
newCell1.width=90;
var newCell2 = newRow.insertCell(2);
newCell2.innerHTML = default_np_data[a][b].ruledesc ;
if(c == "invalid" || c== "undefined" ){
var newCell3 = newRow.insertCell(3);
newCell3.innerHTML = "<B><font color=red>invalid trunk</font></B>" ;
newCell3.width=85;
}else{
var newCell3 = newRow.insertCell(3);
newCell3.innerHTML = trunks_desc[c].comment ;
newCell3.width=85;
}
var newCell4 = newRow.insertCell(4);
newCell4.innerHTML = "<A href=\"#\" onclick=\"editcallingrule('"+ a +"', '"+ b +"')\">Edit</A> <A href=\"#\" onclick=\"deletecallingrule('"+ a +"', '"+ b +"')\">Delete</A>";
newCell4.width=75;
newCell4.align="center";
return true;
}
function deletecallingrule(a,b){
t=confirm("Are you sure ?")
if(t == false){ return true; }
delete_callingrule(a,b, oncomplete = function(){location.reload();} ) ;
}
function delete_callingrule(a,b,oncomplete){
var commentstring = (default_np_data[a][b].ruledesc == 'custom')?"custom":"standard" ;
var rule_string = a + ',' + b + ',Macro(trunkdial,${' + default_np_data[a][b].trunk + '}/${EXTEN:' + default_np_data[a][b].digits2strip + '})' ;
var uri = build_action('delete', 0, "numberplan-custom-1" ,"exten", "", rule_string );
commentstring = a + ',' + b + ',' + default_np_data[a][b].rulename + ',' + commentstring ;
uri += build_action('delete', 1 , "numberplan-custom-1" ,"comment","", commentstring );
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) { oncomplete(); },
onFailure: function(t) {
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(rawman_url, opt);
}
function editcallingrule(a,b){
pattern_beingedited = a ;
pattern_beingedited_priority = b ;
oldselect = _$('trunks').value;
isnewrule = false;
_$('rulename').value = default_np_data[a][b].rulename;
_$('trunks').selectedIndex = -1 ;
for(var i=0; i < _$('trunks').length ; i++ ){
if( _$('trunks').options[i].value == default_np_data[a][b].trunk ){
_$('trunks').selectedIndex = i ;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -