Index: trunk/webapps/common/js/displayutils.js
===================================================================
--- trunk/webapps/common/js/displayutils.js	(revision 551)
+++ trunk/webapps/common/js/displayutils.js	(revision 643)
@@ -17,55 +17,84 @@
 // @param filename the file containing the CSV input
 // @param targetDiv the div element in which the HTML should be placed.
-function loadLog(filename, targetDiv)
+// @param sortOrder true if the items are shown in ascending order by time
+function loadLog(filename, targetDiv, sortOrder)
 {
     // Asynchronous file read of unified log data
     loadJSON("dynamicdata/" + filename, function(response)
     {
+        // Split the file into rows
+        var allRows = response.split(/\r?\n|\r/);
+        targetDiv.innerHTML = formatTable(allRows, sortOrder);
+    }
+    );
+}
+
+function formatTable(allRows, sortOrder)
+{
+    var table = '<table>';
+    if (sortOrder) // ascending order of time (most recent last)
+    {
         // Format the csv data into an HTML table
-        var allRows = response.split(/\r?\n|\r/);
-        var table = '<table>';
+        // Put the last log entry at the BOTTOM of the table
+        for (var singleRow = 0; singleRow <= allRows.length-1; singleRow++)
+        {
+            // split each row into fields
+            var fields = allRows[singleRow].split(',');
+            table += formatRow(fields)
+        }
+    }
+    else  // descending order of time (most recent first)
+    {
+        // Format the csv data into an HTML table
         // Put the last log entry at the TOP of the table
         for (var singleRow = allRows.length-1; singleRow >= 0; singleRow--)
         {
-            var rowCells = allRows[singleRow].split(',');
-            var msg_type = ""; // color white is default
+            // split each row into fields
+            var fields = allRows[singleRow].split(',');
+            table += formatRow(fields)
+        }
+    }
+    
+    table += '</table>';
+    return table;
+}
 
-            // trimming white space in the type field 
-            // ingore the empty line 
-            if (rowCells.length > 1) 
-            {
-                rowCells[1] = rowCells[1].trim();
+function formatRow(rowCells)
+{
+        var msg_type = ""; // color white is default
+
+        // trimming white space in the type field 
+        // ingore the empty line 
+        if (rowCells.length > 1) 
+        {
+            rowCells[1] = rowCells[1].trim();
+        }
+        var label = String(rowCells[1]);
+        var info = String(rowCells[3]).trim();
+        // Implement ticket #190 
+        // Checking for the type of logging information 
+        if (label.startsWith("CAD")) {
+            msg_type = "class=\"CAD\"";
+            if (info.startsWith("Detail")) {
+                msg_type = "class=\"CADdetail\"";
             }
-            var label = String(rowCells[1]);
-            var info = String(rowCells[3]).trim();
-            // Implement ticket #190 
-            // Checking for the type of logging information 
-            if (label.startsWith("CAD")) {
-                msg_type = "class=\"CAD\"";
-                if (info.startsWith("Detail")) {
-                    msg_type = "class=\"CADdetail\"";
-                }
-            } else if (label.startsWith("Activity")) {
-                msg_type = "class=\"Activity\"";
-            //} else if (rowCells[1] == "CMS Activated.") {
-            } else if (label.startsWith("CMS")) {
-                msg_type = "class=\"CMS\"";
-            } else if (label.startsWith("Eval")) {
-                msg_type = "class=\"Evaluation\"";
-            } 
+        } else if (label.startsWith("Activity")) {
+            msg_type = "class=\"Activity\"";
+        //} else if (rowCells[1] == "CMS Activated.") {
+        } else if (label.startsWith("CMS")) {
+            msg_type = "class=\"CMS\"";
+        } else if (label.startsWith("Eval")) {
+            msg_type = "class=\"Evaluation\"";
+        } 
 
-            // add the message type class to that row 
-            table += '<tr ' + msg_type + '>';
-            for (var rowCell = 0; rowCell < rowCells.length; rowCell++)
-            {
-                table += '<td>';
-                table += rowCells[rowCell];
-                table += '</td>';
-            }
-            table += '</tr>';
+        // add the message type class to that row 
+        var row = '<tr ' + msg_type + '>';
+        for (var rowCell = 0; rowCell < rowCells.length; rowCell++)
+        {
+            row += '<td>';
+            row += rowCells[rowCell];
+            row += '</td>';
         }
-        table += '</table>';
-        targetDiv.innerHTML = table;
-    }
-    );
+        row += '</tr>';
+        return row;
 }
