[ng-dhtml] [Dojo-checkins] r1592 - trunk/src

Tom Trenka ttrenka at gmail.com
Sat Sep 24 11:37:13 CDT 2005


I'd actually originally had it in dojo.dom, but it seemed very out of place
there as well...the goal here is to bring Moz-like object support to ASVG
more than anything else (a la Sarissa and a number of the things that Erik's
released, like his DOMParser); since it's kind of aimed at a very specific
platform; the XMLHttpRequest in particular is very specific to ASVG.

I'm certainly open to discussion about the utility of some of this outside
of the context of ASVG, though.

Tom

On 9/23/05, Alex Russell <alex at dojotoolkit.org> wrote:
>
> ISTM that it would be better if we had library methods for serialization
> (like dojo.dom.innerXML, which already exists) that could be used for
> this. I know the hope is to make innerXML() work transparently, but the
> namespace pollution seems icky.
>
> Regards
>
> On Friday 23 September 2005 10:10 am, dojo-checkins at dojotoolkit.org
> wrote:
> > Author: ttrenka
> > Date: Fri Sep 23 10:10:00 2005
> > New Revision: 1592
> >
> > Modified:
> > trunk/src/hostenv_svg.js
> > Log:
> > Added wrapper functions to make ASVG work a little more like the Moz
> > :)
> >
> > Modified: trunk/src/hostenv_svg.js
> > =====================================================================
> >========= --- trunk/src/hostenv_svg.js (original)
> > +++ trunk/src/hostenv_svg.js Fri Sep 23 10:10:00 2005
> > @@ -36,7 +36,7 @@
> > dojo.render.svg.support.builtin = true;
> > // FIXME the following two is a big-ass hack for now.
> > dojo.render.svg.moz = ((navigator.userAgent.indexOf("Gecko") >= 0)
> > && (!((navigator.appVersion.indexOf("Konqueror") >= 0) ||
> > (navigator.appVersion.indexOf("Safari") >= 0))));
> > -dojo.render.svg.adobe = !dojo.render.svg.moz;
> > +dojo.render.svg.adobe = (window.parseXML != null);
> >
> > // agent-specific implementations.
> >
> > @@ -103,3 +103,99 @@
> > }
> > return;
> > };
> > +
> > +// wrapper objects for ASVG
> > +if (!window.XMLSerializer){
> > + window.XMLSerialzer = function(){
> > + // based on WebFX RichTextControl getXHTML() function.
> > + function nodeToString(n, a) {
> > + function fixText(s) { return String(s).replace(/\&/g,
> > "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;"); } + function
> > fixAttribute(s) { return fixText(s).replace(/\"/g, "&quot;"); }
> > + switch (n.nodeType) {
> > + case dojo.dom.ELEMENT_NODE: {
> > + var name = n.nodeName;
> > + a.push("<" + name);
> > + for (var i = 0; i < n.attributes.length; i++) {
> > + if (n.attributes.item(i).specified) {
> > + a.push(" " + n.attributes.item(i).nodeName.toLowerCase() +
> > "=\"" + fixAttribute(n.attributes.item(i).nodeValue) + "\"");
> > + }
> > + }
> > + if (n.canHaveChildren || n.hasChildNodes()) {
> > + a.push(">");
> > + for (var i = 0; i < n.childNodes.length; i++)
> > nodeToString(n.childNodes.item(i), a); + a.push("</" + name +
> > ">\n");
> > + } else a.push(" />\n");
> > + break;
> > + }
> > + case dojo.dom.TEXT_NODE: {
> > + a.push(fixText(n.nodeValue));
> > + break;
> > + }
> > + case dojo.dom.CDATA_SECTION_NODE: {
> > + a.push("<![CDA" + "TA[\n" + n.nodeValue + "\n]" + "]>");
> > + break;
> > + }
> > + case dojo.dom.PROCESSING_INSTRUCTION_NODE: {
> > + a.push(n.nodeValue);
> > + if (/(^<\?xml)|(^<\!DOCTYPE)/.test(n.nodeValue)) a.push("\n");
> > + break;
> > + }
> > + case dojo.dom.COMMENT_NODE: {
> > + a.push("<!-- " + n.nodeValue + " -->\n");
> > + break;
> > + }
> > + }
> > + }
> > + this.serializeToString = function(node){
> > + var a = [];
> > + nodeToString(node, a);
> > + return a.join("");
> > + };
> > + };
> > +}
> > +if (!window.DOMParser){
> > + window.DOMParser = function(){
> > + // mimetype is basically ignored
> > + this.parseFromString = function(s){
> > + return parseXML(s, window.document);
> > + }
> > + };
> > +}
> > +if (!window.XMLHttpRequest){
> > + window.XMLHttpRequest = function(){
> > + var self = this;
> > + var http;
> > + var headers = [];
> > + var uri = null;
> > + var method = "POST";
> > + var isAsync = true; // TODO: allow support of sync ops?
> > + var cb = function(d){
> > + this.responseText = d.content;
> > + try {
> > + this.responseXML = parseXML(this.responseText, window.document);
> > + } catch(e){}
> > + this.status = "200";
> > + this.onreadystatechange();
> > + };
> > +
> > + this.readyState = 4;
> > + this.onreadystatechange = function(){};
> > + this.status = 0;
> > + this.responseXML = null;
> > + this.responseText = null;
> > + this.setHeader = function(nm, val){
> > + var o = [];
> > + o[nm] = val;
> > + headers.push(o);
> > + };
> > + this.open = function(meth, url, async){
> > + method = meth;
> > + uri = url;
> > + };
> > + this.send = function(data){
> > + var d = data || null;
> > + if (method == "GET") getURL(uri, cb);
> > + else postURL(uri, data, cb);
> > + };
> > + };
> > +}
> > _______________________________________________
> > Dojo-checkins mailing list
> > Dojo-checkins at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-checkins
>
> --
> Alex Russell
> alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723
> alex at netWindows.org F687 1964 1EF6 453E 9BD0 5148 A15D 1D43 AB92 9A46
>
> _______________________________________________
> NG-DHTML mailing list
> NG-DHTML at netwindows.org
> http://netwindows.org/mailman/listinfo/ng-dhtml_netwindows.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://netwindows.org/pipermail/ng-dhtml_netwindows.org/attachments/20050924/4d3dab07/attachment-0001.htm


More information about the NG-DHTML mailing list