source: tmcsimulator/trunk/webapps/einotebook/scripts/Incidents.js @ 515

Revision 515, 1.9 KB checked in by jdalbey, 6 years ago (diff)

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

  • Property svn:executable set to *
Line 
1/**
2 * Stores each Incident. You must set Incident.doc to the document that incidents will be
3 * displayed on before using this class.
4 */
5var incidents = new Array();
6
7//========== public members ==========/
8incidents.doc = null;
9incidents.colorpallette = [
10"#d8f0f3",        // PowderBlue
11"#dfecdf",        // DarkSeaGreen
12"#fff5cc",        // CornSilk
13"#ffe8e6",        // MistyRose
14"#ffffcc",       // Dark Orange
15"#d8f0f3" ];
16
17//========== public methods ==========//
18incidents.get = incidents_get;
19incidents.collapseAll = incidents_collapseAll;
20incidents.expandAll = incidents_expandAll;
21incidents.add = incidents_add;
22incidents.size = incidents_size;
23
24//=========== method definitions ==========//
25/**
26 * Searches through each Incident to find an Incident with the given number.
27 * @param number {Integer} The number of an incident.
28 * @return The Incident with the given number.
29 */
30function incidents_get(number)
31{
32        var incident;
33       
34        // FOR each incident
35        for (var i = 0; i < this.length; i++)
36        {
37                // IF the incident's number matches
38                if (this[i].number == number)
39                {
40                        // remember the incident
41                        incident = this[i];
42                }
43        }
44        return incident;
45}
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}
87
88/**
89 * Adds an Incident.
90 * @param incident {Incident} The Incident to be added.
91 */
92function incidents_add(incident)
93{
94        incidents.push(incident);
95}
Note: See TracBrowser for help on using the repository browser.