Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. key: "wrapMatchesAcrossElements",
  2. value: function wrapMatchesAcrossElements(regex, ignoreGroups, filterCb, eachCb, endCb) {
  3. var _this6 = this;
  4. var matchIdx = ignoreGroups === 0 ? 0 : ignoreGroups + 1;
  5. this.getTextNodes(function (dict) {
  6.  
  7. var match = void 0;
  8. //while ((match = regex.exec(dict.value)) !== null && match[matchIdx] !== "") {
  9. while ((match = XRegExp.exec(dict.value, regex)) !== null && match[matchIdx] !== "") {
  10.  
  11. var start = match.index;
  12. if (matchIdx !== 0) {
  13. for (var i = 1; i < matchIdx; i++) {
  14. start += match[i].length;
  15. }
  16. }
  17. var end = start + match[matchIdx].length;
  18.  
  19. _this6.wrapRangeInMappedTextNode(dict, start, end, function (node) {
  20. return filterCb(match[matchIdx], node);
  21. }, function (node, lastIndex) {
  22. regex.lastIndex = lastIndex;
  23. //alert(regex);
  24. eachCb(node);
  25. });
  26. }
  27. endCb();
  28. });
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement