1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* The contents of this file are subject to the Mozilla Public
4
* License Version 1.1 (the "License"); you may not use this file
5
* except in compliance with the License. You may obtain a copy of
6
* the License at http://www.mozilla.org/MPL/
8
* Software distributed under the License is distributed on an "AS
9
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10
* implied. See the License for the specific language governing
11
* rights and limitations under the License.
13
* The Original Code is mozilla.org code
15
* The Initial Developer of the Original Code is Netscape
16
* Communications Corporation. Portions created by Netscape are
17
* Copyright (C) 1998 Netscape Communications Corporation. All
21
* Robert Ginda, rginda@netscape.com, original author
25
* This file contains "static" functions for cview. In this case static just
26
* means not-an-event-handler. If you can come up with a better name, let
27
* me know. The main code of cview is divided between this file and
31
var cview = new Object();
33
* instead of creating a slew of global variables, all app-wide values are
34
* stored on this cview object.
37
/* number of items to process per refresh step */
38
cview.REFRESH_ITEMS_PER_CYCLE = 30;
39
/* number of milliseconds to wait between refresh steps */
40
cview.REFRESH_CYCLE_DELAY = 200;
42
cview.componentMode = "all";
43
cview.interfaceMode = "all";
46
* hide/show entries in the components list based on the componentMode and
47
* componentFilter properties of the cview object.
49
function filterComponents()
51
function filterAll (rec)
55
cview.visibleComponents++;
58
function filterContains (rec)
60
if (rec.name.search(cview.componentFilter) != -1)
64
cview.visibleComponents++;
73
function filterStarts (rec)
75
if (rec.name.search(cview.componentFilter) == 0)
79
cview.visibleComponents++;
88
var cmps = cview.componentView.childData.childData;
89
var count = cmps.length;
91
cview.visibleComponents = 0;
93
switch (cview.componentMode)
96
filterFunction = filterAll;
100
filterFunction = filterContains;
104
filterFunction = filterStarts;
109
for (var i = 0; i < count; ++i)
110
filterFunction (cmps[i]);
117
* Same as filterComponents() except it works on the interface list
119
function filterInterfaces()
121
function filterAll (rec)
125
cview.visibleInterfaces++;
128
function filterContains (rec)
130
if (rec.name.search(cview.interfaceFilter) != -1)
134
cview.visibleInterfaces++;
143
function filterStarts (rec)
145
if (rec.name.search(cview.interfaceFilter) == 0)
149
cview.visibleInterfaces++;
158
var ifcs = cview.interfaceView.childData.childData;
159
var count = ifcs.length;
161
cview.visibleInterfaces = 0;
163
switch (cview.interfaceMode)
166
filterFunction = filterAll;
170
filterFunction = filterContains;
174
filterFunction = filterStarts;
179
for (var i = 0; i < count; ++i)
180
filterFunction (ifcs[i]);
188
* Update the list headings based on the componentMode and
189
* componentFilter properties of the cview object.
191
function refreshLabels()
195
switch (cview.componentMode)
198
value = "All components";
202
value = "Components containing '" + cview.componentFilter + "'";
206
value = "Components starting with '" + cview.componentFilter + "'";
210
value = "Components?";
214
value += " (" + cview.visibleComponents + "/" + cview.totalComponents + ")";
215
document.getElementById("component-label").setAttribute ("value", value);
217
switch (cview.interfaceMode)
220
value = "All interfaces";
224
value = "Interfaces containing '" + cview.interfaceFilter + "'";
228
value = "Interfaces starting with '" + cview.interfaceFilter + "'";
231
case "implemented-by":
232
if (!cview.interfaceFilter)
233
value = "Please select a component";
235
value = "Interfaces implemented by '" +
236
Components.classes[cview.interfaceFilter] + "'";
240
value = "Interfaces?";
244
value += " (" + cview.visibleInterfaces + "/" + cview.totalInterfaces + ")";
245
document.getElementById("interface-label").setAttribute ("value", value);