forked from FlominatorTM/WikiTree
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWikiTreeCountDescendants.js
More file actions
47 lines (41 loc) · 1.19 KB
/
Copy pathWikiTreeCountDescendants.js
File metadata and controls
47 lines (41 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
javascript:
/* counts the number of decendants (via https://www.wikitree.com/g2g/1249590/simple-idea-for-the-descendants-list-within-profiles?show=1250209 ) */
var gens = {
0: 0,
1 : 0,
2 : 0,
3 : 0,
4 : 0,
5 : 0
};
javascript:
/* counts the number of decendants (via https://www.wikitree.com/g2g/1249590/simple-idea-for-the-descendants-list-within-profiles?show=1250209 ) */
var totalDescendants = 0;
for (var i=0; olNode = document.getElementsByTagName("ol")[i]; i++)
{
var numGenerations = CountOls(olNode);
childrenCount = 0;
for(var j=0; olChild = olNode.children[j]; j++)
{
if(olChild.tagName == "LI")
{
gens[numGenerations]++;
totalDescendants++
}
}
}
void(0);
alert("children: " + gens[0] + "\ngchildren: " + gens[1] + "\ng gchildren: " + gens[2] + "\ngg gchildren: " + gens[3] + "\nggg gchildren: " + gens[4] + "\n-----------------" + "\ntotal descendants: " + totalDescendants);
function CountOls(node)
{
var ret = 0;
while(null != node.parentNode)
{
if(node.parentNode.tagName == "OL")
{
ret = ret +1;
}
node = node.parentNode;
}
return ret;
}