1 | var NAVTREE = |
---|
2 | [ |
---|
3 | [ "w3_iic_eeprom Driver", "index.html", [ |
---|
4 | [ "Doc Sections", "modules.html", "modules" ] |
---|
5 | ] ] |
---|
6 | ]; |
---|
7 | |
---|
8 | var NAVTREEINDEX = |
---|
9 | [ |
---|
10 | "group__user__functions.html" |
---|
11 | ]; |
---|
12 | |
---|
13 | var SYNCONMSG = 'click to disable panel synchronisation'; |
---|
14 | var SYNCOFFMSG = 'click to enable panel synchronisation'; |
---|
15 | var navTreeSubIndices = new Array(); |
---|
16 | |
---|
17 | function getData(varName) |
---|
18 | { |
---|
19 | var i = varName.lastIndexOf('/'); |
---|
20 | var n = i>=0 ? varName.substring(i+1) : varName; |
---|
21 | return eval(n.replace(/\-/g,'_')); |
---|
22 | } |
---|
23 | |
---|
24 | function stripPath(uri) |
---|
25 | { |
---|
26 | return uri.substring(uri.lastIndexOf('/')+1); |
---|
27 | } |
---|
28 | |
---|
29 | function stripPath2(uri) |
---|
30 | { |
---|
31 | var i = uri.lastIndexOf('/'); |
---|
32 | var s = uri.substring(i+1); |
---|
33 | var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/); |
---|
34 | return m ? uri.substring(i-6) : s; |
---|
35 | } |
---|
36 | |
---|
37 | function localStorageSupported() |
---|
38 | { |
---|
39 | try { |
---|
40 | return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem; |
---|
41 | } |
---|
42 | catch(e) { |
---|
43 | return false; |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | function storeLink(link) |
---|
49 | { |
---|
50 | if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) { |
---|
51 | window.localStorage.setItem('navpath',link); |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | function deleteLink() |
---|
56 | { |
---|
57 | if (localStorageSupported()) { |
---|
58 | window.localStorage.setItem('navpath',''); |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | function cachedLink() |
---|
63 | { |
---|
64 | if (localStorageSupported()) { |
---|
65 | return window.localStorage.getItem('navpath'); |
---|
66 | } else { |
---|
67 | return ''; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | function getScript(scriptName,func,show) |
---|
72 | { |
---|
73 | var head = document.getElementsByTagName("head")[0]; |
---|
74 | var script = document.createElement('script'); |
---|
75 | script.id = scriptName; |
---|
76 | script.type = 'text/javascript'; |
---|
77 | script.onload = func; |
---|
78 | script.src = scriptName+'.js'; |
---|
79 | if ($.browser.msie && $.browser.version<=8) { |
---|
80 | // script.onload does work with older versions of IE |
---|
81 | script.onreadystatechange = function() { |
---|
82 | if (script.readyState=='complete' || script.readyState=='loaded') { |
---|
83 | func(); if (show) showRoot(); |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | head.appendChild(script); |
---|
88 | } |
---|
89 | |
---|
90 | function createIndent(o,domNode,node,level) |
---|
91 | { |
---|
92 | if (node.parentNode && node.parentNode.parentNode) { |
---|
93 | createIndent(o,domNode,node.parentNode,level+1); |
---|
94 | } |
---|
95 | var imgNode = document.createElement("img"); |
---|
96 | imgNode.width = 16; |
---|
97 | imgNode.height = 22; |
---|
98 | if (level==0 && node.childrenData) { |
---|
99 | node.plus_img = imgNode; |
---|
100 | node.expandToggle = document.createElement("a"); |
---|
101 | node.expandToggle.href = "javascript:void(0)"; |
---|
102 | node.expandToggle.onclick = function() { |
---|
103 | if (node.expanded) { |
---|
104 | $(node.getChildrenUL()).slideUp("fast"); |
---|
105 | if (node.isLast) { |
---|
106 | node.plus_img.src = node.relpath+"ftv2plastnode.png"; |
---|
107 | } else { |
---|
108 | node.plus_img.src = node.relpath+"ftv2pnode.png"; |
---|
109 | } |
---|
110 | node.expanded = false; |
---|
111 | } else { |
---|
112 | expandNode(o, node, false, false); |
---|
113 | } |
---|
114 | } |
---|
115 | node.expandToggle.appendChild(imgNode); |
---|
116 | domNode.appendChild(node.expandToggle); |
---|
117 | } else { |
---|
118 | domNode.appendChild(imgNode); |
---|
119 | } |
---|
120 | if (level==0) { |
---|
121 | if (node.isLast) { |
---|
122 | if (node.childrenData) { |
---|
123 | imgNode.src = node.relpath+"ftv2plastnode.png"; |
---|
124 | } else { |
---|
125 | imgNode.src = node.relpath+"ftv2lastnode.png"; |
---|
126 | domNode.appendChild(imgNode); |
---|
127 | } |
---|
128 | } else { |
---|
129 | if (node.childrenData) { |
---|
130 | imgNode.src = node.relpath+"ftv2pnode.png"; |
---|
131 | } else { |
---|
132 | imgNode.src = node.relpath+"ftv2node.png"; |
---|
133 | domNode.appendChild(imgNode); |
---|
134 | } |
---|
135 | } |
---|
136 | } else { |
---|
137 | if (node.isLast) { |
---|
138 | imgNode.src = node.relpath+"ftv2blank.png"; |
---|
139 | } else { |
---|
140 | imgNode.src = node.relpath+"ftv2vertline.png"; |
---|
141 | } |
---|
142 | } |
---|
143 | imgNode.border = "0"; |
---|
144 | } |
---|
145 | |
---|
146 | function newNode(o, po, text, link, childrenData, lastNode) |
---|
147 | { |
---|
148 | var node = new Object(); |
---|
149 | node.children = Array(); |
---|
150 | node.childrenData = childrenData; |
---|
151 | node.depth = po.depth + 1; |
---|
152 | node.relpath = po.relpath; |
---|
153 | node.isLast = lastNode; |
---|
154 | |
---|
155 | node.li = document.createElement("li"); |
---|
156 | po.getChildrenUL().appendChild(node.li); |
---|
157 | node.parentNode = po; |
---|
158 | |
---|
159 | node.itemDiv = document.createElement("div"); |
---|
160 | node.itemDiv.className = "item"; |
---|
161 | |
---|
162 | node.labelSpan = document.createElement("span"); |
---|
163 | node.labelSpan.className = "label"; |
---|
164 | |
---|
165 | createIndent(o,node.itemDiv,node,0); |
---|
166 | node.itemDiv.appendChild(node.labelSpan); |
---|
167 | node.li.appendChild(node.itemDiv); |
---|
168 | |
---|
169 | var a = document.createElement("a"); |
---|
170 | node.labelSpan.appendChild(a); |
---|
171 | node.label = document.createTextNode(text); |
---|
172 | node.expanded = false; |
---|
173 | a.appendChild(node.label); |
---|
174 | if (link) { |
---|
175 | var url; |
---|
176 | if (link.substring(0,1)=='^') { |
---|
177 | url = link.substring(1); |
---|
178 | link = url; |
---|
179 | } else { |
---|
180 | url = node.relpath+link; |
---|
181 | } |
---|
182 | a.className = stripPath(link.replace('#',':')); |
---|
183 | if (link.indexOf('#')!=-1) { |
---|
184 | var aname = '#'+link.split('#')[1]; |
---|
185 | var srcPage = stripPath($(location).attr('pathname')); |
---|
186 | var targetPage = stripPath(link.split('#')[0]); |
---|
187 | a.href = srcPage!=targetPage ? url : '#'; |
---|
188 | a.onclick = function(){ |
---|
189 | storeLink(link); |
---|
190 | if (!$(a).parent().parent().hasClass('selected')) |
---|
191 | { |
---|
192 | $('.item').removeClass('selected'); |
---|
193 | $('.item').removeAttr('id'); |
---|
194 | $(a).parent().parent().addClass('selected'); |
---|
195 | $(a).parent().parent().attr('id','selected'); |
---|
196 | } |
---|
197 | var pos, anchor = $(aname), docContent = $('#doc-content'); |
---|
198 | if (anchor.parent().attr('class')=='memItemLeft') { |
---|
199 | pos = anchor.parent().position().top; |
---|
200 | } else if (anchor.position()) { |
---|
201 | pos = anchor.position().top; |
---|
202 | } |
---|
203 | if (pos) { |
---|
204 | var dist = Math.abs(Math.min( |
---|
205 | pos-docContent.offset().top, |
---|
206 | docContent[0].scrollHeight- |
---|
207 | docContent.height()-docContent.scrollTop())); |
---|
208 | docContent.animate({ |
---|
209 | scrollTop: pos + docContent.scrollTop() - docContent.offset().top |
---|
210 | },Math.max(50,Math.min(500,dist)),function(){ |
---|
211 | window.location.replace(aname); |
---|
212 | }); |
---|
213 | } |
---|
214 | }; |
---|
215 | } else { |
---|
216 | a.href = url; |
---|
217 | a.onclick = function() { storeLink(link); } |
---|
218 | } |
---|
219 | } else { |
---|
220 | if (childrenData != null) |
---|
221 | { |
---|
222 | a.className = "nolink"; |
---|
223 | a.href = "javascript:void(0)"; |
---|
224 | a.onclick = node.expandToggle.onclick; |
---|
225 | } |
---|
226 | } |
---|
227 | |
---|
228 | node.childrenUL = null; |
---|
229 | node.getChildrenUL = function() { |
---|
230 | if (!node.childrenUL) { |
---|
231 | node.childrenUL = document.createElement("ul"); |
---|
232 | node.childrenUL.className = "children_ul"; |
---|
233 | node.childrenUL.style.display = "none"; |
---|
234 | node.li.appendChild(node.childrenUL); |
---|
235 | } |
---|
236 | return node.childrenUL; |
---|
237 | }; |
---|
238 | |
---|
239 | return node; |
---|
240 | } |
---|
241 | |
---|
242 | function showRoot() |
---|
243 | { |
---|
244 | var headerHeight = $("#top").height(); |
---|
245 | var footerHeight = $("#nav-path").height(); |
---|
246 | var windowHeight = $(window).height() - headerHeight - footerHeight; |
---|
247 | (function (){ // retry until we can scroll to the selected item |
---|
248 | try { |
---|
249 | var navtree=$('#nav-tree'); |
---|
250 | navtree.scrollTo('#selected',0,{offset:-windowHeight/2}); |
---|
251 | } catch (err) { |
---|
252 | setTimeout(arguments.callee, 0); |
---|
253 | } |
---|
254 | })(); |
---|
255 | } |
---|
256 | |
---|
257 | function expandNode(o, node, imm, showRoot) |
---|
258 | { |
---|
259 | if (node.childrenData && !node.expanded) { |
---|
260 | if (typeof(node.childrenData)==='string') { |
---|
261 | var varName = node.childrenData; |
---|
262 | getScript(node.relpath+varName,function(){ |
---|
263 | node.childrenData = getData(varName); |
---|
264 | expandNode(o, node, imm, showRoot); |
---|
265 | }, showRoot); |
---|
266 | } else { |
---|
267 | if (!node.childrenVisited) { |
---|
268 | getNode(o, node); |
---|
269 | } if (imm || ($.browser.msie && $.browser.version>8)) { |
---|
270 | // somehow slideDown jumps to the start of tree for IE9 :-( |
---|
271 | $(node.getChildrenUL()).show(); |
---|
272 | } else { |
---|
273 | $(node.getChildrenUL()).slideDown("fast"); |
---|
274 | } |
---|
275 | if (node.isLast) { |
---|
276 | node.plus_img.src = node.relpath+"ftv2mlastnode.png"; |
---|
277 | } else { |
---|
278 | node.plus_img.src = node.relpath+"ftv2mnode.png"; |
---|
279 | } |
---|
280 | node.expanded = true; |
---|
281 | } |
---|
282 | } |
---|
283 | } |
---|
284 | |
---|
285 | function glowEffect(n,duration) |
---|
286 | { |
---|
287 | n.addClass('glow').delay(duration).queue(function(next){ |
---|
288 | $(this).removeClass('glow');next(); |
---|
289 | }); |
---|
290 | } |
---|
291 | |
---|
292 | function highlightAnchor() |
---|
293 | { |
---|
294 | var anchor = $($(location).attr('hash')); |
---|
295 | if (anchor.parent().attr('class')=='memItemLeft'){ |
---|
296 | var rows = $('.memberdecls tr[class$="'+ |
---|
297 | window.location.hash.substring(1)+'"]'); |
---|
298 | glowEffect(rows.children(),300); // member without details |
---|
299 | } else if (anchor.parents().slice(2).prop('tagName')=='TR') { |
---|
300 | glowEffect(anchor.parents('div.memitem'),1000); // enum value |
---|
301 | } else if (anchor.parent().attr('class')=='fieldtype'){ |
---|
302 | glowEffect(anchor.parent().parent(),1000); // struct field |
---|
303 | } else if (anchor.parent().is(":header")) { |
---|
304 | glowEffect(anchor.parent(),1000); // section header |
---|
305 | } else { |
---|
306 | glowEffect(anchor.next(),1000); // normal member |
---|
307 | } |
---|
308 | } |
---|
309 | |
---|
310 | function selectAndHighlight(hash,n) |
---|
311 | { |
---|
312 | var a; |
---|
313 | if (hash) { |
---|
314 | var link=stripPath($(location).attr('pathname'))+':'+hash.substring(1); |
---|
315 | a=$('.item a[class$="'+link+'"]'); |
---|
316 | } |
---|
317 | if (a && a.length) { |
---|
318 | a.parent().parent().addClass('selected'); |
---|
319 | a.parent().parent().attr('id','selected'); |
---|
320 | highlightAnchor(); |
---|
321 | } else if (n) { |
---|
322 | $(n.itemDiv).addClass('selected'); |
---|
323 | $(n.itemDiv).attr('id','selected'); |
---|
324 | } |
---|
325 | showRoot(); |
---|
326 | } |
---|
327 | |
---|
328 | function showNode(o, node, index, hash) |
---|
329 | { |
---|
330 | if (node && node.childrenData) { |
---|
331 | if (typeof(node.childrenData)==='string') { |
---|
332 | var varName = node.childrenData; |
---|
333 | getScript(node.relpath+varName,function(){ |
---|
334 | node.childrenData = getData(varName); |
---|
335 | showNode(o,node,index,hash); |
---|
336 | },true); |
---|
337 | } else { |
---|
338 | if (!node.childrenVisited) { |
---|
339 | getNode(o, node); |
---|
340 | } |
---|
341 | $(node.getChildrenUL()).show(); |
---|
342 | if (node.isLast) { |
---|
343 | node.plus_img.src = node.relpath+"ftv2mlastnode.png"; |
---|
344 | } else { |
---|
345 | node.plus_img.src = node.relpath+"ftv2mnode.png"; |
---|
346 | } |
---|
347 | node.expanded = true; |
---|
348 | var n = node.children[o.breadcrumbs[index]]; |
---|
349 | if (index+1<o.breadcrumbs.length) { |
---|
350 | showNode(o,n,index+1,hash); |
---|
351 | } else { |
---|
352 | if (typeof(n.childrenData)==='string') { |
---|
353 | var varName = n.childrenData; |
---|
354 | getScript(n.relpath+varName,function(){ |
---|
355 | n.childrenData = getData(varName); |
---|
356 | node.expanded=false; |
---|
357 | showNode(o,node,index,hash); // retry with child node expanded |
---|
358 | },true); |
---|
359 | } else { |
---|
360 | var rootBase = stripPath(o.toroot.replace(/\..+$/, '')); |
---|
361 | if (rootBase=="index" || rootBase=="pages") { |
---|
362 | expandNode(o, n, true, true); |
---|
363 | } |
---|
364 | selectAndHighlight(hash,n); |
---|
365 | } |
---|
366 | } |
---|
367 | } |
---|
368 | } else { |
---|
369 | selectAndHighlight(hash); |
---|
370 | } |
---|
371 | } |
---|
372 | |
---|
373 | function getNode(o, po) |
---|
374 | { |
---|
375 | po.childrenVisited = true; |
---|
376 | var l = po.childrenData.length-1; |
---|
377 | for (var i in po.childrenData) { |
---|
378 | var nodeData = po.childrenData[i]; |
---|
379 | po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2], |
---|
380 | i==l); |
---|
381 | } |
---|
382 | } |
---|
383 | |
---|
384 | function gotoNode(o,subIndex,root,hash,relpath) |
---|
385 | { |
---|
386 | var nti = navTreeSubIndices[subIndex][root+hash]; |
---|
387 | o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]); |
---|
388 | if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index |
---|
389 | navTo(o,NAVTREE[0][1],"",relpath); |
---|
390 | $('.item').removeClass('selected'); |
---|
391 | $('.item').removeAttr('id'); |
---|
392 | } |
---|
393 | if (o.breadcrumbs) { |
---|
394 | o.breadcrumbs.unshift(0); // add 0 for root node |
---|
395 | showNode(o, o.node, 0, hash); |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | function navTo(o,root,hash,relpath) |
---|
400 | { |
---|
401 | var link = cachedLink(); |
---|
402 | if (link) { |
---|
403 | var parts = link.split('#'); |
---|
404 | root = parts[0]; |
---|
405 | if (parts.length>1) hash = '#'+parts[1]; |
---|
406 | else hash=''; |
---|
407 | } |
---|
408 | if (root==NAVTREE[0][1]) { |
---|
409 | $('#nav-sync').css('top','30px'); |
---|
410 | } else { |
---|
411 | $('#nav-sync').css('top','5px'); |
---|
412 | } |
---|
413 | if (hash.match(/^#l\d+$/)) { |
---|
414 | var anchor=$('a[name='+hash.substring(1)+']'); |
---|
415 | glowEffect(anchor.parent(),1000); // line number |
---|
416 | hash=''; // strip line number anchors |
---|
417 | //root=root.replace(/_source\./,'.'); // source link to doc link |
---|
418 | } |
---|
419 | var url=root+hash; |
---|
420 | var i=-1; |
---|
421 | while (NAVTREEINDEX[i+1]<=url) i++; |
---|
422 | if (navTreeSubIndices[i]) { |
---|
423 | gotoNode(o,i,root,hash,relpath) |
---|
424 | } else { |
---|
425 | getScript(relpath+'navtreeindex'+i,function(){ |
---|
426 | navTreeSubIndices[i] = eval('NAVTREEINDEX'+i); |
---|
427 | if (navTreeSubIndices[i]) { |
---|
428 | gotoNode(o,i,root,hash,relpath); |
---|
429 | } |
---|
430 | },true); |
---|
431 | } |
---|
432 | } |
---|
433 | |
---|
434 | function showSyncOff(n,relpath) |
---|
435 | { |
---|
436 | n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>'); |
---|
437 | } |
---|
438 | |
---|
439 | function showSyncOn(n,relpath) |
---|
440 | { |
---|
441 | n.html('<img src="'+relpath+'sync_on.png"/ title="'+SYNCONMSG+'">'); |
---|
442 | } |
---|
443 | |
---|
444 | function toggleSyncButton(relpath) |
---|
445 | { |
---|
446 | var navSync = $('#nav-sync'); |
---|
447 | if (navSync.hasClass('sync')) { |
---|
448 | navSync.removeClass('sync'); |
---|
449 | showSyncOff(navSync,relpath); |
---|
450 | storeLink(stripPath2($(location).attr('pathname'))+$(location).attr('hash')); |
---|
451 | } else { |
---|
452 | navSync.addClass('sync'); |
---|
453 | showSyncOn(navSync,relpath); |
---|
454 | deleteLink(); |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | function initNavTree(toroot,relpath) |
---|
459 | { |
---|
460 | var o = new Object(); |
---|
461 | o.toroot = toroot; |
---|
462 | o.node = new Object(); |
---|
463 | o.node.li = document.getElementById("nav-tree-contents"); |
---|
464 | o.node.childrenData = NAVTREE; |
---|
465 | o.node.children = new Array(); |
---|
466 | o.node.childrenUL = document.createElement("ul"); |
---|
467 | o.node.getChildrenUL = function() { return o.node.childrenUL; }; |
---|
468 | o.node.li.appendChild(o.node.childrenUL); |
---|
469 | o.node.depth = 0; |
---|
470 | o.node.relpath = relpath; |
---|
471 | o.node.expanded = false; |
---|
472 | o.node.isLast = true; |
---|
473 | o.node.plus_img = document.createElement("img"); |
---|
474 | o.node.plus_img.src = relpath+"ftv2pnode.png"; |
---|
475 | o.node.plus_img.width = 16; |
---|
476 | o.node.plus_img.height = 22; |
---|
477 | |
---|
478 | if (localStorageSupported()) { |
---|
479 | var navSync = $('#nav-sync'); |
---|
480 | if (cachedLink()) { |
---|
481 | showSyncOff(navSync,relpath); |
---|
482 | navSync.removeClass('sync'); |
---|
483 | } else { |
---|
484 | showSyncOn(navSync,relpath); |
---|
485 | } |
---|
486 | navSync.click(function(){ toggleSyncButton(relpath); }); |
---|
487 | } |
---|
488 | |
---|
489 | navTo(o,toroot,window.location.hash,relpath); |
---|
490 | |
---|
491 | $(window).bind('hashchange', function(){ |
---|
492 | if (window.location.hash && window.location.hash.length>1){ |
---|
493 | var a; |
---|
494 | if ($(location).attr('hash')){ |
---|
495 | var clslink=stripPath($(location).attr('pathname'))+':'+ |
---|
496 | $(location).attr('hash').substring(1); |
---|
497 | a=$('.item a[class$="'+clslink+'"]'); |
---|
498 | } |
---|
499 | if (a==null || !$(a).parent().parent().hasClass('selected')){ |
---|
500 | $('.item').removeClass('selected'); |
---|
501 | $('.item').removeAttr('id'); |
---|
502 | } |
---|
503 | var link=stripPath2($(location).attr('pathname')); |
---|
504 | navTo(o,link,$(location).attr('hash'),relpath); |
---|
505 | } |
---|
506 | }) |
---|
507 | |
---|
508 | $(window).load(showRoot); |
---|
509 | } |
---|
510 | |
---|