navtree.js 16 KB

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