📄 users.html.svn-base
字号:
<!-- * Asterisk-GUI - an Asterisk configuration interface * * Create Users and assign them devices , dialplans etc * * 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/astman.js"></script><script src="scripts/tooltip.js"></script><link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" /><script>var origwidth;var widgets = new Object;var callbacks = new Object;var extencallbacks = new Object;var allcodecs = new Array;var fieldnames = ['callwaiting' ,'cancel' ,'cid_number' ,'context' ,'delete' ,'email' ,'fullname' ,'group' ,'hasagent' ,'hasdirectory' ,'hasiax' ,'hasmanager' ,'hassip' ,'hasvoicemail' ,'deletevoicemail' ,'host' ,'mailbox' ,'name' ,'new' ,'save' ,'secret' ,'threewaycalling' ,'vmsecret' ,'zapchan', 'registeriax', 'registersip','macaddress','autoprov','label','canreinvite','nat','dtmfmode', 'disallow','allow', 'insecure'];var localextenlength = 4;var allow_aliasextns = "no";var allow_an_extns = "no" ;var USER_ZAPCHAN = '' ; // this global variable is used to know if the selected user's zapchan is changed between// callbacks.postselect and callbacks.savechanges, if it is changed we set parent.REQUIRE_RESTART to true;// and if parent.REQUIRE_RESTART is true - we nolonger care about updating/keeping track of this variable anyway.function load_customerinfo(){ parent.$('buynow_div').innerHTML = "Need a phone, some software, or something else?<BR> Click on the 'Where to Buy' button to get directly to products.<BR/><BR/><input type=\"button\" id=\"buynow_button\" value=\"Where to Buy\">"; parent.$('buynow_button').onclick = function(){ win=window.open('','myWin'); document.buynow_form.target='myWin'; document.buynow_form.submit(); }}extencallbacks.format = function(t, x) { if ((t.name != specialcontext)){ return null; } return format_extension(_$('extensions'), t, x);}extencallbacks.loaded = function() { merge_extensions(_$('devices'), _$('extensions')); parent.loadscreen(this); load_customerinfo();}extencallbacks.eachline = true;var add_DigitalChannels = function(k){ // k could be 'x', 'x-y' var n, _zapchan = _$('zapchan') ; if( k.contains('-') ){ var l = Number(k.split('-')[0]); var m = Number(k.split('-')[1]); for( n = l ; n <= m; n++ ){ ASTGUI.selectbox.append(_zapchan,"Channel #" + n, n); } }else{ n = Number(k); ASTGUI.selectbox.append(_zapchan,"Channel #" + n, n); }}callbacks.format = function(t) { if ((t.name == 'general')){ if (t.fieldbyname['localextenlength'] && t.fieldbyname['localextenlength'].length){ localextenlength = t.fieldbyname['localextenlength'] ; } if ( t.fieldbyname['allow_an_extns'] && t.fieldbyname['allow_an_extns'].length ){ allow_an_extns = t.fieldbyname['allow_an_extns'] ; if(allow_an_extns == "yes"){ $('name').setAttribute("pattern", '^[a-zA-Z0-9]*$'); } } if (t.fieldbyname['allow_aliasextns'] && t.fieldbyname['allow_aliasextns'].length){ allow_aliasextns = t.fieldbyname['allow_aliasextns'] ; } return null; } if ( t.name.beginsWith('span_') && t.fieldbyname['signalling'].beginsWith('fxo') && t.fieldbyname['zapchan'] ) { add_DigitalChannels(t.fieldbyname['zapchan']); return null; } if ( t.fieldbyname['context'] == asterisk_guiTDPrefix + t.name ) { return null; } if (t.fieldbyname['fullname'] && t.fieldbyname['fullname'].length ) { return t.name + " -- " + t.fieldbyname['fullname']; } else{ return t.name; }}callbacks.loaded = function() { _$('devices').disabled = false; if( _$('zapchan').options.length == 0) { _$('zapchan').style.display="none"; _$('noanaloglines').style.display=""; } parent.astmanEngine.config2list("extensions.conf", _$('extensions'), new Array(), extencallbacks);}callbacks.sortfunc = function(a,b) { return (a.name < b.name) ? -1 : 1;}callbacks.checkparams = function(box) { _$('mailbox').value = _$('name').value; _$('group').value = ''; if($('macaddress').value.length > 0) { $('autoprov').value = "yes"; $('label').value = $('name').value; } else { $('autoprov').value = "no"; $('label').value = ""; } return false;}callbacks.newcategory = function() { var tmp = null; var x; var _devices = _$('devices'); gen = _devices.stored_config.catbyname['general']; gen.fieldbyname['allow'] = 'all'; gen.fieldbyname['disallow'] = 'all'; tmp = objcopy(gen); try{ if (gen){ x = gen.fieldbyname['userbase']; for( var f=0; f < _devices.options.length ; f++ ){ if( x < _devices.options[f].innerHTML.split(' -- ')[0] ){ break; } x++; } }else{ try{ x = ( parseInt( _devices.options[ _devices.options.length - 1 ].innerHTML.split(' -- ')[0] ) ) + 1; }catch(err){ x = 6000; // a default value if one is not defined in users.conf's general context } } if(isNaN(x)){x=6000;} }catch(err){ x = 6000; } tmp.name = x return tmp;}callbacks.identifier = "extension";callbacks.beforeSaving = function(){ var _devices = _$('devices'); var _name = _$('name'); var _fullname = _$('fullname'); if(!_fullname.value.length){ gui_alert("Sorry, a User Name must be specified !"); _fullname.focus(); return false; } // check whether the length of extension is valid if( localextenlength !=0 && (allow_an_extns == "no" && localextenlength != _name.value.length) ){ gui_alert( "Sorry, User Extension must be "+ localextenlength + " digits !" ); return false; } if (!check_patternonfields( ['name', 'fullname', 'secret','email', 'cid_number'] ) ){ return false; } if( _$('macaddress').value.length != 12 && _$('macaddress').value.length != 0 ) { alert("Sorry, Phone Serial must be 12 characters !"); _$('macaddress').focus(); return false; } if(allow_aliasextns == "no"){ // check whether the selected analog line is assigned to another user extension var tmp_usedanaloglines = [] ; for ( var i=1; i < _devices.stored_config.categories.length ; i++){ if ( _devices.stored_config.categories[i] != null ){ if ( _devices.stored_config.categories[i].fieldbyname['zapchan'] && _devices.stored_config.categories[i].fieldbyname.zapchan.length && _devices.stored_config.categories[i].name != _devices.value ) tmp_usedanaloglines.push( _devices.stored_config.categories[i].fieldbyname.zapchan); } } if ( InArray(tmp_usedanaloglines,_$('zapchan').value)){ gui_alert("This Analog Phone has already been assigned to another user extension.\n Please select a different Phone"); return false; } } if(_devices.value != _name.value){ for(var k=0; k<_devices.length; k++ ){ var tmp = _devices.options[k].innerHTML.split(' -- '); if( tmp[0] == _name.value ){ gui_alert("Sorry, an entry named " + _name.value + " already exists!"); return false; } } } _$('registeriax').checked =_$('hasiax').checked ; _$('registersip').checked =_$('hassip').checked ; return true;}callbacks.postselect = function(box, val) { parent._$('tooltip').innerHTML = parent.tooltip_default ; _$('codecs_text').innerHTML = '' ; if( box.selectedIndex == -1) return true; if(val == "reserved" ){ if( box.options[box.selectedIndex].text.toLowerCase().match("-- call queue") || box.options[box.selectedIndex].text.toLowerCase().match('call queue ') ){ //parent.$('tooltip').innerHTML = " <font size=\"-2\" color=\"#FF0000\">Click on \'Call Queues\' panel to edit call queues </font>"; box.selectedIndex = -1; gui_alert(" You can not edit the selected entry from here.\n Please click on the \'Call Queues\' panel to edit the selected entry"); return true; } if( box.options[box.selectedIndex].text.toLowerCase().match("-- conference bridge") || box.options[box.selectedIndex].text.toLowerCase().match('conference bridge ') ){ //parent.$('tooltip').innerHTML = " <font size=\"-2\" color=\"#FF0000\">Click on \'Conferencing\' panel to edit a Conference Bridge</font>"; box.selectedIndex = -1; gui_alert(" You can not edit the selected entry from here.\n Please click on the \'Conferencing\' panel to edit the selected entry"); return true; } if( box.options[box.selectedIndex].text.toLowerCase().match("-- check voicemail") || box.options[box.selectedIndex].text.toLowerCase().match('check voicemail ') ){ box.selectedIndex = -1; //parent.$('tooltip').innerHTML = " <font size=\"-2\" color=\"#FF0000\">Click on \'Voicemail\' panel to edit Voicemail Preferences</font>"; gui_alert(" You can not edit the selected entry from here.\n Please click on the \'Voicemail\' panel to edit the selected entry"); return true; } if( box.options[box.selectedIndex].text.toLowerCase().match("-- voice menu") || box.options[box.selectedIndex].text.toLowerCase().match('voice menu ') ){ box.selectedIndex = -1; //parent.$('tooltip').innerHTML = " <font size=\"-2\" color=\"#FF0000\">Click on \'Voicemail\' panel to edit Voicemail Preferences</font>"; gui_alert(" You can not edit the selected entry from here.\n Please click on the \'Voice Menus\' panel to edit the selected entry"); return true; } } showhide(); /* check to see if we need to display out email/voicemail settings. */ _$('codecs_text').innerHTML = 'disallow: '+ _$('disallow').value + ' <BR> allow:' + _$('allow').value ; USER_ZAPCHAN = _$('zapchan').value ;}callbacks.savechanges = function(){ if( parent.REQUIRE_RESTART == false && _$('zapchan').value != USER_ZAPCHAN ){ parent.REQUIRE_RESTART = true; } var y = _$('name').value ; var uri1 = build_action('update', 0 , y , 'signalling', 'fxo_ks'); // set the signalling to fxo_ks makerequest( 'u', 'users.conf' , uri1 , function(t){ } );}function dialplans_loaded(b){ var c = b ; var _context = _$('context') ; for( var d in c ){ if ( c.hasOwnProperty(d) && d.substr(0,11) == 'numberplan-' ) { var txt = (c[d]['plancomment'])?unescape(c[d]['plancomment']) : d; ASTGUI.selectbox.append(_context,txt, d); } } parent.astmanEngine.config2list("users.conf", _$('devices'), widgets, callbacks);}function localajaxinit() { ASTGUI.events.add(document, 'mouseover', show_tooltip); /* // Automatically open the related panel - like when this page is called using a back button // This is working .. but is causing the current page to load twice. for( var v=0; v < parent.panels.length ; v++){ if ( parent.panels[v].name == "users"){ parent.accordion.showTabByIndex(v,true); break; } } */ setWindowTitle("User Extensions"); _$('devices').disabled = true; for (var x =0; x < fieldnames.length; x++ ) { widgets[fieldnames[x]] = _$(fieldnames[x]); widgets[fieldnames[x]].disabled = true; } load_codecs_fromast(); //parent.astmanEngine.config2list("zapscan.conf", _$('zapchan'), new Array(), phonecallbacks);}function load_codecs_fromast() { parent.astmanEngine.cliCommand('module show like codec_', function(resp) { resp = resp.replace(/Response: Follows/, ""); resp = resp.replace(/Privilege: Command/, ""); resp = resp.replace(/--END COMMAND--/, ""); resp = resp.split("\n"); for(var i=0; resp[i] != undefined; i++) { resp[i] = resp[i].split("_"); if(resp[i][1]) { resp[i][1] = resp[i][1].split(/[. ]/); if(resp[i][1][0]) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -