User:Proteins/unindent.js: Difference between revisions

Content deleted Content added
Proteins (talk | contribs)
change only if indented
Proteins (talk | contribs)
change the DOM tree; still need to delete old elements
Line 23:
var parent_node;
var top_DL_node;
var top_DD_node;
 
// Colors to help sighted people after the unindenting
Line 40 ⟶ 41:
// Find the topmost DL element for this DD node
top_DL_node = null;
top_DD_node = null;
parent_node = temp_DD_element.parentNode;
 
Line 57 ⟶ 59:
top_DL_node = parent_node;
} // closes check for a parental DL element
 
if (parent_node.nodeName == "DD") { top_DD_node = parent_node; }
 
parent_node = parent_node.parentNode;
Line 65 ⟶ 69:
temp_DD_element.style.cssText = "background-color:" + DD_background_colors[indent_level];
diagnostic_string += "DD element " + DD_element_index + " is indented to level " + indent_level + ".\n";
if ((top_DD_node) && (top_DL_node)) {
}
sibling_node = top_DD_node.nextSibling;
while ((sibling_node) && (sibling_node.nodeType != 1)) {
sibling_node = sibling_node.nextSibling;
}
if (sibling_node) {
top_DL_node.insertBefore(temp_DD_element, sibling_code);
} else {
top_DL_node.appendChild(temp_DD_element);
}
} // check that both the top_DD and top_DL elements are defined
} // check for unindenting
 
} // closes loop over the DD elements of the document