[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qsos-commits] qsos/apps/tpl-xuleditor/chrome/content Template.js
From: |
Raphaël Semeteys |
Subject: |
[Qsos-commits] qsos/apps/tpl-xuleditor/chrome/content Template.js |
Date: |
Sun, 14 May 2006 22:26:54 +0000 |
CVSROOT: /sources/qsos
Module name: qsos
Branch:
Changes by: Raphaël Semeteys <address@hidden> 06/05/14 22:26:54
Modified files:
apps/tpl-xuleditor/chrome/content: Template.js
Log message:
New serializer implemented
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/qsos/apps/tpl-xuleditor/chrome/content/Template.js.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
Patches:
Index: qsos/apps/tpl-xuleditor/chrome/content/Template.js
diff -u qsos/apps/tpl-xuleditor/chrome/content/Template.js:1.7
qsos/apps/tpl-xuleditor/chrome/content/Template.js:1.8
--- qsos/apps/tpl-xuleditor/chrome/content/Template.js:1.7 Mon May 8
21:08:56 2006
+++ qsos/apps/tpl-xuleditor/chrome/content/Template.js Sun May 14 22:26:54 2006
@@ -134,13 +134,60 @@
outputStream.init(file, 0x04 | 0x08 | 0x20, 420, 0);
- var serializer = new XMLSerializer();
- serializer.serializeToStream(sheet, outputStream, "UTF-8");
+ //var serializer = new XMLSerializer();
+ //serializer.serializeToStream(sheet, outputStream, "UTF-8");
+
//var xml = serializer.serializeToString(sheet);
//var result = outputStream.write( xml, xml.length );
+
+ var xml = serialize(sheet.documentElement, 0);
+ outputStream.write(xml, xml.length);
+
outputStream.close();
}
+ //Serialize and write the local QSOS XML file
+ function serialize(node, depth) {
+ var indent = "";
+ var line = "";
+
+ if (depth == 0) {
+ line = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ }
+
+ for (i=0; i < depth; i++) {
+ indent += " ";
+ }
+
+ line += indent + "<" + node.tagName;
+ if (node.hasAttributes()) {
+ var attributes = node.attributes;
+ for (var i = 0; i < attributes.length; i++) {
+ var attribute = attributes[i];
+ line += " " + attribute.name + "=\"" + attribute.value
+ "\"";
+ }
+ }
+ line += ">";
+
+ var test = false;
+ var children = node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ var child = children[i];
+ if (child.tagName) {
+ line += "\n" + serialize(child, depth+1);
+ test = true;
+ }
+ }
+
+ if (test) {
+ line += "\n" + indent + "</" + node.tagName + ">";
+ } else {
+ line += (children[0]?children[0].nodeValue:"") + "</" +
node.tagName + ">";
+ }
+
+ return line;
+ }
+
//Load and parse a remote QSOS XML file
//ex: loadremote("http://localhost/qedit/xul/kolab.qsos")
//initializes local variable: sheet
@@ -153,9 +200,9 @@
}
//Show the XML DOM structure in a dialogbox
- function dump() {
+ function dump(node) {
var serializer = new XMLSerializer();
- var xml = serializer.serializeToString(sheet);
+ var xml = serializer.serializeToString(node);
alert(xml);
}
- [Qsos-commits] qsos/apps/tpl-xuleditor/chrome/content Template.js,
Raphaël Semeteys <=