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