Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

quotes.xsl 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:import href="translations.xsl" />
  4. <xsl:output method="xml" encoding="UTF-8" indent="yes" />
  5. <xsl:template name="quote-box">
  6. <xsl:param name="tag" select="''"/> <!-- if left empty, all quotes will be selected -->
  7. <div id="cb1-back">
  8. <xsl:call-template name="first-quote">
  9. <xsl:with-param name="tag" select="$tag" />
  10. </xsl:call-template>
  11. </div>
  12. <div id="cb1-front">
  13. <!-- -->
  14. </div>
  15. <!-- javascript code for rotating quotes -->
  16. <script type="text/javascript">
  17. var quotes = [
  18. <xsl:choose>
  19. <xsl:when test="/html/set/textset-content/quotes/quote[@tag=$tag or $tag='']">
  20. <xsl:call-template name="get-js-quotes">
  21. <xsl:with-param name="quotes-xpath" select="/html/set/textset-content/quotes/quote[@tag=$tag or $tag='']" />
  22. </xsl:call-template>
  23. </xsl:when>
  24. <xsl:otherwise>
  25. <xsl:call-template name="get-js-quotes">
  26. <xsl:with-param name="quotes-xpath" select="/html/set/textset-content-backup/quotes/quote[@tag=$tag or $tag='']" />
  27. </xsl:call-template>
  28. </xsl:otherwise>
  29. </xsl:choose>
  30. ];
  31. var index = 0;
  32. function changeImage () {
  33. var oldIndex = index;
  34. index = (index+1)%quotes.length;
  35. var newContent =
  36. "&lt;a href='/donate/donate.html'&gt;" +
  37. "&lt;img src='"+quotes[index]['photo']+"' /&gt;" +
  38. "&lt;p&gt;"+quotes[index]['text']+"&lt;br/&gt;"+
  39. "&lt;strong&gt;"+quotes[index]['author']+"&lt;/strong&gt;&lt;/p&gt;"+
  40. "&lt;/a&gt;";
  41. $('#cb1-front').html($('#cb1-back').html());
  42. $('#cb1-front').fadeIn(0);
  43. $('#cb1-back').fadeOut(0);
  44. $('#cb1-back').html(newContent);
  45. $('#cb1-front').fadeOut('slow', function() {
  46. $('#cb1-back').fadeIn('slow', function() {});
  47. });
  48. setTimeout("changeImage();",10000);
  49. }
  50. setTimeout("changeImage();",10000);
  51. </script>
  52. </xsl:template>
  53. <xsl:template name="get-js-quotes">
  54. <xsl:param name="quotes-xpath" />
  55. <xsl:for-each select="$quotes-xpath">
  56. <xsl:sort select="@pos" data-type="number" />
  57. {
  58. 'photo': "<xsl:call-template name="get-quote-photo"><xsl:with-param name="id" select="@id" /></xsl:call-template>",
  59. 'text': "<xsl:call-template name="get-quote-text"><xsl:with-param name="id" select="@id" /></xsl:call-template>",
  60. 'author': "<xsl:call-template name="get-quote-author"><xsl:with-param name="id" select="@id" /></xsl:call-template>"
  61. },
  62. </xsl:for-each>
  63. </xsl:template>
  64. <xsl:template name="first-quote">
  65. <xsl:param name="tag" />
  66. <xsl:choose>
  67. <xsl:when test="/html/set/textset-content/quotes/quote[@tag=$tag or $tag='']">
  68. <xsl:call-template name="display-first-quote">
  69. <xsl:with-param name="quotes-xpath" select="/html/set/textset-content/quotes/quote[@tag=$tag or $tag='']" />
  70. </xsl:call-template>
  71. </xsl:when>
  72. <xsl:otherwise >
  73. <xsl:call-template name="display-first-quote">
  74. <xsl:with-param name="quotes-xpath" select="/html/set/textset-content-backup/quotes/quote[@tag=$tag or $tag='']" />
  75. </xsl:call-template>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:template>
  79. <xsl:template name="display-first-quote">
  80. <xsl:param name="quotes-xpath" />
  81. <xsl:for-each select="$quotes-xpath">
  82. <xsl:sort select="@pos" data-type="number" />
  83. <xsl:if test="position() = 1">
  84. <a href="/donate/donate.html">
  85. <xsl:element name="img">
  86. <xsl:attribute name="src">
  87. <xsl:call-template name="get-quote-photo">
  88. <xsl:with-param name="id" select="@id" />
  89. </xsl:call-template>
  90. </xsl:attribute>
  91. </xsl:element>
  92. <p>
  93. <xsl:call-template name="get-quote-text">
  94. <xsl:with-param name="id" select="@id" />
  95. </xsl:call-template>
  96. <br/>
  97. <strong>
  98. <xsl:call-template name="get-quote-author">
  99. <xsl:with-param name="id" select="@id" />
  100. </xsl:call-template>
  101. </strong>
  102. </p>
  103. </a>
  104. </xsl:if>
  105. </xsl:for-each>
  106. </xsl:template>
  107. </xsl:stylesheet>