Remove extra blank lines <br> in reports

I want to remove blanks in reports.

<!-- ****************************************************************************** -->
<!-- TODO LO QUE ENGLOBAR style type SON LAS CARACTERISTICAS CSS ************************************************************** -->
<style type="text/css">
  a {
        text-decoration: none;
line-height:0px;
    }  
    a:link {
        color: #200772;
        font-weight: normal;
        text-decoration: none;
line-height:0px;
    }
    a:hover {
        color: #FF8000;
        font-weight: normal;
        text-decoration: none;
line-height:0px;
    }
    table {
     margin: 0;
   border-collapse: collapse;
      line-height:0px;
        vertical-align:top;
        color: #222;
        font: 8pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
    }
    th {
        font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
        color: navy;
        font-weight: normal;
        background-color: #F2F2F2;
        border: 1px solid #cccccc;
        margin: 0;
        padding: 4px 10px 4px 5px;         
        text-align: left;
    }
   
    td {
        color: #222;
        font: 8pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
        border-bottom: 1px solid #cccccc;
        margin: 0;
        vertical-align:top;
        /* padding: 6px 20px 1px 0;  */
padding: 8px 20px 5px 5px;
    }
   
    td.userinput {
        color: #222;
        font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
        font-weight: bold;
        border-bottom: 0px;
        margin: 0;
        vertical-align:top;
        padding: 6px 20px 1px 0;
    }
   
    td.errormsg {
        color: red;
        font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
        font-weight: bold;
        border-bottom: 0px;
        margin: 0;
        padding: 6px 20px 1px 0;
    }
    td.msg {
        color: #747170;
        font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
        font-weight: bold;
        border-bottom: 0px;
        margin: 0;
        line-height:0%;
        vertical-align:top;
        padding: 6px 20px 1px 0;
    }
   
    H1 {
        font: 16pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
        background-color: #747170;
        padding: 4px 4px 4px 4px;
        color: white;
        width: 100%;
    }
</style>
<table>
<table id="resultsTable" class="sortable" line-height="0px" border="all" cellpadding="0" cellspacing="0">
<!-- AQUI EMPIEZA LA CABEZERA************************************************************** -->
<th><H1>Newly</H1></th><th  line-height="0px"><H1>Hostname</H1></th><th line-height="0px"><H1>IP</H1></th><th line-height="0px"><H1>MAC</H1></th><th line-height="0px"><H1>SCAN TIME</H1></th>
 <?Relevance  
