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