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

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Sat Mar 7 14:05:51 CST 2009


Author: rbrindley
Date: Sat Mar  7 14:05:47 2009
New Revision: 4591

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

- copied astgui_manageVoiceMenus.parseContext to pbx.voice_menus.parse
- copied astgui_manageVoiceMenus.addMenu to pbx.voice_menus.add


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=4591&r1=4590&r2=4591
==============================================================================
--- team/rbrindley/astman_revamp/config/js/pbx2.js (original)
+++ team/rbrindley/astman_revamp/config/js/pbx2.js Sat Mar  7 14:05:47 2009
@@ -241,7 +241,101 @@
  */
 pbx.voicemail = {};
 
+/*---------------------------------------------------------------------------*/
 /**
  * Voice Menus object.
  */
 pbx.voice_menus = {};
+
+/**
+ * Parse Voice Menus.
+ * This takes an array as input and parses the array returning a VoiceMenu structured object.
+ * @param cxt The Context Array.
+ * @return a voicemenu object.
+ */
+pbx.voice_menus.parse = function(cxt) {
+	var vm = {
+		comment: '',
+		alias_exten: '',
+		includes: [],
+		steps: [],
+		keypress_events: { 0:'', 1:'', 2:'', 3:'', 4:'', 5:'', 6:'', 7:'', 8:'', 9:'', '#':'', '*':'', t:'', i:''}
+	};
+
+	try {
+		var steps = ASTGUI.sortContextByExten(cxt, true);
+		steps['s'].forEach( function(s) {
+			return ASTGUI.parseContextLine.getAppWithArgs(s);
+		});
+
+		vm.steps = steps['s'];
+		vm.comment = vm.steps[0].getNoOp();
+		['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '#', '*', 't', 'i'].each( function(key) {
+			if (steps.hasOwnProperty(key) && steps[key].length == 1) {
+				vm.keypress_events[key] = ASTGUI.parseContextLine.getAppWithArgs(steps[key][0]);
+			}
+		});
+
+		cxt.each( function(line, index) {
+			if (line.beginsWith('include=')) {
+				vm.includes.push(line.afterChar('='));
+				return true;
+			}
+		});
+	} catch(err) {
+		top.log.error('Error Parsing VoiceMenu. Error info follows.');
+		top.log.error(err);
+	} finally {
+		return ASTGUI.toCustomObject(vm);
+	}
+};
+
+/**
+ * Add a Voice Menu.
+ * @param name The Voice Menu's name.
+ * @param menu The Voice Menu's info.
+ * @param callback Callback function.
+ */
+pbx.voice_menus.add = function(name, menu, callback) {
+	var actions = new listOfActions();
+	actions.filename('extensions.conf');
+	actions.new_action('delcat', name, '', '');
+	actions.new_action('newcat', name, '', '');
+
+	new_menu.includes.each( function(item) {
+		actions.new_action('append', name, 'include', item);
+	});
+
+	if (menu.alias_exten) {
+		if (!menu.alias_exten.contains(',') || !menu.alias_exten.toLowerCase().contains('goto(')) {
+			menu.alias_exten = menu.alias_exten.lChop('exten=') + ',1,Goto(' + name + ',s,1)';
+		}
+
+		actions.new_action('append', ASTGUI.contexts.VoiceMenuExtensions, 'exten', menu.alias_exten);
+	}
+
+	menu.steps.each( function(step) {
+		if (!step.beginsWith('s,')) {
+			step = 's,' + (i+1) + ',' + step;
+		}
+
+		actions.new_action('append', name, 'exten', step);
+	});
+
+	for (var evt in menu.keypress_events) {
+		if (!menu.keypress_events.hasOwnProperty(evt) || menu.keypress_events[evt] === '') {
+			continue;
+		}
+
+		var kext = evt + ',1,' + menu.keypress_events[evt];
+		actions.new_action('append', name, 'exten', kext);
+	}
+
+	var cb = function() {
+		sessionData.pbxinfo.voicemenus[name] = ASTGUI.toCustomObject(menu);
+		callback();
+	};
+	actions.callActions(cb);
+};
+
+/*---------------------------------------------------------------------------*/




More information about the asterisk-gui-commits mailing list