annotate C++/api/html/navtree.js @ 592:76c6b3fd0a05

First commit. Refer to the api [1] 'Philosophy of the implementation' for information on the approach used to implement CARFAC in C++. [1] aimc/C++/api/html/index.html
author flatmax
date Sat, 09 Feb 2013 23:53:48 +0000
parents
children 97976133eb4d
rev   line source
flatmax@592 1 var NAVTREE =
flatmax@592 2 [
flatmax@592 3 [ "CARFAC C++", "index.html", [
flatmax@592 4 [ "CARFAC C++", "index.html", null ],
flatmax@592 5 [ "Classes", null, [
flatmax@592 6 [ "Class List", "annotated.html", "annotated" ],
flatmax@592 7 [ "Class Index", "classes.html", null ],
flatmax@592 8 [ "Class Hierarchy", "hierarchy.html", "hierarchy" ],
flatmax@592 9 [ "Class Members", "functions.html", [
flatmax@592 10 [ "All", "functions.html", null ],
flatmax@592 11 [ "Functions", "functions_func.html", null ],
flatmax@592 12 [ "Variables", "functions_vars.html", null ]
flatmax@592 13 ] ]
flatmax@592 14 ] ],
flatmax@592 15 [ "Files", null, [
flatmax@592 16 [ "File List", "files.html", "files" ],
flatmax@592 17 [ "File Members", "globals.html", [
flatmax@592 18 [ "All", "globals.html", null ],
flatmax@592 19 [ "Typedefs", "globals_type.html", null ],
flatmax@592 20 [ "Defines", "globals_defs.html", null ]
flatmax@592 21 ] ]
flatmax@592 22 ] ]
flatmax@592 23 ] ]
flatmax@592 24 ];
flatmax@592 25
flatmax@592 26 function getData(varName)
flatmax@592 27 {
flatmax@592 28 var i = varName.lastIndexOf('/');
flatmax@592 29 var n = i>=0 ? varName.substring(i+1) : varName;
flatmax@592 30 return eval(n);
flatmax@592 31 }
flatmax@592 32
flatmax@592 33 function stripPath(uri)
flatmax@592 34 {
flatmax@592 35 return uri.substring(uri.lastIndexOf('/')+1);
flatmax@592 36 }
flatmax@592 37
flatmax@592 38 function getScript(scriptName,func,show)
flatmax@592 39 {
flatmax@592 40 var head = document.getElementsByTagName("head")[0];
flatmax@592 41 var script = document.createElement('script');
flatmax@592 42 script.id = scriptName;
flatmax@592 43 script.type = 'text/javascript';
flatmax@592 44 script.onload = func;
flatmax@592 45 script.src = scriptName+'.js';
flatmax@592 46 script.onreadystatechange = function() {
flatmax@592 47 if (script.readyState == 'complete') { func(); if (show) showRoot(); }
flatmax@592 48 };
flatmax@592 49 head.appendChild(script);
flatmax@592 50 }
flatmax@592 51
flatmax@592 52 function createIndent(o,domNode,node,level)
flatmax@592 53 {
flatmax@592 54 if (node.parentNode && node.parentNode.parentNode)
flatmax@592 55 {
flatmax@592 56 createIndent(o,domNode,node.parentNode,level+1);
flatmax@592 57 }
flatmax@592 58 var imgNode = document.createElement("img");
flatmax@592 59 imgNode.width = 16;
flatmax@592 60 imgNode.height = 22;
flatmax@592 61 if (level==0 && node.childrenData)
flatmax@592 62 {
flatmax@592 63 node.plus_img = imgNode;
flatmax@592 64 node.expandToggle = document.createElement("a");
flatmax@592 65 node.expandToggle.href = "javascript:void(0)";
flatmax@592 66 node.expandToggle.onclick = function()
flatmax@592 67 {
flatmax@592 68 if (node.expanded)
flatmax@592 69 {
flatmax@592 70 $(node.getChildrenUL()).slideUp("fast");
flatmax@592 71 if (node.isLast)
flatmax@592 72 {
flatmax@592 73 node.plus_img.src = node.relpath+"ftv2plastnode.png";
flatmax@592 74 }
flatmax@592 75 else
flatmax@592 76 {
flatmax@592 77 node.plus_img.src = node.relpath+"ftv2pnode.png";
flatmax@592 78 }
flatmax@592 79 node.expanded = false;
flatmax@592 80 }
flatmax@592 81 else
flatmax@592 82 {
flatmax@592 83 expandNode(o, node, false, false);
flatmax@592 84 }
flatmax@592 85 }
flatmax@592 86 node.expandToggle.appendChild(imgNode);
flatmax@592 87 domNode.appendChild(node.expandToggle);
flatmax@592 88 }
flatmax@592 89 else
flatmax@592 90 {
flatmax@592 91 domNode.appendChild(imgNode);
flatmax@592 92 }
flatmax@592 93 if (level==0)
flatmax@592 94 {
flatmax@592 95 if (node.isLast)
flatmax@592 96 {
flatmax@592 97 if (node.childrenData)
flatmax@592 98 {
flatmax@592 99 imgNode.src = node.relpath+"ftv2plastnode.png";
flatmax@592 100 }
flatmax@592 101 else
flatmax@592 102 {
flatmax@592 103 imgNode.src = node.relpath+"ftv2lastnode.png";
flatmax@592 104 domNode.appendChild(imgNode);
flatmax@592 105 }
flatmax@592 106 }
flatmax@592 107 else
flatmax@592 108 {
flatmax@592 109 if (node.childrenData)
flatmax@592 110 {
flatmax@592 111 imgNode.src = node.relpath+"ftv2pnode.png";
flatmax@592 112 }
flatmax@592 113 else
flatmax@592 114 {
flatmax@592 115 imgNode.src = node.relpath+"ftv2node.png";
flatmax@592 116 domNode.appendChild(imgNode);
flatmax@592 117 }
flatmax@592 118 }
flatmax@592 119 }
flatmax@592 120 else
flatmax@592 121 {
flatmax@592 122 if (node.isLast)
flatmax@592 123 {
flatmax@592 124 imgNode.src = node.relpath+"ftv2blank.png";
flatmax@592 125 }
flatmax@592 126 else
flatmax@592 127 {
flatmax@592 128 imgNode.src = node.relpath+"ftv2vertline.png";
flatmax@592 129 }
flatmax@592 130 }
flatmax@592 131 imgNode.border = "0";
flatmax@592 132 }
flatmax@592 133
flatmax@592 134 function newNode(o, po, text, link, childrenData, lastNode)
flatmax@592 135 {
flatmax@592 136 var node = new Object();
flatmax@592 137 node.children = Array();
flatmax@592 138 node.childrenData = childrenData;
flatmax@592 139 node.depth = po.depth + 1;
flatmax@592 140 node.relpath = po.relpath;
flatmax@592 141 node.isLast = lastNode;
flatmax@592 142
flatmax@592 143 node.li = document.createElement("li");
flatmax@592 144 po.getChildrenUL().appendChild(node.li);
flatmax@592 145 node.parentNode = po;
flatmax@592 146
flatmax@592 147 node.itemDiv = document.createElement("div");
flatmax@592 148 node.itemDiv.className = "item";
flatmax@592 149
flatmax@592 150 node.labelSpan = document.createElement("span");
flatmax@592 151 node.labelSpan.className = "label";
flatmax@592 152
flatmax@592 153 createIndent(o,node.itemDiv,node,0);
flatmax@592 154 node.itemDiv.appendChild(node.labelSpan);
flatmax@592 155 node.li.appendChild(node.itemDiv);
flatmax@592 156
flatmax@592 157 var a = document.createElement("a");
flatmax@592 158 node.labelSpan.appendChild(a);
flatmax@592 159 node.label = document.createTextNode(text);
flatmax@592 160 node.expanded = false;
flatmax@592 161 a.appendChild(node.label);
flatmax@592 162 if (link)
flatmax@592 163 {
flatmax@592 164 a.className = stripPath(link.replace('#',':'));
flatmax@592 165 if (link.indexOf('#')!=-1)
flatmax@592 166 {
flatmax@592 167 var aname = '#'+link.split('#')[1];
flatmax@592 168 var srcPage = stripPath($(location).attr('pathname'));
flatmax@592 169 var targetPage = stripPath(link.split('#')[0]);
flatmax@592 170 a.href = srcPage!=targetPage ? node.relpath+link : '#';
flatmax@592 171 a.onclick = function(){
flatmax@592 172 $('.item').removeClass('selected');
flatmax@592 173 $('.item').removeAttr('id');
flatmax@592 174 $(a).parent().parent().addClass('selected');
flatmax@592 175 $(a).parent().parent().attr('id','selected');
flatmax@592 176 var anchor = $(aname);
flatmax@592 177 $("#doc-content").animate({
flatmax@592 178 scrollTop: anchor.position().top +
flatmax@592 179 $('#doc-content').scrollTop() -
flatmax@592 180 $('#doc-content').offset().top
flatmax@592 181 },500,function(){
flatmax@592 182 window.location.replace(aname);
flatmax@592 183 });
flatmax@592 184 };
flatmax@592 185 }
flatmax@592 186 else
flatmax@592 187 {
flatmax@592 188 a.href = node.relpath+link;
flatmax@592 189 }
flatmax@592 190 }
flatmax@592 191 else
flatmax@592 192 {
flatmax@592 193 if (childrenData != null)
flatmax@592 194 {
flatmax@592 195 a.className = "nolink";
flatmax@592 196 a.href = "javascript:void(0)";
flatmax@592 197 a.onclick = node.expandToggle.onclick;
flatmax@592 198 }
flatmax@592 199 }
flatmax@592 200
flatmax@592 201 node.childrenUL = null;
flatmax@592 202 node.getChildrenUL = function()
flatmax@592 203 {
flatmax@592 204 if (!node.childrenUL)
flatmax@592 205 {
flatmax@592 206 node.childrenUL = document.createElement("ul");
flatmax@592 207 node.childrenUL.className = "children_ul";
flatmax@592 208 node.childrenUL.style.display = "none";
flatmax@592 209 node.li.appendChild(node.childrenUL);
flatmax@592 210 }
flatmax@592 211 return node.childrenUL;
flatmax@592 212 };
flatmax@592 213
flatmax@592 214 return node;
flatmax@592 215 }
flatmax@592 216
flatmax@592 217 function showRoot()
flatmax@592 218 {
flatmax@592 219 var headerHeight = $("#top").height();
flatmax@592 220 var footerHeight = $("#nav-path").height();
flatmax@592 221 var windowHeight = $(window).height() - headerHeight - footerHeight;
flatmax@592 222 (function (){ // retry until we can scroll to the selected item
flatmax@592 223 try {
flatmax@592 224 navtree.scrollTo('#selected',0,{offset:-windowHeight/2});
flatmax@592 225 } catch (err) {
flatmax@592 226 setTimeout(arguments.callee, 0);
flatmax@592 227 }
flatmax@592 228 })();
flatmax@592 229 }
flatmax@592 230
flatmax@592 231 function expandNode(o, node, imm, showRoot)
flatmax@592 232 {
flatmax@592 233 if (node.childrenData && !node.expanded)
flatmax@592 234 {
flatmax@592 235 if (typeof(node.childrenData)==='string')
flatmax@592 236 {
flatmax@592 237 var varName = node.childrenData;
flatmax@592 238 getScript(node.relpath+varName,function(){
flatmax@592 239 node.childrenData = getData(varName);
flatmax@592 240 expandNode(o, node, imm, showRoot);
flatmax@592 241 }, showRoot);
flatmax@592 242 }
flatmax@592 243 else
flatmax@592 244 {
flatmax@592 245 if (!node.childrenVisited)
flatmax@592 246 {
flatmax@592 247 getNode(o, node);
flatmax@592 248 }
flatmax@592 249 if (imm)
flatmax@592 250 {
flatmax@592 251 $(node.getChildrenUL()).show();
flatmax@592 252 }
flatmax@592 253 else
flatmax@592 254 {
flatmax@592 255 $(node.getChildrenUL()).slideDown("fast");
flatmax@592 256 }
flatmax@592 257 if (node.isLast)
flatmax@592 258 {
flatmax@592 259 node.plus_img.src = node.relpath+"ftv2mlastnode.png";
flatmax@592 260 }
flatmax@592 261 else
flatmax@592 262 {
flatmax@592 263 node.plus_img.src = node.relpath+"ftv2mnode.png";
flatmax@592 264 }
flatmax@592 265 node.expanded = true;
flatmax@592 266 }
flatmax@592 267 }
flatmax@592 268 }
flatmax@592 269
flatmax@592 270 function showNode(o, node, index)
flatmax@592 271 {
flatmax@592 272 if (node.childrenData && !node.expanded)
flatmax@592 273 {
flatmax@592 274 if (typeof(node.childrenData)==='string')
flatmax@592 275 {
flatmax@592 276 var varName = node.childrenData;
flatmax@592 277 getScript(node.relpath+varName,function(){
flatmax@592 278 node.childrenData = getData(varName);
flatmax@592 279 showNode(o,node,index);
flatmax@592 280 },true);
flatmax@592 281 }
flatmax@592 282 else
flatmax@592 283 {
flatmax@592 284 if (!node.childrenVisited)
flatmax@592 285 {
flatmax@592 286 getNode(o, node);
flatmax@592 287 }
flatmax@592 288 $(node.getChildrenUL()).show();
flatmax@592 289 if (node.isLast)
flatmax@592 290 {
flatmax@592 291 node.plus_img.src = node.relpath+"ftv2mlastnode.png";
flatmax@592 292 }
flatmax@592 293 else
flatmax@592 294 {
flatmax@592 295 node.plus_img.src = node.relpath+"ftv2mnode.png";
flatmax@592 296 }
flatmax@592 297 node.expanded = true;
flatmax@592 298 var n = node.children[o.breadcrumbs[index]];
flatmax@592 299 if (index+1<o.breadcrumbs.length)
flatmax@592 300 {
flatmax@592 301 showNode(o,n,index+1);
flatmax@592 302 }
flatmax@592 303 else
flatmax@592 304 {
flatmax@592 305 if (typeof(n.childrenData)==='string')
flatmax@592 306 {
flatmax@592 307 var varName = n.childrenData;
flatmax@592 308 getScript(n.relpath+varName,function(){
flatmax@592 309 n.childrenData = getData(varName);
flatmax@592 310 node.expanded=false;
flatmax@592 311 showNode(o,node,index); // retry with child node expanded
flatmax@592 312 },true);
flatmax@592 313 }
flatmax@592 314 else
flatmax@592 315 {
flatmax@592 316 if (o.toroot=="index.html" || n.childrenData)
flatmax@592 317 {
flatmax@592 318 expandNode(o, n, true, true);
flatmax@592 319 }
flatmax@592 320 var a;
flatmax@592 321 if ($(location).attr('hash'))
flatmax@592 322 {
flatmax@592 323 var link=stripPath($(location).attr('pathname'))+':'+
flatmax@592 324 $(location).attr('hash').substring(1);
flatmax@592 325 a=$('.item a[class*=\""'+link+'"\"]');
flatmax@592 326 }
flatmax@592 327 if (a && a.length)
flatmax@592 328 {
flatmax@592 329 a.parent().parent().addClass('selected');
flatmax@592 330 a.parent().parent().attr('id','selected');
flatmax@592 331 var anchor = $($(location).attr('hash'));
flatmax@592 332 var targetDiv = anchor.next();
flatmax@592 333 $(targetDiv).children('.memproto,.memdoc').
flatmax@592 334 effect("highlight", {}, 1500);
flatmax@592 335 }
flatmax@592 336 else
flatmax@592 337 {
flatmax@592 338 $(n.itemDiv).addClass('selected');
flatmax@592 339 $(n.itemDiv).attr('id','selected');
flatmax@592 340 }
flatmax@592 341 }
flatmax@592 342 }
flatmax@592 343 }
flatmax@592 344 }
flatmax@592 345 }
flatmax@592 346
flatmax@592 347 function getNode(o, po)
flatmax@592 348 {
flatmax@592 349 po.childrenVisited = true;
flatmax@592 350 var l = po.childrenData.length-1;
flatmax@592 351 for (var i in po.childrenData)
flatmax@592 352 {
flatmax@592 353 var nodeData = po.childrenData[i];
flatmax@592 354 po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
flatmax@592 355 i==l);
flatmax@592 356 }
flatmax@592 357 }
flatmax@592 358
flatmax@592 359 function initNavTree(toroot,relpath)
flatmax@592 360 {
flatmax@592 361 var o = new Object();
flatmax@592 362 o.toroot = toroot;
flatmax@592 363 o.node = new Object();
flatmax@592 364 o.node.li = document.getElementById("nav-tree-contents");
flatmax@592 365 o.node.childrenData = NAVTREE;
flatmax@592 366 o.node.children = new Array();
flatmax@592 367 o.node.childrenUL = document.createElement("ul");
flatmax@592 368 o.node.getChildrenUL = function() { return o.node.childrenUL; };
flatmax@592 369 o.node.li.appendChild(o.node.childrenUL);
flatmax@592 370 o.node.depth = 0;
flatmax@592 371 o.node.relpath = relpath;
flatmax@592 372 o.node.expanded = false;
flatmax@592 373 o.node.isLast = true;
flatmax@592 374 o.node.plus_img = document.createElement("img");
flatmax@592 375 o.node.plus_img.src = relpath+"ftv2pnode.png";
flatmax@592 376 o.node.plus_img.width = 16;
flatmax@592 377 o.node.plus_img.height = 22;
flatmax@592 378
flatmax@592 379 getScript(relpath+"navtreeindex",function(){
flatmax@592 380 var navTreeIndex = eval('NAVTREEINDEX');
flatmax@592 381 if (navTreeIndex) {
flatmax@592 382 o.breadcrumbs = navTreeIndex[toroot];
flatmax@592 383 if (o.breadcrumbs==null) o.breadcrumbs = navTreeIndex["index.html"];
flatmax@592 384 o.breadcrumbs.unshift(0);
flatmax@592 385 showNode(o, o.node, 0);
flatmax@592 386 }
flatmax@592 387 },true);
flatmax@592 388
flatmax@592 389 $(window).bind('hashchange', function(){
flatmax@592 390 if (window.location.hash && window.location.hash.length>1){
flatmax@592 391 var anchor = $(window.location.hash);
flatmax@592 392 var targetDiv = anchor.next();
flatmax@592 393 $(targetDiv).children('.memproto,.memdoc').effect("highlight",{},1500);
flatmax@592 394 var docContent = $('#doc-content');
flatmax@592 395 if (docContent && anchor && anchor[0] && anchor[0].ownerDocument){
flatmax@592 396 docContent.scrollTop(anchor.position().top+docContent.scrollTop()-docContent.offset().top);
flatmax@592 397 }
flatmax@592 398 var a;
flatmax@592 399 if ($(location).attr('hash')){
flatmax@592 400 var link=stripPath($(location).attr('pathname'))+':'+
flatmax@592 401 $(location).attr('hash').substring(1);
flatmax@592 402 a=$('.item a[class*=\""'+link+'"\"]');
flatmax@592 403 }
flatmax@592 404 if (a && a.length){
flatmax@592 405 $('.item').removeClass('selected');
flatmax@592 406 $('.item').removeAttr('id');
flatmax@592 407 a.parent().parent().addClass('selected');
flatmax@592 408 a.parent().parent().attr('id','selected');
flatmax@592 409 var anchor = $($(location).attr('hash'));
flatmax@592 410 var targetDiv = anchor.next();
flatmax@592 411 showRoot();
flatmax@592 412 }
flatmax@592 413 } else {
flatmax@592 414 var docContent = $('#doc-content');
flatmax@592 415 if (docContent){ docContent.scrollTop(0); }
flatmax@592 416 }
flatmax@592 417 })
flatmax@592 418
flatmax@592 419 $(window).load(showRoot);
flatmax@592 420 }
flatmax@592 421