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

📄 feditor.html.svn-base

📁 asterisk-gui asterisk网关接口编程 控制asterisk的接口
💻 SVN-BASE
字号:
<!-- * Asterisk-GUI	-	an Asterisk configuration interface * * File Editor - Edit asterisk config files from the GUI * * 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 global_contextBeingEdited = ""; var global_fileBeingEdited = "";function show_createfile(){	_$('New_FileName').value = "";	var f = _$('createfile_button');	var tmp_left = f.offsetLeft -1;	var tmp_top = f.offsetTop -1 ;	var tmp_parent = f;	while(tmp_parent.offsetParent != document.body){		tmp_parent = tmp_parent.offsetParent;		tmp_left += tmp_parent.offsetLeft;		tmp_top += tmp_parent.offsetTop;	}	_$('CreateFile').style.left = tmp_left;	_$('CreateFile').style.top = tmp_top ;	_$('CreateFile').style.display = "" ;	_$('New_FileName').focus();}function create_file(){	var fn = _$('New_FileName').value;	if( fn.substr( (fn.length - 5), fn.length) != ".conf") { fn = fn+'.conf'; }	parent.astmanEngine.run_tool( "touch " + asterisk_configfolder + fn, callback = function() {		cancel_file();		gui_feedback("Created file: '" + fn + "'",'blue');		ASTGUI.selectbox.append(_$('filenames'),fn, fn);		_$('filenames').selectedIndex = _$('filenames').options.length -1 ;		loadfile();	});}function cancel_file(){	_$('CreateFile').style.display = "none" ;}function delete_context(){	if(!confirm("Are you sure you want to delete the selected context ?")){ return true; }	var uri = build_action('delcat', 0, global_contextBeingEdited ,"", "");	makerequest('u', global_fileBeingEdited, uri , function(t) {			_$('AddContext').style.display = "none";			_$('div_editcontext').style.display = "none"; 			global_contextBeingEdited = "";			gui_feedback('Context Deleted','blue');			config2json( global_fileBeingEdited, 0, fileparsed );		});}function cancel_context(){	global_contextBeingEdited = "";	_$('div_editcontext').style.display = "none";}function update_context(){ // rename from global_contextBeingEdited to $('context_edited').value	var uri = build_action('renamecat', 0, global_contextBeingEdited ,"", _$('context_edited').value );	makerequest('u',global_fileBeingEdited, uri, function(t) {			_$('AddContext').style.display = "none";			_$('div_editcontext').style.display = "none"; 			global_contextBeingEdited = "";			gui_feedback('Context Updated','blue');			config2json( global_fileBeingEdited, 0, fileparsed );		});}function resetmainscreen(){	top._$('mainscreen').width= 540;}function localajaxinit() {	var adjust_toScreen = function(){		var i = ASTGUI.displayHeight(); 		_$('file_output').style.height = (i -75); 	}	ASTGUI.events.add( window , 'resize', adjust_toScreen);	top._$('mainscreen').width= 798;	setWindowTitle("File Editor");	load_recordedfiles();	showdiv_statusmessage();	_$('message_text').innerHTML ="Saving Changes...";	_$('status_message').style.display ="none";	ASTGUI.events.add( _$('filenames') , 'change' , loadfile ) ;	parent.loadscreen(this);}function load_recordedfiles(){	parent.astmanEngine.run_tool(asterisk_guiListFiles + " " + asterisk_configfolder, callback = function() { 	var opt = { method: 'get', asynchronous: true,		onComplete: function(originalRequest){			// Add config files to the list of files			var recfiles = originalRequest.responseText.split("\n") ;			ASTGUI.selectbox.append(_$('filenames'),"Config Files", "");			_$('filenames').options[0].style.fontWeight = "bold";			var file_name;			for( var i =0 ; i < recfiles.length ; i++){				if( typeof recfiles[i] == "undefined"  || recfiles[i] == "" ){					continue;				}				recfiles[i] = recfiles[i].replace(/^\s*|\s*$/g,'') ;				if( recfiles[i] == "" ){ continue; }				if( recfiles[i].substr( (recfiles[i].length - 5), recfiles[i].length) != ".conf") { continue; }				file_name = recfiles[i].stripTags() ;				ASTGUI.selectbox.append(_$('filenames'),file_name, file_name);			}		},		onFailure: function(t) { alert("Config Error: " + t.status + ": " + t.statusText); }	};	opt.parameters="";	var tmp = new Ajax.Request(asterisk_guiSysInfo_output , opt);	});}function loadfile(){	if( !_$('filenames').value ) return;	global_fileBeingEdited = _$('filenames').value ;	_$('AddContext').style.display = "none";	_$('div_filename').style.display = "";	_$('CurrentFileName').innerHTML = global_fileBeingEdited;	config2json( global_fileBeingEdited, 0, fileparsed ) ;}function showeditcontext(event){	var t = (event.srcElement)?event.srcElement:this;	_$('AddContext').style.display = "none";	_$('div_editcontextContent').style.display = "none";	//move div_editcontext ontop of h_id and display it	var h_id = t.getAttribute('id') ;	global_contextBeingEdited = t.getAttribute('context');	_$(h_id).insertBefore(_$('div_editcontext'), null );	_$('div_editcontext').style.display = "";	var f = t.getAttribute('context')	_$('context_edited').value = f ;	_$('context_edited').size = f.length;	_$('context_edited').focus();}function showeditcontextContent(event){	var t = (event.srcElement)?event.srcElement:this;	_$('AddContext').style.display = "none";	_$('div_editcontext').style.display = "none";	var i_id = t.getAttribute('id') ;	global_contextBeingEdited = t.getAttribute('context');		_$(i_id).insertBefore(_$('div_editcontextContent'), null );	_$('div_editcontextContent').style.display = "";		_$('context_Content').value = t.CONTEXTCONTENT ;	_$('context_Content').rows = t.CONTEXTCONTENT_ROWS ;	//_$('context_edited').size = f.length;	_$('context_Content').focus();}function cancel_contextContent(){	global_contextBeingEdited = "";	_$('div_editcontextContent').style.display = "none";}function update_contextContent(){	_$('status_message').style.display ="" ;	_$('bg_transparent').style.display ="" ;	try{	var chs = new listOfActions(); 	chs.filename(global_fileBeingEdited);	var c = 0;	chs.build_action('delcat', c , global_contextBeingEdited ,"", "");	chs.build_action('newcat', c , global_contextBeingEdited, "", "");	var r = 0 , posofeq, firstpart, secondpart ;	var u = _$('context_Content').value.split("\n") ;	for( var f=0; f < u.length ; f++ ){		// in u[f] find 'first occurance of =' and split it there		posofeq = u[f].indexOf("=");		if( posofeq == -1){ continue; }		firstpart = u[f].substring(0, posofeq );		secondpart = u[f].substring( posofeq+1 );		chs.build_action('append', c, global_contextBeingEdited, firstpart, secondpart );	}	}catch(err){		_$('status_message').style.display = 'none';		_$('bg_transparent').style.display = 'none';	}	var after = function(){		_$('div_editcontextContent').style.display = "none"; 		global_contextBeingEdited = "";		gui_feedback('Context Content Updated','blue');		config2json( global_fileBeingEdited, 0, fileparsed );	};	chs.callActions(after);}function fileparsed(b){		_$('temp_holding').insertBefore(_$('div_editcontext'), null );	_$('temp_holding').insertBefore(_$('div_editcontextContent'), null );	_$('div_editcontext').style.display = "none";	_$('div_editcontextContent').style.display = "none";	//alert(b);	var zz = _$('file_output');	var c = b;	var p = "";	var rows ;	while(zz.firstChild){		zz.removeChild(zz.firstChild);	}	for( var d in c ){		if ( c.hasOwnProperty(d) ) {			var h = document.createElement("div");			var h_id = "context_" + d;			h.setAttribute("id",h_id);			h.setAttribute("context",d);			h.align="left";			h.style.backgroundColor = '#4D5423';			h.style.color = '#FFFFFF';			h.style.marginTop = '15px' ;			h.style.width = '95%';			h.style.fontFamily = "'trebuchet ms',helvetica,sans-serif";			h.style.fontSize = '10pt' ;			h.style.padding = '2px 2px 3px 3px' ;			h.innerHTML = "&nbsp;&nbsp;[" + d + "]";			zz.appendChild(h);			//Rico.Corner.round(h_id, {compact:true});			ASTGUI.events.add( _$(h_id) , 'click', showeditcontext );			var i = document.createElement("div");			var i_id = "contextContent_" + d;			i.setAttribute("id", i_id );			i.setAttribute("context",d);			i.align= "left";			i.style.backgroundColor = '#E0E6C4';			i.style.marginTop = '5px' ;			i.style.width = '95%';			i.style.fontSize = '9pt' ;			i.style.padding = '2px 2px 3px 3px' ;			i.style.fontFamily = 'courier' ;			var temp_contextContent = "" ;			rows = 0;			if(c[d].length == 0){i.innerHTML += "&nbsp;&nbsp;<BR>" ;}			for(var r=0; r < c[d].length ; r++ ){				p = unescape( c[d][r] );				i.innerHTML += "&nbsp;&nbsp;" + p.replace(/</g, '&lt;').replace(/>/g, '&gt;') + "<BR>" ;				temp_contextContent += p + "\n";				rows++;			}						i.CONTEXTCONTENT = temp_contextContent ;			i.CONTEXTCONTENT_ROWS = rows ;			zz.appendChild(i);			//Rico.Corner.round("contextContent_" + d, {compact:true});			ASTGUI.events.add( _$(i_id) , 'click', showeditcontextContent );		}	}	_$('status_message').style.display = 'none';	_$('bg_transparent').style.display = 'none';}function stopBubble(b) {    if (!b) { b = window.event; }    b.cancelBubble = true;}function show_addcontext(){	_$('New_ContextName').value = "";		var acb = _$('AddContextButton');	var tmp_left = acb.offsetLeft -1;	var tmp_top = acb.offsetTop -1 ;	var tmp_parent = acb;	while(tmp_parent.offsetParent != document.body){		tmp_parent = tmp_parent.offsetParent;		tmp_left += tmp_parent.offsetLeft;		tmp_top += tmp_parent.offsetTop;	}	_$('AddContext').style.left = tmp_left;	_$('AddContext').style.top = tmp_top ;	_$('AddContext').style.display = "" ;	_$('New_ContextName').focus();}function cancel_addcontext(){ _$('AddContext').style.display = "none"; _$('New_ContextName').value = "";}function add_context(){	var uri = build_action('newcat', 0, _$('New_ContextName').value ,"", "");	makerequest('u',global_fileBeingEdited,uri, function(){			cancel_addcontext(); 			global_contextBeingEdited = "";			gui_feedback('New Context Added','blue');			config2json( global_fileBeingEdited, 0, fileparsed );	});}</script><body id="foo" onload="localajaxinit()"  bgcolor="FFFFFF" onunload="resetmainscreen();"><div style="font-size : 12px; padding : 4px 6px 4px 6px; border-style : solid none solid none; border-top-color : #BDC7E7; border-bottom-color : #182052; border-width : 1px 0px 1px 0px; background-color : #ef8700; color : #ffffff;">	<span style="margin-left: 4px;font-weight:bold;">File Editor</span>	<span style="cursor: pointer; cursor: hand;" onclick="window.location.href=window.location.href;" >&nbsp;<img src="images/refresh.png" title=" Refresh " border=0 >&nbsp;</span>	<span><select id="filenames" class="input9"></select></span>	&nbsp;&nbsp;	<input id="createfile_button" type=button value="Create NewFile" class="input8" onclick="show_createfile();"></div><div style="display:none; font-size:14px; font-weight:bold; font-family:helvetica,sans-serif,'trebuchet ms'; padding : 6px 0px 6px 10px;" id="div_filename">	<span id="CurrentFileName"></span>&nbsp;&nbsp;	<a href=# class="splbutton" onclick="show_addcontext();" id="AddContextButton">Add Context</a></div><div id="file_output" style="height:475px;width= 770px; overflow :auto;" align="center"></div><span id="temp_holding"></span><span id="div_editcontext" style="display:none; z-index:1000; background-color : #4D5423" onclick="stopBubble(event)">	<input id="context_edited" size=15 class="input8">&nbsp;	<input id="save_context" type=button value="Save" class="input8" onclick="update_context();">&nbsp;	<input id="cancel_context" type=button value="Cancel" class="input8" onclick="cancel_context();">&nbsp;	<input id="delete_context" type=button value="Delete" class="input8" onclick="delete_context();"></span><div id="div_editcontextContent" style="display:none; z-index:1001; background-color : #E0E6C4"  onclick="stopBubble(event)">	<table>	<tr>	<td valign="top" align="right">		<input id="save_contextContent" type=button value="Save" class="input8" onclick="update_contextContent();">&nbsp;		<input id="cancel_contextContent" type=button value="Cancel" class="input8" onclick="cancel_contextContent();">	</td>	</tr>	<tr>		<td>	<textarea id="context_Content" rows=1 cols=95 class="input9"></textarea>	</td>	</tr>	</table></div><div id="AddContext" style="display:none; position:absolute; z-index:1004; background-color : #C1D7EC; padding : 6px 6px 6px 10px;">Add New Context : <input id="New_ContextName" size=20 class="input9">&nbsp;		<input type="button" value="Add" style="font-size: 8pt; border:1px solid; padding : 0px 0px 0px 0px;" onclick="add_context();">&nbsp;		<input type="button" value="Cancel" style="font-size: 8pt; border:1px solid; padding : 0px 0px 0px 0px;" onclick="cancel_addcontext();"></div><div id="CreateFile" style="display:none; position:absolute; z-index:1005; background-color : #C1D7EC; padding : 6px 6px 6px 10px;">	<table>	<tr>	<td colspan=2 align=center><B>Create New ConfigFile</B></td>	</tr>	<tr>	<td>New FileName :</td>		<td>	<input id="New_FileName" size=20 class="input9">&nbsp; 			<input type="button" value="Add" style="font-size: 8pt; border:1px solid; padding : 0px 0px 0px 0px;" onclick="create_file();">&nbsp;			<input type="button" value="Cancel" style="font-size: 8pt; border:1px solid; padding : 0px 0px 0px 0px;" onclick="cancel_file();"><BR>		</td>	</tr>	<tr>	<td></td>		<td>&nbsp;(Ex: newfile.conf)</td>	</tr>	</table></div><div id="bg_transparent" STYLE="display:none; position: absolute; left: 0; top: 24; width:100%; height:100%;  background-color:#EFEFEF; -moz-opacity:.50;opacity:.50; border-width: 1px; border-color: #EFEFEF; border-style: solid; z-index:1002"></div></body>

⌨️ 快捷键说明

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