📄 menus.html
字号:
<!--
* Asterisk-GUI - an Asterisk configuration interface
*
* Create/Manage IVR Menus
*
* 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 widgets = {};
var adstatus;
var menuscallbacks = new Object;
var extencallbacks = new Object;
var usercallbacks = new Object;
var numcallbacks = new Object;
var fieldnames = new Array('delete', 'new','save','cancel');
var voicemenusdata = new Object;
var current_context;
var keys = new Array('0','1','2','3','4','5','6','7','8','9','*','#','t','i');
var extensions_array = new Array;
var answer_call_string = "s,1,Answer";
var localextenlength ;
function format_step(this_step){
var temp = this_step.split(',');
if( temp[2].match("Answer") )
return "Answer the Call";
if( temp[2].match("Authenticate") ){
// Background('') - whatever in the brackets
temp[2] = temp[2].replace(/Authenticate\(/, "");
temp[2] = temp[2].replace(/\)/, "");
return "Authenticate for Password '" + temp[2] + "'";
}
if( temp[2].match("Background") ){
// Background('') - whatever in the brackets
temp[2] = temp[2].replace(/Background\(/, "");
temp[2] = temp[2].replace(/\)/, "");
return "Play '" + temp[2] + "' & Listen for KeyPress";
}
if( temp[2].match("DigitTimeout") ){
temp[2] = temp[2].replace(/Set\(TIMEOUT\(digit\)\=/, "");
temp[2] = temp[2].replace(/\)/, "");
return "Wait '"+ temp[2] +"' sec for KeyPress";
}
if( temp[2].match("TIMEOUT") ){
temp[2] = temp[2].replace(/Set\(TIMEOUT\(response\)\=/, "");
temp[2] = temp[2].replace(/\)/, "");
return "Response Timeout to '" + temp[2] + "' sec";
}
if( temp[2].match("Playback") ){
temp[2] = temp[2].replace(/Playback\(/, "");
temp[2] = temp[2].replace(/\)/, "");
return "Play '" + temp[2] + "' & Donot Listen for KeyPress";
}
if( temp[2].match("WaitExten") ){
temp[2] = temp[2].replace(/WaitExten\(/, "");
temp[2] = temp[2].replace(/\)/, "");
return "WaitExten '"+ temp[2] + "' sec";
}else if( temp[2].match("Wait") ){
temp[2] = temp[2].replace(/Wait\(/, "");
temp[2] = temp[2].replace(/\)/, "");
return "Wait '"+ temp[2] + "' sec";
}
if( temp[2].match("Goto") && temp[2].match("voicemenu-") ){
var tmp = temp[2].split('(');
var tmp1 = tmp[1].split('|');
try{
return "Goto Menu '"+ voicemenusdata[tmp1[0]].comment + "'";
}
catch(e){
return "Goto Menu '"+ tmp1[0] + "'";
}
}
if( temp[2].match("Goto") && !temp[2].match("voicemenu-") ){
var tmp = temp[2].split('(');
var tmp1 = tmp[1].split('|');
return "Goto Exten '"+ tmp1[1] + "'";
}
if( temp[2].match("Hangup") )
return "Hangup";
return this_step;
}
function load_extensions(my_field_options){
var _mo = _$(my_field_options);
_mo.options.length=0;
for(var x=0; x < extensions_array.length; x++){
var newoption = document.createElement("option");
newoption.text = extensions_array[x] ;
newoption.value = extensions_array[x] ;
_mo.options.add(newoption);
}
}
function load_menus(my_field_options){
var _mo = _$(my_field_options) ;
var _vms = _$('vmenus') ;
_mo.options.length=0;
for(var x=0; x < _vms.length; x++){
if( _vms.options[x].text == "New Entry" ){ continue ; }
var newoption = document.createElement("option");
newoption.text = voicemenusdata[ _vms.options[x].value].comment ;
newoption.value = _vms.options[x].value ;
_mo.options.add(newoption);
}
}
function select_menu (my_field_options, menustring, a){
var tmp = menustring.split('(');
var tmp1 = tmp[1].split('|');
var _mfo = _$(my_field_options) ;
if(a == "ismenu"){
var check_against = tmp1[0];
}else if(a == "isext"){
var check_against = tmp1[1] ;
}
for(var y=0; y < _mfo.options.length; y++ ){
if( _mfo.options[y].value == check_against ){
_mfo.options[y].selected = true;
return true;
}
}
// if not in the current list of voicemenus/extensions then add it to the menu
var newoption = document.createElement("option");
newoption.text = check_against ;
newoption.value = check_against ;
_mfo.options.add(newoption);
_mfo.options[y].style.fontWeight = 'bold';
_mfo.options[y].selected = true;
_mfo.style.color = '#CC0000';
}
function add_newvmenu_tolistofkeymenus(){
var _vms = _$('vmenus') ;
var _vmsv = _vms.options[_vms.selectedIndex].value ;
var _cv = _$('comment').value ;
for (var k=0; k< keys.length; k++){
var current_key_menus='keypress_'+ keys[k] + '_menus';
var newoption = document.createElement("option");
newoption.text = _cv ;
newoption.value = _vmsv ;
_$(current_key_menus).options.add(newoption);
}
// and also add it to $('add_newstep_menus')
var newoption = document.createElement("option");
newoption.text = _cv ;
newoption.value = _vmsv ;
_$('add_newstep_menus').options.add(newoption);
}
function delete_vmenu_fromlistofmenus(){
var _cv = _$('comment').value ;
for (var k=0; k< keys.length; k++){
var current_key_menus='keypress_'+ keys[k] + '_menus';
var _ckm = _$(current_key_menus);
for(var i=0; i< _ckm.options.length; i++){
if( _ckm.options[i].text == _cv ){
// delete this option from the $(current_key_menus)
var deleted_voicmenu = _ckm.options[i].value ;
_ckm.remove(i);
break;
}
}
}
var _anm = _$('add_newstep_menus') ;
for(var i=0; i< _anm.options.length; i++){
if( _anm.options[i].text == _cv ){
_anm.remove(i);
break;
}
}
// use the deleted_voicmenu to delete the alias (if it exists) in the default
if(_$('alias_exten').value.length > 0){
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) {
delete voicemenusdata[deleted_voicmenu];
},
onFailure: function(t) {
gui_alert("Config Error: " + t.status + ": " + t.statusText);
}
};
var existing_alias_string = voicemenusdata[deleted_voicmenu].alias_exten + ",1,Goto(" + deleted_voicmenu + "|s|1)" ;
var uri = build_action('delete', 0, specialcontext ,"exten", "", existing_alias_string );
opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
var tmp = new Ajax.Request(asterisk_rawmanPath, opt);
}
delete voicemenusdata[deleted_voicmenu];
}
function change_vmenuname_inlistofmenus(oldname,newname){
for (var k=0; k< keys.length; k++){
var current_key_menus='keypress_'+ keys[k] + '_menus';
var _ckm = _$(current_key_menus) ;
for(var i=0; i< _ckm.options.length; i++){
if( _ckm.options[i].text == oldname ){
_ckm.options[i].text = newname;
break;
}
}
}
}
function key_action(a, field){
enable_savecancel();
_mft = _$('keypress_'+ field + '_text' );
_mfe = _$('keypress_'+ field + '_exts').style;
_mfm = _$('keypress_'+ field + '_menus').style
_mft.style.display = "none";
_mfe.display = "none";
_mfm.display = "none";
if(a=='gotomenu'){ //show menus dropdown
_mfm.display = "";
}else if(a=='gotoextension'){ //show extensions dropdown
_mfe.display = "";
}else if(a=='Custom'){ //show a text box
_mft.style.display = "";
_mft.focus();
}else if(a=='disabled' || a=='Hangup' || a=='PlayInvalid'){ //show nothing
}
}
function sortNumber(a,b){
return a - b ;
}
function add_newstep(){
var _vmv = _$('vmenus').value ;
var _nsa = _$('newstep_action');
var _nsv = _$('newstep_var') ;
if( !_nsa.value ){
gui_alert("Please select an action for this step");
_nsa.focus();
return;
}
if( _nsa.value != "Answer" && _nsa.value != "Hangup" && !_nsv .value ){
gui_alert("Please enter a value for '" + _nsa.value +"'");
_nsv.focus();
return;
}
_$('status_message').style.display = "";
// prepare a request to add the new step to the voicemenu
// make a request to append
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function() {
setTimeout(function(){ _$('status_message').style.display = 'none'; },sc_displaytime);
// if request successfull then add this to the steps select box
var newoption = document.createElement("option");
newoption.text = format_step(action_string );
newoption.value = action_string ;
var _steps = _$('steps') ;
_steps.options.add ( newoption );
// and also add the information to the voicemenus data
if(voicemenusdata[_vmv].extensions['s']){
voicemenusdata[_vmv].extensions['s'].push(action_string);
}else{
voicemenusdata[_vmv].extensions['s'] = new Array;
voicemenusdata[_vmv].extensions['s'][0] = action_string;
}
// empty this textbox & disable this button, select the newly added item to the steps options box
_nsa.selectedIndex = 0;
_$('deletestep').disabled = false;
_steps.selectedIndex = _steps.length - 1 ;
gui_feedback('New step added !','blue');
update_updown();
_nsv.value = "";
_nsv.style.display = "none" ;
_$('add_newstep_extensions').style.display = "none";
_$('add_newstep_menus').style.display = "none";
_$('combodiv_sounds').style.display = "none" ;
_nsvd = _$('newstep_var_digit');
_nsvd.value= "";
_nsvd.style.display= "none" ;
},
onFailure: function(t) {
_$('status_message').style.display = 'none';
gui_alert("Config Error: " + t.status + ": " + t.statusText);
}
};
var uri = "";
var action_string = "";
var priorities = new Array;
// algorithm 4 calculate new priority
if(voicemenusdata[_vmv].extensions['s'] && voicemenusdata[_vmv].extensions['s'].length > 0 ){
for( var p=0; p < voicemenusdata[_vmv].extensions['s'].length; p ++){
var temp = voicemenusdata[_vmv].extensions['s'][p].split(',');
priorities.push(temp[1]);
}
priorities = priorities.sort(sortNumber);
newpriority = parseInt(priorities[priorities.length - 1]) + 1;
}else{
newpriority = 1;
}
switch ( _nsa.value ){
case 'Answer':
action_string = "s,"+ newpriority+ ",Answer";
break;
case 'Authenticate':
action_string = "s,"+ newpriority+ ",Authenticate(" + _nsv.value + ")";
break;
case 'Background':
action_string = "s,"+ newpriority+ ",Background(" + _nsv.value + ")";
break;
case 'DigitTimeout':
action_string = "s,"+ newpriority+ ",Set(TIMEOUT(digit)=" + _nsv.value + ")";
break;
case 'ResponseTimeout':
action_string = "s,"+ newpriority+ ",Set(TIMEOUT(response)=" + _nsv.value + ")";
break;
case 'Playback':
action_string = "s,"+ newpriority+ ",Playback(" + _nsv.value + ")";
break;
case 'Wait':
action_string = "s,"+ newpriority+ ",Wait(" + _nsv.value + ")";
break;
case 'WaitExten':
action_string = "s,"+ newpriority+ ",WaitExten(" + _nsv.value + ")";
break;
case 'GotoMenu':
action_string = "s,"+ newpriority+ ",Goto(" + _nsv.value + "|s|1)";
break;
case 'GotoExtension':
action_string = "s,"+ newpriority+ ",Goto(default|" + _nsv.value + "|1)";
break;
case 'Hangup':
action_string = "s,"+ newpriority+ ",Hangup";
break;
default :
action_string = "s,undefined,undefined";
}
uri += build_action('append', 0, _vmv,"exten", action_string );
opt.parameters="action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
tmp = new Ajax.Request(asterisk_rawmanPath, opt);
}
function next_freevmenu(){ // return the next smallest available voicemenu name
var x=1;
while(typeof voicemenusdata['voicemenu-custom-'+x] != 'undefined' ) x++;
return 'voicemenu-custom-'+x ;
}
function save_vmenu(){
var _ae = _$('alias_exten') ;
var _vms = _$('vmenus') ;
var _ale = _$('allowexten');
if( _ae.value.length > 0 && localextenlength !=0 && localextenlength != _ae.value.length){
gui_alert("Sorry, An Extension must be "+ localextenlength + " digits !");
_ae.focus();
return false;
}
if (!check_patternonfields( [ 'comment', 'newstep_var_digit' ] ) ){
return false;
}
_$('status_message').style.display ="" ;
var _cmv = _$('comment').value ;
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function() {
setTimeout( function(){_$('status_message').style.display="none"; },sc_displaytime );
gui_feedback('Updated.','blue');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -