added clear svg function

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@8 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Narendra Sisodiya 2009-02-13 09:32:31 +00:00
parent 899d973ffb
commit 76c17ae3e8
1 changed files with 55 additions and 50 deletions

View File

@ -319,63 +319,68 @@ function assignAttr(Node,Attr){
function SVGclear_svg() function SVGclear_svg()
{ {
for(var i=1; i<path_num; i++){ var Nodes = SVGRoot.childNodes ;
var element = SVGDocument.getElementById("path_" + i); var Length = SVGRoot.childNodes.length ;
if(element != null ) { element.parentNode.removeChild(element); } var i = 0 ;
for(var Rep=0; Rep< Length; Rep++){
} if(Nodes[i].nodeType == 1){
path_num = 1 ; Nodes[i].parentNode.removeChild(Nodes[i]);
}
else{
i++;
}
}//for
} }
function SvgToString(elem , indent) function SvgToString(elem , indent)
{ {
var out = "" ; var out = "" ;
if (elem) if (elem)
{ {
var attrs = elem.attributes; var attrs = elem.attributes;
var attr; var attr;
var i; var i;
var childs = elem.childNodes; var childs = elem.childNodes;
for (i=0; i<indent; i++) out += " "; for (i=0; i<indent; i++) out += " ";
out += "<" + elem.nodeName; out += "<" + elem.nodeName;
for (i=attrs.length-1; i>=0; i--)
{
attr = attrs.item(i);
out += " " + attr.nodeName + "=\"" + attr.nodeValue+ "\"";
}
for (i=attrs.length-1; i>=0; i--)
if (elem.hasChildNodes()) {
{ attr = attrs.item(i);
out += ">\n"; out += " " + attr.nodeName + "=\"" + attr.nodeValue+ "\"";
indent++; }
for (i=0; i<childs.length; i++)
{
if (childs.item(i).nodeType == 1) // element node ..
out = out + SvgToString(childs.item(i) ,indent);
else if (childs.item(i).nodeType == 3) // text node ..
{
for (j=0; j<indent; j++) out += " ";
out += childs.item(i).nodeValue + "\n";
}
}
indent--;
for (i=0; i<indent; i++) out += " ";
out += "</" + elem.nodeName + ">\n";
}
else
{
out += " />\n";
}
}
return out;
} if (elem.hasChildNodes())
{
out += ">\n";
indent++;
for (i=0; i<childs.length; i++)
{
if (childs.item(i).nodeType == 1) // element node ..
out = out + SvgToString(childs.item(i) ,indent);
else if (childs.item(i).nodeType == 3) // text node ..
{
for (j=0; j<indent; j++) out += " ";
out += childs.item(i).nodeValue + "\n";
}
}
indent--;
for (i=0; i<indent; i++) out += " ";
out += "</" + elem.nodeName + ">\n";
}
else
{
out += " />\n";
}
}
return out;
}
function SVGsubmit_svg(){ function SVGsubmit_svg(){
var str = "<?xml version=\"1.0\" standalone=\"no\"?> \ var str = "<?xml version=\"1.0\" standalone=\"no\"?> \