📄 trunks.html
字号:
for (var x=0;x<_zapchan.options.length;x++)
_zapchan.options[x].selected = false;
_zapchan.value = '';
_$('group').value = '';
_$('disallow').value= "";
_$('allow').value = "all";
}
}
callbacks.newcategory = function() {
var tmp = null;
var x;
var _devices = _$('devices');
if ( _devices.stored_config.catbyname['general'])
tmp = objcopy( _devices.stored_config.catbyname['general']);
if (tmp) {
x = 1;
while( _devices.stored_config.catbyname['trunk_' + x]) x++;
tmp.name = 'trunk_' + x;
}
tmp.fieldbyname['hasexten'] = 'no';
tmp.fieldbyname['context'] = asterisk_guiTDPrefix + tmp.name;
_$('customvoip_name').value = "";
_$('customvoip_username').value = "";
_$('customvoip_secret').value = "";
_$('customvoip_protocol').selectedIndex = 0;
_$('customvoip_host').value ="";
_$('analog').style.display="none";
_$('voip').style.display="none";
_$('customvoip').style.display="none";
_$('userscontent_title').innerHTML = "Add Service Provider";
isnewtrunk = 1;
return tmp;
}
callbacks.identifier = "extension";
phonecallbacks.format = function(t) {
if (t.fieldbyname['port'] == 'fxs')
return "Analog Port #" + t.name;
return null;
}
phonecallbacks.loaded = function() {
parent.astmanEngine.config2list("providers.conf", _$('provider'), provwidgets, providercallbacks);
}
function update_zapchan(){
_$('save').disabled = false;
_$('cancel').disabled = false;
var _zapchan = _$('zapchan');
for (k=0;k< _zapchan.length ;k++ ){
_zapchan.options[k].selected = ( _$("selectedline" + k).checked ) ?true:false;
}
}
function activateanalogvoip() {
_$('analog').style.display = "none";
var _zapchan = _$('zapchan');
_zapchan.style.display = "none";
var _zcal = _$('zapchan_analoglines');
_zcal.style.display = "none";
_zcal.innerHTML ="";
_$('customvoip').style.display = "none" ;
_$('voip').style.display= "none";
if (_$('trunkstyleanalog').checked) {
_$('analog').style.display = "block";
_zcal.style.display = "";
if(_zapchan.options.length ==0){
_zcal.innerHTML = "No analog line hardware installed on the system";
}else{
for (k=0;k< _zapchan.length ;k++ ){
var selectedline = "selectedline" + k;
if(_zapchan.options[k].selected){
_zcal.innerHTML += '<LABEL FOR="' + selectedline + '"><INPUT id="' + selectedline + '" TYPE="CHECKBOX" VALUE="'+ _zapchan.options[k].value+ '" checked onclick="update_zapchan()">' + _zapchan.options[k].text + '</LABEL><BR>';
}else{
_zcal.innerHTML += '<LABEL FOR="'+ selectedline+'"><INPUT id="' + selectedline + '" TYPE="CHECKBOX" VALUE="'+ _zapchan.options[k].value+ '" onclick="update_zapchan()">' + _zapchan.options[k].text + '</LABEL><BR>';
}
}
}
}else if (_$('trunkstylevoip').checked) {
_$('voip').style.display = "";
_$('voip').style.height =350;
}else if (_$('trunkstylecustomvoip').checked) {
_$('customvoip').style.display = "" ;
}
}
function localajaxinit() {
setWindowTitle("Service Providers");
_$('devices').contentEditable = 'false';
_$('zapchan').splitchar=',';
var _trunkstyleanalog = _$('trunkstyleanalog') ;
_trunkstyleanalog.altonclick = _trunkstyleanalog.onclick;
_trunkstyleanalog.onclick = null;
var _trunkstylevoip = _$('trunkstylevoip');
_trunkstylevoip.altonclick = _trunkstylevoip.onclick;
_trunkstylevoip.onclick = null;
var _trunkstylecustomvoip = _$('trunkstylecustomvoip');
_trunkstylecustomvoip.altonclick = _trunkstylecustomvoip.onclick;
_trunkstylecustomvoip.onclick = null;
add_event( _$('custom_trunkname') , 'change' , function(){
_$('name').value = _$('custom_trunkname').value;
_$('save').disabled = false;
}
) ;
for (var x =0; x< fieldnames.length; x++) {
widgets[fieldnames[x]] = _$(fieldnames[x]);
widgets[fieldnames[x]].disabled = true;
}
for (var x =0; x < provfieldnames.length ; x++) {
provwidgets[provfieldnames[x]] = _$(provfieldnames[x]);
provwidgets[provfieldnames[x]].disabled = true;
}
parent.astmanEngine.config2list("zapscan.conf", _$('zapchan'), new Array(), phonecallbacks);
}
function loadServiceProvidersintotable(){
var _spt = _$('serviceproviderstable');
for( var i=0; i < _spt.rows.length; ){
_spt.deleteRow(i);
}
var _devices = _$('devices');
if( _devices.length == "0" ){
_$('table_one').style.display="none";
var newRow = _spt.insertRow(-1);
var newCell0 = newRow.insertCell(0);
newCell0 .align = "center";
newCell0 .innerHTML = "<BR>A <I>Service Provider</I> is not defined<BR><BR> Please click on the 'Add Service Provider' button<BR> to add a service provider<BR><BR>" ;
return true;
}
_$('table_one').style.display="";
for(i=0; i< _devices.length; i++){
if( _devices.options[i].text != "New Entry")
addrow_totable(_devices.options[i].text, _devices.options[i].value);
}
}
function addrow_totable(sp_text, sp_value){
var _spt = _$('serviceproviderstable') ;
var sno = _spt.rows.length + 1;
var newRow = _spt.insertRow(-1);
newRow.id ="row" + sp_value ;
newRow["sp_value"] = sp_value ;
var newCell0 = newRow.insertCell(0);
newCell0 .innerHTML = sno ;
newCell0 .style.width = 40;
var newCell1 = newRow.insertCell(1);
newCell1 .innerHTML = sp_text ;
newCell1 .style.width = 200;
var newCell2 = newRow.insertCell(2);
switch ( _$('devices').stored_config.catbyname[sp_value].fieldbyname['trunkstyle'] ){
case "customvoip":
newCell2.innerHTML = "Custom Voip";
break;
case "analog":
newCell2.innerHTML = "Analog";
break;
case "voip":
newCell2.innerHTML = "Voip";
break;
default :
newCell2.innerHTML = "?";
}
var newCell3 = newRow.insertCell(3);
var _span_menu = "span" + sp_value;
newCell3 .innerHTML = "<span class=\"downmenubutton\" id='" + "span_" + sp_value + "' onclick=\"show_downmenu( '"+ sp_value + "');\">Options <img src=images/1.gif></span>" ;
newCell3 .style.width = 90;
newCell3 .align = "center";
}
function show_downmenu( a ) {
var menu = document.getElementById('mymenu');
menu.sp_value = "";
menu.sp_value = a ;
var tmp_left = _$("span_"+a).offsetLeft;
var tmp_top = _$("span_"+a).offsetTop + _$("span_"+a).offsetHeight;
var tmp_parent = _$("span_"+a);
while(tmp_parent.offsetParent != document.body){
tmp_parent = tmp_parent.offsetParent;
tmp_left += tmp_parent.offsetLeft;
tmp_top += tmp_parent.offsetTop;
}
menu.style.top =tmp_top ;
menu.style.left = tmp_left ;
setTimeout( function(){ _$('mymenu').style.display=""; } , 100 );
}
function hide_mymenu( ) {
document.getElementById('mymenu').style.display="none";
}
function preparemenus(){
var menu_div = document.getElementById('mymenu') ;
menu_div.style.width="80";
menu_div.style.borderColor = "#eee #bbb #bbb #ddd";
add_event( document.body , "click", function(){ _$('mymenu').style.display="none"; } );
var menuitem1 = document.createElement('div');
menuitem1.innerHTML = "Edit" ;
menuitem1.onclick = function(){ hide_mymenu( ); editSP( this.parentNode.sp_value) };
menuitem1.onmouseover= function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#F6E7B6';
this.style.backgroundColor='#EFEFEF';
};
menuitem1.onmouseout=function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#FFFFFF';
this.style.backgroundColor='#FFFFFF';
};
menu_div.appendChild(menuitem1);
var menuitem2 = document.createElement('div');
menuitem2.innerHTML = "Codecs" ;
menuitem2.onclick = function(){
var _devices = _$('devices');
for(var i=0; i< _devices.length; i++){
if( this.parentNode.sp_value == _devices.options[i].value ){
_devices.selectitem(i);
showCodec_details();
break;
}
}
};
menuitem2.onmouseover= function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#F6E7B6';
this.style.backgroundColor='#EFEFEF';
};
menuitem2.onmouseout=function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#FFFFFF';
this.style.backgroundColor='#FFFFFF';
};
menu_div.appendChild(menuitem2);
var menuitem4 = document.createElement('div');
menuitem4.innerHTML = "Advanced" ;
menuitem4.onclick = function(){
hide_mymenu( );
var _devices = _$('devices');
for(var i=0; i< _devices.length; i++){
if( this.parentNode.sp_value == _devices.options[i].value ){
_devices.selectitem(i);
_$('bg_transparent').style.display = "";
_$('custom_trunkname').value = _$('name').value ;
_$('advanced_content').style.display = "";
break;
}
}
};
menuitem4.onmouseover= function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#F6E7B6';
this.style.backgroundColor='#EFEFEF';
};
menuitem4.onmouseout=function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#FFFFFF';
this.style.backgroundColor='#FFFFFF';
};
menu_div.appendChild(menuitem4);
var menuitem3 = document.createElement('div');
menuitem3.innerHTML = "Delete" ;
menuitem3.onclick = function(){ hide_mymenu( ); deleteSP( this.parentNode.sp_value ); };
menuitem3.onmouseover= function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#F6E7B6';
this.style.backgroundColor='#EFEFEF';
};
menuitem3.onmouseout=function(){
document.getElementById('row'+this.parentNode.sp_value ).style.backgroundColor='#FFFFFF';
this.style.backgroundColor='#FFFFFF';
};
menu_div.appendChild(menuitem3);
}
function codecs_save(){
_$('save').click( );
_$('codecs_content').style.display = 'none';
_$('bg_transparent').style.display ='none';
}
function showCodec_details(){
update_div_setordercodecs();
_$('codecs_content').style.display = "";
_$('bg_transparent').style.display ='';
}
function hide_codecs(){
_$('cancel').click( );
_$('codecs_content').style.display = 'none';
_$('bg_transparent').style.display ='none';
}
function editSP(sp_value){
isnewtrunk = 0;
$('userscontent_title').innerHTML = "Edit Service Provider";
var _devices = _$('devices');
for(var i=0; i< _devices.length; i++){
if(sp_value == _devices.options[i].value ){
_devices.selectitem(i);
showSPdetails();
break;
}
}
}
// Allowed/Disallowed codescs related functions
function enable_selectedcodec(){
// add to allowed
selectbox_add("allowed" , _$('disallowed').value );
// remove selected from disallowed
selectbox_remove("disallowed", _$('disallowed').value );
update_ordercodecs();
}
function disable_selectedcodec(){
// add to disallowed
selectbox_add("disallowed" , _$('allowed').value );
// remove selected from allowed
selectbox_remove("allowed", _$('allowed').value );
update_ordercodecs();
}
function selectbox_add(selectbox_id, codec){
switch(codec) {
case 'ulaw': addtosel("u-law","ulaw",selectbox_id) ; break;
case 'alaw': addtosel("a-law","alaw",selectbox_id) ; break;
case 'gsm': addtosel("GSM","gsm",selectbox_id) ; break ;
case 'ilbc': addtosel("ILBC","ilbc",selectbox_id) ; break ;
case 'speex': addtosel("SPEEX","speex",selectbox_id) ; break ;
case 'g726': addtosel("G.726","g726",selectbox_id) ; break ;
case 'adpcm': addtosel("ADPCM","adpcm",selectbox_id) ; break ;
case 'lpc10': addtosel("LPC10","lpc10",selectbox_id) ; break ;
case 'g729': addtosel("G.729","g729",selectbox_id) ; break ;
default: break
}
function addtosel(a,b,c){ // a is text, b is value, c is the select box id
var newoption = document.createElement('option');
newoption.text = a ;
newoption.value = b ;
var selectbox = document.getElementById( c );
try {
selectbox.add(newoption, null); // standards compliant; doesn't work in IE
}catch(ex) {
selectbox.add(newoption); // IE only
}
}
}
function selectbox_remove(selectbox_id,codec){
for (var x=0; x < $(selectbox_id).length; x++){
if( $(selectbox_id).options[x].value==codec ){ $(selectbox_id).remove(x); return true;}
}
}
function update_ordercodecs(){
var _allow = _$('allow') ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -