Changeset 26

Show
Ignore:
Timestamp:
09/12/07 23:24:58 (1 year ago)
Author:
tal
Message:
The log view now has collapsable/expandable sections.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • applications/FeatureProof/trunk/Lib/featureProof/logToHTML.py

    r5 r26  
     1from AppKit import NSBundle, NSURL 
     2bundle = NSBundle.mainBundle() 
     3path = bundle.pathForResource_ofType_("webDisclosureClosed", "png") 
     4url = NSURL.fileURLWithPath_(path) 
     5closedDisclosureImageURL = url.absoluteString() 
     6path = bundle.pathForResource_ofType_("webDisclosureOpen", "png") 
     7url = NSURL.fileURLWithPath_(path) 
     8openDisclosureImageURL = url.absoluteString() 
     9 
    110_head = u""" 
    211<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
     
    2433  color: white; 
    2534  margin: 0px -10px 0px -10px; 
    26   padding: 0px 10px 0px 10px; 
     35  padding: 0px 10px 0px 20px; 
    2736  border-bottom: 1px solid #fff; 
    2837} 
    2938 
     39h1.table { 
     40  background-image: url(%s); 
     41  background-repeat: no-repeat; 
     42} 
     43 
    3044h2 { 
     45  background-image: url(%s); 
     46    background-repeat: no-repeat; 
    3147  background-color: #333; 
    3248  color: white; 
     
    3450 
    3551h3 { 
     52  background-image: url(%s); 
     53  background-repeat: no-repeat; 
    3654  background-color: #666; 
    37   color: black
     55  color: white
    3856} 
    3957 
    4058h4 { 
     59  padding-left: 10px; 
    4160  background-color: #999; 
    4261  color: black; 
     
    4463 
    4564h5 { 
     65  padding-left: 10px; 
    4666  background-color: #ccc; 
    4767  color: black; 
     
    5070 
    5171h6 { 
     72  padding-left: 10px; 
    5273  background-color: #fff; 
    5374  color: black; 
     
    89110 
    90111</style> 
     112 
     113<script type="text/javascript"> 
     114 
     115    function toggle(elementID) { 
     116        var element = document.getElementById(elementID); 
     117        var head = document.getElementById(elementID + "_head"); 
     118        if (element.style.display == "") { 
     119            element.style.display = "none"; 
     120            head.style.backgroundImage = "url(%s)"; 
     121        } else if (element.style.display != "block") { 
     122            element.style.display = "block"; 
     123            head.style.backgroundImage = "url(%s)"; 
     124        } else { 
     125            element.style.display = "none"; 
     126            head.style.backgroundImage = "url(%s)"; 
     127        } 
     128    } 
     129 
     130</script> 
     131 
    91132</head> 
    92 <body>""" 
     133<body>""" % (openDisclosureImageURL, openDisclosureImageURL, openDisclosureImageURL, closedDisclosureImageURL, openDisclosureImageURL, closedDisclosureImageURL) 
    93134 
    94135_tail = u"""</body> 
    95136</html> 
    96137""" 
     138 
     139elementIDCounter = 0 
    97140 
    98141def logToHTML(xml): 
     
    130173    <Element 'processing' at 0xe770> 
    131174    """ 
     175    global elementIDCounter; 
     176    localID = elementIDCounter 
     177    elementIDCounter += 1 
    132178    html = [] 
    133179    name = element.get("name") 
    134     s = "<h1>Table: <b>%s</b></h1>" % name 
     180    s = "<h1 id=\"table%d_head\" class=\"table\" onclick=\"toggle('table%d');\">Table: <b>%s</b></h1>" % (localID, localID, name) 
    135181    html.append(s) 
     182    html.append("<div id=\"table%d\">" % localID) 
    136183    for i in element: 
    137184        if i.tag == "featureStates": 
     
    143190        elif i.tag == "results": 
    144191            html += _logResults(i, name != "GSUB") 
     192    html.append("</div>") 
    145193    return html 
    146194 
    147195def _logFeatureStates(element): 
    148     html = ["<h2>Features:</h2>"] 
     196    global elementIDCounter; 
     197    localID = elementIDCounter 
     198    elementIDCounter += 1 
     199    html = ["<h2 id=\"features%d_head\" onclick=\"toggle('features%d');\">Features:</h2>" % (localID, localID), "<div id=\"features%d\">" % localID] 
    149200    for i in element: 
    150201        name = i.get("name") 
     
    156207        s = '<p><span class="%s">&#10004;</span> %s</p>' % (checkClass, name) 
    157208        html.append(s) 
     209    html.append("</div>") 
    158210    return html 
    159211 
    160212def _logApplicableLookups(element): 
    161     html = ["<h2>Applicable Lookup Indices:</h2>"] 
     213    global elementIDCounter; 
     214    localID = elementIDCounter 
     215    elementIDCounter += 1 
     216    html = ["<h2 id=\"applicableLookupIndices%d_head\" onclick=\"toggle('applicableLookupIndices%d');\">Applicable Lookup Indices:</h2>" % (localID, localID), "<div id=\"applicableLookupIndices%d\">" % localID] 
    162217    for i in element: 
    163218        feature = i.get("feature") 
     
    167222    if len(html) == 1: 
    168223        html.append("<p>None</p>") 
     224    html.append("</div>") 
    169225    return html 
    170226 
     
    185241 
    186242def _logProcessing(element): 
    187     html = ["<h2>Lookup Application:</h2>"] 
     243    global elementIDCounter; 
     244    localID = elementIDCounter 
     245    elementIDCounter += 1 
     246    html = ["<h2 id=\"lookupApplication%d_head\" onclick=\"toggle('lookupApplication%d');\">Lookup Application:</h2>" % (localID, localID), "<div id=\"lookupApplication%d\">" % localID] 
    188247    for i in element: 
    189248        html += _logLookup(i) 
     249    html.append("</div>") 
    190250    return html 
    191251 
    192252def _logLookup(element): 
     253    global elementIDCounter; 
     254    localID = elementIDCounter 
     255    elementIDCounter += 1 
    193256    html = [] 
    194257    feature = element.get("feature") 
    195258    index = element.get("index") 
    196     s = "<h3>Feature: <b>%s</b> Lookup Index: <b>%s</b></h3>" % (feature, index) 
     259    s = "<h3 id=\"lookup%d_head\" onclick=\"toggle('lookup%d');\">Feature: <b>%s</b> Lookup Index: <b>%s</b></h3>" % (localID, localID, feature, index) 
    197260    html.append(s) 
     261    html.append("<div id=\"lookup%d\">" % localID) 
    198262    for i in element: 
    199263        html += _logSubTable(i) 
     264    html.append("</div>") 
    200265    return html 
    201266 
  • applications/FeatureProof/trunk/setup.py

    r5 r26  
    2424        "Resources/English.lproj", 
    2525        #"Resources/icon.icns" 
     26        "Resources/buttonAdd.tif", 
     27        "Resources/buttonRemove.tif", 
     28        "Resources/fileListButtonFill.tif", 
     29        "Resources/webDisclosureClosed.png", 
     30        "Resources/webDisclosureOpen.png", 
    2631        ] 
    2732