code:
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
| <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<title> XML Quiz </title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script language="javascript">
<xsl:comment><![CDATA[
var seconds = 25;
var questions = 7;
function _wait() {
time.innerHTML = 'Resterende tijd: '+seconds;
if(seconds <= 0) {
clearTimeout(timerId);
for(i=0; i<questions; i++) {
document.getElementById(i).style.visibility = 'hidden';
}
time.innerHTML = 'Resterende tijd: 0';
end.innerHTML = 'Jammer, tijd is op. Klik om <a href=quiz.htm>nog een keer te proberen</a> <br /><br /> [img]images/noob.gif[/img]';
} else {
timerId = setTimeout("_wait()",1000);
document.getElementById('sound').src = 'sound.wav';
seconds = seconds -1;
}
}
function _verify(input) {
if(input.value == "true") {
input.parentNode.style.visibility="hidden";
if (input.parentNode.nextSibling && input.parentNode.nextSibling.className == 'question'){
input.parentNode.nextSibling.style.visibility="visible";
} else {
clearTimeout(timerId);
end.innerHTML = 'Ziek figuur! Het is niet gezond dat je deze quiz haalde! Zeker niet met een deze eindtijd. <br> ZOEK HULP! <br /><br /> [img]images/nurse.gif[/img]';
}
} else {
seconds = seconds - 10;
input.style.visibility="hidden";
}
}
]]>//</xsl:comment>
</script>
</head>
<body onload="_wait()">
<div class="timer"><h3 id="time"></h3></div>
<div style="position:absolute; left:50px; top:75px; font-family: verdana; font-weight: bold;" id="end"></div>
<bgsound id="sound" loop="1" />
<xsl:apply-templates select="quiz/statement" />
<script language="javascript">
document.getElementById('0').parentNode.style.visibility = "visible";
</script>
</body>
</html>
</xsl:template>
<!-- Parse all available questions of the XML document -->
<xsl:template match="statement">
<div class="question">
<div><h3><xsl:value-of select="question" /></h3></div>
<xsl:for-each select="answer">
<div class="choice" id="{../@id}" value="{@trace}" onClick="_verify(this);">
<xsl:value-of select="@value" />
</div>
</xsl:for-each>
<div><br /><img>
<xsl:attribute name="src"><xsl:value-of select="image" /></xsl:attribute>
</img></div>
</div>
</xsl:template>
</xsl:stylesheet> |
Op regel 24 staat een voorlus die ALLE layers met een ID op hidden moet zetten, maar dat doet ie gewoon niet!
Voor de rest werkt het wel.
PS. dit is mijn eerste XML/XSL doc hoor
Weet iemand wat ik verkeerd doe? Kom er maar niet uit.
mijn naam slaat nergens op, althans niet op mij :P