Changeset 1522 for rfc2629xslt/rfc2629.xslt
- Timestamp:
- 01/02/12 01:11:11 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rfc2629xslt/rfc2629.xslt
r1497 r1522 2 2 XSLT transformation from RFC2629 XML format to HTML 3 3 4 Copyright (c) 2006-201 1, Julian Reschke (julian.reschke@greenbytes.de)4 Copyright (c) 2006-2012, Julian Reschke (julian.reschke@greenbytes.de) 5 5 All rights reserved. 6 6 … … 1081 1081 1082 1082 <xsl:template match="front"> 1083 1084 1083 <xsl:if test="$xml2rfc-topblock!='no'"> 1085 1084 <!-- collect information for left column --> … … 1899 1898 <xsl:apply-templates select="front/title" mode="get-text-content" /> 1900 1899 </title> 1900 <xsl:call-template name="insertScript" /> 1901 1901 <xsl:call-template name="insertCss" /> 1902 1902 <!-- <link rel="alternate stylesheet" type="text/css" media="screen" title="Plain (typewriter)" href="rfc2629tty.css" /> --> … … 2011 2011 </head> 2012 2012 <body> 2013 <xsl:if test="/rfc/x:feedback"> 2014 <xsl:attribute name="onload">init();</xsl:attribute> 2015 </xsl:if> 2016 2013 2017 <!-- insert diagnostics --> 2014 2018 <xsl:call-template name="insert-diagnostics"/> … … 3271 3275 </xsl:template> 3272 3276 3277 <!-- optional scripts --> 3278 <xsl:template name="insertScript"> 3279 <xsl:if test="/rfc/x:feedback"> 3280 <script> 3281 var buttonsAdded = false; 3282 3283 function init() { 3284 var fb = document.createElement("div"); 3285 fb.setAttribute("class", "feedback"); 3286 fb.setAttribute("onclick", "feedback();"); 3287 fb.appendChild(document.createTextNode("feedback")); 3288 3289 var bodyl = document.getElementsByTagName("body"); 3290 bodyl.item(0).appendChild(fb); 3291 } 3292 3293 function feedback() { 3294 toggleButtonsToElementsByName("h1"); 3295 toggleButtonsToElementsByName("h2"); 3296 toggleButtonsToElementsByName("h3"); 3297 toggleButtonsToElementsByName("h4"); 3298 3299 buttonsAdded = !buttonsAdded; 3300 } 3301 3302 function toggleButtonsToElementsByName(name) { 3303 var list = document.getElementsByTagName(name); 3304 for (var i = 0; i < list.length; i++) { 3305 toggleButton(list.item(i)); 3306 } 3307 } 3308 3309 function toggleButton(node) { 3310 if (! buttonsAdded) { 3311 3312 // docname 3313 var template = "<xsl:call-template name="replace-substring"> 3314 <xsl:with-param name="string" select="/rfc/x:feedback/@template"/> 3315 <xsl:with-param name="replace">"</xsl:with-param> 3316 <xsl:with-param name="by">\"</xsl:with-param> 3317 </xsl:call-template>"; 3318 3319 var id = node.getAttribute("id"); 3320 // better id available? 3321 var titlelinks = node.getElementsByTagName("a"); 3322 for (var i = 0; i < titlelinks.length; i++) { 3323 var tl = titlelinks.item(i); 3324 if (tl.getAttribute("id")) { 3325 id = tl.getAttribute("id"); 3326 } 3327 } 3328 3329 // ref 3330 var ref = window.location.toString(); 3331 var hash = ref.indexOf("#"); 3332 if (hash != -1) { 3333 ref = ref.substring(0, hash); 3334 } 3335 if (id != "") { 3336 ref += "#" + id; 3337 } 3338 3339 // docname 3340 var docname = "<xsl:value-of select="/rfc/@docName"/>"; 3341 3342 // section 3343 var section = node.textContent; 3344 3345 // build URI from template 3346 var uri = template.replace("{docname}", encodeURIComponent(docname)); 3347 uri = uri.replace("{section}", encodeURIComponent(section)); 3348 uri = uri.replace("{ref}", encodeURIComponent(ref)); 3349 3350 var button = document.createElement("a"); 3351 button.setAttribute("class", "fbbutton"); 3352 button.setAttribute("href", uri); 3353 button.appendChild(document.createTextNode("send feedback")); 3354 node.appendChild(button); 3355 } 3356 else { 3357 var buttons = node.getElementsByTagName("a"); 3358 for (var i = 0; i < buttons.length; i++) { 3359 var b = buttons.item(i); 3360 if (b.getAttribute("class") == "fbbutton") { 3361 node.removeChild(b); 3362 } 3363 } 3364 } 3365 }</script> 3366 </xsl:if> 3367 </xsl:template> 3273 3368 3274 3369 <!-- insert CSS style info --> … … 3677 3772 font-size: smaller; 3678 3773 font-weight: bold; 3774 }</xsl:if><xsl:if test="/rfc/x:feedback">.feedback { 3775 position: fixed; 3776 bottom: 1%; 3777 right: 1%; 3778 padding: 3px 5px; 3779 color: white; 3780 border-radius: 5px; 3781 background: #a00000; 3782 border: 1px solid silver; 3783 } 3784 .fbbutton { 3785 margin-left: 1em; 3786 color: #303030; 3787 font-size: small; 3788 font-weight: normal; 3789 background: #d0d000; 3790 padding: 1px 4px; 3791 border: 1px solid silver; 3792 border-radius: 5px; 3679 3793 }</xsl:if><xsl:if test="$xml2rfc-ext-justification='always'"> 3680 3681 3794 dd, li, p { 3682 3795 text-align: justify; … … 5034 5147 5035 5148 <xsl:template name="replace-substring"> 5036 5037 5149 <xsl:param name="string" /> 5038 5150 <xsl:param name="replace" /> … … 6414 6526 <xsl:text>http://greenbytes.de/tech/webdav/rfc2629.xslt, </xsl:text> 6415 6527 <!-- when RCS keyword substitution in place, add version info --> 6416 <xsl:if test="contains('$Revision: 1.56 1$',':')">6417 <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.56 1$', 'Revision: '),'$','')),', ')" />6528 <xsl:if test="contains('$Revision: 1.564 $',':')"> 6529 <xsl:value-of select="concat('Revision ',normalize-space(translate(substring-after('$Revision: 1.564 $', 'Revision: '),'$','')),', ')" /> 6418 6530 </xsl:if> 6419 <xsl:if test="contains('$Date: 201 1-12-24 13:06:50$',':')">6420 <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 201 1-12-24 13:06:50$', 'Date: '),'$','')),', ')" />6531 <xsl:if test="contains('$Date: 2012-01-28 14:56:56 $',':')"> 6532 <xsl:value-of select="concat(normalize-space(translate(substring-after('$Date: 2012-01-28 14:56:56 $', 'Date: '),'$','')),', ')" /> 6421 6533 </xsl:if> 6422 6534 <xsl:value-of select="concat('XSLT vendor: ',system-property('xsl:vendor'),' ',system-property('xsl:vendor-url'))" />
Note: See TracChangeset
for help on using the changeset viewer.