première tentative d'import de XML depuis la texte area (ne fonctionne pas)

This commit is contained in:
MCMic 2010-04-12 23:27:21 +00:00
commit 884395c8ee

View file

@ -80,15 +80,17 @@
<div> <div>
<form method="post" action="javascript:chargerURL(document.getElementById('url').value)"> <form method="post" action="javascript:chargerURL(document.getElementById('url').value)">
<fieldset style="" id="upload"> <fieldset style="" id="upload">
<legend>Charger un strip</legend> <legend>Charger un strip depuis une URL</legend>
<label for="url">Adresse du fichier : </label><input type="text" id="url" name="url" value="geekscottes_133.xml" size="50"/> <label for="url">Adresse du fichier : </label><input type="text" id="url" name="url" value="geekscottes_133.xml" size="50"/>
<input type="submit" value="Ouvrir"/> <input type="submit" value="Charger" id="xml_url_validation"/>
</fieldset> </fieldset>
</form>
<form method="post" action="javascript:chargerXML(document.getElementById('xml_area').value)">
<fieldset> <fieldset>
<legend>Code XML</legend> <legend>Charger un strip depuis du code XML</legend>
<label for="xml_area">nom</label> <label for="xml_area">nom</label>
<textarea id="xml_area" name="xml_area" rows="15" cols="130">code</textarea> <textarea id="xml_area" name="xml_area" rows="15" cols="130">code</textarea>
<input type="button" value="Envoyer"/> <input type="button" value="Charger" id="xml_area_validation"/>
</fieldset> </fieldset>
</form> </form>
</div> </div>
@ -601,7 +603,15 @@
function chargerURL(url) { function chargerURL(url) {
alert("c'est parti..."); 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(); strip.draw();
alert("voilà"); alert("voilà");
} }
@ -620,14 +630,20 @@
strip.supprimerCase(0); strip.supprimerCase(0);
strip.clear(); strip.clear();
strip.draw();*/ strip.draw();*/
function getXmlFromURL(url) {
function parseStrip(xmlFile) {
var xmlDoc; var xmlDoc;
xmlDoc=new window.XMLHttpRequest(); xmlDoc=new window.XMLHttpRequest();
xmlDoc.open("GET",xmlFile,false); xmlDoc.open("GET",url,false);
xmlDoc.send(""); xmlDoc.send("");
for(i=0;xmlDoc.responseXML.childNodes[i].nodeType != 1;i++); return xmlDoc.responseXML;
strip_node = xmlDoc.responseXML.childNodes[i]; }
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); //alert(strip_node.textContent);
strip = new Strip("strip",strip_node.getAttribute("x"),strip_node.getAttribute("y"),strip_node.getAttribute("height"),true); strip = new Strip("strip",strip_node.getAttribute("x"),strip_node.getAttribute("y"),strip_node.getAttribute("height"),true);

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Before After
Before After