SVG – Learning by Coding

[ handleClicks.svg --> Grafik anzeigen ]

 1: <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
 2: <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
 3:   "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
 4:   <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink">
 5: ]>
 6: 
 7: <!-- SVG Learning by Coding http://www.datenverdrahten.de/svglbc/ -->
 8: <!--    AuthorDrThomas Meinike 04/03 thomas@handmadecode.de     -->
 9: 
10: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
11: 
12:   <title>SVG Learning by Coding</title>
13:   <desc>SVG-Spezifikation in Beispielen</desc>
14: 
15:   <defs>
16: 
17:     <script type="text/javascript">
18:       <![CDATA[
19: 
20:       var klick=true,zeit1=0,zeit2=0,verzoegerung=300;
21:       // verzoegerung = Testzeit in ms
22: 
23: 
24:       function handleClicks()
25:       {
26:         zeit2=zeit1;
27:         zeit1=new Date().getTime();
28:         if(klick)
29:         {
30:           klick=false;
31:           setTimeout("checkClickDiff()",verzoegerung);
32:         }
33:       }
34: 
35: 
36:       function checkClickDiff()
37:       {
38:         if(zeit1-zeit2<verzoegerung)alert("Doppelklick");
39:         else alert("Einfachklick");
40:         klick=true;
41:       }
42: 
43:       ]]>
44:     </script>
45: 
46:   </defs>
47: 
48:   <text x="20" y="30" style="fill: #000; font-size: 24px">
49:     Doppelklick von Einfachklick unterscheiden</text>
50: 
51:   <circle cx="250" cy="80" r="20" style="fill: #F00" onclick="handleClicks()"/>
52:   <text x="200" y="130">[Kreis anklicken!]</text>
53: 
54: </svg>

[zum Anfang]