summaryrefslogtreecommitdiffstats
path: root/ksvg/test/ecma
diff options
context:
space:
mode:
Diffstat (limited to 'ksvg/test/ecma')
-rw-r--r--ksvg/test/ecma/bbox/bbox-circle.svg13
-rw-r--r--ksvg/test/ecma/bbox/bbox-ellipse.svg14
-rw-r--r--ksvg/test/ecma/bbox/bbox-line.svg35
-rw-r--r--ksvg/test/ecma/bbox/bbox-path.svg15
-rw-r--r--ksvg/test/ecma/bbox/bbox-path2.svg14
-rw-r--r--ksvg/test/ecma/bbox/bbox-polygon.svg13
-rw-r--r--ksvg/test/ecma/bbox/bbox-polyline.svg13
-rw-r--r--ksvg/test/ecma/bbox/bbox-rect.svg15
-rw-r--r--ksvg/test/ecma/bbox/bbox.js103
-rw-r--r--ksvg/test/ecma/broken.svg30
-rw-r--r--ksvg/test/ecma/circle.svg38
-rw-r--r--ksvg/test/ecma/clock.svg66
-rw-r--r--ksvg/test/ecma/dom01.svg40
13 files changed, 409 insertions, 0 deletions
diff --git a/ksvg/test/ecma/bbox/bbox-circle.svg b/ksvg/test/ecma/bbox/bbox-circle.svg
new file mode 100644
index 00000000..10ff5e3c
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-circle.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 6)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <circle id="test-0" cx="100" cy="140" r="50" fill="none" stroke="black" />
+ <circle id="test-1" cx="220" cy="140" r="35" fill="red" stroke="black" />
+ <circle id="test-2" cx="340" cy="140" r="20" fill="black" stroke="lime" stroke-width="4" />
+ <circle id="test-3" cx="100" cy="260" r="20" stroke="lime" fill="yellow" stroke-width="4" />
+ <circle id="test-4" cx="220" cy="260" r="35" stroke="none" fill="blue" />
+ <circle id="test-5" cx="340" cy="260" r="50" stroke="red" fill="none" stroke-width="10" />
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-ellipse.svg b/ksvg/test/ecma/bbox/bbox-ellipse.svg
new file mode 100644
index 00000000..0fccee5b
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-ellipse.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 7)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <ellipse id="test-0" fill="none" stroke="#000000" cx="50" cy="135" rx="30" ry="50"/>
+ <ellipse id="test-1" fill="red" cx="160" cy="135" rx="30" ry="50"/>
+ <ellipse id="test-2" fill="none" stroke="#000000" cx="270" cy="140" rx="35" ry="35"/>
+ <ellipse id="test-3" fill="red" cx="370" cy="140" rx="35" ry="35"/>
+ <ellipse id="test-4" fill="none" stroke="#0000FF" stroke-width="8" cx="50" cy="310" rx="30" ry="50"/>
+ <ellipse id="test-5" fill="#00FF00" stroke="#0000FF" stroke-width="8" cx="160" cy="310" rx="30" ry="50"/>
+ <ellipse id="test-6" fill="#00FF00" stroke="#0000FF" stroke-width="8" cx="330" cy="310" rx="70" ry="40"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-line.svg b/ksvg/test/ecma/bbox/bbox-line.svg
new file mode 100644
index 00000000..b9caf551
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-line.svg
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 4)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <g id="test-0" transform="translate(0,20)">
+ <line x1="37.5" y1="137" x2="112.5" y2="50" fill="none" stroke="black" stroke-width="1" />
+ <line x1="112.5" y1="137" x2="187.5" y2="50" fill="none" stroke="red" stroke-width="5" />
+ <line x1="187.5" y1="137" x2="262.5" y2="50" fill="none" stroke="green" stroke-width="7.5" />
+ <line x1="262.5" y1="137" x2="337.5" y2="50" fill="none" stroke="blue" stroke-width="10" />
+ <line x1="337.5" y1="137" x2="412.5" y2="50" fill="none" stroke="fuchsia" stroke-width="12.5" />
+ </g>
+ <g id="test-1" stroke="black" stroke-width="1" transform="translate(0,20)">
+ <line x1="125" y1="200" x2="175" y2="200"/>
+ <line x1="175" y1="200" x2="175" y2="250"/>
+ <line x1="175" y1="250" x2="225" y2="250"/>
+ <line x1="225" y1="250" x2="225" y2="200"/>
+ <line x1="225" y1="200" x2="275" y2="200"/>
+ </g>
+ <g id="test-2" stroke="blue" stroke-width="10" transform="translate(0,20)">
+ <line x1="25" y1="300" x2="75" y2="300"/>
+ <line x1="75" y1="300" x2="75" y2="350"/>
+ <line x1="75" y1="350" x2="125" y2="350"/>
+ <line x1="125" y1="350" x2="125" y2="300"/>
+ <line x1="125" y1="300" x2="175" y2="300"/>
+ </g>
+ <g id="test-3" stroke-width="10" transform="translate(0,20)">
+ <line x1="275" y1="350" x2="325" y2="350" stroke="black" />
+ <line x1="325" y1="300" x2="375" y2="300" stroke="fuchsia" />
+ <line x1="225" y1="300" x2="275" y2="300" stroke="blue" />
+ <line x1="275" y1="300" x2="275" y2="350" stroke="green" />
+ <line x1="325" y1="350" x2="325" y2="300" stroke="red" />
+ </g>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-path.svg b/ksvg/test/ecma/bbox/bbox-path.svg
new file mode 100644
index 00000000..bdfd24fe
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-path.svg
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 8)">
+ <script xlink:href="bbox.js"/>
+ <g transform="translate(0,50)">
+ <path id="test-0" fill="#FF0000" stroke="#00C000" d=" M 250 130 C 185 130 150 80 150 80 S 115 25 50 25 m 0 105 c 65 0 100 -50 100 -50 s 35 -55 100 -55 "/>
+ <path id="test-1" fill="none" stroke="#000000" d=" M 300 90 c 0 30 7 50 50 0 c 43 -50 50 -30 50 0 c 0 83 -68 -34 -90 -30 C 300 60 300 90 300 90 z "/>
+ <path id="test-2" fill="none" stroke="#000000" d=" M 100 170 C 120 170 180 170 200 170 Z "/>
+ <path id="test-3" fill="#00C000" stroke="none" d=" M 25 360 C 60 360 80 275 75 260 c -5 15 15 100 50 100 Z "/>
+ <path id="test-4" fill="none" stroke="#000000" d=" m 200 300 c 50 -40 50 -100 25 -100 s -25 60 25 100 "/>
+ <path id="test-5" fill="#0000FF" stroke="#000000" d=" M 320 160 C 380 150 420 190 410 250 "/>
+ <path id="test-6" fill="#FFFF00" stroke="#000000" d=" M 360 280 c 0 20 -16 36 -36 36 s -36 -16 -36 -36 s 16 -36 36 -36 s 36 16 36 36 z "/>
+ <path id="test-7" fill="#F0F0F0" stroke="#FF0000" d=" m 340 425 c -40 -60 95 -100 80 0 z "/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-path2.svg b/ksvg/test/ecma/bbox/bbox-path2.svg
new file mode 100644
index 00000000..988641a1
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-path2.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="480" onload="gen_buttons(evt, 7)">
+ <script xlink:href="bbox.js"/>
+ <g transform="translate(0,70)">
+ <path id="test-0" fill="none" stroke="#0000FF" stroke-width="3" d=" M 15 20 Q 30 120 130 30 M 180 80 q -75 -100 -163 -60 z "/>
+ <path id="test-1" fill="#FFFF00" stroke="#CF0000" d=" m 350 130 q -100 -80 50 -120 z m 70 0 q 50 -150 -80 -90 Z "/>
+ <path id="test-2" fill="none" stroke="#00FFFF" d=" M 215 115 Q 225 0 295 45 Z "/>
+ <path id="test-3" fill="#00C000" stroke="#000000" d=" M 200 200 Q 250 300 300 200 T 250 150 Q 120 120 200 200 z "/>
+ <path id="test-4" fill="#CF0000" stroke="none" d=" M 60 100 Q -40 150 60 200 Q 160 150 60 100 z "/>
+ <path id="test-5" fill="none" stroke="#FF0000" d=" M 15 320 q 25 -100 50 0 t 50 0 t 50 0 t 50 0 t 50 0 z "/>
+ <path id="test-6" fill="#0000C0" stroke="#00CF00" stroke-width="2" d=" M 350 300 q -100 50 0 50 Q 250 350 350 400 q 100 -50 0 -50 Q 450 350 350 300 z "/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-polygon.svg b/ksvg/test/ecma/bbox/bbox-polygon.svg
new file mode 100644
index 00000000..025bdeb5
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-polygon.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 6)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <polygon id="test-0" fill="none" stroke="#000000" points="59,75,95,93,108,135,82,169,39,170,11,137,19,95"/>
+ <polygon id="test-1" fill="red" points="179,75,218,93,228,135,202,169,159,170,131,137,139,95,179,75"/>
+ <polygon id="test-2" fill="blue" stroke="black" stroke-width="6" points="350,75 375,110 410,125 375,140 350,175 325,150 290,125 325,100,350,75"/>
+ <polygon id="test-3" fill="none" stroke="#0000FF" stroke-width="8" points="59,225,98,243,108,285,82,319,39,320,11,287,19,245,59,225"/>
+ <polygon id="test-4" fill="#00FF00" stroke="#0000FF" stroke-width="8" points="179,225,218,243,228,285,202,319,159,320,131,287,139,245"/>
+ <polygon id="test-5" fill="none" stroke="#00FF00" stroke-width="8" points="270,265 300,285 320,265 340,285 280,320 390,320 420,280 280,225"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-polyline.svg b/ksvg/test/ecma/bbox/bbox-polyline.svg
new file mode 100644
index 00000000..c60321da
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-polyline.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 6)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <polyline id="test-0" fill="none" stroke="#000000" points="10,80,35,180,60,80,85,180,110,80,135,180"/>
+ <polyline id="test-1" fill="none" stroke="blue" stroke-width="8" points="220,80,267,114,249,170,190,170,172,114,220,80"/>
+ <polyline id="test-2" fill="blue" stroke="#00FF00" stroke-width="4" points="310,80,335,180,360,80,385,180,410,80,435,180"/>
+ <polyline id="test-3" fill="none" stroke="red" stroke-width="8" points="59,225,98,243,108,285,82,319,39,320,11,287,19,245"/>
+ <polyline id="test-4" fill="#00FF00" stroke="#0000FF" stroke-width="8" points="189,225,228,243,238,285,212,319,169,320,141,287,149,245"/>
+ <polyline id="test-5" fill="#FF00FF" stroke="none" stroke-width="8" points="270,265 300,285 320,265 340,285 280,320 390,320 420,280 280,225"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-rect.svg b/ksvg/test/ecma/bbox/bbox-rect.svg
new file mode 100644
index 00000000..b35285ec
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox-rect.svg
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 8)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <rect id="test-0" fill="none" stroke="#000000" x="30" y="86" width="50" height="100"/>
+ <rect id="test-1" fill="red" x="130" y="86" width="50" height="100"/>
+ <rect id="test-2" fill="none" stroke="#000000" x="250" y="86" width="50" height="100" rx="30"/>
+ <rect id="test-3" fill="red" x="350" y="86" width="50" height="100" rx="30"/>
+ <rect id="test-4" fill="none" stroke="#0000FF" stroke-width="8" x="30" y="266" width="50" height="100"/>
+ <rect id="test-5" fill="#00FF00" stroke="#0000FF" stroke-width="8" x="130" y="266" width="50" height="100"/>
+ <rect id="test-6" fill="none" stroke="#0000FF" stroke-width="8" x="250" y="266" width="50" height="100" rx="30" ry="50"/>
+ <rect id="test-7" fill="#00FF00" x="350" y="266" width="50" height="100" rx="30" ry="50"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox.js b/ksvg/test/ecma/bbox/bbox.js
new file mode 100644
index 00000000..2d692694
--- /dev/null
+++ b/ksvg/test/ecma/bbox/bbox.js
@@ -0,0 +1,103 @@
+function clear_test(evt, number)
+{
+ for(var i = 0; i < number; i++)
+ {
+ var element = evt.target.getOwnerDocument().getElementById("bbox" + (i + 1));
+ element.getParentNode().removeChild(element);
+ }
+}
+
+function bbox_loop(drawit, number)
+{
+ var doc = evt.target.getOwnerDocument();
+
+ for(var i = 0; i < number; i++)
+ {
+ var shape = doc.getElementById("test-" + i);
+ var bbox = shape.getBBox();
+
+ if(drawit == "true")
+ {
+ draw_it(doc, bbox, shape, i + 1);
+ }
+ else
+ {
+ do_string(bbox, i + 1);
+ }
+ }
+}
+
+function do_string(shape, number)
+{
+ var string = "\nShape " + number + "\nX = " + shape.x + "\nY = " + shape.y + "\nW = " + shape.width + "\nH = " + shape.height;
+ alert(string);
+}
+
+function draw_it(doc, bbox, shape, number)
+{
+ var element = doc.createElement("rect");
+ element.setAttribute("x", bbox.x);
+ element.setAttribute("y", bbox.y);
+ element.setAttribute("width", bbox.width);
+ element.setAttribute("height", bbox.height);
+ element.setAttribute("fill", "none");
+ element.setAttribute("stroke", "red");
+ element.setAttribute("stroke-width", "3");
+ element.setAttribute("id", "bbox" + number);
+
+ shape.getParentNode().appendChild(element);
+}
+
+function gen_buttons(evt, number)
+{
+ var doc = evt.target.getOwnerDocument();
+ var main = doc.getElementById("svg-root");
+
+ var aone = doc.createElement("a");
+ var atwo = doc.createElement("a");
+ var athree = doc.createElement("a");
+
+ var rect = doc.createElement("rect");
+ var text = doc.createElement("text");
+
+ aone.setAttribute("onclick", "bbox_loop('false'," + number + ")");
+
+ atwo.setAttribute("onclick", "bbox_loop('true'," + number + ")");
+ atwo.setAttribute("transform", "translate(0,22)");
+
+ athree.setAttribute("onclick", "clear_test(evt," + number + ")");
+ athree.setAttribute("transform", "translate(0,44)");
+
+ rect.setAttribute("x", "0");
+ rect.setAttribute("y", "0");
+ rect.setAttribute("width", "110");
+ rect.setAttribute("height", "20");
+
+ text.setAttribute("x", "0");
+ text.setAttribute("y", "15");
+ text.setAttribute("fill", "white");
+
+ // First button
+ aone.appendChild(rect.cloneNode(1));
+ var aonetext = text.cloneNode(1);
+ aonetext.appendChild(doc.createTextNode("Calculate bbox"));
+ aone.appendChild(aonetext);
+
+ main.appendChild(aone);
+
+ // Second button
+ atwo.appendChild(rect.cloneNode(1));
+ var atwotext = text.cloneNode(1);
+ atwotext.appendChild(doc.createTextNode("Draw bbox"));
+ atwo.appendChild(atwotext);
+
+ main.appendChild(atwo);
+
+ // Third button
+ athree.appendChild(rect.cloneNode(1));
+ var athreetext = text.cloneNode(1);
+ athreetext.appendChild(doc.createTextNode("Clear bbox drawing"));
+ athree.appendChild(athreetext);
+
+ main.appendChild(athree);
+}
diff --git a/ksvg/test/ecma/broken.svg b/ksvg/test/ecma/broken.svg
new file mode 100644
index 00000000..82eb021e
--- /dev/null
+++ b/ksvg/test/ecma/broken.svg
@@ -0,0 +1,30 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010719//EN"
+ "http://www.w3.org/TR/2001/PR-SVG-20010719/DTD/svg10.dtd">
+<svg width="6cm" height="5cm" viewBox="0 0 600 500">
+ <desc>Example script01 - invoke an ECMAScript function from an onclick event
+ </desc>
+ <!-- ECMAScript to change the radius with each click -->
+ <script type="text/ecmascript"> <![CDATA[
+ function circle_click(evt) {
+ var circle = evt.target;
+ var currentRadius = circle.r.baseVal.value;
+ if (currentRadius == 100)
+ circle.r.baseVal.value = currentRadius*2;
+ else
+ circle.r.baseVal.value = currentRadius*0.5;
+ }
+ ]]> </script>
+
+ <!-- Outline the drawing area with a blue line -->
+ <rect x="1" y="1" width="598" height="498" fill="none" stroke="blue"/>
+
+ <!-- Act on each click event -->
+ <circle onclick="circle_click(evt)" cx="300" cy="225" r="100"
+ fill="red"/>
+
+ <text x="300" y="480"
+ font-family="Verdana" font-size="35" text-anchor="middle">
+ Click on circle to change its size
+ </text>
+</svg>
diff --git a/ksvg/test/ecma/circle.svg b/ksvg/test/ecma/circle.svg
new file mode 100644
index 00000000..e9b198c3
--- /dev/null
+++ b/ksvg/test/ecma/circle.svg
@@ -0,0 +1,38 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg width="6cm" height="5cm" viewBox="0 0 600 500" onload="foobar(evt)">
+ <script type="text/ecmascript"> <![CDATA[
+ function foobar(evt)
+ {
+ var circle = evt.getTarget().ownerDocument.getElementById('moo');
+
+ var id = circle.id; // Should call SVGElementImpl::getValueProperty
+
+ var name = circle; // Should call toString()
+
+ var nodeName = circle.nodeName;
+
+ var prop = circle.cx; // Should call SVGCircleElementImpl::getValueProperty
+
+ alert('NODENAME: ' + nodeName + '\nID: ' + id + '\nNAME: ' + name + '\nPROP: ' + prop.baseVal.value);
+ }
+
+ function click(evt)
+ {
+ var circle = evt.target;
+
+ var id = circle.id; // Should call SVGElementImpl::getValueProperty
+
+ var name = circle; // Should call toString()
+
+ var nodeName = circle.nodeName;
+
+ var prop = circle.cx; // Should call SVGCircleElementImpl::getValueProperty
+
+ alert('NODENAME: ' + nodeName + '\nID: ' + id + '\nNAME: ' + name + '\nPROP: ' + prop.baseVal.value);
+ }
+
+ ]]> </script>
+
+ <circle id="moo" onclick="click(evt)" cx="300" cy="225" r="100" fill="red"/>
+</svg>
diff --git a/ksvg/test/ecma/clock.svg b/ksvg/test/ecma/clock.svg
new file mode 100644
index 00000000..906f1303
--- /dev/null
+++ b/ksvg/test/ecma/clock.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="200px" height="280px">
+ <g transform="translate(100,100) rotate(-90)">
+ <circle r="100" fill="white" strok="black" stroke-width="2px"/>
+
+ <g style="stroke-linecap: round; stroke: black; stroke-width: 2px;">
+ <line x1="100" y1="0" x2="90" y2="0" />
+ <line x1="87" y1="50" x2="78" y2="45" />
+ <line x1="50" y1="87" x2="45" y2="78" />
+ <line x1="0" y1="100" x2="0" y2="90" />
+ <line x1="-50" y1="87" x2="-45" y2="78" />
+ <line x1="-87" y1="50" x2="-78" y2="45" />
+ <line x1="-100" y1="0" x2="-90" y2="0" />
+ <line x1="-87" y1="-50" x2="-78" y2="-45"/>
+ <line x1="-50" y1="-87" x2="-45" y2="-78"/>
+ <line x1="0" y1="-100" x2="0" y2="-90"/>
+ <line x1="50" y1="-87" x2="45" y2="-78"/>
+ <line x1="87" y1="-50" x2="78" y2="-45"/>
+ <line id="hourhand" stroke-width="8px" stroke="blue" x1="0" y1="0" x2="0" y2="40"/>
+ <line id="minutehand" stroke-width="5px" stroke="green" x1="0" y1="0" x2="0" y2="65"/>
+ <line id="secondhand" stroke-width="2px" stroke="red" x1="0" y1="0" x2="0" y2="90"/>
+ </g>
+ </g>
+ <text id="datetext" x="10" y="250">test</text>
+
+ <script type="text/javascript">
+ var sHand = document.getElementById('secondhand');
+ var mHand = document.getElementById('minutehand');
+ var hHand = document.getElementById('hourhand');
+ var digital = document.getElementById('datetext');
+
+ function updateSeconds() {
+ var angle = (new Date()).getSeconds() * Math.PI/30;
+
+ if (angle == 0)
+ updateMinutes();
+
+ sHand.setAttribute('x2', 90 * Math.cos(angle));
+ sHand.setAttribute('y2', 90 * Math.sin(angle));
+
+ var d = (new Date()).toUTCString();
+ digital.firstChild.data = d;
+ }
+
+ function updateMinutes() {
+ var angle = (new Date()).getMinutes() * Math.PI/30;
+
+ if (angle == 0)
+ updateHours();
+
+ mHand.setAttribute('x2', 65 * Math.cos(angle));
+ mHand.setAttribute('y2', 65 * Math.sin(angle));
+ }
+
+ function updateHours() {
+ var angle = (new Date()).getHours() * Math.PI/6;
+ hHand.setAttribute('x2', 40 * Math.cos(angle));
+ hHand.setAttribute('y2', 40 * Math.sin(angle));
+ }
+ updateSeconds();
+ updateMinutes();
+ updateHours();
+ setInterval('updateSeconds()', 1000);
+
+ </script>
+</svg>
diff --git a/ksvg/test/ecma/dom01.svg b/ksvg/test/ecma/dom01.svg
new file mode 100644
index 00000000..d5b98937
--- /dev/null
+++ b/ksvg/test/ecma/dom01.svg
@@ -0,0 +1,40 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg width="4cm" height="2cm" viewBox="0 0 400 200"
+ onload="StartAnimation(evt)"
+ xmlns="http://www.w3.org/2000/svg">
+
+ <script type="text/ecmascript"><![CDATA[
+ var timevalue = 0;
+ var timer_increment = 50;
+ var max_time = 5000;
+ var text_element;
+ function StartAnimation(evt) {
+ text_element = evt.target.ownerDocument.getElementById("TextElement");
+ ShowAndGrowElement();
+ }
+ function ShowAndGrowElement() {
+ timevalue = timevalue + timer_increment;
+ if (timevalue > max_time)
+ return;
+
+ // Scale the text string gradually until it is 20 times larger
+ scalefactor = (timevalue * 20.) / max_time * 40;
+ text_element.setAttribute("transform", "scale(" + scalefactor + ")");
+ // Make the string more opaque
+ opacityfactor = timevalue / max_time;
+// text_element.setAttribute("opacity", opacityfactor);
+
+ // Call ShowAndGrowElement again <timer_increment> milliseconds later.
+// setTimeout("ShowAndGrowElement()", timer_increment)
+ }
+ window.ShowAndGrowElement = ShowAndGrowElement
+ ]]></script>
+ <rect x="1" y="1" width="398" height="198"
+ fill="none" stroke="blue" stroke-width="2"/>
+
+ <g transform="translate(50,150)" fill="red" font-size="7">
+ <text id="TextElement">SVG</text>
+ </g>
+</svg>