bkruse: branch 2.0 r3706 - /branches/2.0/config/js/pbx.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Mon Aug 25 16:09:58 CDT 2008


Author: bkruse
Date: Mon Aug 25 16:09:57 2008
New Revision: 3706

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=3706
Log:
Pulled a function from 1.0 with minor changes
to parse a manager response into an Array

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=3706&r1=3705&r2=3706
==============================================================================
--- branches/2.0/config/js/pbx.js (original)
+++ branches/2.0/config/js/pbx.js Mon Aug 25 16:09:57 2008
@@ -731,6 +731,35 @@
 		return to_return;
 	},
 
+	/* returns an array based on a manager packet/response */
+	responseToArray: function(resp) {
+		var msgs = new Array();
+		var inmsg = 0;
+		var msgnum = 0;
+		var x,y;
+		var s = resp;
+		var allheaders = s.split('\r\n');
+		for (x=0;x<allheaders.length;x++) {
+			if (allheaders[x].length) {
+				var fields = allheaders[x].split(': ');
+				if (!inmsg) {
+					msgs[msgnum] = new Object();
+					msgs[msgnum].headers = {};
+					msgs[msgnum].names = new Array();
+					y=0;
+				}
+				msgs[msgnum].headers[fields[0].toLowerCase()] = allheaders[x].substr(fields[0].length +2);
+				msgs[msgnum].names[y++] = fields[0].toLowerCase();
+				inmsg=1;
+			} else {
+				if (inmsg) {
+					inmsg = 0;
+					msgnum++;
+				}
+			}
+		}
+	},
+
 	getUserDetails: function(user){ // returns an object with the specified user details, if the specified user is not found returns null ;
 		return sessionData.pbxinfo.users[user] || null ;
 	},




More information about the asterisk-gui-commits mailing list