source/web/extras/components/dashlets/audit-application.js
/**
       * Add utility prototypes to String, so that they can be used easily throughout
       *
       * @method addUtilPrototypes
       */
Add utility prototypes to String, so that they can be used easily throughout
@method addUtilPrototypes
Add utility prototypes to String so that they can be used easily throughout @method addUtilPrototypes
function AuditApplication_addUtilPrototypes()
      {
         String.prototype.swapHighlightMarkers = function(prefix)
         {
            return this.replace(/\uFFFE/g, (prefix ? prefix : "") + "<span class='regex-highlight'>").replace(/\uFFFF/g,"</span>");
         };
         String.prototype.trimHighlightMarkers = function(replacement)
         {
            return this.replace(/[\uFFFE\uFFFF]/g, replacement ? replacement : "");
         };
         String.prototype.sanitizeforHighlighting = function(text)
         {
            var metacharacters="$()*+.?[\^{|";
            return this.replace(/([\$\(\)\*\+\.\?\[\\\^\{\|])/g,function($0)
            {
               return "\\"+$0;
            });
         };
         String.prototype.elideHighlightMarkers = function(open_marker_char, close_marker_char)
         {
         var opened=false; var skip_next_close_stack=[];
         var rebuild=""; var c ='';
         for(var j=0; j< this.length; j++)
         {
            c = this.charAt(j);
            if (c == open_marker_char)
            {
               if (!opened)  { opened=true;rebuild+=c;}
               else skip_next_close_stack.push(true);
            }
            else if (c == close_marker_char)
            {
               if (skip_next_close_stack.length == 0) {rebuild+=c; opened=false;}
               else skip_next_close_stack.pop();
            }
            else rebuild+=c;
         }
         return rebuild;
         };
      }
function AuditApplication_addUtilPrototypes ( ) { String . prototype . swapHighlightMarkers = function ( prefix ) { return this . replace ( / \uFFFE / g , ( prefix ? prefix : "" ) + "<span class='regex-highlight'>" ) . replace ( / \uFFFF / g , "</span>" ) ; } ; String . prototype . trimHighlightMarkers = function ( replacement ) { return this . replace ( / [\uFFFE\uFFFF] / g , replacement ? replacement : "" ) ; } ; String . prototype . sanitizeforHighlighting = function ( text ) { var metacharacters = "$()*+.?[\^{|" ; return this . replace ( / ([\$\(\)\*\+\.\?\[\\\^\{\|]) / g , function ( $0 ) { return "\\" + $0 ; } ) ; } ; String . prototype . elideHighlightMarkers = function ( open_marker_char , close_marker_char ) { var opened = false ; var skip_next_close_stack = [ ] ; var rebuild = "" ; var c = '' ; for ( var j = 0 ; j < this . length ; j ++ ) { c = this . charAt ( j ) ; if ( c == open_marker_char ) { if ( ! opened ) { opened = true ; rebuild += c ; } else skip_next_close_stack . push ( true ) ; } else if ( c == close_marker_char ) { if ( skip_next_close_stack . length == 0 ) { rebuild += c ; opened = false ; } else skip_next_close_stack . pop ( ) ; } else rebuild += c ; } return rebuild ; } ; }
Add utility prototypes to String, so that they can be used easily throughout
 @method addUtilPrototypes
Add utility prototypes to String so that they can be used easily throughout @method addUtilPrototypes
// use unassignable/non-characters unicode codepoints as markers. see unicode.org/charts/PDF/uFFF0.pdf. // These characters have been reserved for in-process usage by the unicode chart, and are guaranteed to not map // to an actual character, in any alphabet.Therefore they won't need to be escaped throughout the string. // prefix : an optional prefix before the span // remove markers and replace with an optional replacement //treat metacharacters in the text as literal since there may be dots in an audit value that would be in a filename for example // marker block elision : eliminate nested markers, that are already enclosed in a larger mark block // e.g : <Space<s<S>>tore> => <SpacesStore>, etc...