CFLib.org – Common Function Library Project

viewCSS(cssCode)

Last updated December 20, 2005

author

Shlomy Gantz

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
This function returns each stylesheet element (class,id...) name displayed using the same element's style.

Return Values:
Returns a string.

Example:

<cfscript>
function viewCSS(cssCode) {
    var i ="";
    var cssItem="";
    var ret="";
    for(i=1;i lte listlen(arguments.cssCode,'}');i=i+1)
    {
    cssItem = listgetAt(arguments.cssCode,i,'}');
    if(findNocase('{',cssItem)){
                                ret = ret & '<div style="#trim(mid(cssItem,findNocase("{",cssItem)+1,len(cssItem)))#">#trim(mid(cssItem,1,findNocase("{",cssItem)-1))#</div><br>';
                                }
    }
    return ret;
}
</cfscript>
<cfsavecontent variable="cssTxt">
.panel {
  border-width:1px;
  border-style:solid;
  border-color:#cce6ff #668099 #668099 #cce6ff;
  background-color:#f0f0f0;
}


.header {
  font-family:verdana;
  font-size:14px;
  width:23px;
  text-align:center;
  color:#ffffff;
  background-color:#99b3cc;
  border-width:1px;
  border-style:solid;
  border-color:#cce6ff #668099 #668099 #cce6ff;
  padding:1px;
  cursor:pointer;
}


.footer {
  font-family:verdana;
  font-size:11px;
  width:50px;
  margin:0px 1px;
  text-align:center;
  color:#ffffff;
  background-color:#99b3cc;
  border-width:1px;
  border-style:solid;
  border-color:#cce6ff #668099 #668099 #cce6ff;
  padding:1px;
  cursor:pointer;
}


.title {
  font-family:verdana;
  font-size:11px;
  text-align:center;
  color:#ffffff;
  background-color:#cc9999;
  border-width:1px;
  border-style:solid;
  border-color:#996666 #ffcccc #ffcccc #996666;
  padding:0px 3px;
}

.time_list {
  font-family:verdana;
  font-size:12px;
}

</cfsavecontent>
<CFOUTPUT>#viewCSS(cssTxt)#</CFOUTPUT>

Parameters:

Name Description Required
cssCode CSS to parse. Yes

Full UDF Source:

/**
 * Returns a visual representation of stylesheet elements.
 * 
 * @param cssCode      CSS to parse. (Required)
 * @return Returns a string. 
 * @author Shlomy Gantz (shlomy@bluebrick.com) 
 * @version 1, December 20, 2005 
 */
function viewCSS(cssCode) {
    var i ="";
    var cssItem="";
    var ret="";
    for(i=1;i lte listlen(arguments.cssCode,'}');i=i+1) {
        cssItem = listgetAt(arguments.cssCode,i,'}');
        if(findNocase('{',cssItem)) ret = ret & '<div style="#trim(mid(cssItem,findNocase("{",cssItem)+1,len(cssItem)))#">#trim(mid(cssItem,1,findNocase("{",cssItem)-1))#</div><br>';
    }
    return ret;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson