<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE stylesheet [
<!ENTITY % w3centities-f PUBLIC "-//W3C//ENTITIES Combined Set//EN//XML"
"http://www.w3.org/2003/entities/2007/w3centities-f.ent">
%w3centities-f;
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:param name = "folder-view-columns" select="0" />
<xsl:template match="/bonsole_window">
<html>
<head>
<xsl:if test="count(file) &gt; 0">
<style type="text/css">
.__Bonsole_d_file,   .__Bonsole_d_file a, .__Bonsole_d_file a:link, .__Bonsole_d_file a:visited, .__Bonsole_d_file a:hover, .__Bonsole_d_file a:active {
  
  color: red;
}
.__Bonsole_r_file,   .__Bonsole_r_file a, .__Bonsole_r_file a:link, .__Bonsole_r_file a:visited, .__Bonsole_r_file a:hover, .__Bonsole_r_file a:active {
  
  color: blue;
}

.__Bonsole_u_file,   .__Bonsole_u_file a, .__Bonsole_u_file a:link, .__Bonsole_u_file a:visited, .__Bonsole_u_file a:hover, .__Bonsole_u_file a:active {
  
  color: yellow;
}
</style>

</xsl:if>

<xsl:if test="count(base) &gt; 0">
<style type="text/css">
#baseURL {

  display: none;
}
</style>
<script type="text/javascript">
<![CDATA[
document.addEventListener('DOMContentLoaded', function (event) {
var base = document.getElementById("baseURL");
var anchors = document.querySelectorAll('a');
function toHTMLENT(text) {
  var ta = document.createElement('textarea');
  ta.innerText = text;
  return ta.innerHTML;
}
for (anchor of anchors) {
  
  anchor.addEventListener('click', function (event) {
    event.preventDefault();
    window.location.href = 'app:' + toHTMLENT(base.innerText) + toHTMLENT(this.getAttribute('href').slice('app:'.length));
    return false;
  }, true);
}
}, true);
]]>
</script>
</xsl:if>
</head>
<body>
<xsl:apply-templates select="*"/>
</body>
</html>
</xsl:template>
<xsl:template match="progress">
<xsl:copy-of select="."/>
<!-- <progress><xsl:copy-of select="@*"/><xsl:copy-of select="text"/></progress> -->
</xsl:template>
<xsl:template match="h1">
<h1>&nbsp;<xsl:value-of select="." />&nbsp;</h1>
</xsl:template>
<xsl:template match="base">
<span id="baseURL"><xsl:value-of select="."/></span>
</xsl:template>
<xsl:template match="file">
  <xsl:choose>
    <xsl:when test="$folder-view-columns &gt; 0">
      <div>
        <xsl:attribute name="class">
          <xsl:choose>
             <xsl:when test="@type = 'directory'">
               <xsl:value-of select="concat('__Bonsole_d_file ', @class)"  />
             </xsl:when>
             <xsl:when test="@type = 'regular'">
               <xsl:value-of select="concat('__Bonsole_r_file ', @class)"  />
             </xsl:when>
             <xsl:otherwise>
               <xsl:value-of select="concat('__Bonsole_u_file ', @class)"  />
             </xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
        <xsl:copy-of select="*" /> 
       </div>
    </xsl:when>
    <xsl:otherwise>
      <span>
        <xsl:attribute name="class">
          <xsl:choose>
             <xsl:when test="@type = 'directory'">
               <xsl:value-of select="concat('__Bonsole_d_file ', @class)"  />
             </xsl:when>
             <xsl:when test="@type = 'regular'">
               <xsl:value-of select="concat('__Bonsole_r_file ', @class)"  />
             </xsl:when>
             <xsl:otherwise>
               <xsl:value-of select="concat('__Bonsole_u_file ', @class)"  />
             </xsl:otherwise>
           </xsl:choose>
         </xsl:attribute>
         <xsl:copy-of select="*" /> 
       </span><xsl:text>&nbsp;</xsl:text>
     </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
   <xsl:template match="message">
    <div style="background: yellow"><xsl:copy-of select="*|text()|@*" /></div>
  </xsl:template>
  <xsl:template match="/internal_window">
  <html>
  <head>
  <title>Error</title>
  </head>
  <body>
  <xsl:apply-templates select="*"/>
  <a href="app:__Bonsole_internal_message_viewed">Ok</a>
  </body>
  </html>
  </xsl:template>
  <xsl:template match="edit">
  <input>
  <xsl:attribute name="name">
  <xsl:value-of select="@name" />
  </xsl:attribute>
  <xsl:attribute name="value">
  <xsl:value-of select="@value" />
  </xsl:attribute>
  </input>
  <br/>
  </xsl:template>
  <xsl:template match="checkbox">
  <input>
  <xsl:attribute name="type">
  <xsl:value-of select="'checkbox'" />
  </xsl:attribute>
  <xsl:attribute name="name">
  <xsl:value-of select="@name" />
  </xsl:attribute>
  <xsl:attribute name="value">
  <xsl:value-of select="@value" />
  </xsl:attribute>
  <xsl:copy-of select="text()" />
  </input>
  <br/>
  </xsl:template>
  <xsl:template match="a">
  <xsl:copy-of select="." />
  </xsl:template>
  <xsl:template match="text()">
  <xsl:value-of select="." />
  </xsl:template>
  <xsl:template match="form">
  
  <xsl:copy>
  <xsl:copy-of select="@*" />
  <xsl:attribute name="method">
  <xsl:value-of select="'get'" />
  </xsl:attribute>
  <xsl:apply-templates select="*|text()" />
  <input type="submit">
  <xsl:attribute name="onclick">
  <xsl:value-of select="concat('get_form_data(&quot;', @action,'&quot;,&quot;app:__Bonsole__app_form_', @action, '&quot;);')"  />
  </xsl:attribute>
  </input>
  </xsl:copy>
  </xsl:template>
  <xsl:template match="/internal_struct">
  <xsl:apply-templates select="*"/>
  </xsl:template>
  <xsl:template match="debug_info">
  <xsl:copy-of select="." />
  </xsl:template>
  <xsl:template match="br">
    <br/>
  </xsl:template>
</xsl:stylesheet>