trs of (concatenation of  (((td of (values of fields  whose (name of it is "Newly Discovered") of it)) & (td of (values of fields  whose (name of it is "Hostname") of it))  & (td of (values of fields  whose (name of it is "IP Address") of it)) & (td of (values of fields  whose (name of it is "MAC Address") of it))  & (td of (values of fields  whose (name of it is "Import Time (Server Time)") of it))))) of bes unmanagedassets  whose (((value of fields  whose (name of it is "Newly Discovered") of it) = "no"))  ?></table>
<script type="text/javascript">   
    addEvent(window, "load", init_load);
    function init_load()
    {
stripe('resultsTable', '#fff', '#E6E3E8');
// #E6E3E8, original edf3fe'
     sortables_init();
    }  
    var SORT_COLUMN_INDEX;
    function sortables_init(){
   
        // Find all tables with class sortable and make them sortable
        if (!document.getElementsByTagName)
            return;
        tbls = document.getElementsByTagName("table");
        for (ti = 0; ti < tbls.length; ti++) {
            thisTbl = tbls[ti];
            if (((' ' + thisTbl.className + ' ').indexOf("sortable") != -1) && (thisTbl.id)) {
                //initTable(thisTbl.id);
                ts_makeSortable(thisTbl);
            }
        }
    }
   
    function ts_makeSortable(table){
        if (table.rows && table.rows.length > 0) {
            var firstRow = table.rows[0];
        }
        if (!firstRow)
            return;
       
              for (var i = 0; i < firstRow.cells.length; i++) {
            var cell = firstRow.cells[i];
            var txt = ts_getInnerText(cell);
            cell.innerHTML = '<a href="#" class="sortheader" ' +
            'onclick="ts_resortTable(this, ' +
            i +
            ');return false;">' +
            txt +
            '<span class="sortarrow">   </span></a>';
        }
    }
   
    function ts_getInnerText(el){
        if (typeof el == "string")
            return el;
        if (typeof el == "undefined") {
            return el
        };
        if (el.innerText)
            return el.innerText; //Not needed but it is faster
        var str = "";
       
        var cs = el.childNodes;
        var l = cs.length;
        for (var i = 0; i < l; i++) {
            switch (cs[i].nodeType) {
                case 1: //ELEMENT_NODE
                    str += ts_getInnerText(cs[i]);
                    break;
                case 3: //TEXT_NODE
                    str += cs[i].nodeValue;
                    break;
            }
        }
        return str;
    }
  
    function ts_resortTable(lnk, clid){
        var span;
        for (var ci = 0; ci < lnk.childNodes.length; ci++) {
            if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span')
                span = lnk.childNodes[ci];
        }
        var spantext = ts_getInnerText(span);
        var td = lnk.parentNode;
        var column = clid || td.cellIndex;
        var table = getParent(td, 'TABLE');
       
           if (table.rows.length <= 1)
            return;
        var itm = ts_getInnerText(table.rows[1].cells[column]);
        sortfn = ts_sort_caseinsensitive;
        if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/))
            sortfn = ts_sort_date;
        if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/))
            sortfn = ts_sort_date;
        if (itm.match(/^[ $]/))
            sortfn = ts_sort_currency;
        if (itm.match(/^[\d\.]+$/))
            sortfn = ts_sort_numeric;
        SORT_COLUMN_INDEX = column;
        var firstRow = new Array();
        var newRows = new Array();
        for (i = 0; i < table.rows[0].length; i++) {
            firstRow[i] = table.rows[0][i];
        }
        for (j = 1; j < table.rows.length; j++) {
            newRows[j - 1] = table.rows[j];
        }
        newRows.sort(sortfn);
        if (span.getAttribute("sortdir") == 'down') {
            ARROW = ' <img src="/images/besreports/ENU/maximizebutton1.gif" border="0" height="12" width="15" alt="">';
            newRows.reverse();
            span.setAttribute('sortdir', 'up');
        }
        else {
            ARROW = ' <img src="/images/besreports/ENU/minimizebutton1.gif" border="0" height="12" width="15" alt="">';
            span.setAttribute('sortdir', 'down');
        }
        for (i = 0; i < newRows.length; i++) {
            if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) {
                table.tBodies[0].appendChild(newRows[i]);
                if (i % 2 > 0)
                    newRows[i].className = 'wr_oddRow';
                else
                    newRows[i].className = 'wr_evenRow';
            }
        }
          for (i = 0; i < newRows.length; i++) {
            if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1))
                table.tBodies[0].appendChild(newRows[i]);
        }
       
               var allspans = document.getElementsByTagName("span");
        for (var ci = 0; ci < allspans.length; ci++) {
            if (allspans[ci].className == 'sortarrow') {
                if (getParent(allspans[ci], "table") == getParent(lnk, "table")) { // in the same table as us?
                    allspans[ci].innerHTML = '   ';
                }
            }
        }
                span.innerHTML = ARROW;
stripe('resultsTable', '#fff', '#E6E3E8');
    }
   
    function getParent(el, pTagName){
        if (el == null)
            return null;
        else
            if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug, supposed to be uppercase
                return el;
            else
                return getParent(el.parentNode, pTagName);
    }   
    function ts_sort_date(a, b){
                aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        if (aa.length == 10) {
            dt1 = aa.substr(6, 4) + aa.substr(3, 2) + aa.substr(0, 2);
        }
        else {
            yr = aa.substr(6, 2);
            if (parseInt(yr) < 50) {
                yr = '20' + yr;
            }
            else {
                yr = '19' + yr;
            }
            dt1 = yr + aa.substr(3, 2) + aa.substr(0, 2);
        }
        if (bb.length == 10) {
            dt2 = bb.substr(6, 4) + bb.substr(3, 2) + bb.substr(0, 2);
        }
        else {
            yr = bb.substr(6, 2);
            if (parseInt(yr) < 50) {
                yr = '20' + yr;
            }
            else {
                yr = '19' + yr;
            }
            dt2 = yr + bb.substr(3, 2) + bb.substr(0, 2);
        }
       
        if (dt1 == dt2)
            return 0;
        if (dt1 < dt2)
            return -1;
        return 1;
    }
   
    function ts_sort_currency(a, b){
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g, '');
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g, '');
        return parseFloat(aa) - parseFloat(bb);
    }
   
    function ts_sort_numeric(a, b){
        aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
        if (isNaN(aa))
            aa = 0;
        bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
        if (isNaN(bb))
            bb = 0;
        return aa - bb;
    }
   
    function ts_sort_caseinsensitive(a, b){
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
        if (aa == bb)
            return 0;
        if (aa < bb)
            return -1;
        return 1;
    }
    function ts_sort_default(a, b){
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        if (aa == bb)
            return 0;
        if (aa < bb)
            return -1;
        return 1;
    } 
    function addEvent(elm, evType, fn, useCapture)// addEvent and removeEvent
    {
        if (elm.addEventListener) {
            elm.addEventListener(evType, fn, useCapture);
            return true;
        }
        else
            if (elm.attachEvent) {
                var r = elm.attachEvent("on" + evType, fn);
                return r;
            }
            else {
                alert("Handler could not be removed");
            }
    }
