pari: branch 2.0 r3882 - /branches/2.0/config/js/pbx.js
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Wed Sep 24 18:50:00 CDT 2008
Author: pari
Date: Wed Sep 24 18:50:00 2008
New Revision: 3882
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=3882
Log:
use 'getChunksFromManagerOutput' instead of manually parsing output of status in listOfChannels function
Modified:
branches/2.0/config/js/pbx.js
Modified: branches/2.0/config/js/pbx.js
URL: http://svn.digium.com/view/asterisk-gui/branches/2.0/config/js/pbx.js?view=diff&rev=3882&r1=3881&r2=3882
==============================================================================
--- branches/2.0/config/js/pbx.js (original)
+++ branches/2.0/config/js/pbx.js Wed Sep 24 18:50:00 2008
@@ -609,42 +609,18 @@
var raw_chan_status = makeSyncRequest ( { action :'status' } );
var to_return = [];
try {
- raw_chan_status = raw_chan_status.replace(/Response: Success/, "");
- raw_chan_status = raw_chan_status.replace(/Message: Channel status will follow/, "");
- raw_chan_status = raw_chan_status.replace(/Event: StatusComplete/, "");
- raw_chan_status = raw_chan_status.trim();
- var chunks = raw_chan_status.split('Event: Status');
-
- chunks.each( function(this_chunk){
- // Privilege: Call
- // Channel: Console/dsp
- // CallerID: <unknown>
- // CallerIDNum: <unknown>
- // CallerIDName: <unknown>
- // Account:
- // State: Up
- // Context: default
- // Extension: 6050
- // Priority: 1
- // Seconds: 66
- // Uniqueid: 1219466028.58
- this_chunk = this_chunk.trim();
- if( !this_chunk.contains('Channel:') ){ return; }
- var this_chunk_lines = this_chunk.split('\n');
-
- var this_chan_data = {};
- for ( var r =0 ; r < this_chunk_lines.length ; r++ ){
- var this_chunk_line = this_chunk_lines[r];
- this_chunk_line = this_chunk_line.trim();
- this_chan_data[this_chunk_line.beforeChar(':').trim()] = this_chunk_line.afterChar(':').trim();
- }
-
- to_return.push(this_chan_data);
- });
+ var chunks = ASTGUI.miscFunctions.getChunksFromManagerOutput( raw_chan_status.trim().replace(/Event: StatusComplete/, "") ) ;
+ while( chunks.length ){
+ var this_chunk = ;
+ if( chunks[0].hasOwnProperty('Channel') ){
+ to_return.push(chunks[0]);
+ }
+ chunks.removeFirst();
+ }
} catch(e) {
ASTGUI.debugLog("Error listOfChannels: " + e);
- return [];
+ return to_return;
}
return to_return;
},
More information about the asterisk-gui-commits
mailing list