| 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 | */ |
|---|
| 5 | var incidents = new Array(); |
|---|
| 6 | |
|---|
| 7 | //========== public members ==========/ |
|---|
| 8 | incidents.doc = null; |
|---|
| 9 | incidents.colorpallette = [ |
|---|
| 10 | "#d8f0f3", // PowderBlue |
|---|
| 11 | "#dfecdf", // DarkSeaGreen |
|---|
| 12 | "#fff5cc", // CornSilk |
|---|
| 13 | "#ffe8e6", // MistyRose |
|---|
| 14 | "#ffffcc", // Dark Orange |
|---|
| 15 | "#A0CFEC" // Jeans Blue |
|---|
| 16 | ]; |
|---|
| 17 | |
|---|
| 18 | //========== public methods ==========// |
|---|
| 19 | incidents.get = incidents_get; |
|---|
| 20 | incidents.collapseAll = incidents_collapseAll; |
|---|
| 21 | incidents.expandAll = incidents_expandAll; |
|---|
| 22 | incidents.add = incidents_add; |
|---|
| 23 | incidents.size = incidents_size; |
|---|
| 24 | |
|---|
| 25 | //=========== method definitions ==========// |
|---|
| 26 | /** |
|---|
| 27 | * Searches through each Incident to find an Incident with the given number. |
|---|
| 28 | * @param number {Integer} The number of an incident. |
|---|
| 29 | * @return The Incident with the given number. |
|---|
| 30 | */ |
|---|
| 31 | function incidents_get(number) |
|---|
| 32 | { |
|---|
| 33 | var incident; |
|---|
| 34 | |
|---|
| 35 | // FOR each incident |
|---|
| 36 | for (var i = 0; i < this.length; i++) |
|---|
| 37 | { |
|---|
| 38 | // IF the incident's number matches |
|---|
| 39 | if (this[i].number == number) |
|---|
| 40 | { |
|---|
| 41 | // remember the incident |
|---|
| 42 | incident = this[i]; |
|---|
| 43 | } |
|---|
| 44 | } |
|---|
| 45 | return incident; |
|---|
| 46 | } |
|---|
| 47 | /** |
|---|
| 48 | * Accessor to the number of incidents |
|---|
| 49 | */ |
|---|
| 50 | function incidents_size() |
|---|
| 51 | { |
|---|
| 52 | return this.length; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * Collapses each Incident. |
|---|
| 57 | */ |
|---|
| 58 | function incidents_collapseAll() |
|---|
| 59 | { |
|---|
| 60 | // FOR each incident |
|---|
| 61 | for (var i = 0; i < this.length; i++) |
|---|
| 62 | { |
|---|
| 63 | // IF the incident is expanded THEN |
|---|
| 64 | if (this[i].expanded) |
|---|
| 65 | { |
|---|
| 66 | // collapse incident |
|---|
| 67 | this[i].expandAction(); |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | /** |
|---|
| 73 | * Expands each incident. |
|---|
| 74 | */ |
|---|
| 75 | function incidents_expandAll() |
|---|
| 76 | { |
|---|
| 77 | // FOR each incident |
|---|
| 78 | for (var i = 0; i < this.length; i++) |
|---|
| 79 | { |
|---|
| 80 | // IF incident is collapsed THEN |
|---|
| 81 | if (!this[i].expanded) |
|---|
| 82 | { |
|---|
| 83 | // expand incident |
|---|
| 84 | this[i].expandAction(); |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | /** |
|---|
| 90 | * Adds an Incident. |
|---|
| 91 | * @param incident {Incident} The Incident to be added. |
|---|
| 92 | */ |
|---|
| 93 | function incidents_add(incident) |
|---|
| 94 | { |
|---|
| 95 | incidents.push(incident); |
|---|
| 96 | } |
|---|