/** * Represents an incident. (Does not contain events. Event links itself to Incident.) * @param time {Time} * @param numbers {Number} * @param title {String} * @param summary {String} */ function Incident(time, number, title, summary) { //========== public read-only members ==========// this.time = time; this.number = number; this.title = title; this.summary = summary; this.expanded = true; //========== public methods ==========// this.html = html; this.expandAction = expandAction; //========== private methods ==========// this.formatHeader = formatHeader; this.expandOption = expandOption; this.expandOptionSymbol = expandOptionSymbol; /** * @return The html representation of this incident; */ function html() { return "" + "" + "" + "" + "" + "" + "" + "
" + this.formatHeader() + "
" + (this.expanded ? this.summary : "") + "
"; } /** * @return The html of the rectangle that contains the expand/collapse symbol, time, * incident number * and incident title. */ function formatHeader() { return "" + "" + "" + "" + "" + "" + "" + "
" + this.expandOption() + "Time: " + this.time.format() + "" + this.number + "" + this.title + "
"; } /** * @return The html that for the + or - symbol that expands or collapses the incident. */ function expandOption() { return ""; } /** * Returns the symbol for the expand option. * @return Either "+" or "-" depending on whether this incidents is collapsed or * expanded. */ function expandOptionSymbol() { return this.expanded == true ? "–" : "+"; } /** * Performs the action of clicking on the + or - symbol that expands or collapses * the incident. */ function expandAction() { if (this.expanded) { incidents.doc.getElementById("summary" + this.number).innerHTML = ""; incidents.doc.getElementById("expandOption" + this.number).innerHTML = "+"; } else { incidents.doc.getElementById("summary" + this.number).innerHTML = this.summary; incidents.doc.getElementById("expandOption" + this.number).innerHTML = "–"; } this.expanded = !this.expanded; } }