PageSourceSearch

https://congtynemthangloi.com/assets/js/seek-and-wrap.js?v=sWrDaVvjX

js congtynemthangloi.com collected 2026-10-07 23:40:13 UTC 2,073 bytes, 66 lines download raw bytes

1/**
2 * seekAndWrap v 0.1
3 * @author Jamel Eddine Zarga http://www.tooltipy.com
4 *
5 * jQuery Plugin to find a text in a given element and wrap it with a tag and attributes in parameter in order to use it in useful cases.
6 *
7 */
8$.fn.seekAndWrap = function( opt ){
9  var defaut = {
10    "search": "",
11    "attribs":null,
12    "tag":"div",
13    "class":"",
14    "insensitive": true
15  };
16  var params = $.extend(defaut, opt);
17  function wrapIt( elem, params ){
18    elem.contents().each(function(){
19      if( this.nodeType == Node.TEXT_NODE ){
20        var content = $(this).text();
21        var before_search = '^|\\W'; // ^|\W : start OR non-word character
22        var after_search = '$|\\W';  // $|\\W : end OR non-word character
23        var flags = 'g';
24        if( params.insensitive === true ){
25          flags = flags+'i'
26        }
27        var pattern = new RegExp('('+before_search+')('+params.search+')('+after_search+')',flags);
28        var new_elem;
29        console.log(pattern);
30        var replacer = function(match, p1, p2, p3, offset, string){
31          // p1 group before the word
32          // p2 the word needed
33          // p3 group after the word
34          new_elem = $("<"+params.tag+" />");
35          new_elem.text( p2 );
36          if( params.attribs != null && Array.isArray(params.attribs) ){
37            params.attribs.forEach(function(attr, index){
38              if( attr.name != "" ){
39                return new_elem.attr(attr.name, attr.value);
40              }
41            });
42          }
43          if(params.class != ""){
44            new_elem.addClass(params.class);
45          }          
46          return p1+new_elem.prop('outerHTML')+p3;//
47        }
48        content = content.replace(pattern, replacer);
49        if($(this).parents('a').length > 0){
50          console.log($(this));
51        }else{
52          $(this).replaceWith(content);
53        }
54        
55      }else{
56        wrapIt( $(this), params );
57      }
58    });
59  }
60  return this.each(function(index){
61    if( "" === params.search ){
62      return false;
63    }
64    wrapIt($(this), params );
65  });
66}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.