Changeset 515 in tmcsimulator for trunk/webapps


Ignore:
Timestamp:
11/08/2019 11:49:12 AM (6 years ago)
Author:
jdalbey
Message:

Event.js, Incident.js, Incidents.js, LoadEvents?.js modified to implement ticket #158: color coding incidents.

Location:
trunk/webapps/einotebook/scripts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/einotebook/scripts/Event.js

    r418 r515  
    146146        function html() 
    147147        { 
    148         //console.log("building html for event: ", this.eventHeaderID, incidentColor[this.incident.number]); 
     148        //console.log("building html for event: ", this.eventHeaderID, this.incident.color); //incidentColor[this.incident.number]); 
    149149 
    150150                return "<table class='event'>" + 
    151151                           "<tr>" + 
    152                            "<td class='eventHeader' style='background-color:" + incidentColor[this.incident.number] + "'" + 
     152                           "<td class='eventHeader' style='background-color:" + this.incident.color + "'" + 
    153153               "id='" + this.eventHeaderID + "'>" +  
    154154                              this.headerHTML() + "</td>" + 
    155155                           "</tr>" + 
    156156                           "<tr>" +  
    157                            "<td class='eventData' style='background-color:" + incidentColor[this.incident.number] + "' id='" + this.dataID + "'>" +  
     157                           "<td class='eventData' style='background-color:" + this.incident.color + "' id='" + this.dataID + "'>" +  
    158158                           (this.expanded ? this.dataHTML() : "") +  
    159159                           "</td>" + 
     
    187187                events.doc.getElementById(this.eventHeaderID).style.color = "black"; 
    188188                events.doc.getElementById(this.dataID).style.color = "black"; 
    189         events.doc.getElementById(this.dataID).style.backgroundColor = incidentColor[this.incident.number]; 
     189        events.doc.getElementById(this.dataID).style.backgroundColor = this.incident.color; 
    190190                 
    191191                // IF this event is expanded THEN 
     
    220220        function normalize() 
    221221        { 
    222         var myColor = incidentColor[this.incident.number]; 
     222        var myColor = this.incident.color; 
    223223                events.doc.getElementById(this.eventHeaderID).style.backgroundColor = "white"; 
    224224                events.doc.getElementById(this.eventHeaderID).style.borderColor = "black"; 
  • trunk/webapps/einotebook/scripts/Incident.js

    r468 r515  
    66 * @param summary {String} 
    77 */ 
    8 function Incident(time, number, title, summary) 
     8function Incident(time, number, title, summary, color) 
    99{        
    1010        //========== public read-only members ==========// 
     
    1313        this.title = title; 
    1414        this.summary = summary; 
    15         this.expanded = true; 
     15    this.color = color;  /* hex color code for background of this incident */ 
    1616         
    1717        //========== public methods ==========// 
  • trunk/webapps/einotebook/scripts/Incidents.js

    r468 r515  
    77//========== public members ==========/ 
    88incidents.doc = null; 
     9incidents.colorpallette = [ 
     10"#d8f0f3",        // PowderBlue 
     11"#dfecdf",        // DarkSeaGreen 
     12"#fff5cc",        // CornSilk 
     13"#ffe8e6",        // MistyRose 
     14"#ffffcc",       // Dark Orange 
     15"#d8f0f3" ]; 
    916 
    1017//========== public methods ==========// 
    1118incidents.get = incidents_get; 
     19incidents.collapseAll = incidents_collapseAll; 
     20incidents.expandAll = incidents_expandAll; 
    1221incidents.add = incidents_add; 
     22incidents.size = incidents_size; 
    1323 
    1424//=========== method definitions ==========// 
     
    3444        return incident; 
    3545} 
     46/** 
     47 * Accessor to the number of incidents 
     48*/ 
     49function incidents_size() 
     50{ 
     51    return this.length; 
     52} 
     53 
     54/** 
     55 * Collapses each Incident. 
     56 */ 
     57function incidents_collapseAll() 
     58{ 
     59        // FOR each incident 
     60        for (var i = 0; i < this.length; i++) 
     61        { 
     62                // IF the incident is expanded THEN 
     63                if (this[i].expanded) 
     64                { 
     65                        // collapse incident 
     66                        this[i].expandAction(); 
     67                } 
     68        } 
     69} 
     70 
     71/** 
     72 * Expands each incident. 
     73 */ 
     74function incidents_expandAll() 
     75{ 
     76        // FOR each incident 
     77        for (var i = 0; i < this.length; i++) 
     78        { 
     79                // IF incident is collapsed THEN 
     80                if (!this[i].expanded) 
     81                { 
     82                        // expand incident 
     83                        this[i].expandAction(); 
     84                } 
     85        } 
     86} 
    3687 
    3788/** 
  • trunk/webapps/einotebook/scripts/LoadEvents.js

    r468 r515  
    4242                        if (incidents.get(incidentNum) == undefined) 
    4343                        { 
     44                            // prepare title field 
    4445                            incidentTitle =  currEvt.childNodes[child].textContent; 
     46                            // select a color from the pallette 
     47                            var palletteSize = incidents.colorpallette.length; 
     48                            var currColor = incidents.colorpallette[incidents.size()]; // modulo palleteSize 
    4549                            // Construct the incident 
    46                             var theIncident = new Incident(evtTime, incidentNum, incidentTitle, ""); 
     50                            var theIncident = new Incident(evtTime, incidentNum, incidentTitle, "", currColor);                         
    4751                            // Add the incident to the list of incidents 
    4852                            incidents.add(theIncident); 
Note: See TracChangeset for help on using the changeset viewer.