📄 4.html
字号:
<!--
* Asterisk-GUI - an Asterisk configuration interface
*
* Setup WIzard/ Service Providers
*
* 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 provwidgets = {} ;
var callbacks = new Object;
var phonecallbacks = new Object;
var providercallbacks = new Object;
var globalvars = new Object;
var fieldnames = ['callerid', 'cancel', 'context', 'delete', 'dialformat', 'fromdomain', 'fromuser', 'group', 'hasexten', 'hasiax', 'hassip', 'host', 'host', 'insecure', 'name', 'new', 'provider', 'registeriax', 'registersip', 'save', 'secret', 'trunkname', 'trunkstyleanalog', 'trunkstylecustomvoip', 'trunkstylevoip', 'username', 'zapchan'];
var provfieldnames = new Array('providerdesc', 'providerlogo');
var isnewtrunk;
var dids_array = [];
var old_trunkname;
function add_didcontext(trunk){
var didcontext = asterisk_guiTDPrefix + trunk ;
var uri = build_action('newcat', 0, didcontext ,"", "");
uri += build_action('append', 1, didcontext ,"include", "default");
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) { },
onFailure: function(t) {
alert("Config Error: " + t.status + ": " + t.statusText);
alert("Failed to create a DID context for " + trunk);
}
};
opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
var tmp = new Ajax.Request(rawman_url, opt);
}
function update_didcontext(old_trunk, new_trunk){
var old_didcontext = asterisk_guiTDPrefix + old_trunk ;
var new_didcontext = asterisk_guiTDPrefix + new_trunk ;
var uri = build_action('renamecat', 0, old_didcontext ,"", new_didcontext );
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) { },
onFailure: function(t) {
alert("Config Error: " + t.status + ": " + t.statusText);
alert("Failed to Rename the DID context for " + old_didcontext );
}
};
opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
var tmp = new Ajax.Request(rawman_url, opt);
}
function delete_didcontext(trunk){
var didcontext = asterisk_guiTDPrefix + trunk ;
var uri = build_action('delcat', 0, didcontext ,"", "");
var opt = {
method: 'get',
asynchronous: true,
onSuccess: function(t) { },
onFailure: function(t) {
alert("Config Error: " + t.status + ": " + t.statusText);
alert("Failed to delete DID context for " + trunk);
}
};
opt.parameters= "action=updateconfig&srcfilename=" + encodeURIComponent("extensions.conf") + "&dstfilename=" + encodeURIComponent("extensions.conf") + uri;
var tmp = new Ajax.Request(rawman_url, opt);
}
function localinit(){
var focus_fields = [ 'username','secret','provider','customvoip_name','customvoip_protocol','customvoip_host','customvoip_username','customvoip_secret' ];
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._$('back').onclick = function(){ window.location.href="3.html"; };
parent._$('next').onclick = function(){ window.location.href="5.html"; };
//parent.$('next').disabled = true;
parent._$('back').disabled = false;
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") ) {
parent.window.location.href = parent.window.location.href ;
return;
}
if (originalRequest.responseText.match("Pong") ) {
localajaxinit();
}
}
providercallbacks.format = function(t) {
return t.fieldbyname['providername'];
}
globalvars.format = function(t) {
if ( t.name.substring(0,asterisk_guiTDPrefix.length) == asterisk_guiTDPrefix ){
dids_array.push( t.name.substring( asterisk_guiTDPrefix.length ) );
}
if (t.name == "globals")
return t.name
return null;
}
globalvars.loaded = function() {
parent.astmanEngine.config2list("users.conf", _$('devices'), widgets, callbacks);
}
providercallbacks.loaded = function() {
_$('provider').altonchange = _$('provider').onchange;
_$('provider').onchange = null;
parent.astmanEngine.config2list("extensions.conf", _$('hiddenglobals'), new Array, globalvars);
}
providercallbacks.postselect = function(){
if (_$('provider').selectIndex == -1 || _$('provider').selectIndex == ""){
return true;
}else{
var element = document.getElementById("providerlogo_image");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
var sp1 = document.createElement("img");
sp1.src = "../images/" + _$('providerlogo').value ;
//sp1.width="214";
//sp1.height="46";
_$('providerlogo_image').appendChild(sp1);
}
}
callbacks.format = function(t) {
if( InArray(dids_array, t.name) ){
return t.fieldbyname['trunkname'];
}
return null;
}
callbacks.cancelnewcategory = function(){
hideSPdetails();
}
callbacks.cancelchanges = function(){
hideSPdetails();
}
callbacks.loaded = function() {
parent.astmanEngine.pollEvents();
_$('devices').contentEditable = 'true';
_$('devices').disabled = 0;
_$('new').addEventListener("click", showSPdetails, false);
loadServiceProvidersintotable();
}
callbacks.postselect = function(){
if( _$('trunkstylecustomvoip').checked ){
// Custom VOIP
var tmp = _$('trunkname').value.split("Custom - ") ;
_$('customvoip_name').value = tmp[1];
_$('customvoip_username').value = _$('username').value;
_$('customvoip_secret').value = _$('secret').value;
if ( _$('hassip').value == "yes" ){
_$('customvoip_protocol').selectedIndex = 1;
}else {
_$('customvoip_protocol').selectedIndex = 0;
}
_$('customvoip_host').value = _$('host').value;
if(_$('registeriax').value == "yes" || _$('registersip').value == "yes"){
_$('customvoip_register').checked = true;
}else{
_$('customvoip_register').checked = false;
}
}else if ( _$('trunkstylevoip').checked ){
// VOIP
_$('customvoip_name').value = "";
_$('customvoip_username').value = _$('username').value;
_$('customvoip_secret').value = _$('secret').value;
_$('customvoip_protocol').selectedIndex = 0;
_$('customvoip_host').value ="";
}
}
callbacks.delchanges = function(box, value) {
deletesp_fromui(value);
delete_didcontext(value);
var oldvalue = _$('hiddenglobals').stored_config.catbyname['globals'].fieldbyname[value];
if (oldvalue) {
uri = build_action('delete', 0, 'globals', value, "");
apply_uri(_$('hiddenglobals'), uri);
_$('hiddenglobals').stored_config.catbyname['globals'].fieldbyname[value] = null;
return true;
}
}
callbacks.beforeSaving = function(){
if (_$('trunkstylevoip').checked && !_$('provider').value) {
alert("Please select a service provider!");
return false;
}
if (_$('trunkstylevoip').checked && !_$('username').value.length ) {
alert("When using VoIP, the username must not be empty!");
return false;
}
if (_$('trunkstyleanalog').checked ) {
if( _$('zapchan').options.length == 0 ){
alert("No analog line hardware installed on the system");
return false;
}
if (!_$('zapchan').value) {
alert("When using Analog, at least one port must be selected.");
return false;
}
}
if ( _$('trunkstylecustomvoip').checked ) {
if( _$('customvoip_name').value.length == 0 ){
alert("Please enter a Comment for this Service Provider");
_$('customvoip_name').focus();
return false;
}
if ( !_$('customvoip_host').value ) {
alert("Please enter a host name");
_$('customvoip_host').focus();
return false;
}
if ( !_$('customvoip_username').value ) {
alert("Please enter a Username");
_$('customvoip_username').focus();
return false;
}
}
if(!$('trunkstylevoip').checked && !$('trunkstyleanalog').checked && !$('trunkstylecustomvoip').checked ){
alert("A trunk must be Analog or VoIP or Custom VOIP");
return false;
}
if(isnewtrunk ==1){
try{
provider = _$('provider').stored_config.catbyname[_$('provider').value];
if( typeof provider.fieldbyname['trunk_username'] != "undefined" && _$('trunkstylevoip').checked ){
_$('name').value = provider.fieldbyname['trunk_username'];
}
}catch(e){
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -