⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7.html

📁 asterisk 的图形管理界面
💻 HTML
字号:
<!--
 * Asterisk-GUI	-	an Asterisk configuration interface
 *
 * Setup WIzard/ User Extensions
 *
 * 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 origwidth;
var widgets = {} ;
var adstatus;
var callbacks = new Object;
var phonecallbacks = new Object;
var numcallbacks = new Object;
var extencallbacks = new Object;
var fieldnames = ['callwaiting', 'cancel', 'cid_number', 'context', 'delete', 'email', 'fullname', 'group', 'hasagent', 'hasdirectory', 'hasiax', 'hasmanager', 'hassip', 'hasvoicemail', 'host', 'mailbox', 'name', 'new', 'save', 'secret', 'threewaycalling', 'zapchan'];

var allow_aliasextns;

callbacks.format = function(t) {
	if ((t.name == 'general')){
		if (t.fieldbyname['allow_aliasextns'] && t.fieldbyname['allow_aliasextns'].length){
			allow_aliasextns =  t.fieldbyname['allow_aliasextns'] ;
		}else{
			allow_aliasextns = 'no' ;
		}
		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.savechanges = function(){
	saveuserdetails();
}

callbacks.cancelnewcategory = function(){
	hideuserdetails();
}

callbacks.cancelchanges = function(){
	hideuserdetails();
}


callbacks.loaded = function() {
	_$('devices').contentEditable = 'true';
	_$('devices').disabled = 0;
	_$('new').addEventListener("click", showuserdetails, false); 
	parent.astmanEngine.pollEvents();
	loadusersintotable();
}

callbacks.sortfunc = function(a,b) {
	return (a.name < b.name) ? -1 : 1;
}

callbacks.checkparams = function(box) {
	_$('mailbox').value = _$('name').value;
	_$('group').value = '';
	return false;
}

callbacks.newcategory = function() {
	var tmp = null;
	var x;
	if (_$('devices').stored_config.catbyname['general'])
		tmp = objcopy(_$('devices').stored_config.catbyname['general']);
	if (tmp) {
		x = tmp.fieldbyname['userbase'];
		if (x) {
			tmp.name = first_free_exten(_$('devices'), x);
		}
	}
	return tmp;
}
callbacks.identifier = "extension";
callbacks.beforeSaving = function(){
	if(!_$('fullname').value.length){
		alert("Sorry, a User Name must be specified !");
		_$('fullname').focus();
		return false;
	}
	// check whether the extension entered matches with any of the - voicemail, queue, voicemenu, conference extensions
	for(var k=0; k< _$('extensions').length; k++ ){
		var tmp = _$('extensions').options[k].innerHTML.split(' -- '); 
		if( tmp[0] ==  $('name').value   ){
			alert("Sorry, an entry named " + _$('name').value + " already exists!");
			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].fieldbyname['zapchan'] && _$('devices').stored_config.categories[i].fieldbyname.zapchan.length )
				tmp_usedanaloglines.push(_$('devices').stored_config.categories[i].fieldbyname.zapchan);
		}
		if ( InArray(tmp_usedanaloglines,_$('zapchan').value)){
			alert("This Analog Phone has already been assigned to another user extension.\n Please select a different Phone");
			return false;
		}
	}

	return true;
}

callbacks.postselect = function(box, val) {
	if (adstatus == "hidden") {
		adstatus = "shown";
		 togglefeatures() ;
	}
	if( box.selectedIndex == -1)
		return true;
}

phonecallbacks.format = function(t) {
	if (t.fieldbyname['port'] == 'fxo')
		return "Analog Port #" + t.name;
	return null;
}

phonecallbacks.loaded = function() {
	
	if( _$('zapchan').options.length == 0) {
		_$('zapchan').style.display="none";
		_$('noanaloglines').style.display="";
	}

	var noneopt = document.createElement("OPTION");
	_$('zapchan').options.add(noneopt,0);
	noneopt.value = "";
	noneopt.innerText = "None";

	parent.astmanEngine.config2list("extensions.conf", _$('context'), new Array(), numcallbacks);
}

numcallbacks.format = function(t) {
	if ((t.name.substr(0,11) != 'numberplan-'))
		return null;
	if (t.fieldbyname['plancomment'])
		return t.fieldbyname['plancomment'];
	return t.name;
}

numcallbacks.loaded = function() {
	parent.astmanEngine.config2list("extensions.conf", _$('extensions'), new Array(), extencallbacks);
}

