navtree.js 15 KB

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