| 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 | |
|---|
| 10 | //========== public methods ==========// |
|---|
| 11 | incidents.get = incidents_get; |
|---|
| 12 | incidents.collapseAll = incidents_collapseAll; |
|---|
| 13 | incidents.expandAll = incidents_expandAll; |
|---|
| 14 | incidents.add = incidents_add; |
|---|
| 15 | |
|---|
| 16 | //=========== method definitions ==========// |
|---|
| 17 | /** |
|---|
| 18 | * Searches through each Incident to find an Incident with the given number. |
|---|
| 19 | * @param number {Integer} The number of an incident. |
|---|
| 20 | * @return The Incident with the given number. |
|---|
| 21 | */ |
|---|
| 22 | function incidents_get(number) |
|---|
| 23 | { |
|---|
| 24 | var incident; |
|---|
| 25 | |
|---|
| 26 | // FOR each incident |
|---|
| 27 | for (var i = 0; i < this.length; i++) |
|---|
| 28 | { |
|---|
| 29 | // IF the incident's number matches |
|---|
| 30 | if (this[i].number == number) |
|---|
| 31 | { |
|---|
| 32 | // remember the incident |
|---|
| 33 | incident = this[i]; |
|---|
| 34 | } |
|---|
| 35 | } |
|---|
| 36 | return incident; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * Collapses each Incident. |
|---|
| 41 | */ |
|---|
| 42 | function incidents_collapseAll() |
|---|
| 43 | { |
|---|
| 44 | // FOR each incident |
|---|
| 45 | for (var i = 0; i < this.length; i++) |
|---|
| 46 | { |
|---|
| 47 | // IF the incident is expanded THEN |
|---|
| 48 | if (this[i].expanded) |
|---|
| 49 | { |
|---|
| 50 | // collapse incident |
|---|
| 51 | this[i].expandAction(); |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Expands each incident. |
|---|
| 58 | */ |
|---|
| 59 | function incidents_expandAll() |
|---|
| 60 | { |
|---|
| 61 | // FOR each incident |
|---|
| 62 | for (var i = 0; i < this.length; i++) |
|---|
| 63 | { |
|---|
| 64 | // IF incident is collapsed THEN |
|---|
| 65 | if (!this[i].expanded) |
|---|
| 66 | { |
|---|
| 67 | // expand incident |
|---|
| 68 | this[i].expandAction(); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | * Adds an Incident. |
|---|
| 75 | * @param incident {Incident} The Incident to be added. |
|---|
| 76 | */ |
|---|
| 77 | function incidents_add(incident) |
|---|
| 78 | { |
|---|
| 79 | incidents.push(incident); |
|---|
| 80 | } |
|---|