annotate inkscape/firefox/inkscape.js @ 300:1b69da2494e9

Use the opacity of the style to overwrite the default opacity property of the node itself.
author wycc
date Sun, 15 Feb 2009 08:21:37 +0800
parents d5327265da1e
children
rev   line source
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
1 var isInProgress=0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
2
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
3 var MAX_DUMP_DEPTH = 10;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
4 var inkscape;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
5
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
6
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
7
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
8 function dumpObj(obj, name, indent, depth) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
9 if (depth > MAX_DUMP_DEPTH) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
10 return indent + name + ": <Maximum Depth Reached>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
11 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
12 if (typeof obj == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
13 var child = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
14 var output = indent + name + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
15 indent += "\t";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
16 for (var item in obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
17 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
18 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
19 child = obj[item];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
20 } catch (e) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
21 child = "<Unable to Evaluate>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
22 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
23 if (typeof child == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
24 output += dumpObj(child, item, indent, depth + 1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
25 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
26 output += indent + item + ": " + child + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
27 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
28 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
29 return output;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
30 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
31 return obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
32 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
33 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
34 function dumpObjItem(obj, name, indent, depth) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
35 if (depth > MAX_DUMP_DEPTH) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
36 return indent + name + ": <Maximum Depth Reached>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
37 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
38 if (typeof obj == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
39 var child = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
40 var output = indent + name + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
41 indent += "\t";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
42 for (var item in obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
43 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
44 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
45 child = obj[item];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
46 } catch (e) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
47 child = "<Unable to Evaluate>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
48 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
49 if (typeof child == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
50 output += dumpObjItem(child, item, indent, depth + 1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
51 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
52 output += indent + item + ":\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
53 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
54 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
55 return output;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
56 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
57 return obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
58 }
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 * Inkscape class
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
62 *
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
63 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
64 function Inkscape(file)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
65 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
66 var ink = document.getElementById('inkscape');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
67 ink.innerHTML = "<embed src="+file+" width=1000 height=800 />";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
68 this.isInProgress = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
69
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
70 setTimeout("inkscape.fetchDocument()",4000);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
71 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
72
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
73 Inkscape.prototype.gotoScene = function (n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
74 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
75 nextScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
76 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
77 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
78 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
79 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
80 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
81 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
82 Inkscape.prototype.gotoScene1 = function (resp,n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
83 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
84 var soapBody = new SOAPObject("SCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
85 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
86 v1.val(nextScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
87 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
88 var sr = new SOAPRequest("SCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
89 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
90 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene2(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
91 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
92 Inkscape.prototype.gotoScene2 = function (resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
93 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
94 var soapBody = new SOAPObject("PUBLISH");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
95 var sr = new SOAPRequest("PUBLISH", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
96 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
97 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene3(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
98 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
99
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
100 Inkscape.prototype.gotoScene3 = function (resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
101 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
102 this.isInProgress--;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
103 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
104 Inkscape.prototype.publishDocument= function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
105 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
106 mbsvg = new MBSVGString(resp.Body[0].GETDOCResponse[0].Result[0].Text);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
107 mbsvg.renderUI();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
108
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
109 var soapBody = new SOAPObject("PUBLISH");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
110 var sr = new SOAPRequest("PUBLISH", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
111 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
112 SOAPClient.SendRequest(sr, function(resp,arg) {arg.operationDone(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
113 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
114
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
115 Inkscape.prototype.refreshDocument = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
116 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
117 var soapBody = new SOAPObject("GETDOC");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
118 var sr = new SOAPRequest("GETDOC", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
119 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
120 SOAPClient.SendRequest(sr, function(resp,arg) { arg.publishDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
121 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
122
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
123 Inkscape.prototype.operationDone = function (res)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
124 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
125 this.isInProgress--;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
126 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
127 Inkscape.prototype.insertKey= function(n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
128 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
129 nextScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
130 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
131 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
132 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
133 SOAPClient.SendRequest(sr, function (resp,arg) {arg.insertKey1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
134 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
135 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
136 Inkscape.prototype.insertKey1 = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
137 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
138 var soapBody = new SOAPObject("INSERTKEY");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
139 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
140 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
141 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
142 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
143 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
144 v2.val(nextScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
145 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
146 var sr = new SOAPRequest("INSERTKEY", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
147 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
148 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
149 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
150
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
151 Inkscape.prototype.extendScene=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
152 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
153 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
154 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
155 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
156 SOAPClient.SendRequest(sr, function (resp,arg) {arg.extendScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
157 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
158 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
159
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
160
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
161 Inkscape.prototype.extendScene1 = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
162 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
163 var soapBody = new SOAPObject("EXTENDSCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
164 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
165 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
166 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
167 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
168 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
169 v2.val(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
170 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
171 var sr = new SOAPRequest("EXTENDSCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
172 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
173 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
174 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
175
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
176
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
177 Inkscape.prototype.deleteScene=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
178 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
179 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
180 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
181 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
182 SOAPClient.SendRequest(sr, function (resp,arg) {arg.deleteScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
183 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
184 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
185
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
186 Inkscape.prototype.deleteScene1=function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
187 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
188 var soapBody = new SOAPObject("DELETESCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
189 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
190 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
191 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
192 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
193 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
194 v2.val(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
195 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
196 var sr = new SOAPRequest("EXTENDSCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
197 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
198 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
199 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
200
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
201 Inkscape.prototype.fetchDocument = function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
202 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
203 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
204 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
205 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
206 SOAPClient.SendRequest(sr,function(resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
207 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
208 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
209
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
210
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
211
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
212 function MBSVG(file)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
213 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
214 var xmlDoc=document.implementation.createDocument("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","",null);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
215 xmlDoc.async=false;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
216 xmlDoc.load(file);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
217 MBSVG_loadFromDoc(this,xmlDoc);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
218
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
219 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
220 function MBSVGString(xml)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
221 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
222 var xmlParser = new DOMParser();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
223 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
224 MBSVG_loadFromDoc(this,xmlDoc);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
225 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
226
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
227
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
228
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
229 function MBSVG_loadFromDoc(self,xmlDoc)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
230 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
231 var scenesNode = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scene");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
232 if (scenesNode == null) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
233 alert('This is not a valid scene file');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
234 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
235 var len = scenesNode.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
236 var i,j;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
237 var max = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
238 var scenes = new Array();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
239
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
240 // Get the length of scenes
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
241 for(i=0;i<len;i++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
242 var s = scenesNode[i];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
243 var start = s.getAttribute("start");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
244 var end = s.getAttribute("end");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
245 var ref = s.getAttribute("ref");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
246 var ss = new Object();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
247
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
248 if (end == null) end = start
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
249 if (max <end) max = end;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
250 ss.node = s;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
251 ss.start = start;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
252 ss.end = end;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
253 ss.ref = ref;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
254 ss.layer = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
255 scenes.push(ss);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
256 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
257 if (max < 20) max = 20;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
258 // Collect all layers
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
259 var nodes = xmlDoc.getElementsByTagNameNS("http://www.w3.org/2000/svg","svg")[0].childNodes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
260 var layers = new Array();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
261 len = nodes.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
262 for(i=0;i<len;i++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
263 if (nodes[i].localName == 'g') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
264 var subnodes = nodes[i].childNodes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
265 for(j=0;j<subnodes.length;j++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
266 if (subnodes[j].localName == 'g') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
267 for(var k=0;k<scenes.length;k++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
268 if (scenes[k].ref == subnodes[j].getAttribute('id')) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
269 scenes[k].layer = nodes[i].getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
270 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
271 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
272 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
273 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
274 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
275 layers.push(nodes[i]);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
276 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
277 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
278 self.layers = layers;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
279 self.scenes = scenes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
280 self.maxframe = max;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
281 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
282
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
283 MBSVGString.prototype=MBSVG.prototype;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
284 MBSVG.prototype.renderUI=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
285 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
286 var layers = this.layers;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
287 var scenes = this.scenes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
288 var max = this.maxframe;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
289 var cmd = "<table border=1>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
290 cmd = cmd + "<tr><td></td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
291 for(var j=1;j<=max;j++)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
292 cmd = cmd + "<td>"+j+"</td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
293
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
294 for(var i=layers.length-1;i>=0;i--) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
295 var l = layers[i];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
296 var id = l.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
297 var label = l.getAttribute('inkscape:label');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
298 cmd = cmd + "<tr><td>"+label+"</td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
299 for(j=0;j<max;j++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
300 var empty = 1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
301 var n = j +1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
302 var id_str = id+"#"+n
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
303 for(var k=0;k<scenes.length;k++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
304 if (id != scenes[k].layer) continue;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
305 if (n == scenes[k].start) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
306 cmd = cmd + "<td><img class='normal' src=start.png id='"+id_str+"' onClick='selectCell(this)' /></td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
307 empty = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
308 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
309 } else if ((n>scenes[k].start)&&(n <= scenes[k].end)) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
310 cmd = cmd + "<td><img class='normal' src=fill.png id='"+id_str+"' onClick='selectCell(this)' /></td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
311 empty = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
312 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
313 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
314 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
315 if (empty) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
316 cmd = cmd + "<td><img class='normal' src=empty.png id='"+id_str+"'onClick='selectCell(this)' /></td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
317 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
318
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
319 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
320 cmd = cmd + "</tr>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
321 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
322 cmd = cmd + "</table>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
323 var frame = document.getElementById('frame');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
324 frame.innerHTML=cmd;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
325 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
326
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
327
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
328
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
329 /**
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
330 * UI for madbuilder.html to build the scene editor
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
331 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
332
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
333 function selectCell(obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
334 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
335 var id = obj.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
336 var layer,n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
337 var f = id.split('#');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
338 layer=f[0];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
339 n = f[1];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
340 var img = obj.getAttribute('src');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
341 var f = img.split('-');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
342
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
343 if (f[0] == 'active')
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
344 return;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
345 else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
346 obj.setAttribute('src', 'active-'+img);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
347 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
348
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
349 if (last_select != null) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
350 f = last_select.getAttribute('src').split('-');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
351 last_select.setAttribute('src', f[1]);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
352 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
353 last_select = obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
354 currentScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
355 currentLayer = layer;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
356 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
357
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
358
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
359 function onButtonClick(obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
360 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
361 if (inkscape.isInProgress != 0) return;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
362 var id = obj.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
363 if (id == 'Jump') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
364 if (currentScene != 0)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
365 inkscape.gotoScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
366 } else if (id == 'InsertKey') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
367 inkscape.insertKey(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
368 } else if (id == 'ExtendScene') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
369 inkscape.extendScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
370 } else if (id == 'DeleteScene') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
371 inkscape.deleteScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
372 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
373 alert(id+' has not been implemented yet');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
374 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
375 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
376
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
377 function gotoScene_cb(resObj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
378 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
379
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
380 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
381 var nextScene;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
382 var currentScene = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
383 var currentLayer = '';
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
384
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
385 var last_select = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
386 inkscape = new Inkscape("scene.mbsvg");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
387
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
388 $('a.button').mouseover(function () {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
389 if (inkscape.isInProgress==0)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
390 this.style.MozOpacity = 0.1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
391 }).mouseout(function () {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
392 this.style.MozOpacity= 1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
393 });
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
394