| 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)]; |