MCPcopy Index your code
hub / github.com/dvnc/annotator / getTextNodes

Function getTextNodes

example/scripts/annotation.js:241–256  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

239 found = false;
240
241 function getTextNodes(node) {
242 if (node.nodeType == Node.TEXT_NODE && !/^\s*$/.test(node.nodeValue)) {
243 if ( found != true) {
244 if(count+node.nodeValue.length >= offset) {
245 textNode = node;
246 found = true;
247 } else {
248 count += node.nodeValue.length
249 }
250 }
251 } else if (node.nodeType == Node.ELEMENT_NODE ) {
252 for (var i = 0, len = node.childNodes.length; i < len; ++i) {
253 getTextNodes(node.childNodes[i]);
254 }
255 }
256 }
257
258 getTextNodes(rootNode);
259 return [textNode, (count == 0 ? offset : offset - count)];

Callers 1

annotation.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected