annotate inkscape/firefox/content/jqSOAPClient.js @ 1087:cd34de1a6960 openvg

Fix issue of incorrect color for color paint. It is always black (nearly). It is caused by translate RGBA values from MadButterfly to OpenVG with wrong function.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 03 Dec 2010 18:18:43 +0800
parents 63aaf96209cd
children
rev   line source
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
1 /*
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
2 This program is free software: you can redistribute it and/or modify
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
3 it under the terms of the GNU General Public License as published by
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
4 the Free Software Foundation, either version 3 of the License, or
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
5 (at your option) any later version.
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
6
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
7 This program is distributed in the hope that it will be useful,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
10 GNU General Public License for more details.
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
11
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
12 You should have received a copy of the GNU General Public License
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
13 along with this program. If not, see <http://www.gnu.org/licenses/>.
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
14 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
15 //Singleton SOAP Client
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
16 var SOAPClient = {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
17 Proxy: "",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
18 SOAPServer: "",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
19 ContentType: "text/xml",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
20 CharSet: "utf-8",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
21 ResponseXML: null,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
22 ResponseText: "",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
23 Status: 0,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
24 ContentLength: 0,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
25 Namespace: function(name, uri) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
26 return {"name":name, "uri":uri};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
27 },
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
28 SendRequest: function(soapReq, callback,arg) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
29 if(!!SOAPClient.Proxy) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
30 SOAPClient.ResponseText = "";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
31 SOAPClient.ResponseXML = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
32 SOAPClient.Status = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
33
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
34 var content = soapReq.toString();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
35 SOAPClient.ContentLength = content.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
36
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
37 function getResponse(xData) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
38 if(!!callback) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
39 SOAPClient.Status = xData.status;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
40 SOAPClient.ResponseText = xData.responseText;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
41 SOAPClient.ResponseXML = xData.responseXML;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
42 var jsOut = $.xmlToJSON(xData.responseXML);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
43 callback(jsOut,arg);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
44 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
45 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
46 $.ajax({
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
47 type: "POST",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
48 url: SOAPClient.Proxy,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
49 dataType: "xml",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
50 processData: false,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
51 data: content,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
52 complete: getResponse,
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
53 contentType: SOAPClient.ContentType + "; charset=\"" + SOAPClient.CharSet + "\"",
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
54 beforeSend: function(req) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
55 req.setRequestHeader("Method", "POST");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
56 req.setRequestHeader("Content-Length", SOAPClient.ContentLength);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
57 req.setRequestHeader("SOAPServer", SOAPClient.SOAPServer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
58 req.setRequestHeader("SOAPAction", soapReq.Action);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
59 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
60 });
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
61 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
62 },
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
63 ToXML: function(soapObj) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
64 var out = [];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
65 var isNSObj=false;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
66 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
67 if(!!soapObj&&typeof(soapObj)==="object"&&soapObj.typeOf==="SOAPObject") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
68 //Namespaces
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
69 if(!!soapObj.ns) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
70 if(typeof(soapObj.ns)==="object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
71 isNSObj=true;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
72 out.push("<"+soapObj.ns.name+":"+soapObj.name);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
73 out.push(" xmlns:"+soapObj.ns.name+"=\""+soapObj.ns.uri+"\"");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
74 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
75 out.push("<"+soapObj.name);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
76 out.push(" xmlns=\""+soapObj.ns+"\"");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
77 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
78 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
79 out.push("<"+soapObj.name);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
80 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
81 //Node Attributes
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
82 if(soapObj.attributes.length > 0) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
83 var cAttr;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
84 var aLen=soapObj.attributes.length-1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
85 do {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
86 cAttr=soapObj.attributes[aLen];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
87 if(isNSObj) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
88 out.push(" "+soapObj.ns.name+":"+cAttr.name+"=\""+cAttr.value+"\"");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
89 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
90 out.push(" "+cAttr.name+"=\""+cAttr.value+"\"");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
91 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
92 } while(aLen--);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
93 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
94 out.push(">");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
95 //Node children
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
96 if(soapObj.hasChildren()) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
97 var cPos, cObj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
98 for(cPos in soapObj.children){
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
99 cObj = soapObj.children[cPos];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
100 if(typeof(cObj)==="object"){out.push(SOAPClient.ToXML(cObj));}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
101 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
102 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
103 //Node Value
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
104 if(!!soapObj.value){out.push(soapObj.value);}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
105 //Close Tag
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
106 if(isNSObj){out.push("</"+soapObj.ns.name+":"+soapObj.name+">");}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
107 else {out.push("</"+soapObj.name+">");}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
108 return out.join("");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
109 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
110 } catch(e){alert("Unable to process SOAPObject! Object must be an instance of SOAPObject");}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
111 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
112 };
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
113 //Soap request - this is what being sent using SOAPClient.SendRequest
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
114 var SOAPRequest=function(action, soapObj) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
115 this.Action=action;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
116 var nss=[];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
117 var headers=[];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
118 var bodies=(!!soapObj)?[soapObj]:[];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
119 this.addNamespace=function(ns, uri){nss.push(new SOAPClient.Namespace(ns, uri));};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
120 this.addHeader=function(soapObj){headers.push(soapObj);};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
121 this.addBody=function(soapObj){bodies.push(soapObj);};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
122 this.toString=function() {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
123 var soapEnv = new SOAPObject("soapenv:Envelope");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
124 soapEnv.attr("xmlns:soapenv","http://schemas.xmlsoap.org/soap/envelope/");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
125 //Add Namespace(s)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
126 if(nss.length>0){
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
127 var tNs, tNo;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
128 for(tNs in nss){if(!nss.hasOwnProperty || nss.hasOwnProperty(tNs)){tNo=nss[tNs];if(typeof(tNo)==="object"){soapEnv.attr("xmlns:"+tNo.name, tNo.uri);}}}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
129 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
130 //Add Header(s)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
131 if(headers.length>0) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
132 var soapHeader = soapEnv.appendChild(new SOAPObject("soapenv:Header"));
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
133 var tHdr;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
134 for(tHdr in headers){if(!headers.hasOwnProperty || headers.hasOwnProperty(tHdr)){soapHeader.appendChild(headers[tHdr]);}}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
135 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
136 //Add Body(s)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
137 if(bodies.length>0) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
138 var soapBody = soapEnv.appendChild(new SOAPObject("soapenv:Body"));
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
139 var tBdy;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
140 for(tBdy in bodies){if(!bodies.hasOwnProperty || bodies.hasOwnProperty(tBdy)){soapBody.appendChild(bodies[tBdy]);}}
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
141 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
142 return soapEnv.toString();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
143 };
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
144 };
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
145
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
146 //Soap Object - Used to build body envelope and other structures
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
147 var SOAPObject = function(name) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
148 this.typeOf="SOAPObject";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
149 this.ns=null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
150 this.name=name;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
151 this.attributes=[];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
152 this.children=[];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
153 this.value=null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
154 this.attr=function(name, value){this.attributes.push({"name":name, "value":value});return this;};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
155 this.appendChild=function(obj){this.children.push(obj);return obj;};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
156 this.hasChildren=function(){return (this.children.length > 0)?true:false;};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
157 this.val=function(v){if(!v){return this.value;}else{this.value=v;return this;}};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
158 this.toString=function(){return SOAPClient.ToXML(this);};
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
159 };