Changeset 643 in tmcsimulator for trunk/webapps/common/js


Ignore:
Timestamp:
03/15/2021 04:53:11 PM (5 years ago)
Author:
jdalbey
Message:

displayutils.js Add a parameter to indicate if output should be ascending or descending

Location:
trunk/webapps/common/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/common/js/displayutils.js

    r551 r643  
    1717// @param filename the file containing the CSV input 
    1818// @param targetDiv the div element in which the HTML should be placed. 
    19 function loadLog(filename, targetDiv) 
     19// @param sortOrder true if the items are shown in ascending order by time 
     20function loadLog(filename, targetDiv, sortOrder) 
    2021{ 
    2122    // Asynchronous file read of unified log data 
    2223    loadJSON("dynamicdata/" + filename, function(response) 
    2324    { 
     25        // Split the file into rows 
     26        var allRows = response.split(/\r?\n|\r/); 
     27        targetDiv.innerHTML = formatTable(allRows, sortOrder); 
     28    } 
     29    ); 
     30} 
     31 
     32function formatTable(allRows, sortOrder) 
     33{ 
     34    var table = '<table>'; 
     35    if (sortOrder) // ascending order of time (most recent last) 
     36    { 
    2437        // Format the csv data into an HTML table 
    25         var allRows = response.split(/\r?\n|\r/); 
    26         var table = '<table>'; 
     38        // Put the last log entry at the BOTTOM of the table 
     39        for (var singleRow = 0; singleRow <= allRows.length-1; singleRow++) 
     40        { 
     41            // split each row into fields 
     42            var fields = allRows[singleRow].split(','); 
     43            table += formatRow(fields) 
     44        } 
     45    } 
     46    else  // descending order of time (most recent first) 
     47    { 
     48        // Format the csv data into an HTML table 
    2749        // Put the last log entry at the TOP of the table 
    2850        for (var singleRow = allRows.length-1; singleRow >= 0; singleRow--) 
    2951        { 
    30             var rowCells = allRows[singleRow].split(','); 
    31             var msg_type = ""; // color white is default 
     52            // split each row into fields 
     53            var fields = allRows[singleRow].split(','); 
     54            table += formatRow(fields) 
     55        } 
     56    } 
     57     
     58    table += '</table>'; 
     59    return table; 
     60} 
    3261 
    33             // trimming white space in the type field  
    34             // ingore the empty line  
    35             if (rowCells.length > 1)  
    36             { 
    37                 rowCells[1] = rowCells[1].trim(); 
     62function formatRow(rowCells) 
     63{ 
     64        var msg_type = ""; // color white is default 
     65 
     66        // trimming white space in the type field  
     67        // ingore the empty line  
     68        if (rowCells.length > 1)  
     69        { 
     70            rowCells[1] = rowCells[1].trim(); 
     71        } 
     72        var label = String(rowCells[1]); 
     73        var info = String(rowCells[3]).trim(); 
     74        // Implement ticket #190  
     75        // Checking for the type of logging information  
     76        if (label.startsWith("CAD")) { 
     77            msg_type = "class=\"CAD\""; 
     78            if (info.startsWith("Detail")) { 
     79                msg_type = "class=\"CADdetail\""; 
    3880            } 
    39             var label = String(rowCells[1]); 
    40             var info = String(rowCells[3]).trim(); 
    41             // Implement ticket #190  
    42             // Checking for the type of logging information  
    43             if (label.startsWith("CAD")) { 
    44                 msg_type = "class=\"CAD\""; 
    45                 if (info.startsWith("Detail")) { 
    46                     msg_type = "class=\"CADdetail\""; 
    47                 } 
    48             } else if (label.startsWith("Activity")) { 
    49                 msg_type = "class=\"Activity\""; 
    50             //} else if (rowCells[1] == "CMS Activated.") { 
    51             } else if (label.startsWith("CMS")) { 
    52                 msg_type = "class=\"CMS\""; 
    53             } else if (label.startsWith("Eval")) { 
    54                 msg_type = "class=\"Evaluation\""; 
    55             }  
     81        } else if (label.startsWith("Activity")) { 
     82            msg_type = "class=\"Activity\""; 
     83        //} else if (rowCells[1] == "CMS Activated.") { 
     84        } else if (label.startsWith("CMS")) { 
     85            msg_type = "class=\"CMS\""; 
     86        } else if (label.startsWith("Eval")) { 
     87            msg_type = "class=\"Evaluation\""; 
     88        }  
    5689 
    57             // add the message type class to that row  
    58             table += '<tr ' + msg_type + '>'; 
    59             for (var rowCell = 0; rowCell < rowCells.length; rowCell++) 
    60             { 
    61                 table += '<td>'; 
    62                 table += rowCells[rowCell]; 
    63                 table += '</td>'; 
    64             } 
    65             table += '</tr>'; 
     90        // add the message type class to that row  
     91        var row = '<tr ' + msg_type + '>'; 
     92        for (var rowCell = 0; rowCell < rowCells.length; rowCell++) 
     93        { 
     94            row += '<td>'; 
     95            row += rowCells[rowCell]; 
     96            row += '</td>'; 
    6697        } 
    67         table += '</table>'; 
    68         targetDiv.innerHTML = table; 
    69     } 
    70     ); 
     98        row += '</tr>'; 
     99        return row; 
    71100} 
  • trunk/webapps/common/js/revision_number.dat

    r631 r643  
    11 
    2     var revisionNumber = "616"; 
     2    var revisionNumber = "640"; 
    33     
Note: See TracChangeset for help on using the changeset viewer.