Cleanup code, remove console log debugs.

This commit is contained in:
VonC 2013-10-26 22:33:43 +02:00
parent 28198b2ff0
commit 7aa93af0ca
1 changed files with 11 additions and 18 deletions

View File

@ -284,23 +284,18 @@
if ( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) { if ( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
var classes = matches[1]; var classes = matches[1];
console.log("'" + classes + "'"); nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
nodeValue = nodeValue.substring(0,matches.index) + nodeValue.substring(mardownClassesInElementsRegex.lastIndex) + "ee";
console.log("'" + nodeValue + "'");
node.nodeValue = nodeValue; node.nodeValue = nodeValue;
console.log("'" + elementTarget.tagName + "'");
while( matchesClass = mardownClassRegex.exec( classes ) ) { while( matchesClass = mardownClassRegex.exec( classes ) ) {
console.log("attr='" + matchesClass[1] + "'='" + matchesClass[2] + "'");
elementTarget.setAttribute(matchesClass[1], matchesClass[2]); elementTarget.setAttribute(matchesClass[1], matchesClass[2]);
console.log("=>'" + elementTarget.attributes[matchesClass[1]].nodeValue + "'");
} }
} }
} }
/** /**
* Add classes to the parent element of a text node * Add attributes to the parent element of a text node,
* From http://stackoverflow.com/questions/9178174/find-all-text-nodes * or the element of an attribute node.
*/ */
function addAttributes( element ) function addAttributes( element )
{ {
@ -312,17 +307,15 @@
} }
var nodeValue; var nodeValue;
var elementTarget; var elementTarget;
// From http://stackoverflow.com/questions/9178174/find-all-text-nodes
if ( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) { if ( element.nodeType == Node.TEXT_NODE && /\S/.test(element.nodeValue) ) {
addAttributeInElement( element, element.parentNode ); addAttributeInElement( element, element.parentNode );
} }
if ( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) { if ( element.nodeType == Node.ELEMENT_NODE && element.attributes.length > 0 ) {
console.log("Element '" + element.tagName + "' has " + element.attributes.length + " attributes");
for ( iattr=0; iattr<element.attributes.length; iattr++ ){ for ( iattr=0; iattr<element.attributes.length; iattr++ ){
var attr = element.attributes[iattr]; var attr = element.attributes[iattr];
console.log("Check attr '" + attr + "', name='" + attr.name + "'='" + attr.value + "'");
addAttributeInElement(attr, element) addAttributeInElement(attr, element)
} }
console.log("<== Element '" + element.tagName + "' had " + element.attributes.length + " attributes");
} }
} }