function hasClass(obj) {
var result = false;
if (obj.getAttributeNode("class") != null) {
    result = obj.getAttributeNode("class").value;
}
return result;
}  
function stripe(id) {
var even = false;
var evenColor = arguments[1] ? arguments[1] : "#fff";
var oddColor = arguments[2] ? arguments[2] : "#eee";
var table = document.getElementById(id);
if (! table) { return; }
var tbodies = table.getElementsByTagName("tbody");
for (var h = 0; h < tbodies.length; h++) {
 var trs = tbodies[h].getElementsByTagName("tr");
 for (var i = 0; i < trs.length; i++) {
     var tds = trs[i].getElementsByTagName("td");
     for (var j = 0; j < tds.length; j++) {
  
       var mytd = tds[j];
         mytd.style.backgroundColor =
           even ? evenColor : oddColor;
     }
   even =  ! even;
 }
}
}
</script>

Try this:

<?Relevance
trs of (concatenation of (((td of (values of fields whose (name of it is "Newly Discovered") of it)) & (td of (values of fields whose (name of it is "Hostname") of it)) & (td of (values of fields whose (name of it is "IP Address") of it)) & (td of (values of fields whose (name of it is "MAC Address") of it)) & (td of (values of fields whose (name of it is "Import Time (Server Time)") of it))))) of bes unmanagedassets whose ( ((value of fields whose (name of it is "Newly Discovered") of it) = "no") AND ( exists values whose("" != it as trimmed string) of fields of it) ) ?>

no, if copy in custom webreport , you see blanks in first report.

I think that is the tag “table” without which introduces blanks

Can you post a screenshot?

I think that is the tag table without which introduces blanks

if only write <?relevance -----?> ok , without blanks, but with table , only table insert blanks.

ALRIGHT. SOLUTIONS concatenations of (trs of —) , the other forms insert blanks
Thanks For all

<?Relevance
concatenations of (trs of (concatenation of (((td of (values of fields whose (name of it is "Newly Discovered") of it)) & (td of (values of fields whose (name of it is "Hostname") of it)) & (td of (values of fields whose (name of it is "IP Address") of it)) & (td of (values of fields whose (name of it is "MAC Address") of it)) & (td of (values of fields whose (name of it is "Import Time (Server Time)") of it))))) of bes unmanagedassets whose ( ((value of fields whose (name of it is "Newly Discovered") of it) = "no") AND ( exists values whose("" != it as trimmed string) of fields of it) ) )?></table><script type="text/javascript">
1 Like

Okay, now I get it.

I’m not completely sure why the blank space is being introduced that way even without the fix, but it is the case that without concatenations there will be a new line in between each of the TRS results.

I think what is happening is that there are some results that are empty, and those are causing blank lines which should have been table rows.

Try this to see if it has the same effect:

<?Relevance
it whose(it as string as trimmed string != "") of (trs of (concatenation of (((td of (values of fields whose (name of it is "Newly Discovered") of it)) & (td of (values of fields whose (name of it is "Hostname") of it)) & (td of (values of fields whose (name of it is "IP Address") of it)) & (td of (values of fields whose (name of it is "MAC Address") of it)) & (td of (values of fields whose (name of it is "Import Time (Server Time)") of it))))) of bes unmanagedassets whose ( ((value of fields whose (name of it is "Newly Discovered") of it) = "no") AND ( exists values whose("" != it as trimmed string) of fields of it) ) )?>

I don’t use webreports often and I don’t have any bes unmanagedassets to test against.

2 Likes

What have you done also works. Thanks, so thanks.

1 Like

I just came across this exact same problem myself today, and I found a new solution.

The solution as mentioned above is to use concatenations of OR html concatenations of in front of a plural session relevance statement to prevent the extra newlines from being added, but here is a CSS based solution:

<style>
br + br {
    display: none;
}
</style>

What this does is negate the affect of any <br> tag that follows another <br> tag, so if you have 100 of them in a row, you only get a single new line.

I don’t have this issue doing the same session relevance in a Windows Console Dashboard, but for some reason in webreports, I see this:

webreports_added_br_tags

It seems like there is a solution as mentioned above to prevent the <br> tags, but this style solution also negates them if they do happen to appear and you can’t figure out how to get rid of them, with very little risk of causing problems with formatting, as multiple <br> tags shouldn’t be used generally anyway, in favor of CSS padding.

If the above CSS does cause any issues, then you can be more specific so that you only negate the initial repeated <br> in webreports like this:

<style>
div#wr_datapage > br + br {
    display: none;
}
</style>

Related:

2 Likes