This repository contains QRP documentation built using Doxygen.
Source
xxxxxxxxxx
1
+
/*
2
+
@licstart The following is the entire license notice for the JavaScript code in this file.
3
+
4
+
The MIT License (MIT)
5
+
6
+
Copyright (C) 1997-2020 by Dimitri van Heesch
7
+
8
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
10
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
11
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12
+
furnished to do so, subject to the following conditions:
13
+
14
+
The above copyright notice and this permission notice shall be included in all copies or
15
+
substantial portions of the Software.
16
+
17
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+
@licend The above is the entire license notice for the JavaScript code in this file
24
+
*/
25
+
26
+
function initNavTree(toroot,relpath) {
27
+
let navTreeSubIndices = [];
28
+
const ARROW_DOWN = '▼';
29
+
const ARROW_RIGHT = '►';
30
+
const NAVPATH_COOKIE_NAME = ''+'navpath';
31
+
32
+
const getData = function(varName) {
33
+
const i = varName.lastIndexOf('/');
34
+
const n = i>=0 ? varName.substring(i+1) : varName;
35
+
return eval(n.replace(/-/g,'_'));
36
+
}
37
+
38
+
const stripPath = function(uri) {
39
+
return uri.substring(uri.lastIndexOf('/')+1);
40
+
}
41
+
42
+
const stripPath2 = function(uri) {
43
+
const i = uri.lastIndexOf('/');
44
+
const s = uri.substring(i+1);
45
+
const m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
46
+
return m ? uri.substring(i-6) : s;
47
+
}
48
+
49
+
const hashValue = function() {
50
+
return $(location).attr('hash').substring(1).replace(/[^\w-]/g,'');
51
+
}
52
+
53
+
const hashUrl = function() {
54
+
return '#'+hashValue();
55
+
}
56
+
57
+
const pathName = function() {
58
+
return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;()]/g, '');
59
+
}
60
+
61
+
const storeLink = function(link) {
62
+
if (!$("#nav-sync").hasClass('sync')) {
63
+
Cookie.writeSetting(NAVPATH_COOKIE_NAME,link,0);
64
+
}
65
+
}
66
+
67
+
const deleteLink = function() {
68
+
Cookie.eraseSetting(NAVPATH_COOKIE_NAME);
69
+
}
70
+
71
+
const cachedLink = function() {
72
+
return Cookie.readSetting(NAVPATH_COOKIE_NAME,'');
73
+
}
74
+
75
+
const getScript = function(scriptName,func) {
76
+
const head = document.getElementsByTagName("head")[0];
77
+
const script = document.createElement('script');
78
+
script.id = scriptName;
79
+
script.type = 'text/javascript';
80
+
script.onload = func;
81
+
script.src = scriptName+'.js';
82
+
head.appendChild(script);
83
+
}
84
+
85
+
const createIndent = function(o,domNode,node) {
86
+
let level=-1;
87
+
let n = node;
88
+
while (n.parentNode) { level++; n=n.parentNode; }
89
+
if (node.childrenData) {
90
+
const imgNode = document.createElement("span");
91
+
imgNode.className = 'arrow';
92
+
imgNode.style.paddingLeft=(16*level).toString()+'px';
93
+
imgNode.innerHTML=ARROW_RIGHT;
94
+
node.plus_img = imgNode;
95
+
node.expandToggle = document.createElement("a");
96
+
node.expandToggle.href = "javascript:void(0)";
97
+
node.expandToggle.onclick = function() {
98
+
if (node.expanded) {
99
+
$(node.getChildrenUL()).slideUp("fast");
100
+
node.plus_img.innerHTML=ARROW_RIGHT;
101
+
node.expanded = false;
102
+
} else {
103
+
expandNode(o, node, false, true);
104
+
}
105
+
}
106
+
node.expandToggle.appendChild(imgNode);
107
+
domNode.appendChild(node.expandToggle);
108
+
} else {
109
+
let span = document.createElement("span");
110
+
span.className = 'arrow';
111
+
span.style.width = 16*(level+1)+'px';
112
+
span.innerHTML = ' ';
113
+
domNode.appendChild(span);
114
+
}
115
+
}
116
+
117
+
let animationInProgress = false;
118
+
119
+
const gotoAnchor = function(anchor,aname) {
120
+
let pos, docContent = $('#doc-content');
121
+
let ancParent = $(anchor.parent());
122
+
if (ancParent.hasClass('memItemLeft') || ancParent.hasClass('memtitle') ||
123
+
ancParent.hasClass('fieldname') || ancParent.hasClass('fieldtype') ||
124
+
ancParent.is(':header')) {
125
+
pos = ancParent.position().top;
126
+
} else if (anchor.position()) {
127
+
pos = anchor.position().top;
128
+
}
129
+
if (pos) {
130
+
const dcOffset = docContent.offset().top;
131
+
const dcHeight = docContent.height();
132
+
const dcScrHeight = docContent[0].scrollHeight
133
+
const dcScrTop = docContent.scrollTop();
134
+
let dist = Math.abs(Math.min(pos-dcOffset,dcScrHeight-dcHeight-dcScrTop));
135
+
animationInProgress = true;
136
+
docContent.animate({
137
+
scrollTop: pos + dcScrTop - dcOffset
138
+
},Math.max(50,Math.min(500,dist)),function() {
139
+
window.location.href=aname;
140
+
animationInProgress=false;
141
+
});
142
+
}
143
+
}
144
+
145
+
const newNode = function(o, po, text, link, childrenData, lastNode) {
146
+
const node = {
147
+
children : [],
148
+
childrenData : childrenData,
149
+
depth : po.depth + 1,
150
+
relpath : po.relpath,
151
+
isLast : lastNode,
152
+
li : document.createElement("li"),
153
+
parentNode : po,
154
+
itemDiv : document.createElement("div"),
155
+
labelSpan : document.createElement("span"),
156
+
label : document.createTextNode(text),
157
+
expanded : false,
158
+
childrenUL : null,
159
+
getChildrenUL : function() {
160
+
if (!this.childrenUL) {
161
+
this.childrenUL = document.createElement("ul");
162
+
this.childrenUL.className = "children_ul";
163
+
this.childrenUL.style.display = "none";
164
+
this.li.appendChild(node.childrenUL);
165
+
}
166
+
return node.childrenUL;
167
+
},
168
+
};
169
+
170
+
node.itemDiv.className = "item";
171
+
node.labelSpan.className = "label";
172
+
createIndent(o,node.itemDiv,node);
173
+
node.itemDiv.appendChild(node.labelSpan);
174
+
node.li.appendChild(node.itemDiv);
175
+
176
+
const a = document.createElement("a");
177
+
node.labelSpan.appendChild(a);
178
+
po.getChildrenUL().appendChild(node.li);
179
+
a.appendChild(node.label);
180
+
if (link) {
181
+
let url;
182
+
if (link.substring(0,1)=='^') {
183
+
url = link.substring(1);
184
+
link = url;
185
+
} else {
186
+
url = node.relpath+link;
187
+
}
188
+
a.className = stripPath(link.replace('#',':'));
189
+
if (link.indexOf('#')!=-1) {
190
+
const aname = '#'+link.split('#')[1];
191
+
const srcPage = stripPath(pathName());
192
+
const targetPage = stripPath(link.split('#')[0]);
193
+
a.href = srcPage!=targetPage ? url : aname;
194
+
a.onclick = function() {
195
+
storeLink(link);
196
+
aPPar = $(a).parent().parent();
197
+
if (!aPPar.hasClass('selected')) {
198
+
$('.item').removeClass('selected');
199
+
$('.item').removeAttr('id');
200
+
aPPar.addClass('selected');
201
+
aPPar.attr('id','selected');
202
+
}
203
+
const anchor = $(aname);
204
+
gotoAnchor(anchor,aname);
205
+
};
206
+
} else {
207
+
a.href = url;
208
+
a.onclick = () => storeLink(link);
209
+
}
210
+
} else if (childrenData != null) {
211
+
a.className = "nolink";
212
+
a.href = "javascript:void(0)";
213
+
a.onclick = node.expandToggle.onclick;
214
+
}
215
+
return node;
216
+
}
217
+
218
+
const showRoot = function() {
219
+
const headerHeight = $("#top").height();
220
+
const footerHeight = $("#nav-path").height();
221
+
const windowHeight = $(window).height() - headerHeight - footerHeight;
222
+
(function() { // retry until we can scroll to the selected item
223
+
try {
224
+
const navtree=$('#nav-tree');
225
+
navtree.scrollTo('#selected',100,{offset:-windowHeight/2});
226
+
} catch (err) {
227
+
setTimeout(arguments.callee, 0);
228
+
}
229
+
})();
230
+
}
231
+
232
+
const expandNode = function(o, node, imm, setFocus) {
233
+
if (node.childrenData && !node.expanded) {
234
+
if (typeof(node.childrenData)==='string') {
235
+
const varName = node.childrenData;
236
+
getScript(node.relpath+varName,function() {
237
+
node.childrenData = getData(varName);
238
+
expandNode(o, node, imm, setFocus);
239
+
});
240
+
} else {
241
+
if (!node.childrenVisited) {
242
+
getNode(o, node);
243
+
}
244
+
$(node.getChildrenUL()).slideDown("fast");
245
+
node.plus_img.innerHTML = ARROW_DOWN;
246
+
node.expanded = true;
247
+
if (setFocus) {
248
+
$(node.expandToggle).focus();
249
+
}
250
+
}
251
+
}
252
+
}
253
+
254
+
const glowEffect = function(n,duration) {
255
+
n.addClass('glow').delay(duration).queue(function(next) {
256
+
$(this).removeClass('glow');next();
257
+
});
258
+
}
259
+
260
+
const highlightAnchor = function() {
261
+
const aname = hashUrl();
262
+
const anchor = $(aname);
263
+
if (anchor.parent().attr('class')=='memItemLeft') {
264
+
let rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
265
+
glowEffect(rows.children(),300); // member without details
266
+
} else if (anchor.parent().attr('class')=='fieldname') {
267
+
glowEffect(anchor.parent().parent(),1000); // enum value
268
+
} else if (anchor.parent().attr('class')=='fieldtype') {
269
+
glowEffect(anchor.parent().parent(),1000); // struct field
270
+
} else if (anchor.parent().is(":header")) {
271
+
glowEffect(anchor.parent(),1000); // section header
272
+
} else {
273
+
glowEffect(anchor.next(),1000); // normal member
274
+
}
275
+
gotoAnchor(anchor,aname);
276
+
}
277
+
278
+
const selectAndHighlight = function(hash,n) {
279
+
let a;
280
+
if (hash) {
281
+
const link=stripPath(pathName())+':'+hash.substring(1);
282
+
a=$('.item a[class$="'+link+'"]');
283
+
}
284
+
if (a && a.length) {
285
+
a.parent().parent().addClass('selected');
286
+
a.parent().parent().attr('id','selected');
287
+
highlightAnchor();
288
+
} else if (n) {
289
+
$(n.itemDiv).addClass('selected');
290
+
$(n.itemDiv).attr('id','selected');
291
+
}
292
+
let topOffset=5;
293
+
if ($('#nav-tree-contents .item:first').hasClass('selected')) {
294
+
topOffset+=25;
295
+
}
296
+
$('#nav-sync').css('top',topOffset+'px');
297
+
showRoot();
298
+
}
299
+
300
+
const showNode = function(o, node, index, hash) {
301
+
if (node && node.childrenData) {
302
+
if (typeof(node.childrenData)==='string') {
303
+
const varName = node.childrenData;
304
+
getScript(node.relpath+varName,function() {
305
+
node.childrenData = getData(varName);
306
+
showNode(o,node,index,hash);
307
+
});
308
+
} else {
309
+
if (!node.childrenVisited) {
310
+
getNode(o, node);
311
+
}
312
+
$(node.getChildrenUL()).css({'display':'block'});
313
+
node.plus_img.innerHTML = ARROW_DOWN;
314
+
node.expanded = true;
315
+
const n = node.children[o.breadcrumbs[index]];
316
+
if (index+1<o.breadcrumbs.length) {
317
+
showNode(o,n,index+1,hash);
318
+
} else if (typeof(n.childrenData)==='string') {
319
+
const varName = n.childrenData;
320
+
getScript(n.relpath+varName,function() {
321
+
n.childrenData = getData(varName);
322
+
node.expanded=false;
323
+
showNode(o,node,index,hash); // retry with child node expanded
324
+
});
325
+
} else {
326
+
const rootBase = stripPath(o.toroot.replace(/\..+$/, ''));
327
+
if (rootBase=="index" || rootBase=="pages" || rootBase=="search") {
328
+
expandNode(o, n, true, false);
329
+
}
330
+
selectAndHighlight(hash,n);
331
+
}
332
+
}
333
+
} else {
334
+
selectAndHighlight(hash);
335
+
}
336
+
}
337
+
338
+
const removeToInsertLater = function(element) {
339
+
const parentNode = element.parentNode;
340
+
const nextSibling = element.nextSibling;
341
+
parentNode.removeChild(element);
342
+
return function() {
343
+
if (nextSibling) {
344
+
parentNode.insertBefore(element, nextSibling);
345
+
} else {
346
+
parentNode.appendChild(element);
347
+
}
348
+
};
349
+
}
350
+
351
+
const getNode = function(o, po) {
352
+
const insertFunction = removeToInsertLater(po.li);
353
+
po.childrenVisited = true;
354
+
const l = po.childrenData.length-1;
355
+
for (let i in po.childrenData) {
356
+
const nodeData = po.childrenData[i];
357
+
po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2], i==l);
358
+
}
359
+
insertFunction();
360
+
}
361
+
362
+
const gotoNode = function(o,subIndex,root,hash,relpath) {
363
+
const nti = navTreeSubIndices[subIndex][root+hash];
364
+
o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
365
+
if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
366
+
navTo(o,NAVTREE[0][1],"",relpath);
367
+
$('.item').removeClass('selected');
368
+
$('.item').removeAttr('id');
369
+
}
370
+
if (o.breadcrumbs) {
371
+
o.breadcrumbs.unshift(0); // add 0 for root node
372
+
showNode(o, o.node, 0, hash);
373
+
}
374
+
}
375
+
376
+
const navTo = function(o,root,hash,relpath) {
377
+
const link = cachedLink();
378
+
if (link) {
379
+
const parts = link.split('#');
380
+
root = parts[0];
381
+
hash = parts.length>1 ? '#'+parts[1].replace(/[^\w-]/g,'') : '';
382
+
}
383
+
if (hash.match(/^#l\d+$/)) {
384
+
const anchor=$('a[name='+hash.substring(1)+']');
385
+
glowEffect(anchor.parent(),1000); // line number
386
+
hash=''; // strip line number anchors
387
+
}
388
+
const url=root+hash;
389
+
let i=-1;
390
+
while (NAVTREEINDEX[i+1]<=url) i++;
391
+
if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
392
+
if (navTreeSubIndices[i]) {
393
+
gotoNode(o,i,root,hash,relpath)
394
+
} else {
395
+
getScript(relpath+'navtreeindex'+i,function() {
396
+
navTreeSubIndices[i] = eval('NAVTREEINDEX'+i);
397
+
if (navTreeSubIndices[i]) {
398
+
gotoNode(o,i,root,hash,relpath);
399
+
}
400
+
});
401
+
}
402
+
}
403
+
404
+
const showSyncOff = function(n,relpath) {
405
+
n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
406
+
}
407
+
408
+
const showSyncOn = function(n,relpath) {
409
+
n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
410
+
}
411
+
412
+
const o = {
413
+
toroot : toroot,
414
+
node : {
415
+
childrenData : NAVTREE,
416
+
children : [],
417
+
childrenUL : document.createElement("ul"),
418
+
getChildrenUL : function() { return this.childrenUL },
419
+
li : document.getElementById("nav-tree-contents"),
420
+
depth : 0,
421
+
relpath : relpath,
422
+
expanded : false,
423
+
isLast : true,
424
+
plus_img : document.createElement("span"),
425
+
},
426
+
};
427
+
o.node.li.appendChild(o.node.childrenUL);
428
+
o.node.plus_img.className = 'arrow';
429
+
o.node.plus_img.innerHTML = ARROW_RIGHT;
430
+
431
+
const navSync = $('#nav-sync');
432
+
if (cachedLink()) {
433
+
showSyncOff(navSync,relpath);
434
+
navSync.removeClass('sync');
435
+
} else {
436
+
showSyncOn(navSync,relpath);
437
+
}
438
+
439
+
navSync.click(() => {
440
+
const navSync = $('#nav-sync');
441
+
if (navSync.hasClass('sync')) {
442
+
navSync.removeClass('sync');
443
+
showSyncOff(navSync,relpath);
444
+
storeLink(stripPath2(pathName())+hashUrl());
445
+
} else {
446
+
navSync.addClass('sync');
447
+
showSyncOn(navSync,relpath);
448
+
deleteLink();
449
+
}
450
+
});
451
+
452
+
navTo(o,toroot,hashUrl(),relpath);
453
+
showRoot();
454
+
455
+
$(window).bind('hashchange', () => {
456
+
if (window.location.hash && window.location.hash.length>1) {
457
+
let a;
458
+
if ($(location).attr('hash')) {
459
+
const clslink=stripPath(pathName())+':'+hashValue();
460
+
a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
461
+
}
462
+
if (a==null || !$(a).parent().parent().hasClass('selected')) {
463
+
$('.item').removeClass('selected');
464
+
$('.item').removeAttr('id');
465
+
}
466
+
const link=stripPath2(pathName());
467
+
navTo(o,link,hashUrl(),relpath);
468
+
} else if (!animationInProgress) {
469
+
$('#doc-content').scrollTop(0);
470
+
$('.item').removeClass('selected');
471
+
$('.item').removeAttr('id');
472
+
navTo(o,toroot,hashUrl(),relpath);
473
+
}
474
+
});
475
+
476
+
$("div.toc a[href]").click(function(e) {
477
+
e.preventDefault();
478
+
const aname = $(this).attr("href");
479
+
gotoAnchor($(aname),aname);
480
+
});
481
+
}
482
+
/* @license-end */