source: tmcsimulator/trunk/webapps/common/js/displayutils.js @ 551

Revision 551, 2.5 KB checked in by jdalbey, 6 years ago (diff)

Multi-file commit to implement saving evaluation ratings from einotebook to a log file and merging with unified log. Also fix defect #212. cgi-bin/saveEvals.py cgi-bin/saveRatingsToLog.py common/js/displayutils.js common/js/fileutils.js common/js/revision_number.dat common/unifiedlog.css dynamicdata/CADcomments.log dynamicdata/caddetails.csv dynamicdata cms_messages.json dynamicdata/har_messages.json dynamicdata highway_status.json dynamicdata/ratings.csv dynamicdata/unifiedlog.csv dynamicdata/unifiedlog_final.csv einotebook/roles/index.html einotebook roles/roles.js einotebook/script/index.html einotebook/script scrollframe.js einotebook/scripts/Evaluation.js einotebook/scripts/Event.js mergelogs.bash unifiedlogdisplay.html unifiedlogmonitor.html

Line 
1/** Hide an html element given its id */
2function hideElementById(id)
3{
4    // hide the element by setting css attribute
5    document.getElementById(id).style.display = 'none'
6}
7
8// Show the subversion revision number in the page title
9function showRevision()
10{
11    var title = document.title;
12    title = title + revisionNumber;
13    document.title = title;
14}
15
16// Load a CSV file and convert to a string of formatted HTML
17// @param filename the file containing the CSV input
18// @param targetDiv the div element in which the HTML should be placed.
19function loadLog(filename, targetDiv)
20{
21    // Asynchronous file read of unified log data
22    loadJSON("dynamicdata/" + filename, function(response)
23    {
24        // Format the csv data into an HTML table
25        var allRows = response.split(/\r?\n|\r/);
26        var table = '<table>';
27        // Put the last log entry at the TOP of the table
28        for (var singleRow = allRows.length-1; singleRow >= 0; singleRow--)
29        {
30            var rowCells = allRows[singleRow].split(',');
31            var msg_type = ""; // color white is default
32
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();
38            }
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            } 
56
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>';
66        }
67        table += '</table>';
68        targetDiv.innerHTML = table;
69    }
70    );
71}
Note: See TracBrowser for help on using the repository browser.