| 1 | /** |
|---|
| 2 | * Represents an incident. (Does not contain events. Event links itself to Incident.) |
|---|
| 3 | * @param time {Time} |
|---|
| 4 | * @param numbers {Number} |
|---|
| 5 | * @param title {String} |
|---|
| 6 | * @param summary {String} |
|---|
| 7 | */ |
|---|
| 8 | function Incident(time, number, title, summary, color) |
|---|
| 9 | { |
|---|
| 10 | //========== public read-only members ==========// |
|---|
| 11 | this.time = time; |
|---|
| 12 | this.number = number; |
|---|
| 13 | this.title = title; |
|---|
| 14 | this.summary = summary; |
|---|
| 15 | this.color = color; /* hex color code for background of this incident */ |
|---|
| 16 | |
|---|
| 17 | //========== public methods ==========// |
|---|
| 18 | this.html = html; |
|---|
| 19 | this.setSummary = setSummary; |
|---|
| 20 | |
|---|
| 21 | //========== private methods ==========// |
|---|
| 22 | this.formatHeader = formatHeader; |
|---|
| 23 | |
|---|
| 24 | /** Setter for summary field */ |
|---|
| 25 | function setSummary(description) |
|---|
| 26 | { |
|---|
| 27 | this.summary = description; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | /** |
|---|
| 32 | * @return The html representation of this incident; |
|---|
| 33 | */ |
|---|
| 34 | function html() |
|---|
| 35 | { |
|---|
| 36 | return "<table class='incident'>" + |
|---|
| 37 | "<tr>" + |
|---|
| 38 | "<td class='incidentHeader'>" + this.formatHeader() + "</td>" + |
|---|
| 39 | "</tr>" + |
|---|
| 40 | "<tr>" + |
|---|
| 41 | "<td class='incidentSummary' id='summary" + this.number + "'>" + |
|---|
| 42 | this.summary + "</td>" + |
|---|
| 43 | "</tr>" + |
|---|
| 44 | "</table>"; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | /** |
|---|
| 49 | * @return The html of the rectangle that contains the expand/collapse symbol, time, |
|---|
| 50 | * incident number |
|---|
| 51 | * and incident title. |
|---|
| 52 | */ |
|---|
| 53 | function formatHeader() |
|---|
| 54 | { |
|---|
| 55 | return "<table class='incidentHeader'>" + |
|---|
| 56 | "<tr class='incidentHeader'>" + |
|---|
| 57 | "<td class='incidentExpandOption'></td>" + |
|---|
| 58 | "<td class='incidentTime'>Time: " + this.time.format() + "</td>" + |
|---|
| 59 | "<td class='incidentNumber'>" + this.number + "</td>" + |
|---|
| 60 | "<td class='incidentTitle'>" + this.title + "</td>" + |
|---|
| 61 | "</tr>" + |
|---|
| 62 | "</table>"; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | } |
|---|