Content deleted Content added
another step |
navigate up tree to determine indent level |
||
Line 4:
function unindent() {
var alert_string = "";
var diagnostic_string = "";
var indent_level = 0;
Line 19 ⟶ 20:
var num_unindented_DD_elements = 0;
var top_node;
var parent_node;
var top_DL_node;
// Colors to help sighted people after the unindenting
Line 25 ⟶ 28:
DD_elements = top_node.getElementsByTagName("DD"); diagnostic_string = "";
num_DD_elements = DD_elements.length;
for (DD_element_index=0; DD_element_index<num_DD_elements; DD_element_index++) {
Line 32 ⟶ 38:
indent_level = 0;
// Find the
top_DL_node = null;
parent_node = temp_DD_element.parentNode;
if (!parent_node) { continue; }▼
while (parent_node.nodeName != "DL") { ▼
parent_node = parent_node.parentNode;▼
if (!parent_node) { continue; }▼
// Check whether that DL element has any DT elements▼
num_DT_elements = parent_node.getElementsByTagName("DT");▼
if (num_DT_elements > 0) { continue; } // if so, don't unindent to the higher level▼
▲ num_DT_elements = parent_node.getElementsByTagName("DT");
▲ if (num_DT_elements > 0) {
// ...else make this the new indent level
indent_level++;
} // closes check for a parental DL element
} // closes loop climbing up the document tree
diagnostic_string += "DD element " + DD_element_index + " is indented to level " + indent_level + ".\n";
if (indent_level > 0) { num_unindented_DD_elements++; }
} // closes loop over the DD elements of the document
window.alert(diagnostic_string);
//Acknowledgment
|