OpenCores
URL https://opencores.org/ocsvn/usb_fpga_2_14/usb_fpga_2_14/trunk

Subversion Repositories usb_fpga_2_14

[/] [usb_fpga_2_14/] [trunk/] [docs/] [c/] [html/] [navtree.js] - Blame information for rev 2

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.