/[suikacvs]/test/html-webhacc/cc-script.js
Suika

Diff of /test/html-webhacc/cc-script.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by wakaba, Mon Jul 21 12:56:33 2008 UTC revision 1.6 by wakaba, Sun Aug 10 11:49:43 2008 UTC
# Line 84  function addSourceToParseErrorList (idPr Line 84  function addSourceToParseErrorList (idPr
84    }    }
85  } // addSourceToParseErrorList  } // addSourceToParseErrorList
86    
87    function insertNavSections () {
88      var el = document.createElement ('nav');
89      el.id = 'nav-sections';
90      el.innerHTML = '<ul></ul>';
91      document.body.appendChild (el);
92      document.webhaccSections = {};
93      document.body.setAttribute ('data-scripted', '');
94    } // insertNavSections
95    
96    function addSectionLink (id, label) {
97      var el = document.createElement ('li');
98      el.innerHTML = '<a></a>';
99      el.firstChild.href = '#' + id;
100      el.firstChild.innerHTML = label;
101      document.getElementById ('nav-sections').firstChild.appendChild (el);
102      document.webhaccSections[id] = document.getElementById (id);
103      document.webhaccSections[id].tabElement = el;
104      if (id == 'input') {
105        //
106      } else if (id == 'document-info' && !document.webhaccNavigated) {
107        showTab ('document-info');
108        document.webhaccNavigated = false;
109      } else {
110        document.webhaccSections[id].style.display = 'none';
111      }
112    } // addSectionLink
113    
114    function showTab (id) {
115      var m;
116      if (id.match (/^line-/)) {
117        id = 'source-string';
118      } else if (id.match (/^node-/)) {
119        id = 'document-tree';
120      } else if (m = id.match (/^(subdoc-\d+-)/)) {
121        id = m[1];
122      }
123    
124      if (document.webhaccSections[id]) {
125        for (var i in document.webhaccSections) {
126          document.webhaccSections[i].style.display = 'none';
127          document.webhaccSections[i].tabElement.removeAttribute ('data-active');
128        }
129        document.webhaccSections[id].style.display = 'block';
130        document.webhaccSections[id].tabElement.setAttribute ('data-active', '');
131    
132        document.webhaccNavigated = true;
133      }
134    
135    } // showTab
136    
137    function getAncestorAnchorElement (e) {
138      do {
139        if (e.nodeName == 'A') {
140          return e;
141        }
142        e = e.parentNode;
143      } while (e);
144    } // getAncestorAnchorElement
145    
146    function onbodyclick (ev) {
147      var a = getAncestorAnchorElement (ev.target || ev.srcElement);
148      if (a) {
149        var href = a.getAttribute ('href');
150        if (href && href.match (/^#/)) {
151          var id = decodeURIComponent (href.substring (1));
152          showTab (id);
153          return true;
154        }
155      }
156      return true;
157    } // onbodyclick
158    
159    function onbodyload () {
160      // This block should be executed at the end of initialization process,
161      // since |decodeURIComponent| might throw.
162      if (!document.webhaccNavigated) {
163        var fragment = location.hash;
164        if (fragment) {
165          var id = decodeURIComponent (fragment.substring (1));
166          showTab (id);
167        } else if (document.webhaccSections['result-summary']) {
168          showTab ('result-summary');
169        } else {
170          showTab ('input');
171        }
172      }
173    } // onbodyload
174    
175  // $Date$  // $Date$

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24