details:   /erp/devel/pi/rev/1c27586fbc6d
changeset: 11513:1c27586fbc6d
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Tue Apr 05 19:35:19 2011 +0200
summary:   Moved getTimePassed function to ob-utilities

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
       |  53 +++++++++-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-notes.js
 |  53 +---------
 2 files changed, 54 insertions(+), 52 deletions(-)

diffs (135 lines):

diff -r 674b4882a83c -r 1c27586fbc6d 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Tue Apr 05 19:04:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
  Tue Apr 05 19:35:19 2011 +0200
@@ -788,4 +788,55 @@
     appUrl = appUrl.substring(1);
   }
   return appUrl;
-};
\ No newline at end of file
+};
+
+OB.Utilities.formatTimePassedMessage = function(
+/* number of time units */n, /*
+                 * message id
+                 */messageId) {
+  var message = OB.I18N.getLabel(messageId);
+  return message.replace(/^N/, n);
+};
+OB.Utilities.getTimePassed = function(
+  /* date the note was created */created) {
+    // 0-59 minutes: minutes
+  // 1-24 hours: hours
+  // >24 hours: days
+  // >7 days: weeks
+  // >30 days: months
+
+  var now = new Date(), 
+      msCreated = created.getTime(),
+      msNow = now.getTime(),
+      n;
+
+  // time difference in days
+  var diffDays = Math.floor((msNow - msCreated) / (1000 * 60 * 60 * 24));
+  if (diffDays >= 30) {
+    n = Math.floor(diffDays / 30);
+    return OB.Utilities.formatTimePassedMessage(n,
+        'OBUIAPP_months_ago');
+  } else if (diffDays >= 7) {
+    n = Math.floor(diffDays / 7);
+    return OB.Utilities.formatTimePassedMessage(n,
+        'OBUIAPP_weeks_ago');
+  } else if (diffDays >= 1) {
+    n = diffDays;
+    return OB.Utilities.formatTimePassedMessage(n,
+        'OBUIAPP_days_ago');
+  }
+
+  // time difference in hours
+  var diffHours = Math.floor((msNow - msCreated) / (1000 * 60 * 60));
+  if (diffHours >= 1) {
+    n = diffHours;
+    return OB.Utilities.formatTimePassedMessage(n,
+        'OBUIAPP_hours_ago');
+  }
+
+  // time difference in minutes
+  n = Math.floor((msNow - msCreated) / (1000 * 60));
+  return OB.Utilities.formatTimePassedMessage(n,
+      'OBUIAPP_minutes_ago');
+  };
+    
diff -r 674b4882a83c -r 1c27586fbc6d 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-notes.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-notes.js
    Tue Apr 05 19:04:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form-notes.js
    Tue Apr 05 19:35:19 2011 +0200
@@ -262,11 +262,11 @@
                                                                        colNum) 
{
 
                                                                if 
(this.getFieldName(colNum) !== 'note') {
-                                                                       return 
value;
+                                                                       return 
value;   
                                                                }
 
                                                                value =  value 
+ ' <span class="OBNoteListGridAuthor">' +
-                                                                               
this.getTimePassed(record.created) +
+                                                                       
OB.Utilities.getTimePassed(record.created) +
                                                                                
' ' + OB.I18N.getLabel('OBUIAPP_by') + ' ' +
                                                                                
record['createdBy._identifier'];
 
@@ -283,56 +283,7 @@
                                                                return value;
                                                        },
 
-                                                       getTimePassed : 
function(
-                                                       /* date the note was 
created */created) {
-                                                               // 0-59 
minutes: minutes
-                                                       // 1-24 hours: hours
-                                                       // >24 hours: days
-                                                       // >7 days: weeks
-                                                       // >30 days: months
 
-                                                       var now = new Date(), 
-                                                           msCreated = 
created.getTime(),
-                                                           msNow = 
now.getTime(),
-                                                           n;
-
-                                                       // time difference in 
days
-                                                       var diffDays = 
Math.floor((msNow - msCreated) / (1000 * 60 * 60 * 24));
-                                                       if (diffDays >= 30) {
-                                                               n = 
Math.floor(diffDays / 30);
-                                                               return 
this.formatTimePassedMessage(n,
-                                                                               
'OBUIAPP_months_ago');
-                                                       } else if (diffDays >= 
7) {
-                                                               n = 
Math.floor(diffDays / 7);
-                                                               return 
this.formatTimePassedMessage(n,
-                                                                               
'OBUIAPP_weeks_ago');
-                                                       } else if (diffDays >= 
1) {
-                                                               n = diffDays;
-                                                               return 
this.formatTimePassedMessage(n,
-                                                                               
'OBUIAPP_days_ago');
-                                                       }
-
-                                                       // time difference in 
hours
-                                                       var diffHours = 
Math.floor((msNow - msCreated) / (1000 * 60 * 60));
-                                                       if (diffHours >= 1) {
-                                                               n = diffHours;
-                                                               return 
this.formatTimePassedMessage(n,
-                                                                               
'OBUIAPP_hours_ago');
-                                                       }
-
-                                                       // time difference in 
minutes
-                                                       n = Math.floor((msNow - 
msCreated) / (1000 * 60));
-                                                       return 
this.formatTimePassedMessage(n,
-                                                                       
'OBUIAPP_minutes_ago');
-                                               },
-
-                                               formatTimePassedMessage : 
function(
-                                               /* number of time units */n, /*
-                                                                               
                                 * message id
-                                                                               
                                 */messageId) {
-                                                       var message = 
OB.I18N.getLabel(messageId);
-                                                       return 
message.replace(/^N/, n);
-                                               },
 
                                                getBaseStyle : function(record, 
rowNum, colNum) {
                                                        if 
(this.getFieldName(colNum) !== 'colorBar') {

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to