rbrindley: branch rbrindley/astman_revamp r4550 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Mon Mar 2 19:40:55 CST 2009
Author: rbrindley
Date: Mon Mar 2 19:40:52 2009
New Revision: 4550
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4550
Log:
- added astman.rawman variable, replacing ASTGUI.paths.rawman
- implemented astman.makeSyncRequest, replacing makeSyncRequest in astman.js
Modified:
team/rbrindley/astman_revamp/config/js/astman2.js
Modified: team/rbrindley/astman_revamp/config/js/astman2.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/astman2.js?view=diff&rev=4550&r1=4549&r2=4550
==============================================================================
--- team/rbrindley/astman_revamp/config/js/astman2.js (original)
+++ team/rbrindley/astman_revamp/config/js/astman2.js Mon Mar 2 19:40:52 2009
@@ -25,7 +25,9 @@
* Asterisk Manager object
* This object contains all the methods and variables necessary to communicate with Asterisk.
*/
-var astman = {};
+var astman = {
+ rawman: '../../rawman'
+};
/**
* Manage Asterisk's Internal Database.
@@ -78,14 +80,14 @@
var s = astman.cliCommand('database get ' + k.dbname + ' ' + k.key);
if (!s.contains('Value: ')) {
- throw new Error(astman.parseCLIResponse(s));
+ throw new Error(astman.parseCLI(s));
}
} catch (err) {
log.error(err.message);
return null;
}
- var val = astman.parseCLIResponse(s);
+ var val = astman.parseCLI(s);
val.trim().withOut('Value: ');
return val.trim();
},
@@ -109,7 +111,7 @@
throw new Error(s);
}
- var op = astman.parseCLIResponse(s);
+ var op = astman.parseCLI(s);
if (op.trim() === '') {
return null;
}
@@ -179,12 +181,32 @@
};
/**
+ * Makes a sync request.
+ * This function takes an object and makes a synchronous ajax request. This function was formerly named makeSyncRequest
+ * @param {Object} params the object containg all the parameters/options
+ * @return {String} response text from the ajax call.
+ */
+astman.makeSyncRequest = function(params) {
+ if (top.session && top.session.debug_mode) {
+ log.ajax('AJAX Request: "' + params.getProperties() + '"');
+ }
+
+ if (typeof params !== 'object') {
+ log.error('astman.makeSyncRequest: Expecting params to be an object.');
+ return '';
+ }
+
+ var s = $.ajax({ url: astman.rawman, data: params, async: false});
+ return s.responseText;
+};
+
+/**
* Parses CLI Responses.
* The function takes a raw CLI response and strips unnecessary info, returning only the useful info. This function use to be called ASTGUI.parseCLIResponse.
* @param resp The CLI Response to be parsed.
* @return {String} the parsed CLI responsed
*/
-astman.parseCLIResponse = function(resp) {
+astman.parseCLI = function(resp) {
if (typeof resp !== 'string') {
return resp;
}
More information about the asterisk-gui-commits
mailing list