navtree.js 15 KB

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