extencallbacks.format = function(t, x) {
	if ((t.name != specialcontext))
		return null;
	return format_extension(_$('extensions'), t, x);
}
extencallbacks.loaded = function() {
	parent.astmanEngine.config2list("users.conf", _$('devices'), widgets, callbacks);
}
extencallbacks.eachline = true;

function localinit(){
	var focus_fields = [ 'name','fullname','secret','email','cid_number','context','zapchan'];
	for( var  r =0; r < focus_fields.length ; r++ ){
		var d = _$(focus_fields[r]);
		d.onfocus = function(){ this.className = 'input9_hilight'; }
		d.onblur = function(){ this.className = 'input9'; }
	}
	//parent.$('next').disabled = true;
	parent._$('next').onclick = function(){	 window.location.href="8.html"; };
	parent._$('back').disabled = false;
	parent._$('back').onclick  = function(){	 window.location.href="6.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") ) {
		// start here
		for (var x in fieldnames) {
			widgets[fieldnames[x]] = $(fieldnames[x]);
			widgets[fieldnames[x]].disabled = true;
		}
		parent.astmanEngine.config2list("zapscan.conf", _$('zapchan'), new Array(), phonecallbacks);
	}
}

function addrow_totable(username, extension){
	var sno = _$('userstable').rows.length + 1;
	var newRow = _$('userstable').insertRow(-1);
	newRow.id = "row" + extension; 

	var newCell0 = newRow.insertCell(0);
	newCell0 .innerHTML = sno ;
	newCell0 .style.width = 40;

	var newCell1 = newRow.insertCell(1);
	newCell1 .innerHTML = extension ;
	newCell1 .style.width = 80;
	newCell1 .align = "center";

	var newCell2 = newRow.insertCell(2);
	newCell2 .innerHTML = username ;

	var newCell3 = newRow.insertCell(3);
	newCell3 .innerHTML = " <A href=\"#\" onclick=\"edituser("+ extension +");\">Edit</A>&nbsp;&nbsp;&nbsp;&nbsp;<A href=\"#\" onclick=\"deleteuser("+ extension +");\">Delete</A>" ;
	newCell3 .style.width = 120;
	newCell3 .align = "center";

}

function edituser(extension){
	for(var i=0; i< _$('devices').length; i++){
		//get username and get extension 
		var tmp = _$('devices').options[i].text.split(" -- ");
		if(tmp[0] == extension){
			_$('devices').selectitem(i);
			showuserdetails();
			break;
		}
	}
}

function saveuserdetails(){
	hideuserdetails();
	loadusersintotable();
}

function hideuserdetails(){
	_$('usersettings').style.display = "none";
	_$('bg_transparent').style.display='none';
}

function showuserdetails(){
	_$('cancel').disabled = false;
	_$('usersettings').style.display = "";
	_$('bg_transparent').style.display='';
}

callbacks.delchanges = function(a,b,c){
	deleteuser_fromui(b);
}

function deleteuser(extension){
	// delete from users.conf
	for(var i=0; i< _$('devices').length; i++){
		//get username and get extension 
		var tmp = _$('devices').options[i].text.split(" -- ");
		if(tmp[0] == extension){
			_$('devices').selectedIndex = i ;
			_$('delete').disabled = 0;
			if( !_$('delete').click() ){
				return;
			}
			break;
		}
	}
}

function deleteuser_fromui(extension){
	// delete from UI
	var delete_id = "row" + extension;
	for( var i=0; i <  _$('userstable'). rows.length; i++){
		if  ( _$('userstable'). rows[i].id == delete_id  ){
			_$('userstable').deleteRow(i);
			loadusersintotable();
			break;
		}
	}
}

function loadusersintotable(){
	for( var i=0; i <  _$('userstable').rows.length; ){
		_$('userstable').deleteRow(i);
	}

	for(i=0; i< _$('devices').length; i++){
		//get username and get extension 
		var tmp = _$('devices').options[i].text.split(" -- ");
		addrow_totable(tmp[1], tmp[0]);
	}
}

</SCRIPT>
<BODY bgcolor="#FFFFFF" onload="localinit()" topmargin=0 leftmargin=0>
<table width="100%" height="100%" border=0 cellpadding=0 cellspacing=0>
<tr>
<td width="170" valign=top align=left>
	<div id="menu">
	<table cellpadding=3 cellspacing=2 border=0 id="sidelist">
		<tr><td width=3></td><td>Start</td></tr>
		<tr><td></td><td>Verify Analog Ports</td></tr>
		<!-- <tr><td></td><td>Date & Time</td></tr> -->
		<tr><td></td><td>Local Extension Settings</td></tr>
		<tr><td></td><td>Service Providers</td></tr>
		<tr><td></td><td>Calling Rules</td></tr>
		<tr><td></td><td>VoiceMail Settings</td></tr>
		<tr><td></td><td class="slselected">User Extensions</td></tr>
		<tr><td></td><td>Incoming Calls</td></tr>
		<!-- <tr><td></td><td>VoiceMenus</td></tr> -->
		<tr><td></td><td>Finish</td></tr>
	</table>
	</div>
