rbrindley: branch rbrindley/astman_revamp r4636 - /team/rbrindley/astman_reva...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Thu Mar 12 15:55:10 CDT 2009


Author: rbrindley
Date: Thu Mar 12 15:55:07 2009
New Revision: 4636

URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4636
Log:

- copied astgui_manageRingGroups.parseContext() to pbx.ring_groups.parse()


Modified:
    team/rbrindley/astman_revamp/config/js/pbx2.js

Modified: team/rbrindley/astman_revamp/config/js/pbx2.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/pbx2.js?view=diff&rev=4636&r1=4635&r2=4636
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Thu Mar 12 15:55:07 2009
@@ -324,10 +324,85 @@
 };
 /*---------------------------------------------------------------------------*/
 
+/*---------------------------------------------------------------------------*/
 /**
  * Ring Groups object.
  */
 pbx.ring_groups = {};
+
+
+/**
+ * Parse Ring Groups' context.
+ * @param cxt_name Context name.
+ * @param cxt Context.
+ * @param extens Ring Group extensions.
+ * @return ring group object.
+ */
+pbx.ring_groups.parse = function(cxt_name, cxt, extens) {
+	if (!cxt_name) {
+		top.log.error('pbx.ring_groups.parse: cxt_name is empty.');
+		return null;
+	} else if (!cxt) {
+		top.log.error('pbx.ring_groups.parse: cxt is empty.');
+		return null;
+	} else if (!extens) {
+		top.log.error('pbx.ring_groups.parse: extens is empty.');
+		return null;
+	}
+
+	var rg = new ASTGUI.customObject;
+	rg.name = '';
+	rg.members = [];
+	rg.strategy = '';
+	rg.ignore = true;
+
+	if (cxt[0].contains('exten=s,1') && cxt[0].toLowerCase().contains('noop(')) {
+		/* TODO: this is clearly a bad assumption for those who might want
+		 * to edit this ring group. We need to strengthen this */
+		rg.name = cxt[0].betweenXY('(', ')');
+		cxt.splice(0,1);
+	} else {
+		rg.name = 'RingGroup ' + cxt_name.withOut(ASTGUI.contexts.RingGroupPrefix);
+	}
+
+	var dialcount = 0;
+	cxt.each(function(line) {
+		/* check for old gui ring group name */
+		if (line.beginsWith('gui_ring_groupname=')) {
+			rg.name = line.afterChar('=');
+			return;
+		}
+
+		if (line.toLowerCase().contains('dial(')) {
+			dialcount++;
+			var args = ASTGUI.parseContextLine.getArgs(line);
+			if (args[0].contains('&')) {
+				rg.members = rg.members.concat(args[0].split('&'));
+			} else {
+				rg.members.push(args[0]);
+			}
+
+			rg.ringtime = args[1];
+			rg.ignore = (args[2] && args[2].contains('i')) ? true : false;
+		}
+	});
+
+	rg.strategy = (dialcount > 1) ? 'ringinorder' : 'ringall';
+	var lastline = cxt[cxt.length-1].toLowerCase();
+	if (!lastline.contains('dial(') && lastline.beginsWith('exten=s,n')) {
+		rg.fallback = cxt[cxt.length-1].split('=s,n,')[1];
+	}
+
+	for (var a=0; a<extens.length; a++) {
+		if (extens[a].contains(cxt_name + '|') && extens[a].contains(cxt_name + ',')) {
+			rg.extension = ASTGUI.parseContextLine.getExten(extens[a]);
+			break;
+		}
+	}
+
+	return rg;
+};
+/*---------------------------------------------------------------------------*/
 
 /*---------------------------------------------------------------------------*/
 /**




More information about the asterisk-gui-commits mailing list