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

📄 timerules.html.svn-base

📁 asterisk-gui asterisk网关接口编程 控制asterisk的接口
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
<!-- * Asterisk-GUI	-	an Asterisk configuration interface * * Time Based Rules  * * Copyright (C) 2006-2007, Digium, Inc. * * 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><link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" /><script>var timebasedrules = {};var voicemenus = [];var user_extens = [];var isNewRule;var NOW_EDITING ;function clear_table(){	var t = _$('tbrulesTable') ;	for( var i=0; i < t.rows.length; ){ t.deleteRow(i); }}function showlist_of_rules(){	var t;	for( t in timebasedrules ){		if(timebasedrules.hasOwnProperty(t)){ addrow_totable( timebasedrules[t],t ); }	}	var u = _$('tbrulesTable');	if( u.rows.length == 0 ){		_$('table_one').style.display="none";		var newRow = u.insertRow(-1);		var newCell0 = newRow.insertCell(0);		newCell0.align = "center";		newCell0.innerHTML = "<BR><I> No Previous Time Rules found !!</I> <BR><BR>" +			"Please click on the 'New Time Rule' button<BR> to define a New Time Based Rule<BR><BR>" ;	}}function addrow_totable(k,l){	// sno, rulename, desc, options	var newRow = _$('tbrulesTable').insertRow(-1);	newRow.style.backgroundColor='#FFFFFF';	newRow.onmouseover= function(){ this.style.backgroundColor='#F9F0D1'; };	newRow.onmouseout=function(){ this.style.backgroundColor='#FFFFFF'; };		var newCell0 = newRow.insertCell(0);	newCell0 .innerHTML =_$('tbrulesTable').rows.length  ;	newCell0 .width = 35;	newCell0.align = "center";		var newCell1 = newRow.insertCell(1);	newCell1 .innerHTML = k.rulename ;	newCell1.align = "left";		var newCell2 = newRow.insertCell(2);	newCell2 .innerHTML = "<input type=\"button\" onclick='edit_form(\""+ l+ "\")'  value=\"Edit\" class=\"splbutton\">&nbsp;"  +	"<input type=\"button\" onclick='delete_rule(\""+ l+ "\")'  value=\"Delete\"  class=\"splbutton\">" ;	newCell2.align = "center";	newCell2.width = 115;}function localajaxinit(){	setWindowTitle("File Editor");	parent.loadscreen(this);	config2json('users.conf', 1, get_users) ;}function get_users(m){	var n =  m ;	var l;	for( l in n ){		if(n.hasOwnProperty(l)){			if( l =='general'){ continue;} // ignore 'general' context			if ( n[l]['context'] && unescape(n[l]['context']) == asterisk_guiTDPrefix + l ) {				continue;			}			if( !n[l]['trunkstyle'] ){ // all entries from users.conf other than trunks				var p = {};				p.username = (n[l]['fullname'])? unescape(n[l]['fullname'])+" ("+l+")" : "Local Extension ("+l+")";				p.usercontextstring = "default,"+l+",1" ;				user_extens.push(p);			}		}	}	config2json('extensions.conf', 0, get_timerules) ;}function get_timerules(b){	var c,d,e,t,p,q;	c =  b ;	var found = 0;	var get_menuname = function(c){		var r,s;		for( r =0; r < c.length; r++){			s = unescape(c[r]);			if( s.match('comment=') ){return "VoiceMenu " + s.split('comment=')[1];}		}		return null;	}		var get_ringGroupName = function(c){		var r,s;		for( r =0; r < c.length; r++){			if( c[r].match('gui_ring_groupname=') ){return "RingGroup " + c[r].split('gui_ring_groupname=')[1];}		}		return b;	}	for( d in c ){		if(c.hasOwnProperty(d)){			if( d == TIMERULES_CATEGORY ){ e = c[d]; found = 1;}			if( d.substr(0,17) == 'voicemenu-custom-'){				p = {};				q = get_menuname(c[d]);				p.menuname = (q)?q:d;				p.menucontextstring = d+",s,1";				voicemenus.push(p);				continue;			}			if( d.substr(0,17) == 'ringroups-custom-'){				ASTGUI.selectbox.append(_$('dest_match'), get_ringGroupName(c[d]) , d+",s,1");				ASTGUI.selectbox.append(_$('dest_nomatch'), get_ringGroupName(c[d]) , d+",s,1");			}		}	}	if(!found){ // If Time Based Rules Context Not Found - add one and reload		var as = build_action('newcat', 0, TIMERULES_CATEGORY, "", "") ;		makerequest( 'u','extensions.conf',as, function(){window.location.href=window.location.href;} );		return;	}	for( t=0; t < e.length; t++) {		if( unescape(e[t]).match("NoOp") ){ parsetimeconditions(e,t); }	}	showlist_of_rules();	set_selectboxes();}function parsetimeconditions(a,b){ // a is the [timebasedrules] array, b is the index/*	timebasedrules[1] = {};	timebasedrules[1].rulename =  ; // Ex: July4	timebasedrules[1].ruleconditons = {} ;	timebasedrules[1].ruleconditons.fromhour = '' ;	timebasedrules[1].ruleconditons.fromminutes = '' ;	timebasedrules[1].ruleconditons.tohour = '' ;	timebasedrules[1].ruleconditons.tominutes = '' ;	timebasedrules[1].ruleconditons.from_wday = '' ;	timebasedrules[1].ruleconditons.to_wday = '' ;	timebasedrules[1].ruleconditons.from_mday = '' ;	timebasedrules[1].ruleconditons.to_mday = '' ;	timebasedrules[1].ruleconditons.from_month = '' ;	timebasedrules[1].ruleconditons.to_month = '' ;	timebasedrules[1].ifmatch_goto =  ;	timebasedrules[1].ifnomatch_goto =  ;	console.log( unescape( a[b] ) ); // exten=3,1,NoOp(SomeTimeRule)	console.log( unescape( a[b+1] ) ); // exten=3,n,GotoIfTime(04:00-11:59|mon-sun|1-31|jan-dec?voicemenu-custom-1,s,1)	console.log( unescape( a[b+2] ) ); // exten=3,n,Goto(default,6001,1)*/	var m,n,o;	m = unescape(a[b]);	n = unescape(a[b+1]);	o = unescape(a[b+2]);	var s,t,u,v,w,x,y ;	s = m.split('exten=')[1].split(',')[0]; // s is the extension in the context - 3 in the above case 	timebasedrules[s] = {};	t = m.split('NoOp')[1].substr(1);	t = t.substr(0, t.length-1); // t is the name of the timebased rule - SomeTimeRule in the above case	timebasedrules[s].rulename = t ; 	timebasedrules[s].ruleconditons = {} ;	u = n.split('GotoIfTime')[1].substr(1);	u = u.substr(0, u.length-1); // u is the timeconditon string '04:00-11:59|mon-sun|1-31|jan-dec?voicemenu-custom-1,s,1' in the above case	v = u.split('|'); // v[0] is timeconditions '04:00-11:59', v[1] is dayofweek 'mon-sun', v[2] is dayofmonth '1-31', v[3] is 'jan-dec?voicemenu-custom-1,s,1'	if(v[0]=='*'){		timebasedrules[s].ruleconditons.fromhour = '00' ;		timebasedrules[s].ruleconditons.fromminutes = '00' ;		timebasedrules[s].ruleconditons.tohour = '23' ;		timebasedrules[s].ruleconditons.tominutes = '59' ;	}else{		timebasedrules[s].ruleconditons.fromhour = v[0].split('-')[0].split(':')[0] ;		timebasedrules[s].ruleconditons.fromminutes = v[0].split('-')[0].split(':')[1] ;		timebasedrules[s].ruleconditons.tohour = v[0].split('-')[1].split(':')[0] ;		timebasedrules[s].ruleconditons.tominutes = v[0].split('-')[1].split(':')[1] ;	}	if(v[1]=='*'){		timebasedrules[s].ruleconditons.from_wday = 'sun' ;		timebasedrules[s].ruleconditons.to_wday = 'sat' ;	}else{		timebasedrules[s].ruleconditons.from_wday = v[1].split('-')[0] ;		timebasedrules[s].ruleconditons.to_wday = v[1].split('-')[1] ;	}	if(v[2]=='*'){		timebasedrules[s].ruleconditons.from_mday = '01' ;		timebasedrules[s].ruleconditons.to_mday = '31' ;	}else{		timebasedrules[s].ruleconditons.from_mday = v[2].split('-')[0] ;		timebasedrules[s].ruleconditons.to_mday = v[2].split('-')[1] ;	}	w = v[3].split("?")[0]; //jan-dec	x = v[3].split("?")[1]; //voicemenu-custom-1,s,1	if(w=='*'){		timebasedrules[s].ruleconditons.from_month = 'jan' ;		timebasedrules[s].ruleconditons.to_month = 'dec' ;	}else{		timebasedrules[s].ruleconditons.from_month = w.split('-')[0] ;		timebasedrules[s].ruleconditons.to_month = w.split('-')[1] ;	}	y = o.split('Goto')[1].substr(1);	y = y.substr(0, y.length-1) ; //default,6001,1	timebasedrules[s].ifmatch_goto = x ;	timebasedrules[s].ifnomatch_goto = y ;}function set_selectboxes(){	var tostring = function (s){		return (s<10)?"0"+String(s):s;	}	var updateselect = function( el,start,end ){		for( var s =start; s< end; s++){			s = tostring(s);			ASTGUI.selectbox.append(el,s,s);		}		el.selectedIndex = -1;	}	var update_select_menus = function(el){		var g;		for ( g=0; g <voicemenus.length; g++){			ASTGUI.selectbox.append(el,voicemenus[g].menuname,voicemenus[g].menucontextstring);		}		for ( g=0 ; g <user_extens.length; g++){			ASTGUI.selectbox.append(el,user_extens[g].username,user_extens[g].usercontextstring);		}		for( g in timebasedrules ){ if(timebasedrules.hasOwnProperty(g)){			ASTGUI.selectbox.append( el, "TimeRule -- " + timebasedrules[g].rulename , TIMERULES_CATEGORY + ',' + g + ',1' );		}}	}	updateselect(_$('startime_hour'), 0,24); 	updateselect(_$('endtime_hour'), 0,24);	updateselect(_$('startime_minute'), 0,60);	updateselect(_$('endtime_minute'), 0,60);

⌨️ 快捷键说明

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