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

📄 misdn.html.svn-base

📁 asterisk-gui asterisk网关接口编程 控制asterisk的接口
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
<!-- * Asterisk-GUI	-	an Asterisk configuration interface * * Digital Card Setup / Detection  * * Copyright (C) 2006-2007, Digium, Inc. * * Brandon Kruse <bkruse@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" /><style>	.taglist {		border: 1px solid #666666;		margin-top:10px;		margin-bottom:10px;		max-width: 745;	}	.taglist tr.frow {		background-color: #6b79a5;		color: #CED7EF;	}	.taglist tr.even {		background-color: #DFDFDF;	}	.taglist tr.odd{		background-color: #FFFFFF;	}	.taglist tr.even:hover, .taglist tr.odd:hover {		background-color: #a8b6e5;	}	#errmsg{		border: 1px solid #666666;		margin-left:50px;		margin-right:50px;		margin-top: 50px; 		padding : 20px 10px 20px 10px;		font-size: 125%;		text-align: center;		background-color:#FFFFFF;	}	.pageheading{		padding : 10px 10px 10px 10px;		font-size: 135%;		text-align: center;		font-weight: bold;	}</style><script>var CARDS = 0;var PORTS = {}; // each port corresponds to a physical port on the bri cardvar pmode_defs = {	'te_ptp':'TE-Mode, PTP',	'te_ptmp':'TE-Mode, PTMP',	'te_capi_ptp':'TE-Mode(Capi), PTP',	'te_capi_ptmp':'TE-Mode(Capi), PTMP',	'nt_ptp':'NT-Mode, PTP',	'nt_ptmp':'NT-Mode, PTMP'};var mISDNTRUNKS = {};var isnewTrunk ;function resetmainscreen(){ top._$('mainscreen').width= 540; }function localajaxinit(){	setWindowTitle("misdn Cards Configuration");	top._$('mainscreen').width= 798;	showdiv_statusmessage(); // create status message dialog	_$('message_text').innerHTML = "Detecting BRI Cards ...";	_$('status_message').style.display='';	setTimeout("_$('status_message').style.display='none';", 4000);	parent.loadscreen(this);	setTimeout(		function(){			 parent.astmanEngine.run_tool("touch /etc/asterisk/misdninit_guiRead.conf", function(t){				misdnConfig.detectCards();			})		}	, 1000 );}var misdnConfig = {	detectCards: function(){		parent.astmanEngine.run_tool(asterisk_guiMisdn_scan, function(t) { // run 'misdn-init scan'			var loadScanHtml = function(){				new Ajax.Request("./scan.html", {					method : "get",					asynchronous : true,					onComplete : function(c){						try{							var records = c.responseText.split("\n");							var span=1, ns;							for(var mn = 0; mn < records.length; mn++) {								if(records[mn].contains('card')) { /* assume b410p */									CARDS++; ns = (span + 3);									var csp = 1;									while(span <= ns) {										if(!PORTS[span]) {											PORTS[span] = {}; 											PORTS[span]['card'] = records[mn];											PORTS[span]['cardno'] = CARDS;											PORTS[span]['card_portno'] = csp;										} span++; csp++;									}								}							}							if(CARDS == 0) {								_$('errmsg').innerHTML = "No mISDN Cards detected (found 0 spans)!";								_$('errmsg').style.display = '';								_$('div_misdncardstable').style.display = 'none';								_$('div_misdnTrunkstable').style.display = 'none';								gui_feedback("No mISDN Cards found !!");								return false;							}							_$('b410p_cards').innerHTML = "<B>"+CARDS+"</B> B410p Card(s) detected !";						}catch(err){							_$('errmsg').innerHTML = "No mISDN Cards detected (found 0 spans)!";							_$('errmsg').style.display = '';							_$('div_misdncardstable').style.display = 'none';							gui_feedback("No mISDN Cards found !!");							return false;						}						finally{							misdnConfig.readCardsConfiguration(); // reads and parses misdn-init.conf						}												return true;					},					onFailure : function(){						gui_alert("For some reason, I could not grab scan.html, is the misdn-init tool installed?");						return false;					}				});			};			setTimeout( function(){loadScanHtml();} , 1000); // leave some time for 'misdn-init scan' to generate scan.html		});	},	readCardsConfiguration: function(){		var parseMisdnInit = function(c){			/*			// gui expects misdn-init.conf in the following format			card = 1,0x4			te_ptp = 1,2,3,4			poll = 128			dsp_options = 0			debug = 0 			*/			var records = c['general'] ;			var a,b,c,d;			for(var t=0; t < records.length; t++ ){				if( records[t].beginsWith('nt_ptp') || records[t].beginsWith('nt_ptmp') || records[t].beginsWith('te_ptp') || records[t].beginsWith('te_ptmp')  || records[t].beginsWith('te_capi_ptp') || records[t].beginsWith('te_capi_ptmp') ){					a = records[t].split("=")[0];					b = records[t].split("=")[1];					if(!b.length){ continue; }					if( b.contains(",") ){						c = b.split(",");						c.each( function(d) {							PORTS[d]['portType'] = a.strip(); // set port type of port d to a						});					}else{						PORTS[b]['portType'] = a.strip(); // set port type of port d to a					}				}				if(records[t].beginsWith('option=')){ // 'option=1,master_clock' or 'option=2,ais,nocrc4'					var a = ASTGUI.parseContextLine.read(records[t]); // a[1] is '1,master_clock' or '2,ais,nocrc4'					var b = a[1].split(',')[0]; // b is is the misdn port numer					var c = records[t].split(',').slice(1).join(','); // 'master_clock' or 'ais,nocrc4'					PORTS[b]['option'] = c ;				}			}			// done parsing misdn-init.conf			// show table			parent.astmanEngine.run_tool("touch /etc/asterisk/applymisdn.conf", function(t){}) // just to make sure it is there later when we write to it			try{				misdnConfig.showMisdnConfiginTable();			}catch(err){			}finally{				load_mISDNtrunks();			}		};		var somefunction = function(){			var c = 0;			var uri = build_action('delcat', c, 'general', "", ""); c++;			uri += build_action('newcat', c, 'general', "", ""); c++;			uri += build_action('update', c, 'general', '#include "../misdn-init.conf" ;', ''); c++;			makerequest('u', "misdninit_guiRead.conf", uri, function(t) { config2json("misdninit_guiRead.conf", 0, parseMisdnInit); });		}();	},	showMisdnConfiginTable: function(){		var tbl = _$('misdntable') ;		var add_fRow = function(){			var newRow = tbl.insertRow(-1);			newRow.className = "frow";			var newCell0 = newRow.insertCell(0);			newCell0.innerHTML = "Card/Port";				var newCell1 = newRow.insertCell(1);			newCell1.innerHTML = "Mode";				var newCell2 = newRow.insertCell(2);			newCell2.innerHTML =  "";		};		var addrow_totable = function(port_no){			var sno = tbl.rows.length + 1;			var newRow = tbl.insertRow(-1);			newRow.id = 'misdntable_r'+port_no;			newRow["port_no"] = port_no;			if( PORTS[port_no]['edited'] ){ newRow.style.background = "#C9AAAA"; }			var newCell0 = newRow.insertCell(0);			newCell0.innerHTML = PORTS[port_no]['cardno'] + "/" + PORTS[port_no]['card_portno'];			newCell0.align = "center";			var newCell1 = newRow.insertCell(1);			newCell1.innerHTML = pmode_defs[PORTS[port_no]['portType']] ;			newCell1.align = "center";			var newCell2 = newRow.insertCell(2);			newCell2.innerHTML = '<input type=button value="Edit" onclick="edit_port(' + port_no  + ')">';			newCell2.align = "center";		};		ASTGUI.domActions.clear_table(tbl);		add_fRow();		for( var k in PORTS ){ if( PORTS.hasOwnProperty(k) ){ addrow_totable(k); }}	}};function edit_port(p){	if( !PORTS[p].hasOwnProperty('option') ) { PORTS[p]['option'] = ''; }	ASTGUI.selectbox.selectOption( _$('editport_option'), PORTS[p]['option'] );	ASTGUI.selectbox.selectOption( _$('editport_type'), PORTS[p]['portType'] );	_$('editport_label').innerHTML = PORTS[p]['cardno'] + "/" + PORTS[p]['card_portno'] ;	_$('edit_port').style.display = "";	_$('edit_port')['port_editing'] = p;}function canelPortInfo(){	_$('edit_port').style.display = "none";}function updatePortInfo(){	var p = _$('edit_port')['port_editing'];	PORTS[p]['portType'] = _$('editport_type').value;	if(  _$('editport_option').value == 'master_clock' ){ // condition to make sure none of the other spans on this card is a master_clock		(function (){			var this_card = PORTS[p]['cardno'] ;			var other_ports_onThisCard = [];			for(var d in PORTS){if( PORTS.hasOwnProperty(d) && PORTS[d]['cardno'] == this_card && d != p ){					other_ports_onThisCard.push(d);			}}			for(var y=0; y < other_ports_onThisCard.length ; y ++){				var k = other_ports_onThisCard[y];				if( PORTS[k].hasOwnProperty('option') && PORTS[k]['option'] == 'master_clock'){PORTS[k]['option'] = ''; }			}		})(); 	}	PORTS[p]['option'] = _$('editport_option').value ;	PORTS[p]['edited'] = true;	misdnConfig.showMisdnConfiginTable();	_$('edit_port').style.display = "none";	_$('misdntable_r'+p).style.background = "#C9AAAA";}function reloadpage(){ window.location.href = window.location.href;}function generate_applyMisdn(){ //save the PORTS object with some default options into /etc/misdn-init.conf via /etc/asterisk/applymisdn.conf	 // first generate the output into [general] section of applymisdn.conf	var uri = '', c=0, d= 'general', e, addedcards = {};	var pmode_ports = {'te_ptp':[] , 'te_ptmp':[] ,'te_capi_ptp':[] , 'te_capi_ptmp':[] ,'nt_ptp':[] , 'nt_ptmp': [] };	uri += build_action('delcat', c, d , "", ""); c++;	uri += build_action('newcat', c, d , "", ""); c++;	for( var k in PORTS ){ if( PORTS.hasOwnProperty(k) ){ 		e = PORTS[k]['card'].split('=')[1] ;

⌨️ 快捷键说明

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