diff --git a/striped/StripEd.svg b/striped/StripEd.svg index 78fccbf..c5de90d 100644 --- a/striped/StripEd.svg +++ b/striped/StripEd.svg @@ -80,15 +80,17 @@
- Charger un strip + Charger un strip depuis une URL - +
+
+
- Code XML + Charger un strip depuis du code XML - +
@@ -103,8 +105,8 @@ const xlinkns = "http://www.w3.org/1999/xlink"; const xhtmlns = "http://www.w3.org/1999/xhtml"; var root = document.documentElement; - - + + /* Extends Element functionality to add insertElement method */ Element.prototype.constructElementNS = function( namespace, elementName, attributeObj ) { var el = document.createElementNS( namespace, elementName ); @@ -123,12 +125,12 @@ } Element.prototype.constructElement = function( elementName, attributeObj ) { - var el = this.constructElementNS( this.namespaceURI, elementName, attributeObj ); + var el = this.constructElementNS( this.namespaceURI, elementName, attributeObj ); return el; } Element.prototype.insertElementNS = function( namespace, elementName, attributeObj, index ) { - var el = this.constructElementNS( namespace, elementName, attributeObj ); + var el = this.constructElementNS( namespace, elementName, attributeObj ); // insert child at requested index, or as last child if index is too high or no index is specified if ( null == index ) { @@ -139,24 +141,24 @@ if ( 0 == index ) { targetIndex = 0; } - + var targetEl = this.childNodes[ targetIndex ]; if ( targetEl ) { - this.insertBefore( el, targetEl ); + this.insertBefore( el, targetEl ); } else { this.appendChild( el ); } } - + return el; } Element.prototype.insertElement = function( elementName, attributeObj, index ) { - var el = this.insertElementNS( this.namespaceURI, elementName, attributeObj, index ); + var el = this.insertElementNS( this.namespaceURI, elementName, attributeObj, index ); return el; } - + idstrip = 0; // Point @@ -601,7 +603,15 @@ function chargerURL(url) { alert("c'est parti..."); - strip = parseStrip(url); + xml = getXmlFromURL(url); + strip = parseStrip(xml); + strip.draw(); + alert("voilĂ "); + } + function chargerXML(txt) { + alert("c'est parti (xml) ..."); + xml = getXmlFromText(txt); + strip = parseStrip(xml); strip.draw(); alert("voilĂ "); } @@ -620,14 +630,20 @@ strip.supprimerCase(0); strip.clear(); strip.draw();*/ - - function parseStrip(xmlFile) { + function getXmlFromURL(url) { var xmlDoc; xmlDoc=new window.XMLHttpRequest(); - xmlDoc.open("GET",xmlFile,false); + xmlDoc.open("GET",url,false); xmlDoc.send(""); - for(i=0;xmlDoc.responseXML.childNodes[i].nodeType != 1;i++); - strip_node = xmlDoc.responseXML.childNodes[i]; + return xmlDoc.responseXML; + } + function getXmlFromText(txt) { + var xmlDoc = new XML(txt); + return xmlDoc; + } + function parseStrip(xmlFile) { + for(i=0;xmlFile.childNodes[i].nodeType != 1;i++); + strip_node = xmlFile.childNodes[i]; //alert(strip_node.textContent); strip = new Strip("strip",strip_node.getAttribute("x"),strip_node.getAttribute("y"),strip_node.getAttribute("height"),true);