source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/IndianHealthService.BMXNet.GeneratedDocumentation/Help/Scripts/CommonUtilities.js@ 1172

Last change on this file since 1172 was 1146, checked in by Sam Habiel, 14 years ago

Initial Import of BMX4

File size: 10.2 KB
Line 
1//function codeBlockHandler(id, data, value)
2function codeBlockHandler()
3{
4 // handle groups of snippets to make sure at least one from the group is always shown
5 HandleSnippetGroups();
6
7 // handle any remaining snippets that aren't in groups
8 var spanElements = document.getElementsByTagName("span");
9 for(var i = 0; i < spanElements.length; ++i)
10 {
11 var devlang = spanElements[i].getAttribute("codeLanguage");
12 if (devlang == null) continue;
13
14 if (HasSnippetGroupAncestor(spanElements[i])) continue;
15
16 var checkboxId = GetDevlangCheckboxId(devlang);
17 if (checkboxId != null && checkboxId != "")
18 {
19 if (docSettings[checkboxId] == "on")
20 spanElements[i].style.display = "";
21 else
22 spanElements[i].style.display = "none";
23 }
24 }
25}
26
27function HasSnippetGroupAncestor(object)
28{
29 var parent = object.parentElement;
30 if (parent == null) return false;
31
32 var className = parent.className;
33 if (className != null && className == "snippetgroup")
34 return true
35
36 return HasSnippetGroupAncestor(parent);
37}
38
39function HandleSnippetGroups()
40{
41 var divs = document.getElementsByTagName("DIV");
42 var divclass;
43 for (var i = 0; i < divs.length; i++)
44 {
45 divclass = divs[i].className;
46 if (divclass == null || divclass != "snippetgroup") continue;
47
48 // if all snippets in this group would be hidden by filtering display them all anyhow
49 var unfilteredCount = GetUnfilteredSnippetCount(divs[i]);
50
51 var spanElements = divs[i].getElementsByTagName("span");
52 for(var j = 0; j < spanElements.length; ++j)
53 {
54 var devlang = spanElements[j].getAttribute("codeLanguage");
55 if (devlang == null) continue;
56
57 var checkboxId = GetDevlangCheckboxId(devlang);
58
59 // for filtered devlangs, determine whether they should be shown/hidden
60 if (checkboxId != null && checkboxId != "")
61 {
62 if (unfilteredCount == 0 || docSettings[checkboxId] == "on")
63 spanElements[j].style.display = "";
64 else
65 spanElements[j].style.display = "none";
66 }
67 }
68 }
69}
70
71function GetUnfilteredSnippetCount(group)
72{
73 var count = 0;
74 var spanElements = group.getElementsByTagName("span");
75 for(var i = 0; i < spanElements.length; ++i)
76 {
77 var devlang = spanElements[i].getAttribute("codeLanguage");
78 var checkboxId = GetDevlangCheckboxId(devlang);
79 if (checkboxId != null && checkboxId != "")
80 {
81 if (docSettings[checkboxId] == "on")
82 count++;
83 }
84 }
85 return count;
86}
87
88function GetDevlangCheckboxId(devlang)
89{
90 switch (devlang)
91 {
92 case "VisualBasic":
93 case "VisualBasicDeclaration":
94 case "VisualBasicUsage":
95 return devlangsMenu.GetCheckboxId("VisualBasic");
96 case "CSharp":
97 return devlangsMenu.GetCheckboxId("CSharp");
98 case "ManagedCPlusPlus":
99 return devlangsMenu.GetCheckboxId("ManagedCPlusPlus");
100 case "JScript":
101 return devlangsMenu.GetCheckboxId("JScript");
102 case "JSharp":
103 return devlangsMenu.GetCheckboxId("JSharp");
104 case "JavaScript":
105 return devlangsMenu.GetCheckboxId("JavaScript");
106 default:
107 return "";
108 }
109}
110
111// update stylesheet display settings for spans to show according to user's devlang preference
112function styleSheetHandler(oneDevlang)
113{
114 var devlang = (oneDevlang != "") ? oneDevlang : GetDevlangPreference();
115
116 var sd = getStyleDictionary();
117
118 if (devlang == 'cs') {
119 sd['span.cs'].display = 'inline';
120 sd['span.vb'].display = 'none';
121 sd['span.cpp'].display = 'none';
122 sd['span.nu'].display = 'none';
123 } else if (devlang == 'vb') {
124 sd['span.cs'].display = 'none';
125 sd['span.vb'].display = 'inline';
126 sd['span.cpp'].display = 'none';
127 sd['span.nu'].display = 'none';
128 } else if (devlang == 'cpp') {
129 sd['span.cs'].display = 'none';
130 sd['span.vb'].display = 'none';
131 sd['span.cpp'].display = 'inline';
132 sd['span.nu'].display = 'none';
133 } else if (devlang == 'nu') {
134 sd['span.cs'].display = 'none';
135 sd['span.vb'].display = 'none';
136 sd['span.cpp'].display = 'none';
137 sd['span.nu'].display = 'inline';
138 }
139}
140
141function getStyleDictionary() {
142 var styleDictionary = new Array();
143
144 // iterate through stylesheets
145 var sheets = document.styleSheets;
146
147 for(var i=0; i<sheets.length;i++) {
148 var sheet = sheets[i];
149
150 // Ignore sheets at ms-help Urls
151 if (sheet.href.substr(0,8) == 'ms-help:') continue;
152
153 // get sheet rules
154 var rules = sheet.cssRules;
155
156 if (rules == null) rules = sheet.rules;
157
158 // iterate through rules
159 for(j=0; j<rules.length; j++) {
160 var rule = rules[j];
161
162 // Ignore ones that aren't defined
163 if(rule.selectorText == null)
164 continue;
165
166 // add rule to dictionary
167 styleDictionary[rule.selectorText.toLowerCase()] = rule.style;
168 }
169 }
170
171 return(styleDictionary);
172}
173
174function GetDevlangPreference()
175{
176 var devlangCheckboxIds = devlangsMenu.GetCheckboxIds();
177 var checkedCount = 0;
178 var devlang;
179 for (var key in devlangCheckboxIds)
180 {
181 if (docSettings[devlangCheckboxIds[key]] == "on")
182 {
183 checkedCount++;
184 checkboxData = devlangsMenu.GetCheckboxData(devlangCheckboxIds[key]);
185 var dataSplits = checkboxData.split(',');
186 if (dataSplits.length > 1)
187 devlang = dataSplits[1];
188 }
189 }
190 return (checkedCount == 1 ? devlang : "nu");
191}
192
193
194
195function memberlistHandler()
196{
197 // get all the <tr> nodes in the document
198 var allRows = document.getElementsByTagName("tr");
199 var i;
200
201 for(i = 0; i < allRows.length; ++i)
202 {
203 var memberdata = allRows[i].getAttribute("data");
204 if (memberdata != null)
205 {
206 if ((ShowBasedOnInheritance(memberdata) == false) ||
207 (ShowBasedOnVisibility(memberdata) == false) ||
208 (ShowBasedOnFramework(memberdata) == false) )
209 allRows[i].style.display = "none";
210 else
211 allRows[i].style.display = "";
212 }
213 }
214
215 ShowHideFrameworkImages();
216 ShowHideFrameworkSpans();
217}
218
219function ShowHideFrameworkImages()
220{
221 // show/hide img nodes for filtered framework icons
222 // get all the <img> nodes in the document
223 var allImgs = document.getElementsByTagName("img");
224
225 for(var i = 0; i < allImgs.length; i++)
226 {
227 var imgdata = allImgs[i].getAttribute("data");
228 if (imgdata != null)
229 {
230 var checkboxId = imgdata + "Checkbox";
231 if (docSettings[checkboxId] != "on")
232 {
233 allImgs[i].style.display = "none";
234 }
235 else
236 allImgs[i].style.display = "";
237 }
238 }
239}
240
241function ShowHideFrameworkSpans()
242{
243 // show/hide img nodes for filtered framework icons
244 // get all the <img> nodes in the document
245 var allImgs = document.getElementsByTagName("span");
246
247 for(var i = 0; i < allImgs.length; i++)
248 {
249 var imgdata = allImgs[i].getAttribute("data");
250 if (imgdata != null)
251 {
252 var checkboxId = imgdata + "Checkbox";
253 if (docSettings[checkboxId] != "on")
254 {
255 allImgs[i].style.display = "none";
256 }
257 else
258 allImgs[i].style.display = "";
259 }
260 }
261}
262
263function ShowBasedOnVisibility(memberdata)
264{
265 var isPublic = (memberdata.indexOf("public") != -1);
266 var isProtected = (memberdata.indexOf("protected") != -1);
267 var isPrivate = (memberdata.indexOf("private") != -1);
268 var isExplicitII = (memberdata.indexOf("explicit") != -1);
269
270 // if the public checkbox doesn't exist, default to showPublic == true
271 var publicCheck = docSettings["PublicCheckbox"];
272 var showPublic = (publicCheck == null) ? true : (publicCheck == "on");
273
274 // if the protected checkbox doesn't exist, default to showProtected == true
275 var protectedCheck = docSettings["ProtectedCheckbox"];
276 var showProtected = (protectedCheck == null) ? true : (protectedCheck == "on");
277
278 if ( (showProtected && isProtected) || (showPublic && isPublic) || isExplicitII || isPrivate)
279 return true;
280
281 return false;
282}
283
284function ShowBasedOnInheritance(memberdata)
285{
286 var isInherited = (memberdata.indexOf("inherited") != -1);
287 var isDeclared = (memberdata.indexOf("declared") != -1);
288
289 // if the inherited checkbox doesn't exist, default to showInherited == true
290 var inheritedCheck = docSettings["InheritedCheckbox"];
291 var showInherited = (inheritedCheck == null) ? true : (inheritedCheck == "on");
292
293 // if the declared checkbox doesn't exist, default to showDeclared == true
294 var declaredCheck = docSettings["DeclaredCheckbox"];
295 var showDeclared = (declaredCheck == null) ? true : (declaredCheck == "on");
296
297 if ( (showInherited && isInherited) || (showDeclared && isDeclared) )
298 return true;
299
300 return false;
301}
302
303function ShowBasedOnFramework(memberdata)
304{
305 var isNetfw = (memberdata.indexOf("notNetfw") == -1);
306 var isNetcfw = (memberdata.indexOf("netcfw") != -1);
307 var isXnafw = (memberdata.indexOf("xnafw") != -1);
308
309 var netfwCheck = docSettings["netfwCheckbox"];
310 var netcfwCheck = docSettings["netcfwCheckbox"];
311 var xnafwCheck = docSettings["xnafwCheckbox"];
312
313 // if all the checkboxes are null, it means we have no framework filter; so return true to show member by default
314 if (netfwCheck == null && netcfwCheck == null && xnafwCheck == null)
315 return true;
316
317 var showNetfw = (netfwCheck == "on");
318 var showNetcfw = (netcfwCheck == "on");
319 var showXnafw = (xnafwCheck == "on");
320
321 if ( (isNetfw && showNetfw) || (isNetcfw && showNetcfw) || (isXnafw && showXnafw) )
322 return true;
323
324 return false;
325}
326
327
328function SetDropdownMenuLabel(menu, dropdown)
329{
330 var dropdownLabelId = menu.GetDropdownLabelId();
331 dropdown.SetActivatorLabel(dropdownLabelId);
332 for (var i = 0; i < dropdowns.length; i++)
333 {
334 dropdowns[i].reposition();
335 }
336}
Note: See TracBrowser for help on using the repository browser.