• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3//   <h3><a name="LoggerContext" href="#LoggerContext"><span
4//    class="anchor"/></a>Logger context</h3>
5
6function decorate() {
7  var anchor = findAnchorInURL(document.URL);
8  decoratePropertiesInTables(anchor);
9  decorateDoAnchor(anchor);
10  decorateConversionWordInTables(anchor);
11}
12
13// ----------------------------------------------
14function findAnchorInURL(url) {
15
16 if(url == null) return null
17  var index = url.lastIndexOf("#");
18  if(index != -1 && (index+1) < url.length)
19    return url.substr(index+1);
20  else
21    return null;
22}
23
24// ----------------------------------------------
25function decoratePropertiesInTables(anchor) {
26
27 //if(1==1) return;
28 var elems = $('tr td:first-child span.prop');
29
30 for(var i = 0; i < elems.length; i++) {
31   var e = elems[i];
32   var p = e.parentNode;
33   if(p == null) continue;
34
35   var tmpHTML = p.innerHTML;
36   var propName = e.innerHTML;
37   var nameAttr = $(e).attr('name')
38
39   if(nameAttr == null) {
40     var containerAttr = $(e).attr('container')
41     if(containerAttr != null)
42       nameAttr = containerAttr+capitaliseFirstLetter(propName);
43     else
44       nameAttr = propName;
45   }
46
47   p.innerHTML = "<a name='" + nameAttr + "' href='#" + nameAttr +
48                "'><span class='anchor'/></a><b>" +tmpHTML +"</b>";
49   scrollIfMatch(p, nameAttr, anchor);
50 } // for
51}
52
53function decorateConversionWordInTables(anchor) {
54 var elems = $('tr td.word');
55 for(var i = 0; i < elems.length; i++) {
56   var e = elems[i];
57   var tmpHTML = e.innerHTML;
58   var nameAttr = $(e).attr('name')
59   if(nameAttr == null)
60     continue;
61   e.innerHTML = "<a name='" + nameAttr + "' href='#" + nameAttr +
62                "'><span class='anchor'/></a>" +tmpHTML;
63   scrollIfMatch(e, nameAttr, anchor);
64 }
65}
66
67
68function decorateDoAnchor(anchor) {
69   var elems = $('.doAnchor');
70   for(var i = 0; i < elems.length; i++) {
71     var e = elems[i];
72     var tmpHTML = e.innerHTML;
73     var nameAttr = $(e).attr('name')
74     if(nameAttr == null) {
75       nameAttr = camelCase($.trim(tmpHTML))
76     }
77     e.innerHTML = "<a name='" + nameAttr + "' href='#" + nameAttr +
78                "'><span class='anchor'/></a>" +tmpHTML;
79     scrollIfMatch(e, nameAttr, anchor);
80   }
81}
82
83function scrollIfMatch(element, nameAttr, anchor) {
84  if(anchor != null && nameAttr.toString() == anchor)
85     element.scrollIntoView(true);
86
87
88}
89
90function capitaliseFirstLetter(str) {
91  return str.charAt(0).toUpperCase() + str.slice(1);
92}
93
94
95function camelCase(str) {
96  var res = str.trim().replace(/\s\w/g, function(match) {
97              return match.trim().toUpperCase();
98            });
99  return res;
100}
101
102