pari: trunk r483 - /trunk/config/record.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Sun Mar 25 13:49:27 MST 2007


Author: pari
Date: Sun Mar 25 15:49:27 2007
New Revision: 483

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=483
Log:
Updated Record page - no longer uses gui_custommenus.conf to show the list of recorded sound files 

Modified:
    trunk/config/record.html

Modified: trunk/config/record.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/record.html?view=diff&rev=483&r1=482&r2=483
==============================================================================
--- trunk/config/record.html (original)
+++ trunk/config/record.html Sun Mar 25 15:49:27 2007
@@ -25,12 +25,113 @@
 <script src="scripts/tooltip.js"></script>
 <link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
 <link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
-
 <script>
-var callbacks = new Object;
-var rfilescallbacks = new Object;
-var custom_voicemenusfile = "gui_custommenus.conf";
 var focus_fields = new Array('newvmenu_name','newvmenu_ext');
+var callbacks = {};
+var record_path = '/var/lib/asterisk/sounds/record/';
+
+function localajaxinit(){
+	showdiv_statusmessage();
+	setWindowTitle("Record a Menu");
+	for (var x =0; x < focus_fields.length; x++ ) {
+		_$(focus_fields[x]).onfocus = function(){this.className = 'input8_hilight';}
+		_$(focus_fields[x]).onblur = function(){this.className = 'input8';}
+	}
+	_$('message_text').innerHTML = "Please wait while the system <BR> Calls the specified Extension ... ";
+	parent.astmanEngine.config2list("users.conf", _$('newvmenu_ext'), new Array, callbacks);
+}
+
+function showlist_of_files(){
+	var k = _$('rec_files').innerHTML ;
+	var recfiles = k.split("<br>") ;
+
+	clear_table();
+
+	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; }
+		addrow_totable( recfiles[i].stripTags(), i );
+	}
+
+	var _rft = _$('recfilesTable') ;
+	if( _rft.rows.length == 0 ){
+		_$('table_one').style.display="none";
+		var newRow = _rft.insertRow(-1);
+		var newCell0 = newRow.insertCell(0);
+		newCell0.align = "center";
+		newCell0.innerHTML = "<BR><I> No Recorded menus found !!</I> <BR><BR>" +
+			"Please click on 'Record a new Voice Menu' button to record one.<BR><BR>" ;
+	}
+	parent.loadscreen(this);
+}
+
+function clear_table(){
+	var _rft = _$('recfilesTable') ;
+	for( var i=0; i <  _rft.rows.length; ){
+		 _rft.deleteRow(i);
+	}
+}
+
+function addrow_totable(filename, i){
+	var newRow = _$('recfilesTable').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 = i+1 ;
+	newCell0.width = 35;
+	newCell0.align = "center";
+	
+	var newCell1 = newRow.insertCell(1);
+	newCell1.innerHTML = filename ;
+	newCell1.width = 180;
+	
+	var newCell2 = newRow.insertCell(2);
+	newCell2.innerHTML = "<input type='button' value='Record Again' onclick='record_existing(\"" + filename + "\")' class='splbutton'> &nbsp; <input type=button value='Play' onclick='play_existing(\"" + filename.substr(0,(filename.length - 4) )+ "\")' class='splbutton'> &nbsp; <input type='button' onclick='delete_sounds(\""+ filename + "\")'  value='Delete' class='splbutton'>" ;
+	newCell2.align = "center";
+}
+
+function show_record(){
+	_$('bg_transparent').style.display = "";
+	_$('recordnew_content').style.display = "";
+	_$('newvmenu_name').focus();
+}
+
+function hide_record(){
+	_$('bg_transparent').style.display = "none";
+	_$('recordnew_content').style.display = "none";
+}
+
+callbacks.format = function(t) {
+	if ((t.name == 'general'))
+		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.loaded = function(){
+	parent.astmanEngine.run_tool("sh /etc/asterisk/gui_sysinfo", callback = function() { 
+		var opt = { method: 'get', asynchronous: true,
+			onComplete: function(originalRequest){
+				_$('sysinfohtml').innerHTML = originalRequest.responseText;
+				showlist_of_files();
+				parent.loadscreen(this);
+			},
+			onFailure: function(t) { alert("Config Error: " + t.status + ": " + t.statusText); }
+		};
+		opt.parameters="";
+		var tmp = new Ajax.Request("./bkps/sysinfo_output.html", opt);
+	});
+}
 
 function play_existing(filename){
 	var extension = prompt("Please enter an Extension on which you want to listen to the file",""); 
@@ -44,100 +145,11 @@
 	var tmp = new Ajax.Request("../../rawman", opt);
 }
 
-function delete_sounds(filename){
-	if ( confirm("Delete recorded file "+ filename +" ?") ){
-		var opt = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function(t) { 
-				_$('status').innerHTML = " <I> Delete Request Successfull ! </I>";
-				// remove file name from stored config file
-				var opt2 = {
-					method: 'get',
-					asynchronous: true,
-					onSuccess: function() { 
-						// Remove this TR
-						var delete_id = "delete_" + filename;
-						var tableRow = _$(delete_id).parentNode.parentNode; //gets TR object
-						 var _trf = _$('table_recordefileslist');
-						for( var i=0; i <  _trf. rows.length; i++){
-							if  ( _trf. rows[i].id == tableRow.id){
-								_trf.deleteRow(i);
-								break;
-							}
-						}
-						_$('maintable').style.display = ( _trf. rows.length == 0) ? 'none' : '' ;
-						_$('no_rvmns').style.display = ( _trf. rows.length == 0) ? '': 'none' ;
-					},
-					onFailure: function(t) {
-						_$('status_message').style.display='none';
-						gui_alert("Config Error: " + t.status + ": " + t.statusText);
-					}
-				};	
-				var uri = build_action('delcat', 0, filename,"", ""); 
-				opt2.parameters = "action=updateconfig&srcfilename=" + encodeURIComponent(custom_voicemenusfile) + "&dstfilename=" + encodeURIComponent(custom_voicemenusfile) + uri;
-				var tmp2 = new Ajax.Request('../../rawman', opt2);
-			},
-			onFailure: function(t) {
-				gui_alert("Config Error: " + t.status + ": " + t.statusText);
-			}
-		};
-		opt.parameters="action=originate&channel=" + encodeURIComponent("Local/removefile@"+asterisk_guitools) + "&Variable=var1%3d"+ encodeURIComponent("/var/lib/asterisk/sounds/" + filename )+"&application=noop&timeout=60000";
-		var tmp = new Ajax.Request("../../rawman", opt);
-	}
-	else{
-		//
-	}
-}
-
-
-function save_recordedvmenuname( filename_torecord ){
-	// open custom_voicemenusfile
-	var opt2 = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) {	 
-			addrow_totable(filename_torecord);
-			var _trf = _$('table_recordefileslist'); 
-			_$('maintable').style.display = ( _trf.rows.length == 0) ? 'none' : '';
-			_$('no_rvmns').style.display = ( _trf.rows.length == 0) ? '':'none';
-		},
-		onFailure: function(t) { gui_alert("Config Error: " + t.status + ": " + t.statusText); }
-	};
-
-	var uri = build_action('newcat', 0, filename_torecord ,"", ""); 
-	opt2.parameters ="action=updateconfig&srcfilename=" + encodeURIComponent(custom_voicemenusfile) + "&dstfilename=" + encodeURIComponent(custom_voicemenusfile) + uri;
-	var tmp2 = new Ajax.Request("../../rawman", opt2);
-}
-
-function originate_recordrequest(should_save, newvmenu_ext, filename_torecord){
-	_$('status_message').style.display="";
-	var opt = {
-		method: 'get',
-		asynchronous: true,
-		onSuccess: function(t) { 
-			setTimeout( function(){ _$('status_message').style.display='none'; },sc_displaytime);
-			if ( t.responseText.indexOf("Originate successfully queued") == -1 ){
-					// Request Failed
-			}else{
-				// save the filename in a seperate file so that we can display the list of "Recorded file"
-				if(should_save =="YES"){
-					_$('status').innerHTML = " <I> Configuration Saved ! </I>";
-					_$("newvmenu_name").value="";
-					_$("format").selectedIndex =0;
-					_$("newvmenu_ext").selectedIndex= -1;
-					save_recordedvmenuname( filename_torecord);
-				}
-			}				
-		},
-		onFailure: function(t) {
-			_$('status_message').style.display='none';
-			gui_alert("Config Error: " + t.status + ": " + t.statusText);
-		}
-	};
-	opt.parameters ="action=originate&channel=Local/"+newvmenu_ext + "&context="+asterisk_guitools+"&exten=record_vmenu&priority=1&Variable=var1%3d"+ encodeURIComponent( filename_torecord );
-
-	var tmp = new Ajax.Request("../../rawman", opt);
+function record_existing(filename){
+	if(!confirm("Are you sure you want to Record over an existing Voicemenu?")){ return true; }
+	var extension = prompt("Please enter an Extension to call ","");
+	if(!extension){ return false; }
+	originate_recordrequest(extension, filename);
 }
 
 function record_new(){
@@ -156,189 +168,116 @@
 	}
 
 	var filename_torecord = _nm_n.value + "." + _$('format').value;
-	originate_recordrequest("YES", _nm_e.value, filename_torecord);
+	originate_recordrequest(_nm_e.value, filename_torecord);
 	hide_record();
 }
 
