~ubuntu-branches/ubuntu/wily/sqlite3/wily

« back to all changes in this revision

Viewing changes to images/fileformat/rtdocs.js

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2012-06-13 21:43:48 UTC
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: package-import@ubuntu.com-20120613214348-uy14uupdeq0hh04k
Tags: upstream-3.7.13/www
Import upstream version 3.7.13, component www

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
function populate_toc () {
 
4
  var children = document.getElementsByTagName("h1").item(0).parentNode.childNodes
 
5
  var toc = ""
 
6
 
 
7
  var counters = new Array()
 
8
  counters[1] = 0
 
9
  counters[2] = 0
 
10
  counters[3] = 0
 
11
  counters[4] = 0
 
12
 
 
13
  /* Generate the table of contents */
 
14
  for(var ii=0; ii<children.length; ii++){
 
15
    var node = children.item(ii)
 
16
    var iHeader = -1
 
17
    if( node.tagName == "H1" ){ iHeader = 1 }
 
18
    if( node.tagName == "H2" ){ iHeader = 2 }
 
19
    if( node.tagName == "H3" ){ iHeader = 3 }
 
20
    if( node.tagName == "H4" ){ iHeader = 4 }
 
21
 
 
22
    if( iHeader>0 ){
 
23
      var anchor = "tocentry_" + ii
 
24
 
 
25
      for(var jj=iHeader+1; jj<=4; jj++){ counters[jj] = 0 }
 
26
      counters[iHeader]++
 
27
 
 
28
      var number = ""
 
29
      for(var jj=1; jj<=iHeader; jj++){ number += counters[jj] + "." }
 
30
 
 
31
      toc += '<div style="margin-left:' + (iHeader*6) + 'ex">'
 
32
      toc += '<a href="#' + anchor + '">' + number + " " + node.innerHTML
 
33
      toc += "</a></div>"
 
34
      
 
35
      var a = '<a style="color:inherit" name="' + anchor + '">' + number + '</a>'
 
36
      node.innerHTML = a + " " + node.innerHTML
 
37
    }
 
38
  }
 
39
  document.getElementById("toc").innerHTML = toc
 
40
}
 
41
 
 
42
function number_figs () {
 
43
  /* Number the figures in this document */
 
44
  var figcounter = 1
 
45
  var spans = document.getElementsByTagName("span")
 
46
  for(var ii=0; ii<spans.length; ii++){
 
47
    var s = spans.item(ii)
 
48
    if( s.className=="fig" ){
 
49
      s.innerHTML = figcounter
 
50
      figcounter++
 
51
    }
 
52
  }
 
53
}
 
54
 
 
55
function populate_refs () {
 
56
  /* Fix up <cite> references */
 
57
  var cites = document.getElementsByTagName("cite")
 
58
  for(var ii=0; ii<cites.length; ii++){
 
59
    var t = cites.item(ii).innerHTML
 
60
    var h = document.getElementById(t)
 
61
 
 
62
    if( !h ){
 
63
      alert("Bad reference: " + t)
 
64
      continue
 
65
    }
 
66
 
 
67
    var label
 
68
    if( h.tagName=="H1" || h.tagName=="H2"
 
69
     || h.tagName=="H3" || h.tagName=="H4"
 
70
    ){
 
71
      label = h.firstChild.firstChild.data
 
72
      label = label.substring(0, label.length-1)
 
73
    } else {
 
74
      label = h.firstChild.data
 
75
    }
 
76
 
 
77
    cites.item(ii).innerHTML = '<a href="#' + t + '">' + label + '</a>'
 
78
  }
 
79
}
 
80
 
 
81
function decorate_tables () {
 
82
  /* Decorate tables */
 
83
  var tables = document.getElementsByTagName("table")
 
84
  for(var ii=0; ii<tables.length; ii++){
 
85
    var t = tables.item(ii)
 
86
    if( t.className!="striped" ) continue
 
87
    var rows = t.rows
 
88
    for(var jj=1; jj<rows.length; jj += 2){
 
89
      rows.item(jj).style.backgroundColor = '#DDDDDD'
 
90
    }
 
91
  }
 
92
}
 
93
 
 
94
function check_for_duplicates () {
 
95
  var aReq = new Array();
 
96
  var ps = document.getElementsByTagName("p")
 
97
 
 
98
  for(var ii=0; ii<ps.length; ii++){
 
99
    var p = ps.item(ii)
 
100
    if( p.className!="req" || !p.id ) continue;
 
101
 
 
102
    if( aReq[p.id] ){
 
103
      alert("Duplicate requirement number: " + p.id)
 
104
    }
 
105
    aReq[p.id] = 1;
 
106
  }
 
107
}
 
108
 
 
109
onload = function () {
 
110
  number_figs()
 
111
  populate_toc()
 
112
  populate_refs()
 
113
  decorate_tables()
 
114
  check_for_duplicates()
 
115
}
 
116