rbrindley: branch rbrindley/astman_revamp r4547 - /team/rbrindley/astman_reva...
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Mon Mar 2 18:58:34 CST 2009
Author: rbrindley
Date: Mon Mar 2 18:58:31 2009
New Revision: 4547
URL: http://svn.digium.com/svn-view/asterisk-gui?view=rev&rev=4547
Log:
- implemented Object.prototype.getProperties, replacing ASTGUI.getObjectPropertiesAsString
- implemented log.doLog function, replacing ASTGUI.Log.doLog
Modified:
team/rbrindley/astman_revamp/config/js/log.js
team/rbrindley/astman_revamp/config/js/object.customs.js
Modified: team/rbrindley/astman_revamp/config/js/log.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/log.js?view=diff&rev=4547&r1=4546&r2=4547
==============================================================================
--- team/rbrindley/astman_revamp/config/js/log.js (original)
+++ team/rbrindley/astman_revamp/config/js/log.js Mon Mar 2 18:58:31 2009
@@ -44,8 +44,27 @@
/**
* Core Log Function.
+ * @param msg The message.
+ * @param color The HTML hexademical color code.
*/
-log.doLog = function () {};
+log.doLog = function () {
+ if (!top.session.debug_mode) {
+ return true;
+ }
+
+ if (typeof msg === 'object') {
+ msg = 'OBJECT: ' + msg.getProperties();
+ }
+
+ var now = new Date();
+ var h = now.getHours().addZero() + ':' + now.getMinutes().addZero() + ':' + now.getSeconds().addZero();
+
+ if (top.session.debug_log.length > 250) {
+ top.session.debug_log = top.session.debug_log.slice(0,50);
+ }
+
+ top.session.debug_log.unshift( h + ' <font color='+ color + '>' + msg + '</font>');
+};
/**
* Log as Error.
Modified: team/rbrindley/astman_revamp/config/js/object.customs.js
URL: http://svn.digium.com/svn-view/asterisk-gui/team/rbrindley/astman_revamp/config/js/object.customs.js?view=diff&rev=4547&r1=4546&r2=4547
==============================================================================
--- team/rbrindley/astman_revamp/config/js/object.customs.js (original)
+++ team/rbrindley/astman_revamp/config/js/object.customs.js Mon Mar 2 18:58:31 2009
@@ -151,6 +151,35 @@
return x ;
};
+/******************************************
+ * Custom methods for Javascript's Object
+ *****************************************/
+/**
+ * Get Properties As String.
+ * Gets Object's properties and returns them as a string. Use to be ASTGUI.getObjectPropertiesAsString.
+ * @returns a string of the object's properties
+ */
+Object.prototype.getProperties = function() {
+ var props = [];
+
+ for (var d in this) {
+ if (!this.hasOwnProperty(d)) {
+ continue;
+ }
+
+ if (typeof this[d] === 'object') {
+ if (this[d] instanceof Array) {
+ props.push(d + ': [' + this[d].join(',') + ']');
+ } else {
+ props.push(d + ': ' + this[d].getProperties());
+ }
+ } else {
+ props.push(d + ': ' + this[d]);
+ }
+ }
+ return '{' + props.join(' ,') + '}';
+};
+
// String Manipulation, and other custom methods for String Objects
String.prototype.addZero = function(){
return ( Number(this) < 10)? "0" + this : this;
More information about the asterisk-gui-commits
mailing list