home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / multimedia / mediacoder / MediaCoder-0.6.0.3905.exe / extensions / _include / extbase.xsl < prev    next >
Extensible Markup Language  |  2007-07-16  |  6KB  |  153 lines

  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:output method="html" encoding="utf-8"/>
  4. <!--
  5. *******************************************************************
  6. * MediaCoder extension XSLT template version 0.6.0.1
  7. * Distributed under GPL license
  8. * Copyright (c) 2007 Stanley Huang <stanleyhuangyc@gmail.com>
  9. * All rights reserved.
  10. *******************************************************************
  11. -->
  12. <xsl:template match="/extension">
  13. <html xmlns="http://www.w3.org/1999/xhtml">
  14. <head>
  15. <xsl:call-template name="InitExtension"/>
  16. <script language="javascript">
  17. var entry = null;
  18. <xsl:if test="entry">
  19. entry='<xsl:value-of select="entry"/>';
  20. </xsl:if>
  21. if (entry)
  22.     window.location.href = entry;
  23. else
  24.     alert("No entry defined.");
  25. </script>
  26. </head>
  27. <body style="font-family:Verdana;font-size:large">
  28. Loading Extension...
  29. </body>
  30. </html>
  31. </xsl:template>
  32.  
  33.   <xsl:template name="InitExtension">
  34.       <script language="javascript" src="../_include/extension.js"></script>
  35.     <script>
  36.     <xsl:if test="defaults">SetDefaultPrefs();</xsl:if>
  37.     function SetDefaultPrefs()
  38.     {
  39.         var docExtensionPrefs = document.implementation.createDocument("", "MediaCoderPrefs", null);
  40.         <xsl:for-each select="defaults/node">
  41.         AddPrefNode(docExtensionPrefs,'<xsl:value-of select="@key" />','<xsl:value-of select="@value" />');
  42.         </xsl:for-each>
  43.         PostPrefXML(docExtensionPrefs);
  44.         delete docExtensionPrefs;
  45.     }
  46.     </script>
  47.   </xsl:template>
  48.  
  49.   <xsl:template name="AddElement">
  50.     <xsl:param name="element"/>
  51.     <xsl:param name="option"/>
  52.     <xsl:choose>
  53.     <xsl:when test="$element/@type='checkbox'">
  54.         <label><input type="checkbox">
  55.         <xsl:attribute name="id"><xsl:value-of select="$element/@id"/></xsl:attribute>
  56.         <xsl:if test="$element/@selected or $element/option[2]/@selected">
  57.             <xsl:attribute name="checked">true</xsl:attribute>
  58.         </xsl:if>
  59.         <xsl:attribute name="onclick">onElementChange(id,checked);</xsl:attribute>
  60.         <xsl:choose>
  61.         <xsl:when test="$element/option">
  62.             <xsl:attribute name="onchange">
  63.             if(checked){
  64.             <xsl:for-each select="$element/option[2]/node">SetPrefValue('<xsl:value-of select="@key" />','<xsl:value-of select="@value" />');</xsl:for-each>}else{
  65.             <xsl:for-each select="$element/option[1]/node">SetPrefValue('<xsl:value-of select="@key" />','<xsl:value-of select="@value" />');</xsl:for-each>}
  66.             </xsl:attribute>
  67.         </xsl:when>
  68.         <xsl:otherwise>
  69.             <xsl:attribute name="onchange">SetPrefValue('<xsl:value-of select="$element/@key" />',checked);</xsl:attribute>
  70.             <xsl:if test="$element/@value='true' or $element/@value='1'">
  71.                 <xsl:attribute name="checked">true</xsl:attribute>
  72.             </xsl:if>
  73.         </xsl:otherwise>
  74.         </xsl:choose>
  75.         </input><xsl:value-of select="$element/@text"/></label>
  76.     </xsl:when>
  77.     
  78.     <xsl:when test="$element/@type='radiobox'">
  79.         <label><input type="radio">
  80.         <xsl:attribute name="name"><xsl:value-of select="$element/@id"/></xsl:attribute>
  81.         <xsl:if test="$option/@selected">
  82.             <xsl:attribute name="checked">true</xsl:attribute>
  83.         </xsl:if>
  84.         <xsl:attribute name="onclick">onElementChange(name,'<xsl:value-of select="$option/@text"/>');</xsl:attribute>
  85.         <xsl:attribute name="onchange">
  86.         <xsl:choose>
  87.         <xsl:when test="$element/option"><xsl:for-each select="$option/node">SetPrefValue('<xsl:value-of select="@key" />','<xsl:value-of select="@value" />');</xsl:for-each></xsl:when>
  88.         <xsl:otherwise>SetPrefValue('<xsl:value-of select="$element/@key" />','<xsl:value-of select="$element/@value" />');</xsl:otherwise>
  89.         </xsl:choose>
  90.         </xsl:attribute>
  91.         </input><xsl:value-of select="$option/@text"/></label>
  92.     </xsl:when>
  93.     
  94.     <xsl:when test="$element/@type='editbox'">
  95.         <input type="text">
  96.         <xsl:attribute name="id"><xsl:value-of select="$element/@id"/></xsl:attribute>
  97.         <xsl:attribute name="size"><xsl:value-of select="$element/@size"/></xsl:attribute>
  98.         <xsl:attribute name="value"><xsl:value-of select="$element/@value"/></xsl:attribute>
  99.         <xsl:attribute name="onchange">
  100.           <xsl:choose>
  101.           <xsl:when test="node">
  102.           <xsl:for-each select="$element/node">SetPrefValue('<xsl:value-of select="@key" />',value);</xsl:for-each>onElementChange(id,value);
  103.           </xsl:when>
  104.           <xsl:otherwise>
  105.           SetPrefValue('<xsl:value-of select="$element/@key" />',value);onElementChange(id,value);
  106.           </xsl:otherwise>
  107.           </xsl:choose>
  108.         </xsl:attribute>
  109.         </input>
  110.     </xsl:when>
  111.     
  112.     <xsl:when test="$element/@type='combobox' or $element/@type='listbox'">
  113.         <select>
  114.         <xsl:attribute name="id"><xsl:value-of select="$element/@id"/></xsl:attribute>
  115.         <xsl:attribute name="onclick">onElementChange(id,value);</xsl:attribute>
  116.         <xsl:if test="$element/@size">
  117.         <xsl:attribute name="size"><xsl:value-of select="$element/@size"/></xsl:attribute>
  118.         </xsl:if>
  119.         <xsl:for-each select="$element/option">
  120.           <option>
  121.           <xsl:if test="@selected">
  122.               <xsl:attribute name="selected"/>
  123.           </xsl:if>
  124.           <xsl:if test="@value">
  125.             <xsl:attribute name="value"><xsl:value-of select="@value" /></xsl:attribute>
  126.           </xsl:if>
  127.           <xsl:attribute name="onclick">
  128.             <xsl:choose>
  129.             <xsl:when test="node">
  130.               <xsl:for-each select="node">SetPrefValue('<xsl:choose><xsl:when test="@key"><xsl:value-of select="@key" /></xsl:when><xsl:otherwise><xsl:value-of select="../../@key"/></xsl:otherwise></xsl:choose>','<xsl:value-of select="@value" />');</xsl:for-each>
  131.             </xsl:when>
  132.             <xsl:otherwise>
  133.               <!--no node-->
  134.               SetPrefValue('<xsl:value-of select="../@key"/>','<xsl:value-of select="@value"/>')
  135.             </xsl:otherwise>
  136.             </xsl:choose>
  137.           </xsl:attribute>
  138.           <xsl:choose>
  139.           <xsl:when test="@text">
  140.             <xsl:value-of select="@text" />
  141.           </xsl:when>
  142.           <xsl:otherwise>
  143.             <xsl:value-of select="@value" />
  144.           </xsl:otherwise>
  145.           </xsl:choose>
  146.           </option>
  147.         </xsl:for-each>
  148.         </select>
  149.     </xsl:when>
  150.     </xsl:choose>
  151.  
  152.   </xsl:template>
  153. </xsl:stylesheet>