/** * Stores each Incident. You must set Incident.doc to the document that incidents will be * displayed on before using this class. */ var incidents = new Array(); //========== public members ==========/ incidents.doc = null; incidents.colorpallette = [ "#d8f0f3", // PowderBlue "#dfecdf", // DarkSeaGreen "#fff5cc", // CornSilk "#ffe8e6", // MistyRose "#ffffcc", // Dark Orange "#A0CFEC" // Jeans Blue ]; //========== public methods ==========// incidents.get = incidents_get; incidents.collapseAll = incidents_collapseAll; incidents.expandAll = incidents_expandAll; incidents.add = incidents_add; incidents.size = incidents_size; //=========== method definitions ==========// /** * Searches through each Incident to find an Incident with the given number. * @param number {Integer} The number of an incident. * @return The Incident with the given number. */ function incidents_get(number) { var incident; // FOR each incident for (var i = 0; i < this.length; i++) { // IF the incident's number matches if (this[i].number == number) { // remember the incident incident = this[i]; } } return incident; } /** * Accessor to the number of incidents */ function incidents_size() { return this.length; } /** * Collapses each Incident. */ function incidents_collapseAll() { // FOR each incident for (var i = 0; i < this.length; i++) { // IF the incident is expanded THEN if (this[i].expanded) { // collapse incident this[i].expandAction(); } } } /** * Expands each incident. */ function incidents_expandAll() { // FOR each incident for (var i = 0; i < this.length; i++) { // IF incident is collapsed THEN if (!this[i].expanded) { // expand incident this[i].expandAction(); } } } /** * Adds an Incident. * @param incident {Incident} The Incident to be added. */ function incidents_add(incident) { incidents.push(incident); }