-function record_existing(filename){
-	if(!confirm("Are you sure you want to Record over an existing Voicemenu?")){ return true; }
-	var extension = prompt("Please enter an Extension to call ","");
-	if(!extension){ return false; }
-	originate_recordrequest("NO", extension, filename);
-}
-
-function addrow_totable(filename){
-	var newRow = _$('table_recordefileslist').insertRow(-1);
-	newRow.id = "row" + filename; 
-
-	var newCell1 = newRow.insertCell(0);
-	newCell1 .innerHTML = filename ;
-
-	var newCell2 = newRow.insertCell(1);
-	newCell2 .innerHTML = "<input "+ "type=\"button\"" + " id=\"recordover_" + filename +"\""+ " value='Record Again'"+  " onclick='record_existing(\"" + filename + "\")'>" 
-	+ "&nbsp;"+ "<input type=button id=\"play_"+filename+"\""+ " value='Play'" + " onclick='play_existing(\"" + filename.substr(0,(filename.length - 4) )+ "\")'>" 
-	+ "&nbsp;"+ "<input type=\"button\" id='delete_" + filename + "' onclick='delete_sounds(\""+ filename + "\")'  value=\"Delete\">" ;
-}
-
-callbacks.format = function(t) {
-	if ((t.name == 'general'))
-		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.loaded = function(){
-	parent.loadscreen(this);
-}
-
-rfilescallbacks.format = function(t) {
-	return t.name;
-}
-
-rfilescallbacks.loaded= function() {
-	var _rf = _$('recorded_files');
-	for (var i=0; i < _rf.length; i++){
-		addrow_totable( _rf.options[i].value);
-	}
-	_$('maintable').style.display = ( _rf.length == 0) ? 'none' : '';
-	_$('no_rvmns').style.display = ( _rf.length == 0) ? '' : 'none' ;
-}
-
-function show_record(){
-	_$('bg_transparent').style.display = "";
-	_$('recordnew_content').style.display = "";
-	_$('newvmenu_name').focus();
-}
-
-function hide_record(){
-	_$('bg_transparent').style.display = "none";
-	_$('recordnew_content').style.display = "none";
-}
-
-function localajaxinit() {
-	showdiv_statusmessage();
-	setWindowTitle("Record a Menu");
-	for (var x =0; x < focus_fields.length; x++ ) {
-		_$(focus_fields[x]).onfocus = function(){this.className = 'input8_hilight';}
-		_$(focus_fields[x]).onblur = function(){this.className = 'input8';}
-	}
-
-	var opt = { method: 'get', asynchronous: true, onComplete: check_filexists };
-	opt.parameters="action=getconfig&filename="+ custom_voicemenusfile ;
+function originate_recordrequest(newvmenu_ext, filename_torecord){
+	_$('status_message').style.display="";
+	var opt = {
+		method: 'get',
+		asynchronous: true,
+		onSuccess: function(t) { 
+			setTimeout( function(){ _$('status_message').style.display='none'; },sc_displaytime);
+			
+		},
+		onFailure: function(t) {
+			_$('status_message').style.display='none';
+			gui_alert("Config Error: " + t.status + ": " + t.statusText);
+		}
+	};
+	opt.parameters ="action=originate&channel=Local/"+newvmenu_ext + "&context="+asterisk_guitools+"&exten=record_vmenu&priority=1&Variable=var1%3d"+ encodeURIComponent( record_path + filename_torecord );
+
 	var tmp = new Ajax.Request("../../rawman", opt);
 }
 
-function check_filexists(originalRequest){
-	if( originalRequest.responseText.indexOf("Config file not found") != -1 ){
-		parent.astmanEngine.run_tool("/bin/touch /etc/asterisk/"+custom_voicemenusfile , function(){ load_page();} );
-		return;
-	}
-	load_page();
-}
-
-function load_page(){
-	parent.astmanEngine.config2list(custom_voicemenusfile, _$('recorded_files'), new Array, rfilescallbacks);
-	parent.astmanEngine.config2list("users.conf", _$('newvmenu_ext'), new Array, callbacks);
-	_$('message_text').innerHTML = "Please wait while the system <BR> Calls the specified Extension ... ";
-}
-
-function free_mem(){
-	if( navigator.userAgent.indexOf("MSIE") == -1 ){ return true; }
-	try{
-		purge( document.body );
-	} catch(e){ }
+function delete_sounds(filename){
+	if(!confirm("Delete selected file ?")){ return ; }
+	parent.astmanEngine.run_tool("/bin/rm -f "+ record_path + filename , callback=function(){
+		_$('status').innerHTML = " <I> Delete Request Successfull ! </I>";
+		window.location.href = window.location.href ;
+	});
 }
 </script>
-<body id="foo" onload="localajaxinit()"  bgcolor="EFEFEF"  onunload="free_mem()">
+<body id="foo" onload="localajaxinit()"  bgcolor="EFEFEF">
 <div class="mainscreenTitleBar">
 	<span style="margin-left: 4px;font-weight:bold;">Record a Custom VoiceMenu</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>
 </div>
 <div class="mainscreenContentBox" id="userscontent">
 <table class="mainscreenTable" align="center">
-	<tr><td valign="top" align="center">
-		<BR>
-		<table id="maintable" cellpadding=3 cellspacing=0 border=0 width=400 style="border-width: 1px 1px 1px 1px; border-style: solid; border-color: #7E7E7E; ">
-			<tr><td colspan=2 align=center class="field_text"><B>List of recorded voicemenus</B><select id='recorded_files' style="display:none"></select></td></tr>
-			<tr bgcolor="#FFFFFF"><td><font color="#2D4E93" width="300">File Name</font></td><td  color="#2D4E93" ></td></tr>
-			<tr><td colspan=2>
-				<div style="height:125px;width=400px; overflow :auto;">
-				<table id="table_recordefileslist"  cellpadding=3 cellspacing=0 border=0 width="100%"  class="field_text"></table>
-				</div>
-				</td>
+	<tr>
+	<td valign="top" align="center">
+	<BR>
+	<fieldset  style="height: 390px; "  id="fieldset2">
+		<legend>&nbsp;List of Recorded VoiceMenus&nbsp;</legend>
+		<table class="table_blacksm" cellpadding=2 cellspacing=2 border=0 align=center width=500 id="table_one">
+			<tr>	<td width=35>S.No</td>
+				<td width="180">Name</td>
+				<td align="center">Options</td>
 			</tr>
 		</table>
-
-		<table width="500" cellspacing="1" cellpadding="2" border="0" align="center" id="no_rvmns" style="display: none"  bgcolor="#C2C2C2">
-			<tr>
-			<td align="center" bgcolor="#FFFFFF">
-			<br/>You do not have any <i>Recorded Voicemenus</i> <br/><br/>
-			Please click on the 'Record a new Voice Menu' button<br/> 
-			to record a new Voicemenu.<br/><br/>
-			</td>
-			</tr>
-		</table>
-		<BR><BR>
-		<div id="status"></div>
-		<BR><BR>
-		<input type="button" id="vvv" value="Record a new Voice Menu" onclick="show_record();"  onmouseover="show_tooltip('en', 'record', 0);">
-
-		<div id="recordnew_content" STYLE="display:none; position: absolute; left: 20; top: 125; width:475; height:150;  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 , 'recordnew_content');">
-			<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
-				<TD Height="20" align="center" style="cursor: move">
-					<font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">Record a new Voicemenu</font>
-				</TD>
-				<TD Height="20" align="right" style="cursor: move">
-					<A href="#" onclick="hide_record();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
-				</TD>
-				<TD width=4></TD>
-			</TR>
-			</table>
-			<table cellpadding=2 cellspacing=2 border=0>
-				<tr>	<td colspan=2 height=15 valign=middle align=center class="field_text"></td></tr>
-				<tr onmouseover="show_tooltip('en', 'record', 1);">
-					<td class="field_text">File Name:</td>
-					<td><input id='newvmenu_name' size=24 class="input9">
-						<input type="hidden" id="format" value="gsm">
-					</td>
-				</tr>
-				<!-- 	<tr><td>Format:</td>
-						<td><select id='format'>
-							<option value="gsm">gsm</option>
-	-						<option value="g723">g723</option>
-							<option value="g729">g729</option>
-							<option value="h623">h623</option>
-							<option value="ulaw">ulaw</option>
-							<option value="alaw">alaw</option>
-							<option value="vox">vox</option>
-							<option value="wav">wav</option>
-							<option value="WAV">WAV</option> 
-							</select>
-						</td>
-				</tr> -->
-				<tr   onmouseover="show_tooltip('en', 'record', 2);">	<td class="field_text">Extension used for recording:</td>
-						<td><select id='newvmenu_ext' class="input9"></select></td>
-				</tr>
-				<tr>	<td colspan=2 align=center height=10></td></tr>
-				<tr>	<td colspan=2 align=center>
-						<input type="button" id='record' Value="Record" onclick="record_new()" class="buttonbold">&nbsp;&nbsp;&nbsp;
-						<input type="button" Value="Cancel" onclick="hide_record();" class="buttonbold">
-					</td>
-				</tr>
-				<tr>	<td colspan=2 align=center height=10></td></tr>
-			</table>
+		<div id="recfilesTable_div" style="height:260px;width=100%; overflow :auto; padding : 0px 0px 0px 0px;">
+			<table id="recfilesTable" cellpadding=2 cellspacing=1 border=0 align=center width=500></table>
 		</div>
+		<center><div style="height:25px;color: #FF0000;" id='status'  class="field_text9"></div></center>
+		<BR>
+		<div STYLE="position: absolute; left:186; top: 460;">
+			<input type="button" id="vvv" value="Record a new Voice Menu" onclick="show_record();"  onmouseover="show_tooltip('en', 'record', 0);">
+		</div>
+	</fieldset>
 	</td>
 	</tr>
 </table>
 </div>
+<div id="recordnew_content" STYLE="display:none; position: absolute; left: 20; top: 125; width:475; height:150;  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 , 'recordnew_content');">
+	<TR bgcolor="#7E5538"  style="background-image:url('images/title_gradient.gif');">
+		<TD Height="20" align="center" style="cursor: move">
+			<font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">Record a new Voicemenu</font>
+		</TD>
+		<TD Height="20" align="right" style="cursor: move">
+			<A href="#" onclick="hide_record();"><font style="color:#FFFFFF; font-size: 12px; font-weight:bold;">X</font></A>
+		</TD>
+		<TD width=4></TD>
+	</TR>
+	</table>
+	<table cellpadding=2 cellspacing=2 border=0>
+		<tr>	<td colspan=2 height=15 valign=middle align=center class="field_text"></td></tr>
+		<tr onmouseover="show_tooltip('en', 'record', 1);">
+			<td class="field_text">File Name:</td>
+			<td><input id='newvmenu_name' size=24 class="input9">
+				<input type="hidden" id="format" value="gsm">
+			</td>
+		</tr>
+		<!-- 	<tr><td>Format:</td>
+				<td><select id='format'>
+					<option value="gsm">gsm</option>
+					<option value="g723">g723</option>
+					<option value="g729">g729</option>
+					<option value="h623">h623</option>
+					<option value="ulaw">ulaw</option>
+					<option value="alaw">alaw</option>
+					<option value="vox">vox</option>
+					<option value="wav">wav</option>
+					<option value="WAV">WAV</option> 
+					</select>
+				</td>
+		</tr> -->
+		<tr   onmouseover="show_tooltip('en', 'record', 2);">
+			<td class="field_text">Extension used for recording:</td>
+			<td><select id='newvmenu_ext' class="input9"></select></td>
+		</tr>
+		<tr>	<td colspan=2 align=center height=10></td></tr>
+		<tr>	<td colspan=2 align=center>
+				<input type="button" id='record' Value="Record" onclick="record_new()" class="buttonbold">&nbsp;&nbsp;&nbsp;
+				<input type="button" Value="Cancel" onclick="hide_record();" class="buttonbold">
+			</td>
+		</tr>
+		<tr>	<td colspan=2 align=center height=10></td></tr>
+	</table>
+</div>
+<div id="sysinfohtml" style="display:none"></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:4">
 </div>
-</body>
+</body>



More information about the asterisk-gui-commits mailing list