aboutsummaryrefslogtreecommitdiffhomepage
path: root/etc/proviola/proviola-spp.xsl
blob: 2956016730b6ef16aaa0496f35d92c88fc74fa80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Modified form of proviola.xsl, taken from
     http://mws.cs.ru.nl/proviola 2/8/10. -->

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="/">
  <html>
  <head>
    <style type="text/css">
    body {
      margin: 0px;
      padding: 0px;
    }

    div.commands {
      margin: 0px;
      padding: 0px;
      width: 50%;
    /* border-right: 1px solid #777; */
    }

    span.command:hover {
      background-color: #ccc;
    }

    div.goal {
      position: fixed;
      left: 50%;
      bottom: 0px;
      width: 50%;
      margin: 0px;
      padding-top: 100%;
      border-left: 1px solid #777;
      background-color: #fff;
    }

    div.hidden {
      display: none;
    }

    pre {
      padding: 4px 8px 4px 8px;
      margin: 0px;
      background-color: #fff;
    }

    span.label {
      color: #f00;
    }

    span.comment {
      color: #090;
    }

    span.lemma {
      color: #00f;
    }

    span.obligation {
    /* color: #c40; */
      color: #a0f;
    }
    </style>
  <script type = "text/javascript">
    var responses = new Array();
    
    function mouseover(id) {
      response = get_response(id);
      set_response(response);
    };

    function set_array() {
       <xsl:for-each select="movie/film/frame">
          <xsl:variable name="data">
            <xsl:call-template name="replace">
              <xsl:with-param name="string">
                <xsl:value-of 
                  select="translate(response, '&#x0A;', '&#x09;') "/> 
              </xsl:with-param>
              <xsl:with-param name="from">&quot;</xsl:with-param>
              <xsl:with-param name="to">\"</xsl:with-param>
            </xsl:call-template>
          </xsl:variable>

          i = <xsl:value-of select="@frameNumber"/>;
          data = "<xsl:value-of select="$data"/>";
          responses[i]=data;
        </xsl:for-each>
    };

    function get_response(id) {
      return responses[id];
    };
  
    function set_response(response) {
      goalSpan =  document.getElementById("goal").getElementsByTagName("span")[0];
      goalSpan.innerHTML = response.replace(/&#x09;/g, '\n');
    };
  </script>
  </head>

  <body onload="set_array()">
    <div class = "commands">
    <pre>
    <xsl:for-each select="movie/film/frame">
      <span class ="command">
        <xsl:attribute name="onmouseover">
        mouseover(
          <xsl:value-of select="@frameNumber"/>
        )
        </xsl:attribute>
        <span>
          <xsl:attribute name="class">
	    <xsl:value-of select="command/@class"/>
          </xsl:attribute>
          <xsl:value-of select="command"/>
	</span>
      </span>
    </xsl:for-each>
    </pre>
    </div>

    <div id="goal" class="goal">
    <pre>
        <span>
        </span>
      </pre>
    </div>
  </body>
  </html>
</xsl:template>

<xsl:template name="replace">
<xsl:param name="string"/>
  <xsl:param name="from"/>
  <xsl:param name="to"/>
  <xsl:choose>
    <xsl:when test= "contains($string, $from)">
      <xsl:value-of select="substring-before($string, $from)"/>
        <xsl:value-of select="$to"/>
      <xsl:call-template name="replace">
        <xsl:with-param name="string" 
                        select="substring-after($string, $from)"/>
        <xsl:with-param name="from" select="$from"/>
        <xsl:with-param name="to" select="$to"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$string"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>


</xsl:stylesheet>