</td>
<td valign=top align=center>
<!--  this page -->
	<div style="display:none">
		<select id="devices" ></select>						
		<select id='extensions' style="display:none" ></select>
		<input type='button' id='delete' value='Delete'>
	</div>
	<div ID="usersettings"  STYLE="display:none; position: absolute; left: 240; top: 40; width:530; height:250;  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 , 'usersettings');">
			<TR bgcolor="#7E5538" >
				<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=2 border=0 class="userdetails">
		<TR>	<TD>User Extension</TD>
			<TD><input size='5' id='name' pattern='^\d*$' class="input9"></TD>
			<TD>Full Name:</TD>
			<TD><input size='20' id='fullname' pattern='^[a-zA-Z_0-9 ]*$' class="input9"></TD>
		</TR>
		<TR>	<TD>Password:</TD>
			<TD><input size='5' id='secret' pattern='^[a-zA-Z_0-9 ]*$'  class="input9"></TD>
			<TD>Email:</TD>
			<TD><input size='20' id='email' pattern='^[0-9a-zA-Z\.\-\_\@]*$' class="input9"></TD>
		</TR>
		<TR>	<TD>Caller id:</TD>
			<TD><input size='12' id='cid_number'  pattern='^[\d\-]*$' class="input9"></TD>
			<TD>Analog Phone:</TD>
			<TD><select size="1" id='zapchan' style='width:120px' class="input9"></select>
				<span id="noanaloglines" style="display:none"><I>&nbsp;No Analog lines installed.</I></span>
			</TD>
		</TR>
		<TR>	<TD>Calling Rule:</TD>
			<TD><select size='1' id='context' style='width:120px' class="input9"></select>
				<input type='hidden' id='mailbox'><input type='hidden' id='group'>
			</TD>
			<TD>VoiceMail:</TD>
			<TD><input type='checkbox' id='hasvoicemail'></TD>
		</TR>
		<TR>	<TD>In Directory:</TD>
			<TD><input type='checkbox' id='hasdirectory'></TD>
			<TD>SIP:</TD>
			<TD><input type='checkbox' id='hassip'></TD>
		</TR>
		<TR>	<TD>CTI:</TD>
			<TD><input type='checkbox' id='hasmanager'></TD>
			<TD>IAX:</TD>
			<TD><input type='checkbox' id='hasiax'></TD>
		</TR>
		<TR>	<TD>CallWaiting:</TD>
			<TD><input type='checkbox' id='callwaiting'></TD>
			<TD>3-Way Calling:</TD>
			<TD><input type='checkbox' id='threewaycalling'></TD>
		</TR>
		<TR>	<TD>Is Agent:</TD>
			<TD><input type='checkbox' id='hasagent'><input type='hidden' dfalt='dynamic' id='host'></TD>
			<TD></TD>
			<TD></TD>
		</TR>
		<TR>	<TD colspan=4 align=center>
				<input type='button' id='save' value='Save'  class="buttonbold">&nbsp;&nbsp;
				<input type='button' id='cancel' value='Cancel' class="buttonbold">
			</TD>
		</TR>
		</TABLE>
	</div>
	<div class="heading">Step 6 of <script>document.write(parent.numberofsteps);</script>&nbsp;&nbsp;-  User Extensions </div>
	<div class="subheading">List of User Extensions</div>
	<table class="table_black" cellpadding=2 cellspacing=2 border=0 align=center width=600>
		<tr>	<td width=40>S.no</td>
			<td width="80">Extension</td>
			<td>Name</td>
			<td width="120" align=center>Options</td>
		</tr>
	</table>
	<table id="userstable" cellpadding=2 cellspacing=1 border=0 align=center width=600>
	</table>
	<div style="height:25px"></div>
	<input type='button' id='new' value='Add User Extension'>
<!--  this page -->
</td>
</tr>
</table>
<div id="bg_transparent" STYLE="display:none; position: absolute; left: 0; top: 0; width:100%; height:100%;  background-color:#FFFFFF; filter:alpha(opacity=50); -moz-opacity:.50;opacity:.50; border-width: 0px; z-index:4">
</div>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -