SVG – Learning by Coding

[ geturl_variants.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 01/05 thomas@handmadecode.de     -->
  9: 
 10: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
 11:   onload="Init(evt)">
 12: 
 13:   <title>SVG Learning by Coding</title>
 14:   <desc>SVG-Spezifikation in Beispielen</desc>
 15: 
 16:   <defs>
 17: 
 18:     <style type="text/css">
 19:       <![CDATA[
 20: 
 21:       *
 22:       {
 23:         font-familysans-serif;
 24:         font-size12px;
 25:       }
 26: 
 27:       ]]>
 28:     </style>
 29: 
 30: 
 31:     <script type="text/javascript">
 32:       <![CDATA[
 33: 
 34:       var svgdoc,ret_arr,dt_out,ip_out,ho_out,ua_out,err;
 35: 
 36: 
 37:       function Init(load_evt)
 38:       {
 39:         svgdoc=load_evt.target.ownerDocument;
 40: 
 41:         dt_out=svgdoc.getElementById("dt").firstChild;
 42:         ip_out=svgdoc.getElementById("ip").firstChild;
 43:         ho_out=svgdoc.getElementById("ho").firstChild;
 44:         ua_out=svgdoc.getElementById("ua").firstChild;
 45:       }
 46: 
 47: 
 48:       function GetData(m)
 49:       {
 50:         err=false;
 51:         ret_arr=null;
 52: 
 53:         if(window.getURL)
 54:         {
 55:           if(m=="str")getURL("geturl_variants.php?method=str",callback_str);
 56:           if(m=="arr")getURL("geturl_variants.php?method=arr",callback_arr);
 57:           if(m=="xml")getURL("geturl_variants.php?method=xml",callback_xml);
 58:         }
 59:         else alert("Diese Technik ist nicht verfuegbar!");
 60:       }
 61: 
 62: 
 63:       function callback_str(urlRequestStatus)
 64:       {
 65:         if(urlRequestStatus.success && urlRequestStatus.content!="Error!")
 66:         {
 67:           ret_arr=urlRequestStatus.content.split("|");
 68:           GetResults();
 69:         }
 70:         else err=true;
 71:       }
 72: 
 73: 
 74:       function callback_arr(urlRequestStatus)
 75:       {
 76:         if(urlRequestStatus.success && urlRequestStatus.content!="Error!")
 77:         {
 78:           eval("ret_arr="+urlRequestStatus.content);
 79:           GetResults();
 80:         }
 81:         else err=true;
 82:       }
 83: 
 84: 
 85:       function callback_xml(urlRequestStatus)
 86:       {
 87:         if(urlRequestStatus.success && urlRequestStatus.content!="Error!")
 88:         {
 89:           xmldoc=parseXML(urlRequestStatus.content).documentElement;
 90:           if(xmldoc)
 91:           {
 92:             ret_arr=new Array();
 93:             ret_arr[0]=xmldoc.getElementsByTagName("dt").item(0).firstChild.nodeValue;
 94:             ret_arr[1]=xmldoc.getElementsByTagName("ip").item(0).firstChild.nodeValue;
 95:             ret_arr[2]=xmldoc.getElementsByTagName("ho").item(0).firstChild.nodeValue;
 96:             ret_arr[3]=xmldoc.getElementsByTagName("ua").item(0).firstChild.nodeValue;
 97:           }
 98:           GetResults();
 99:         }
100:         else err=true;
101:       }
102: 
103: 
104:       function GetResults()
105:       {
106:         if(typeof(ret_arr)=="object" && ret_arr!=null && !err)
107:         {
108:           dt_out.nodeValue="Zeitpunkt:  "+ret_arr[0];
109:           ip_out.nodeValue="IP-Adresse: "+ret_arr[1];
110:           ho_out.nodeValue="Hostname:   "+ret_arr[2];
111:           ua_out.nodeValue="User-Agent: "+ret_arr[3];
112:         }
113:         else alert("Es ist ein Fehler aufgetreten!");
114:       }
115: 
116:       ]]>
117:     </script>
118: 
119:   </defs>
120: 
121:   <text x="20" y="30" style="fill: #000; font-size: 24px">
122:     getURL()-Varianten zur externen Datenabfrage
123:   </text>
124: 
125:   <text x="30" y="50" style="fill: #00C; font-family: monospace;
126:     font-size14px; font-weightbold" xml:space="preserve">
127:     <tspan id="dt" x="30" dy="16">Zeitpunkt:  ...</tspan>
128:     <tspan id="ip" x="30" dy="16">IP-Adresse: ...</tspan>
129:     <tspan id="ho" x="30" dy="16">Hostname:   ...</tspan>
130:     <tspan id="ua" x="30" dy="16">User-Agent: ...</tspan>
131:   </text>
132: 
133:   <text x="30" y="150" style="fill: #F00; font-size: 12px">
134:     getURL()-Aufrufe mit Rückgabe ...</text>
135: 
136:   <a xlink:href="" cursor="pointer" onclick="return false">
137:     <text x="30" y="170" onclick="GetData('str')">
138:       &#8250; als einfacher String mit Separator-Zeichen
139:       <set attributeName="fill" attributeType="CSS" to="#F00" begin="mouseover"/>
140:       <set attributeName="fill" attributeType="CSS" to="#000" begin="mouseout"/>
141:     </text>
142:   </a>
143: 
144:   <a xlink:href="" cursor="pointer" onclick="return false">
145:     <text x="30" y="190" onclick="GetData('arr')">
146:       &#8250; als new Array(...)-String
147:       <set attributeName="fill" attributeType="CSS" to="#F00" begin="mouseover"/>
148:       <set attributeName="fill" attributeType="CSS" to="#000" begin="mouseout"/>
149:     </text>
150:   </a>
151: 
152:   <a xlink:href="" cursor="pointer" onclick="return false">
153:     <text x="30" y="210" onclick="GetData('xml')">
154:       &#8250; als XML-Dokument
155:       <set attributeName="fill" attributeType="CSS" to="#F00" begin="mouseover"/>
156:       <set attributeName="fill" attributeType="CSS" to="#000" begin="mouseout"/>
157:     </text>
158:   </a>
159: 
160:   <a xlink:href="geturl_variants_php.txt" target="_top">
161:     <text x="30" y="245">PHP-Script zur Datenabfrage
162:       <set attributeName="fill" attributeType="CSS" to="#00C" begin="mouseover"/>
163:       <set attributeName="fill" attributeType="CSS" to="#000" begin="mouseout"/>
164:     </text>
165:   </a>
166: 
167: </svg>

[zum Anfang]