rbrindley: branch 2.0 r4157 - in /branches/2.0/config: ./ js/
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Nov 19 19:06:31 CST 2008
Author: rbrindley
Date: Wed Nov 19 19:06:30 2008
New Revision: 4157
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4157
Log:
- extracts all javascript any config/*.html file had roughly more than 100 lines of it and places it into an associated config/js/*.js file.
- config/*.html files not affected:
* asterisklogs.html
* cfgbasic.html
* cli.html
* date.html
* digital.html
* directory.html
* emailsettings.html
* flipadvanced.html
* guialert.html
* index.html (already has index.js)
* index_redirect.html
* language.html
* password.html
* reboot.html
* reset_defaults.htlm
* smtp_settings.html
* upload2.html
* upload_abe_overlay.html
* upload_form.html
Added:
branches/2.0/config/js/backup.js
branches/2.0/config/js/bulkadd.js
branches/2.0/config/js/callingrules.js
branches/2.0/config/js/cdr.js
branches/2.0/config/js/dialplans.js
branches/2.0/config/js/features.js
branches/2.0/config/js/feditor.js
branches/2.0/config/js/flashupdate.js
branches/2.0/config/js/followme.js
branches/2.0/config/js/hardware.js
branches/2.0/config/js/hardware_aa50.js
branches/2.0/config/js/iax.js
branches/2.0/config/js/incoming.js
branches/2.0/config/js/meetme.js
branches/2.0/config/js/menuprompts_record.js
branches/2.0/config/js/menuprompts_upload.js
branches/2.0/config/js/menus.js
branches/2.0/config/js/misdn.js
branches/2.0/config/js/mohfiles.js
branches/2.0/config/js/networking.js
branches/2.0/config/js/paging.js
branches/2.0/config/js/preferences.js
branches/2.0/config/js/queues.js
branches/2.0/config/js/registerg729.js
branches/2.0/config/js/ringgroups.js
branches/2.0/config/js/sip.js
branches/2.0/config/js/status.js
branches/2.0/config/js/sysinfo.js
branches/2.0/config/js/timeintervals.js
branches/2.0/config/js/timezone.js
branches/2.0/config/js/trunks_analog.js
branches/2.0/config/js/trunks_digital.js
branches/2.0/config/js/trunks_providers.js
branches/2.0/config/js/trunks_sps.js
branches/2.0/config/js/trunks_voip.js
branches/2.0/config/js/users.js
branches/2.0/config/js/vmgroups.js
branches/2.0/config/js/voicemail.js
branches/2.0/config/js/welcome.js
Modified:
branches/2.0/config/backup.html
branches/2.0/config/bulkadd.html
branches/2.0/config/callingrules.html
branches/2.0/config/cdr.html
branches/2.0/config/dialplans.html
branches/2.0/config/features.html
branches/2.0/config/feditor.html
branches/2.0/config/flashupdate.html
branches/2.0/config/followme.html
branches/2.0/config/hardware.html
branches/2.0/config/hardware_aa50.html
branches/2.0/config/iax.html
branches/2.0/config/incoming.html
branches/2.0/config/meetme.html
branches/2.0/config/menuprompts_record.html
branches/2.0/config/menuprompts_upload.html
branches/2.0/config/menus.html
branches/2.0/config/misdn.html
branches/2.0/config/mohfiles.html
branches/2.0/config/networking.html
branches/2.0/config/paging.html
branches/2.0/config/preferences.html
branches/2.0/config/queues.html
branches/2.0/config/registerg729.html
branches/2.0/config/ringgroups.html
branches/2.0/config/sip.html
branches/2.0/config/status.html
branches/2.0/config/sysinfo.html
branches/2.0/config/timeintervals.html
branches/2.0/config/timezone.html
branches/2.0/config/trunks_analog.html
branches/2.0/config/trunks_digital.html
branches/2.0/config/trunks_providers.html
branches/2.0/config/trunks_sps.html
branches/2.0/config/trunks_voip.html
branches/2.0/config/users.html
branches/2.0/config/vmgroups.html
branches/2.0/config/voicemail.html
branches/2.0/config/welcome.html
Modified: branches/2.0/config/backup.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/backup.html?view=diff&rev=4157&r1=4156&r2=4157
==============================================================================
--- branches/2.0/config/backup.html (original)
+++ branches/2.0/config/backup.html Wed Nov 19 19:06:30 2008
@@ -20,6 +20,7 @@
-->
<script src="js/jquery.js"></script>
<script src="js/astman.js"></script>
+<script src="js/backup.js"></script>
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<style type="text/css">
#table_one tr{
@@ -45,281 +46,7 @@
*/
}
</style>
-<script>
-var bkpPath = ASTGUI.paths.ConfigBkp ;
-var upload_Filename = ""; // will be updated by upload_form.html
-var starteduploading = 0;
-var upload_Path; // path for 'uploads' as defined in http.conf - this variable will be automatically updated from http.conf
-onUploadForm_beforeUploading = function(){
- if( !parent.sessionData.PLATFORM.isAA50 && !parent.sessionData.PLATFORM.isABE && top.sessionData.PLATFORM.isAST_1_4 ){
- alert("File Uploads are supported in Asterisk 1.6.0/trunk");
- return;
- }
- starteduploading = 1;
- parent.ASTGUI.dialog.waitWhile('File Upload in progress, please wait ..');
- return true;
-};
-
-onUploadForm_load = function(){
- if( parent.sessionData.PLATFORM.isABE ){ // ABE-1600
- $('#uploadForm_container').hide();
- return;
- }
- if(!top.sessionData.httpConf.postmappings_defined || !top.sessionData.httpConf.uploadPaths['backups'] ){
- ASTGUI.Log.Error('AG102');
- $('#uploadForm_container').hide();
- return ;
- }
-
- upload_Path = top.sessionData.httpConf.uploadPaths['backups'] ;
- var upload_action_path = (top.sessionData.httpConf.prefix) ? '/' + top.sessionData.httpConf.prefix + '/backups' : '/backups' ;
- _$('uploadiframe').contentWindow.document.getElementById('form22').action = upload_action_path ;
- _$('uploadiframe').contentWindow.document.getElementById('UploadFORM_UPLOAD_BUTTON').value = 'Upload Backup to Unit' ;
-};
-
-
-onUploadForm_unload = function(){
- if(!starteduploading){ return; }
- parent.ASTGUI.dialog.waitWhile('Backup File Uploaded');
- ASTGUI.feedback({ msg:'Backup File Uploaded !!', showfor: 3 });
- $('#uploadForm_container').hide();
- setTimeout( function(){ window.location.href = 'backup.html'; } , 1000 );
- return;
-};
-
-function localajaxinit() {
- top.document.title = 'Configuration Backups';
- if( parent.sessionData.PLATFORM.isAA50 && !parent.sessionData.hasCompactFlash ){
- $('#nocf').show();
- $('#thispageContent').hide();
- return true;
- }
-
- var rand_2 = Math.round(100000*Math.random());
- var tmp_check_perms_guibkps = function(){
- ASTGUI.dialog.waitWhile('Checking write privileges on backups folder');
- ASTGUI.systemCmd( "touch "+ ASTGUI.paths['ConfigBkp'] + rand_2 , function(){
-
- ASTGUI.listSystemFiles( ASTGUI.paths['ConfigBkp'], function(a){
- a = a.join('');
- if( a.contains(rand_2) ){
- ASTGUI.systemCmd( "rm '"+ ASTGUI.paths['ConfigBkp'] + rand_2 + "'" , function(){});
- }else{
- ASTGUI.dialog.alertmsg( 'missing ' + ASTGUI.paths['ConfigBkp'] + '<BR> OR Asterisk does not have write privileges on ' + ASTGUI.paths['ConfigBkp'] );
- return;
- }
-
- localajaxinit_2();
- });
- });
- };
-
- tmp_check_perms_guibkps();
-
-}
-
-var localajaxinit_2 = function(){
- parent.ASTGUI.dialog.waitWhile(' Loading list of Previous Backup files !');
- parent.ASTGUI.systemCmd( "mkdir -p " + bkpPath , function(){
- parent.ASTGUI.listSystemFiles( bkpPath , function(bkpfiles) {
- try{
- ASTGUI.domActions.clear_table(_$('bkpfilesTable'))
- for( var i =0 ; i < bkpfiles.length ; i++){
- addrow_totable( bkpfiles[i].stripTags(), i );
- }
- var _bft = _$('bkpfilesTable') ;
- if( _bft.rows.length == 0 ){
- _$('table_one').style.display="none";
- var newRow = _bft.insertRow(-1);
- var newCell0 = newRow.insertCell(0);
- newCell0 .align = "center";
- newCell0 .innerHTML = "<BR><I> No Previous Backup configurations found !!</I> <BR><BR>" +
- "Please click on the 'Create New Backup' button<BR> to take a backup of the current system configuration<BR><BR>" ;
- }
- }finally{
- parent.ASTGUI.dialog.hide();
- }
- });
- });
-}
-
-function restore_uploadedbkpfile(){
-
-}
-
-function addrow_totable(filename, i ){
- // filename is of format "backup_2008nov19_164527__2008nov19.tar"
- if(!filename.contains('__')){ return true;}
- var fname = filename.split("__") ; // var fname[1] = 2007mar12.tar
-
- var tmp_a = fname[1] ; // tmp_a = 2008nov19.tar
- if(tmp_a.contains('_sounds.')){
- tmp_a = tmp_a.withOut('_sounds');
- fname[0] = fname[0] + '<b>Voicemails & Prompts</b>';
- }
-
- var filedate = tmp_a.rChop('.tar');
- var day = filedate.substr(7);
- var month = filedate.substr(4,3);
- var year = filedate.substr(0,4);
-
- var newRow = _$('bkpfilesTable').insertRow(-1);
- newRow.style.backgroundColor='#FFFFFF';
- newRow.onmouseover= function(){ this.style.backgroundColor='#F9F0D1'; };
- newRow.onmouseout=function(){ this.style.backgroundColor='#FFFFFF'; };
-
- ASTGUI.domActions.tr_addCell( newRow , { html: _$('bkpfilesTable').rows.length , width:35, align:'center' } );
- ASTGUI.domActions.tr_addCell( newRow , { html: fname[0] , width:180 } );
- ASTGUI.domActions.tr_addCell( newRow , { html: month.capitalizeFirstChar() + " " + day + ", " + year , width : 125 } );
-
- var tmp = "<span onclick='dld_bkp(\""+ filename + "\")'class=\"guiButton\">Download from Unit</span> " +
- "<span onclick='restore_bkp(\""+ filename + "\")' class=\"guiButton\">Restore Previous Config</span> " +
- "<span onclick='delete_bkp(\""+ filename + "\")' class=\"guiButtonDelete\">Delete</span>" ;
- ASTGUI.domActions.tr_addCell( newRow , { html: tmp , align:'center'} );
-}
-
-
-function dld_bkp( filename ){
- parent.ASTGUI.systemCmd( "mkdir -p "+ ASTGUI.paths.ConfigBkp_dldPath + " ; /bin/rm " + ASTGUI.paths.ConfigBkp_dldPath + "* ", function(){
- parent.ASTGUI.systemCmd( "/bin/ln -s "+ bkpPath + filename + " " + ASTGUI.paths.ConfigBkp_dldPath + filename , function(){
- var location_dir = window.location.href ;
- location_dir = location_dir.rChop('backup.html') ;
- var download_link = location_dir + "private/bkps/" + filename ;
- var save_text = ( jQuery.browser.msie ) ? "'Save Target As...'" : "'Save Link As..'" ;
-
- ASTGUI.feedback( { msg:'Download using the <i>Download File</i> link', showfor:2 });
- _$('backup_download_Link_url').innerHTML = '<center><A href="' + download_link + '"><b>Download File</b></A>'
- + "<BR>Right Click on the above link and download using the " + save_text + " option</center>" ;
- $('#backup_download_Link').show();
- //var dld_window = window.open ("", "mywindow","toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=200");
- //dld_window.document.write('<BR><center><A href="' + download_link + '"><b>Download From Unit</b></A></center>');
-
- });
- });
-}
-
-
-function restore_bkp(filename){
- if( parent.sessionData.PLATFORM.isAA50 ){
- if(confirm('This will restart the appliance after restoring the backup configuration. \n\n Are you sure you want to proceed ?')){
- restore_bkp_step3(bkpPath + filename);
- }else{
- return;
- }
- }else{
- if(confirm('All your old configuration will be replaced by this backup configuration. \n\n Are you sure you want to proceed ?')){
- //parent.astmanEngine.run_tool("rm /etc/asterisk/* -rf ", callback=function(){ } );
- restore_bkp_step3(bkpPath + filename);
- }
- }
-}
-
-function restore_bkp_step3(file_fullpath){
- if( parent.sessionData.PLATFORM.isAA50 ){
- parent.ASTGUI.dialog.waitWhile(' The Sytem will reboot shortly ');
- parent.ASTGUI.systemCmd( ASTGUI.scripts.restoreBackup + " " + file_fullpath, function(){
- ASTGUI.feedback( { msg:'Configuration restored !!', showfor:2 });
- parent.miscFunctions.AFTER_REBOOT_CMD();
- /* ***************** Todo Restart ******************* */
- //if(starteduploading){ delete_bkp2(file_fullpath); }
- });
- }else{
- parent.ASTGUI.dialog.waitWhile(' Restoring Configuration ');
- parent.ASTGUI.systemCmd( " tar -xvf " + file_fullpath + ' -C / ', function(){
- ASTGUI.feedback( { msg:'Configuration restored !!', showfor:2 });
-
- if(starteduploading){
- delete_bkp2(file_fullpath);
- }else{
- var t = ASTGUI.cliCommand('reload') ;
- setTimeout( function(){ top.window.location.reload(); } , 1000 );
- }
- });
- }
-}
-
-function delete_bkp( filename ){
- if(!confirm("Delete selected Backup Configuration ?")){ return ; }
- delete_bkp2( bkpPath + filename );
-}
-
-function delete_bkp2( file_fullpath ){
- parent.ASTGUI.systemCmd( "/bin/rm -f " + file_fullpath , function(){
- ASTGUI.feedback( { msg:'Delete Request Successfull !', showfor:2 });
- setTimeout( function(){ window.location.reload(); } , 1000 );
- });
-}
-
-
-function take_bkp(){
- ASTGUI.showbg(true);
-
- var months = ["jan", "feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];
- var today=new Date()
- var year = today.getFullYear();
- var month = months[ today.getMonth() ];
- var day = today.getDate().addZero();
- var hour = today.getHours().addZero() ;
- var minute = today.getMinutes().addZero() ;
- var seconds = today.getSeconds().addZero() ;
- var bkpfile = "backup_" + year + month + day + "_" + hour + minute + seconds ;
-
- ASTGUI.updateFieldToValue( 'newbkp_name', bkpfile );
-
- if( parent.sessionData.PLATFORM.isAA50 ){
- $(".AA50only").show();
- }else{
- $(".AA50only").hide();
- }
-
- $('#newbkp_content').show() ;
- _$('newbkp_name').focus();
-}
-
-function cancel_newbackup(){
- ASTGUI.showbg(false);
- _$('newbkp_content').style.display="none" ;
-}
-
-function backup_new(){
- var _nn = _$('newbkp_name');
- if ( !ASTGUI.checkRequiredFields( [_nn] ) ) return ;
- if ( !ASTGUI.validateFields( [_nn] ) ) return ;
-
- var months = ["jan", "feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"];
- var today=new Date()
- var year = today.getFullYear();
- var month = months[ today.getMonth() ];
- var day = today.getDate().addZero();
- //var hour =addzero(today.getHours());
- //var minute =addzero(today.getMinutes());
- //var seconds =addzero(today.getSeconds());
- var bkpfile = _nn.value +"__" + year + month + day +".tar";
-
- if( parent.sessionData.PLATFORM.isAA50 ){
- var fullback = _$('newbkp_completeBackup').checked ;
- if(fullback){
- var tmp_script = ASTGUI.scripts.takeBackup + ' ' + bkpPath + bkpfile + ' ' + 'YES';
- }else{
- var tmp_script = ASTGUI.scripts.takeBackup + ' ' + bkpPath + bkpfile ;
- }
- parent.ASTGUI.systemCmd( tmp_script , function(){
- ASTGUI.feedback( { msg:'Backup Successful', showfor:2 });
- window.location.reload();
- }) ;
- return ;
- }else{
- parent.ASTGUI.systemCmd( "tar -cf " + bkpPath + bkpfile + ' ' + ' /etc/asterisk', function(){
- ASTGUI.feedback( { msg:'Backup Successful', showfor:2 });
- parent.ASTGUI.dialog.waitWhile('Reloading List of backup Files');
- setTimeout( function(){ parent.ASTGUI.dialog.hide(); window.location.reload(); } , 2000 );
- });
- return ;
- }
-}
-
-</script>
<body bgcolor="EFEFEF">
<div class="iframeTitleBar">
Backup / Restore Configurations
Modified: branches/2.0/config/bulkadd.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/bulkadd.html?view=diff&rev=4157&r1=4156&r2=4157
==============================================================================
--- branches/2.0/config/bulkadd.html (original)
+++ branches/2.0/config/bulkadd.html Wed Nov 19 19:06:30 2008
@@ -20,135 +20,14 @@
-->
<script src="js/jquery.js"></script>
<script src="js/astman.js"></script>
+<script src="js/bulkadd.js"></script>
<script src="js/jquery.tooltip.js"></script>
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<style type="text/css">
</style>
-<script>
-var newusers_list = [];
-var NEW_USERS = {} ;
-var localajaxinit = function(){
- ASTGUI.selectbox.populateArray('RANGE_Number', [5,10,15,20,25,30,35,40,45,50]);
- top.document.title = 'Bulk Add' ;
-
- (function(){
- var t = [{ url:'#',
- desc:'Create New users from CSV list',
- click_function: function(){
- $('#table_usersFromCSV').show();
- $('#table_usersFromRange').hide();
- }
- },{ url: '#',
- desc: 'Create a Range of new users',
- click_function: function(){
- $('#table_usersFromCSV').hide();
- $('#table_usersFromRange').show();
- }
- }];
- ASTGUI.tabbedOptions( _$('tabbedMenu') , t );
- })();
-
- $('#tabbedMenu').find('A:eq(0)').click();
-};
-
-
-
-var create_NEW_USERS = function(){
- var addUser_OR_reloadGUI = function(){
- var tmp_first_user = newusers_list[0];
- parent.astgui_manageusers.addUser( tmp_first_user , NEW_USERS[tmp_first_user] , function(){
- newusers_list.splice(0,1);
- if( newusers_list.length ){
- addUser_OR_reloadGUI();
- }else{
- alert( 'Users added \n Click Ok to reload GUI' );
- top.window.location.reload();
- }
- });
- };
-
- ASTGUI.dialog.waitWhile( "Creating list of users ");
- addUser_OR_reloadGUI();
-};
-
-
-
-var addUsers_from_CSV_field = function(){
- NEW_USERS = {} ;
- newusers_list = [];
-
- var csv_text = _$('ta_ba_csv').value ;
- var tmp_lines = csv_text.split('\n');
- var tmp_Heads = tmp_lines[0]; tmp_lines.splice(0, 1);
- var HEADS = tmp_Heads.split(',');
- if( HEADS[0] != 'User' ){
- alert('The first column should be User');
- return;
- }
-
- for(var tli =0; tli< tmp_lines.length ; tli++ ){
- var this_line = tmp_lines[tli];
- if( this_line.trim() == '' ){ continue; }
- var this_user_details = this_line.split(',');
- if( this_user_details.length != HEADS.length ){
- alert('Error: Invalid Number of Fields in line ' + (tli + 1) );
- return;
- }
-
- var this_user = this_user_details[0]; // User
- if( parent.miscFunctions.ifExtensionAlreadyExists(this_user) ){
- alert('Error: Duplicate Extension \n\n '+ ' Extension ' + this_user + ' already exists \n' + ' Please change extension in line ' + (tli + 1) );
- return;
- }
-
- newusers_list.push( this_user ) ;
- NEW_USERS[ this_user ] = {} ;
- for( var f = 1 ; f < HEADS.length ; f++ ){
- NEW_USERS[ this_user ][ HEADS[f] ] = this_user_details[ f ] ;
- }
- };
-
- create_NEW_USERS();
-};
-
-
-var add_RangeOfUsers = function(){
- NEW_USERS = {} ;
- newusers_list = [];
-
- var t = Number( ASTGUI.getFieldValue('RANGE_Number') );
- var tmp_user = Number(ASTGUI.getFieldValue('RANGE_Start'));
-
- while(t){
- var tmp_nu = String(tmp_user);
- if( parent.miscFunctions.ifExtensionAlreadyExists(tmp_nu) ){
- tmp_user++ ;
- continue;
- }
-
- newusers_list.push(tmp_nu);
- ASTGUI.Log.Debug( 'adding user ' + tmp_nu);
- NEW_USERS[ tmp_nu ] = {} ;
- NEW_USERS[ tmp_nu ]['fullname'] = 'User ' + tmp_nu;
- NEW_USERS[ tmp_nu ]['cid_number'] = tmp_nu;
- NEW_USERS[ tmp_nu ]['context'] = '';
- NEW_USERS[ tmp_nu ]['hasvoicemail'] = 'yes';
- NEW_USERS[ tmp_nu ]['vmsecret'] = tmp_nu;
- NEW_USERS[ tmp_nu ]['hassip'] = 'yes';
- NEW_USERS[ tmp_nu ]['hasiax'] = 'yes';
- NEW_USERS[ tmp_nu ]['secret'] = tmp_nu;
- tmp_user++ ;
- t--;
- }
-
- create_NEW_USERS();
-};
-
-
-</script>
<body bgcolor="EFEFEF">
<div class="iframeTitleBar">
Bulk Add <span class='refresh_icon' onclick="window.location.reload();" > <img src="images/refresh.png" title=" Refresh " border=0 > </span>
Modified: branches/2.0/config/callingrules.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/callingrules.html?view=diff&rev=4157&r1=4156&r2=4157
==============================================================================
--- branches/2.0/config/callingrules.html (original)
+++ branches/2.0/config/callingrules.html Wed Nov 19 19:06:30 2008
@@ -20,6 +20,7 @@
-->
<script src="js/jquery.js"></script>
<script src="js/astman.js"></script>
+<script src="js/callingrules.js"></script>
<script src="js/jquery.tooltip.js"></script>
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<style type="text/css">
@@ -43,327 +44,7 @@
</style>
-<script>
-/*
-sessionData.pbxinfo.callingRules : {
- CallingRule_US : [
- '_91NXXXXXXXXX,1,Macro( trunkdial-failover-0.1, ${trunk_1}/${EXTEN:1}, ${trunk_2}/${EXTEN:1} )'
- ]
-}
-*/
-
-var EDIT_CR ; //calling rule being edited
-var EDIT_CR_RULE ;
-var isNew;
-
-var newCallingRule_form = function(){
- isNew = true ;
- EDIT_CR = '';
- EDIT_CR_RULE = '';
-
- _$('cr_dialog_title').innerHTML =' New CallingRule';
- ASTGUI.resetTheseFields ( [ DOM_new_crl_name, DOM_new_crl_pattern, DOM_new_crl_trunk, DOM_new_crl_tr_stripx, DOM_new_crl_tr_prepend, DOM_new_crl_foChkbx, DOM_new_crl_fotrunk, DOM_new_crl_fotr_stripx, DOM_new_crl_fotr_prepend , 'toLocalDest' , 'new_crl_localDest'] );
- _$('toLocalDest').updateStatus();
- $(DOM_new_CRL_DIV).showWithBg();
- ASTGUI.feedback({ msg:'New CallingRule !', showfor:1 });
-};
-
-var edit_CR_form = function(a,b){
- isNew = false;
- _$('cr_dialog_title').innerHTML =' Edit Calling Rule';
-
- EDIT_CR = a;
- EDIT_CR_RULE = b;
- var tmp_cr = ASTGUI.parseContextLine.obCallingRule(b) ;
-
- DOM_new_crl_name.value = EDIT_CR.withOut(ASTGUI.contexts.CallingRulePrefix) ;
- DOM_new_crl_name.disabled = true;
- DOM_new_crl_pattern.value = tmp_cr.pattern ;
- _$('new_crl_localDest').selectedIndex = -1;
- if( tmp_cr.destination ){
- ASTGUI.selectbox.selectOption('new_crl_localDest', tmp_cr.destination);
- _$('toLocalDest').checked = true;
- }else{
- _$('toLocalDest').checked = false;
- ASTGUI.selectbox.selectOption(DOM_new_crl_trunk, tmp_cr.firstTrunk );
- DOM_new_crl_tr_stripx.value = tmp_cr.stripdigits_firstTrunk ;
- DOM_new_crl_tr_prepend.value = tmp_cr.firstPrepend ;
- if(tmp_cr.secondTrunk){
- DOM_new_crl_foChkbx.checked = true
- ASTGUI.selectbox.selectOption(DOM_new_crl_fotrunk, tmp_cr.secondTrunk );
- DOM_new_crl_fotr_stripx.value = tmp_cr.stripdigits_secondTrunk ;
- DOM_new_crl_fotr_prepend.value = tmp_cr.secondPrepend ;
- }
- en_db_fofields();
- }
-
- _$('toLocalDest').updateStatus();
- $(DOM_new_CRL_DIV).showWithBg();
- ASTGUI.feedback({ msg:'Edit CallingRule !', showfor:1 });
-};
-
-
-var en_db_fofields = function(){
- var t = !DOM_new_crl_foChkbx.checked;
- DOM_new_crl_fotrunk.disabled = t;
- DOM_new_crl_fotr_stripx.disabled = t;
- DOM_new_crl_fotr_prepend.disabled = t;
-};
-
-
-var load_DOMelements = function(){
- DOM_tbl_crls = _$('table_CRLS_list');
- // new calling rule dom elements
- DOM_new_cr_button = _$('new_cr_button');
- DOM_new_CRL_DIV = _$('new_CRL_DIV');
- DOM_new_crl_name = _$('new_crl_name');
- DOM_new_crl_pattern = _$('new_crl_pattern');
- DOM_new_crl_trunk = _$('new_crl_trunk');
- DOM_new_crl_tr_stripx = _$('new_crl_tr_stripx');
- DOM_new_crl_tr_prepend = _$('new_crl_tr_prepend');
- DOM_new_crl_foChkbx = _$('new_crl_foChkbx');
- DOM_new_crl_fotrunk = _$('new_crl_fotrunk');
- DOM_new_crl_fotr_stripx = _$('new_crl_fotr_stripx');
- DOM_new_crl_fotr_prepend = _$('new_crl_fotr_prepend');
- // new calling rule dom elements
- (function(){
- en_db_fofields();
- ASTGUI.events.add( DOM_new_crl_foChkbx, 'change' , en_db_fofields);
- ASTGUI.events.add( DOM_new_cr_button , 'click' , newCallingRule_form);
-
- var t = parent.astgui_managetrunks.listofAllTrunks();
- var TMP_FORSORT = [];
- t.each(function(item){
- TMP_FORSORT.push( parent.astgui_managetrunks.misc.getTrunkName(item) + ':::::::' + item);
- });
- TMP_FORSORT.sort();
- TMP_FORSORT.each( function(this_str){
- var a = this_str.split(':::::::');
- ASTGUI.selectbox.append( DOM_new_crl_trunk, a[0], a[1] );
- ASTGUI.selectbox.append( DOM_new_crl_fotrunk , a[0], a[1] );
- });
- })();
-};
-
-moveCrUpDown = function(context , rule , updown){
- ASTGUI.miscFunctions.moveUpDown_In_context( context , rule , updown , function(newcontext){
- parent.sessionData.pbxinfo.callingRules[context] = newcontext ;
- ASTGUI.feedback( { msg: 'Updated !', showfor: 2 , color: 'blue', bgcolor: '#FFFFFF' } );
- window.location.reload();
- });
-};
-
-var update_CRLSTable = function(){
- //DOM_tbl_crls
- var addCell = ASTGUI.domActions.tr_addCell; // temporarily store the function
- (function(){ // add first row
- var newRow = DOM_tbl_crls.insertRow(-1);
- newRow.className = "frow";
- addCell( newRow , { html:'', width: '100px' } );
- addCell( newRow , { html:'Calling Rule'} );
- addCell( newRow , { html:'Pattern'} );
- addCell( newRow , { html:'Trunk'} );
- addCell( newRow , { html:'Failover Trunk'} );
- addCell( newRow , { html:''} );
- //addCell( newRow , { html:'OutBound CID'} );
- })();
-
- var PreviousTRColor = 'odd' ; // 'odd' : 'even' ;
-
- (function (){
- var c = ASTGUI.cloneObject(parent.sessionData.pbxinfo.callingRules) ;
- for(var d in c){if(c.hasOwnProperty(d)){
- var crd = c[d]; // temporarily store all the details of this calling rule
- var tmp = '';
- PreviousTRColor = (PreviousTRColor == 'odd') ? 'even' : 'odd' ;
-
- var this_crl_set = ASTGUI.cloneObject(c[d]) ;
- var crl = d.withOut(ASTGUI.contexts.CallingRulePrefix);
-
- this_crl_set.each( function(this_rule, this_rule_index ){
- ////////////////////////
- var tmp_movepriorities = '';
- if( this_rule_index == 0 ){
- tmp_movepriorities = '<img src=images/arrow_blank.png border=0> ' ;
- }else{
- tmp_movepriorities = "<A href=# title='Move this rule Up'><img src=images/arrow_up.png border=0 onclick=\"moveCrUpDown('" + d + "','" + this_rule+ "', 1)\"></A> " ;
- }
-
- if( this_rule_index != ( this_crl_set.length -1 ) ){
- tmp_movepriorities += "<A href=# title='Move this rule Down'><img src=images/arrow_down.png border=0 onclick=\"moveCrUpDown('" + d + "','" + this_rule+ "', 0)\"></A>" ;
- }else{
- tmp_movepriorities += '<img src=images/arrow_blank.png border=0>' ;
- }
- //////////////////////
-
- var tmp_cr = ASTGUI.parseContextLine.obCallingRule(this_rule) ;
- var newRow = DOM_tbl_crls.insertRow(-1);
- newRow.className = PreviousTRColor ;
-
- addCell( newRow , { html: tmp_movepriorities } );
- addCell( newRow , { html: crl });
- addCell( newRow , { html: tmp_cr.pattern });
-
- if( tmp_cr.hasOwnProperty('firstTrunk') ){
- addCell( newRow , { html: tmp_cr.firstTrunk ? ( parent.astgui_managetrunks.misc.getTrunkName(tmp_cr.firstTrunk) || '<i><font color=red>Invalid Trunk</font></i>' ) : '<i><font color=red>None Assigned</font></i>' });
- addCell( newRow , { html: tmp_cr.secondTrunk ? ( parent.astgui_managetrunks.misc.getTrunkName(tmp_cr.secondTrunk) || '<i><font color=red>Invalid Trunk</font></i>' ): '<i>None Selected</i>' });
- }else{
- addCell( newRow , { html: '<i><font color=blue>Local Destination : ' + ASTGUI.parseContextLine.showAs(tmp_cr.destination) + '</font></i>', align: 'left', colspan : 2 });
- }
-
- tmp = "<span class='guiButton' onclick=\"edit_CR_form('" + d +"','" + this_rule + "')\">Edit</span>" +
- "<span class='guiButtonDelete' onclick=\"delete_CR_confirm('" + d +"','" + this_rule + "')\">Delete</span>" ;
-
- addCell( newRow , { html: tmp} );
- });
- }}
-
- if(DOM_tbl_crls.rows.length == 1){
- ASTGUI.domActions.clear_table(DOM_tbl_crls);
- var newRow = DOM_tbl_crls.insertRow(-1);
- newRow.className = 'even';
- addCell( newRow , { html:'No CallingRules defined !!'} );
- return ;
- }
- })();
-};
-
-
-var localajaxinit = function() {
- top.document.title = "Edit Calling Rules";
- ASTGUI.selectbox.populateArray( 'new_crl_localDest' , parent.miscFunctions.getAllDestinations() );
- ASTGUI.domActions.showHideClassByCheckBox( 'toLocalDest', 'STT_TR_OPTIONS', true );
- load_DOMelements();
- update_CRLSTable();
- ASTGUI.events.add( 'restore_default_clrs_button', 'click' , restore_default_callingRules );
-};
-
-
-var restore_default_callingRules = function(){
- if( !confirm( 'This would restore the factory default Calling Rules.'
- + '\n Any other custom calling rules will not be edited or deleted.'
- + '\n Click OK to continue ' ) )return;
-
-
- var x = new listOfActions('extensions.conf');
- x.new_action('delcat', 'CallingRule_Longdistance', '', '');
- x.new_action('newcat', 'CallingRule_Longdistance', '', '');
- x.new_action('append', 'CallingRule_Longdistance', 'exten', '_91XXXXXXXXXX!,1,Macro(' + ASTGUI.contexts.dialtrunks + ',${}/${EXTEN:1}, , , )' );
-
- x.new_action('delcat', 'CallingRule_IAXTEL', '', '');
- x.new_action('newcat', 'CallingRule_IAXTEL', '', '');
- x.new_action('append', 'CallingRule_IAXTEL', 'exten', '_91700XXXXXXX!,1,Macro(' + ASTGUI.contexts.dialtrunks + ',${}/${EXTEN:1}, , , )' );
-
- x.new_action('delcat', 'CallingRule_Local_AreaCode', '', '');
- x.new_action('newcat', 'CallingRule_Local_AreaCode', '', '');
- x.new_action('append', 'CallingRule_Local_AreaCode', 'exten', '_9256XXXXXXX!,1,Macro(' + ASTGUI.contexts.dialtrunks + ',${}/${EXTEN:4}, , , )' );
-
- x.new_action('delcat', 'CallingRule_International', '', '');
- x.new_action('newcat', 'CallingRule_International', '', '');
- x.new_action('append', 'CallingRule_International', 'exten', '_9011XXXXX.,1,Macro(' + ASTGUI.contexts.dialtrunks + ',${}/${EXTEN:1}, , , )' );
-
- x.new_action('delcat', 'CallingRule_Local_7_digits', '', '');
- x.new_action('newcat', 'CallingRule_Local_7_digits', '', '');
- x.new_action('append', 'CallingRule_Local_7_digits', 'exten', '_9XXXXXXX!,1,Macro(' + ASTGUI.contexts.dialtrunks + ',${}/${EXTEN:1}, , , )' );
-
- x.new_action('delcat', 'CallingRule_Emergency', '', '');
- x.new_action('newcat', 'CallingRule_Emergency', '', '');
- x.new_action('append', 'CallingRule_Emergency', 'exten', '_911!,1,Macro(' + ASTGUI.contexts.dialtrunks + ',${}/${EXTEN:0}, , , )' );
-
-
- x.callActions(function(){
- ASTGUI.feedback( { msg : "Restored 'default Calling Rules' !", showfor: 3, color:'red' });
- alert( "Restored 'default Calling Rules' !" + '\n' + 'The gui will now reload' );
- top.window.location.reload();
- });
-};
-
-
-var new_crl_save_go = function(){
- if ( !ASTGUI.validateFields( [ DOM_new_crl_name, DOM_new_crl_pattern, 'new_crl_tr_stripx' , 'new_crl_tr_prepend' , 'new_crl_fotr_stripx' , 'new_crl_fotr_prepend' ] ) ){
- return ;
- }
-
- if( _$('toLocalDest').checked ){
- if ( !ASTGUI.checkRequiredFields([DOM_new_crl_name, DOM_new_crl_pattern]) ){
- return ;
- }
- if( !_$('new_crl_localDest').value ){
- ASTGUI.feedback( { msg:'select a destination !', showfor:2, color:'red' });
- return ;
- }
- }else{
- if ( !ASTGUI.checkRequiredFields([DOM_new_crl_name, DOM_new_crl_pattern, DOM_new_crl_trunk ]) ){
- return ;
- }
- }
-
- if(_$('new_crl_foChkbx').checked){
- if ( !ASTGUI.checkRequiredFields([DOM_new_crl_fotrunk]) ){
- return ;
- }
- }
-
- if( _$('toLocalDest').checked ){
- var as = DOM_new_crl_pattern.value + ',1,' + ASTGUI.getFieldValue('new_crl_localDest') ;
- }else{
- var t1 = ASTGUI.getFieldValue(DOM_new_crl_trunk);
- var t2 = ASTGUI.getFieldValue(DOM_new_crl_fotrunk);
- if( _$('new_crl_foChkbx').checked && t1 == t2 ){
- ASTGUI.feedback( { msg:'Failover trunk can not be same as the primary trunk !', showfor: 3, color:'red' });
- DOM_new_crl_fotrunk.focus();
- return ;
- }
-
- var tmp_stripx = DOM_new_crl_tr_stripx.value || '0' ;
- var tmp_fotr_stripx = DOM_new_crl_fotr_stripx.value || '0' ;
- var tmp_checkThis = ( DOM_new_crl_pattern.value.beginsWith('_') ) ? DOM_new_crl_pattern.value.length -1 : DOM_new_crl_pattern.value.length ;
-
- if( Number(tmp_stripx) > tmp_checkThis ){
- ASTGUI.feedback( { msg:'You can not strip more digits than in the pattern !', showfor: 3, color:'red' });
- DOM_new_crl_tr_stripx.focus();
- return ;
- }
-
- if( DOM_new_crl_foChkbx.checked && Number(tmp_fotr_stripx) > tmp_checkThis ){
- ASTGUI.feedback( { msg:'You can not strip more digits than in the pattern !', showfor: 3, color:'red' });
- DOM_new_crl_fotr_stripx.focus();
- return ;
- }
-
- var Trunk_Build_str = ',${' + t1 + '}/' + DOM_new_crl_tr_prepend.value + '${EXTEN:' + tmp_stripx + '}' ;
- var foTrunk_Build_str = ',' ;
- if(DOM_new_crl_foChkbx.checked){
- foTrunk_Build_str += '${' + t2 + '}/' + DOM_new_crl_fotr_prepend.value + '${EXTEN:' + tmp_fotr_stripx + '}' ;
- }
-
- var t1 = ',' + t1 ;
- var t2 = ',' + t2 ;
- var as = DOM_new_crl_pattern.value + ',1,Macro(' + ASTGUI.contexts.dialtrunks + Trunk_Build_str + foTrunk_Build_str + t1 + t2 + ')' ;
- }
-
- if( isNew ){
- parent.astgui_manageCallingRules.createCallingRule( DOM_new_crl_name.value , as)
- ASTGUI.feedback( { msg:'CallingRule Created !', showfor:2, color:'green' });
- window.location.reload();
- }else{
- //parent.astgui_manageCallingRules.update( EDIT_CR, DOM_new_crl_name.value , cr_object ) ;
- parent.ASTGUI.dialog.waitWhile(' Updating ...');
- parent.astgui_manageCallingRules.updateCallingRule( EDIT_CR, EDIT_CR_RULE, as )
- ASTGUI.feedback( { msg:'Calling Rule Updated !', showfor:2, color:'green' });
- parent.ASTGUI.dialog.hide();
- window.location.reload();
- }
-};
-
-var delete_CR_confirm = function(a,b){
- if( !confirm('Delete Calling Rule ?') ) return;
- parent.astgui_manageCallingRules.deleteCallingRule(a,b);
- ASTGUI.feedback( { msg:'Calling Rule Deleted !', showfor:2, color:'red' });
- window.location.reload();
-};
-
-</script>
+
<body bgcolor="EFEFEF">
<div class="iframeTitleBar">
Manage Calling Rules
Modified: branches/2.0/config/cdr.html
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/cdr.html?view=diff&rev=4157&r1=4156&r2=4157
==============================================================================
--- branches/2.0/config/cdr.html (original)
+++ branches/2.0/config/cdr.html Wed Nov 19 19:06:30 2008
@@ -21,6 +21,7 @@
-->
<script src="js/jquery.js"></script>
<script src="js/astman.js"></script>
+<script src="js/cdr.js"></script>
<script src="js/jquery.tooltip.js"></script>
<script src="js/jquery.fixedheader.js"></script> <!-- OPTIONAL, for fixed table header. Need not be present -->
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
@@ -55,410 +56,7 @@
}
</style>
-<script type="text/javascript">
-//<![CDATA[
- var backend = "CDR-CSV";
- var records = [];
- var viewCount = 25; /* number of CDR rows displayed at once */
- var offset = 0; /* index into CDR records for first row of current display */
- var fields = [ /* Table column header text */
- "",
- "Account Code", "Source", "Destination", "Dest. Context",
- "Caller ID", "Channel", "Dest. Channel", "Last app.",
- "Last data", "Start time", "Answer Time", "End Time",
- "Duration", "Billable seconds", "Disposition", "AMA flags",
- "Unique ID", "Log userfield"
- ];
- var svindex = [ /* which field to display for short version, add 1 to get index into headers */
- /* use as-is for index into CDR record fields */
- /* -1 is special case for first column (black header, 1..n for each row) */
- -1, 9, 12, 1, 2, 4, 14
- ];
- var longversion = false; /* long version displays all CDR-CSV fields, short only those selected above */
- var sortby = 0; /* Which column (CDR field) to sort the displayed CDR list by. */
- /* negative means descending. Subtract 1 to get index into the records fields array */
- var maxColumns = 0; /* maximum number of columns found in CDR records */
-
- var recordsInbound = [];
- var recordsOutbound = [];
- var recordsInternal = [];
- var recordsExternal = [];
- var recordsSystem = [];
- var uniqueIDs = [];
- var recordsSelected = [];
-
- var showSystemCalls = false; /* don't display CDR records with destination of "asterisk_guitools" */
- var showOutboundCalls = true;
- var showInboundCalls = true;
- var showInternalCalls = true;
- var showExternalCalls = true;
- var nSelected = 0;
- function setSortbyField(index) { /* comes here on click on one of the table headers */
- offset = 0;
- if (Math.abs(sortby) == index) sortby = -sortby; /* if sorting on same column, simply reverse order */
- else sortby = index;
- loadRecords(true);
- }
-
- function sortCompare(a,b) {
- var sb = Math.abs(sortby) - 1; /* subtract one, js arrays are zero-based index */
- var sign = sortby < 0 ? -1 : 1; /* negative requests descending order */
- var cmpa = a[sb];
- var cmpb = b[sb];
- if (cmpa < cmpb) return(-1*sign); /* returns -1 if ascending, 1 if descending requested */
- else if (cmpa > cmpb) return(sign); /* returns 1 if ascending, -1 if descending requested */
- else return(0);
- }
-
- function nextPage() {
- if (nSelected > offset + viewCount) offset += viewCount;
- loadRecords(false);
- }
-
- function prevPage() {
- if (offset) offset -= viewCount;
- if (offset < 0) offset = 0;
- loadRecords(false);
- }
-
- function rowClick(tr) {
- if (tr.asteriskCDRuniqueID) {
- var i = uniqueIDs.length;
- var ir = [];
- while (i--) if (uniqueIDs[i] == tr.asteriskCDRuniqueID) ir.push(i);
- var x = ir.length;
- if (x>0) {
- var td = document.getElementById("cdr_calldetail_text");
- var txt = (x>1)?"<B>Multiple records with same Unique ID</B><BR><BR>":"";
- while (x--) {
- var r = records[ir[x]];
- txt = txt+"<B>Record "+ir[x]+", ID:</B> "+r[16]+"<B> ("+r.callType+" call)</B><BR>"+
- "<B>Timestamps:</B> "+r[9]+", "+r[10]+", "+r[11]+"<BR>"+
- "<B>Durations:</B> "+r[12]+", "+r[13]+"<BR>"+
- "<B>Disposition/AMA flags:</B> "+r[14]+" / "+r[15]+"<BR>"+
- "<B>CallerID:</B> "+r[4]+" <B>Source:</B> "+r[1]+" <B>Destination:</B> "+r[2]+"<BR>"+
- "<B>Source Channel:</B> "+r[5]+"<BR>"+
- "<B>Destination Channel:</B> "+r[6]+"<BR>"+
- "<B>Context:</B> "+r[3]+" <B>Application:</B> "+r[7]+" <B>Data:</B> "+r[8]+"<BR>"+
- "<B>Account code:</B> "+r[0]+
- " <B>Userfield:</B> "+r[17]+"<BR><BR>";
- }
- td.innerHTML = txt;
- $(document.getElementById("cdr_calldetail_DIV")).showWithBg();
- }
- }
- }
-
- function VisibleHeight() { /* need to test to make sure works on all browsers */
- var h = 0;
- if( typeof( window.parent.innerHeight ) == 'number' ) {
- h = window.parent.innerHeight; /* Most browsers except MS IE */
- }
- else if(window.parent.document.documentElement &&
- window.parent.document.documentElement.offsetHeight) {
- h = window.parent.document.documentElement.offsetHeight; /* MS IE 7 */
- }
- else if( document.body && (document.body.clientHeight ) ) {
- h = document.body.clientHeight;
- }
- return h;
- }
- function VisibleWidth() { /* need to test to make sure works on all browsers */
- var w = 0;
- if( typeof( window.parent.innerWidth ) == 'number' ) {
- w = window.parent.innerWidth; /* Most browsers except MS IE */
- }
- else if(window.parent.document.documentElement &&
- window.parent.document.documentElement.offsetWidth) {
- w = window.parent.document.documentElement.offsetWidth; /* MS IE 7 */
- }
- else if( document.body && (document.body.clientWidth ) ) {
- w = document.body.clientWidth;
- }
- return w;
- }
-
- function isset(obj) {
- if (typeof obj != "object")
- return (typeof obj != "undefined");
- for (var i in obj)
- return true;
- return false;
- }
-
- function splitCSV(s) {
- /* Split a Comma Separated Values string into an array of strings. Without thinking we might */
- /* use s.split(","); But we have to handle case where comma is legitimately inside a */
- /* quoted field... "a","b,c","d" must split into 3, not 4 pieces. This nasty looking regular */
- /* expression does the job s.split(/,(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))/); and works on */
- /* firefox and safari, but fails on IE7/8 when "a",,"b". Should split to 3, IE splits to 2 */
- /* So, we roll our own here. */
- var result = [];
- var inQuote = false;
- var l = s.length;
- var i = 0
- var iStart = 0;
- for (i=0; i<l; i++) {
- var c = s.charAt(i);
- if (c == ',' && !inQuote) {
- /* found break point */
- result.push(s.substring(iStart,i));
- iStart = i+1;
- }
- else if (c == '"') inQuote = !inQuote;
- }
- /* got to end, push last value */
- if (iStart<=i) result.push(s.substring(iStart,i));
- return result;
- }
-
- function loadRecords(buildselected) {
-
- try {
-
[... 24514 lines stripped ...]
More information about the asterisk-gui-commits
mailing list