/[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.7 by wakaba, Thu Aug 14 07:19:44 2008 UTC revision 1.10 by wakaba, Sat Aug 16 07:42:20 2008 UTC
# Line 112  function addSectionLink (id, label, pare Line 112  function addSectionLink (id, label, pare
112        .firstChild.appendChild (el);        .firstChild.appendChild (el);
113    
114    var sections = document.webhaccSections;    var sections = document.webhaccSections;
115    if (parentId != '') sections = sections[parentId].webhaccSections;    if (parentId != '') {
116        sections = document.getElementById (parentId).webhaccSections;
117      }
118    sections[id] = document.getElementById (id);    sections[id] = document.getElementById (id);
119    sections[id].tabElement = el;    sections[id].tabElement = el;
120    
# Line 122  function addSectionLink (id, label, pare Line 124  function addSectionLink (id, label, pare
124    } else if (id == 'document-info' && !document.webhaccNavigated) {    } else if (id == 'document-info' && !document.webhaccNavigated) {
125      showTab (id);      showTab (id);
126      document.webhaccNavigated = false;      document.webhaccNavigated = false;
127      } else if (id.match (/-document-info$/)) {
128        sections[id].tabElement.setAttribute ('data-active', '');
129    } else {    } else {
130      sections[id].style.display = 'none';      sections[id].style.display = 'none';
131    }    }
132  } // addSectionLink  } // addSectionLink
133    
134  function showTab (id) {  function showTab (id) {
135    var m;    var ids = [];
136    if (id.match (/^line-/)) {    if (id.match (/^line-/)) {
137      id = 'source-string';      ids = ['source-string'];
138    } else if (id.match (/^node-/)) {    } else if (id.match (/^node-/)) {
139      id = 'document-tree';      ids = ['document-tree'];
140    } else if (m = id.match (/^(subdoc-\d+-)/)) {    } else if (id.match (/^index-/)) {
141      id = m[1];      ids = ['document-structure'];
142      } else if (id.match (/^subdoc-[^-]+-/)) {
143        var m;
144        ids = [''];
145        while (true) {
146          if (m = id.match (/^subdoc-[^-]+-/)) {
147            ids.push (ids[ids.length - 1] + m[0]);
148            id = id.substring (m[0].length);
149          } else {
150            break;
151          }
152        }
153        if (id.length > 0) {
154          if (id.match (/^line-/)) {
155            ids.push (ids[ids.length - 1] + 'source-string');
156          } else if (id.match (/^node-/)) {
157            ids.push (ids[ids.length - 1] + 'document-tree');
158          } else if (id.match (/^index-/)) {
159            ids.push (ids[ids.length - 1] + 'document-structure');
160          } else {
161            ids.push (ids[ids.length - 1] + id);
162          }
163        }
164        ids.shift (); // ''
165      } else if (id.match (/^input-/)) {
166        ids = ['input', id];
167      } else {
168        ids = [id];
169    }    }
170    
171    if (id.match (/^input-/)) {    var sections = document.webhaccSections;
172      _showTab (document.webhaccSections.input.webhaccSections, id);    while (ids.length > 0) {
173      _showTab (document.webhaccSections, 'input');      var myid = ids.shift ();
174    } else {      _showTab (sections, myid);
175      _showTab (document.webhaccSections, id);      sections = sections[myid].webhaccSections;
176        if (!sections) break;
177    }    }
178  } // showTab  } // showTab
179    
# Line 153  function _showTab (sections, id) { Line 185  function _showTab (sections, id) {
185      }      }
186      sections[id].style.display = 'block';      sections[id].style.display = 'block';
187      sections[id].tabElement.setAttribute ('data-active', '');      sections[id].tabElement.setAttribute ('data-active', '');
188        sections[id].tabElement.scrollIntoView ();
189    
190      document.webhaccNavigated = true;      document.webhaccNavigated = true;
191    }    }
# Line 160  function _showTab (sections, id) { Line 193  function _showTab (sections, id) {
193    
194  function getAncestorAnchorElement (e) {  function getAncestorAnchorElement (e) {
195    do {    do {
196      if (e.nodeName == 'A') {      if (e.nodeName == 'A' || e.nodeName == 'AREA') {
197        return e;        return e;
198      }      }
199      e = e.parentNode;      e = e.parentNode;
# Line 188  function onbodyload () { Line 221  function onbodyload () {
221      if (fragment) {      if (fragment) {
222        var id = decodeURIComponent (fragment.substring (1));        var id = decodeURIComponent (fragment.substring (1));
223        showTab (id);        showTab (id);
224          var el = document.getElementById (id);
225          if (el) el.scrollIntoView ();
226      } else if (document.webhaccSections['result-summary']) {      } else if (document.webhaccSections['result-summary']) {
227        showTab ('result-summary');        showTab ('result-summary');
228      } else {      } else {

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.10

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24