From 5398d7856209aaa9be0bb4fc4ab9f8576cd16589 Mon Sep 17 00:00:00 2001 From: AndreasRu <5096188+andreasRu@users.noreply.github.com> Date: Fri, 25 Aug 2023 14:20:18 +0200 Subject: [PATCH] enhance debugging --- components/HtmlHelper.cfc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/components/HtmlHelper.cfc b/components/HtmlHelper.cfc index bc13117..ea61d69 100644 --- a/components/HtmlHelper.cfc +++ b/components/HtmlHelper.cfc @@ -15,17 +15,29 @@ component output = false { public function init() { local.service = { "version" : "0.9.4", - "debug" : false, + "startTickCount": getTickCount(), + "debug" : true, "demarkerStart": "_1.", "demarkerEnd" : "_2.", "debugResult" : function( htmlstring, label = "", regexForDump ) { // if set to debug force output! if( service.debug ) { writeOutput( "
" & label & ":" ); + if( !arguments.label=="result" ){ + writeOutput( "HtmlString.Length(): " & len( arguments.HtmlString ) ) ; + + }else{ + writeOutput( "TimeStamp: " & ((getTickCount() - service.startTickCount)) & "ms" ) ; + service.startTickCount=getTickCount(); + } + if( structKeyExists( arguments, "regexForDump" ) ) { - dump( htmlstring.reMatch( arguments.regexForDump ) ); + writeOutput( "Regex: /" & encodeForHTML( arguments.regexForDump ) & "/" ); + //dump( htmlstring.reMatch( arguments.regexForDump ) ); + } - writeOutput( "
" & encodeForHTML( htmlstring ) & "
" ); + + writeOutput( "
" & encodeForHTML( htmlstring ) & "
" ); } }, "reduceArrayAndReplaceString": function( arrayWithElements, contentString, replaceWith ) { @@ -65,9 +77,10 @@ component output = false { "compressBlankSpaces": function( htmlcontent ) { stringsToRemove = []; result = arguments.htmlcontent; - service.debugResult( htmlstring = result, label = "compressBlankSpaces" ); - stringsToRemove.append( result.reMatch( "[ \t]+" ), true ); // compress spaces/tabs to single spaces - result = service.reduceArrayAndReplaceString( stringsToRemove, result, " " ).reReplace( "\s+[\n\r]", chr( 10 ), "ALL" ); + service.debugResult( htmlstring = result, label = "compressBlankSpaces", regexForDump = "[ \t]+" ); + resure=result.reReplace( "[ \t]+", " ", "All" ).reReplace( "\s+[\n\r]+", chr( 10 ), "ALL" ); + // stringsToRemove.append( result.reMatch( "[ \t]+" ), true ); // compress spaces/tabs to single spaces + // result = service.reduceArrayAndReplaceString( stringsToRemove, result, " " ).reReplace( "\s+[\n\r]+", chr( 10 ), "ALL" ); service.debugResult( htmlstring = result, label = "Result" ); return result; },