navtree.js 16 KB

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