annotate inkscape/firefox/content/inkscape.js @ 1535:9aff42a7e2b9 tip

Fix issue of add/remove a frame at a scene before all key frames of a layer. When you added or removed a frame at a scene before all key frames of a layer, frameline was not updated correctly. It seems nothing happened, but domview is updated. This changeset fix this issue by correcting logic for boundary case.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 30 Sep 2011 22:07:28 +0800
parents ebf83a50e1e1
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
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
6
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
7 function endsWith(str, s){
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
8 var reg = new RegExp (s + "$");
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
9 return reg.test(str);
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
10 }
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
11
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
12 function dumpXML(xml)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
13 {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
14 return (new XMLSerializer()).serializeToString(xml);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
15 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
16
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
17
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
18 function showInWindow(content)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
19 {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
20 $('#debug').append("<pre>"+content+"</pre>");
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
21 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
22
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
23 function dumpObj(obj, name, indent, depth) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
24 if (depth > MAX_DUMP_DEPTH) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
25 return indent + name + ": <Maximum Depth Reached>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
26 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
27 if (typeof obj == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
28 var child = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
29 var output = indent + name + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
30 indent += "\t";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
31 for (var item in 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 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
34 child = obj[item];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
35 } catch (e) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
36 child = "<Unable to Evaluate>";
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 child == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
39 output += dumpObj(child, item, indent, depth + 1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
40 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
41 output += indent + item + ": " + child + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
42 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
43 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
44 return output;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
45 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
46 return obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
47 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
48 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
49 function dumpObjItem(obj, name, indent, depth) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
50 if (depth > MAX_DUMP_DEPTH) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
51 return indent + name + ": <Maximum Depth Reached>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
52 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
53 if (typeof obj == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
54 var child = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
55 var output = indent + name + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
56 indent += "\t";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
57 for (var item in 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 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
60 child = obj[item];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
61 } catch (e) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
62 child = "<Unable to Evaluate>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
63 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
64 if (typeof child == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
65 output += dumpObjItem(child, item, indent, depth + 1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
66 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
67 output += indent + item + ":\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
68 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
69 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
70 return output;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
71 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
72 return obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
73 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
74 }
361
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
75
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
76 /**
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
77 * TextEditor class
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
78 *
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
79 */
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
80
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
81 function TextEditor(file)
361
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
82 {
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
83 var editor = document.getElementById('inkscape');
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
84 editor.innerHTML = "<embed src="+file+" width=900 height=700 />";
361
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
85 this.isInProgress = 0;
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
86 }
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
87
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
88 /**
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
89 * Inkscape class
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
90 *
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
91 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
92 function Inkscape(file)
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 ink = document.getElementById('inkscape');
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
95 ink.innerHTML = "<embed src="+file+" width=900 height=700 />";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
96 this.isInProgress = 0;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
97 this.callback = null;
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
98 this.animation = new MadSwatter(this);
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
99
392
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
100 setTimeout("inkscape.fetchDocument()",3000);
288
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 Inkscape.prototype.gotoScene = function (n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
104 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
105 nextScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
106 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
107 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
108 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
109 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
110 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
111 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
112 Inkscape.prototype.gotoScene1 = function (resp,n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
113 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
114 var soapBody = new SOAPObject("SCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
115 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
116 v1.val(nextScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
117 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
118 var sr = new SOAPRequest("SCENE", 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.gotoScene2(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 Inkscape.prototype.gotoScene2 = function (resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
123 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
124 var soapBody = new SOAPObject("PUBLISH");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
125 var sr = new SOAPRequest("PUBLISH", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
126 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
127 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene3(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
128 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
129
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
130 Inkscape.prototype.gotoScene3 = function (resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
131 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
132 this.isInProgress--;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
133 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
134 Inkscape.prototype.publishDocument= function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
135 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
136 mbsvg = new MBSVGString(resp.Body[0].GETDOCResponse[0].Result[0].Text);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
137 mbsvg.renderUI();
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
138 this.mbsvg = mbsvg;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
139 if (this.callback)
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
140 this.callback(mbsvg);
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
141
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
142 var soapBody = new SOAPObject("PUBLISH");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
143 var sr = new SOAPRequest("PUBLISH", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
144 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
145 SOAPClient.SendRequest(sr, function(resp,arg) {arg.operationDone(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
146 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
147
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
148 Inkscape.prototype.refreshDocument = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
149 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
150 var soapBody = new SOAPObject("GETDOC");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
151 var sr = new SOAPRequest("GETDOC", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
152 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
153 SOAPClient.SendRequest(sr, function(resp,arg) { arg.publishDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
154 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
155
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
156 Inkscape.prototype.operationDone = function (res)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
157 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
158 this.isInProgress--;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
159 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
160 Inkscape.prototype.insertKey= function(n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
161 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
162 nextScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
163 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
164 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
165 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
166 SOAPClient.SendRequest(sr, function (resp,arg) {arg.insertKey1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
167 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
168 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
169 Inkscape.prototype.insertKey1 = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
170 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
171 var soapBody = new SOAPObject("INSERTKEY");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
172 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
173 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
174 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
175 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
176 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
177 v2.val(nextScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
178 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
179 var sr = new SOAPRequest("INSERTKEY", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
180 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
181 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
182 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
183
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
184 Inkscape.prototype.extendScene=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
185 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
186 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
187 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
188 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
189 SOAPClient.SendRequest(sr, function (resp,arg) {arg.extendScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
190 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
191 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
192
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
193
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
194 Inkscape.prototype.extendScene1 = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
195 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
196 var soapBody = new SOAPObject("EXTENDSCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
197 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
198 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
199 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
200 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
201 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
202 v2.val(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
203 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
204 var sr = new SOAPRequest("EXTENDSCENE", 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 }
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 Inkscape.prototype.deleteScene=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
211 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
212 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
213 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
214 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
215 SOAPClient.SendRequest(sr, function (resp,arg) {arg.deleteScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
216 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
217 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
218
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
219 Inkscape.prototype.deleteScene1=function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
220 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
221 var soapBody = new SOAPObject("DELETESCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
222 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
223 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
224 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
225 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
226 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
227 v2.val(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
228 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
229 var sr = new SOAPRequest("EXTENDSCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
230 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
231 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
232 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
233
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
234 Inkscape.prototype.fetchDocument = function(callback)
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
235 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
236 var soapBody = new SOAPObject("START");
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
237 this.callback = callback
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
238 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
239 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
240 SOAPClient.SendRequest(sr,function(resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
241 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
242 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
243
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
244 Inkscape.prototype.changeSymbolName_cb = function(callback)
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
245 {
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
246 var soapBody = new SOAPObject("CHANGESYMBOL");
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
247 var v1 = new SOAPObject("v1");
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
248 v1.attr('type','string');
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
249 v1.val(this.v1);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
250 soapBody.appendChild(v1);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
251 var v2 = new SOAPObject("v2");
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
252 v2.val(this.v2);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
253 soapBody.appendChild(v2);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
254 var sr = new SOAPRequest("CHANGESYMBOL", soapBody);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
255 SOAPClient.Proxy = "http://localhost:19192/";
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
256 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
257 this.inProgress--;
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
258 }
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
259
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
260 Inkscape.prototype.changeSymbolName = function(id,newname,callback)
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
261 {
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
262 var soapBody = new SOAPObject("START");
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
263 this.callback = callback
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
264 var sr = new SOAPRequest("START", soapBody);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
265 SOAPClient.Proxy = "http://localhost:19192/";
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
266 this.v1 = id;
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
267 this.v2 = newname;
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
268 SOAPClient.SendRequest(sr,function(resp,arg) {arg.changeSymbolName_cb(resp);},this);
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
269 this.isInProgress++;
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
270 }
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
271
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
272 /*
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
273 * This module is used to define a symbol for the MadButterfly. This function will search for symbol which is defined in the current select object. We will list all SVG elements
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
274 * in the left side, multiple variables can be defined at one time. When any element is selected, the defined symbol will be listed in the right side.
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
275 *
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
276 */
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
277
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
278 Inkscape.prototype.MakeSymbol=function()
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
279 {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
280 function callback(mbsvg) {
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
281 inkscape.loadSymbolScreen(mbsvg);
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
282 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
283 inkscape.fetchDocument(callback);
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
284 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
285
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
286
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
287 Inkscape.prototype.onChangeSymbolName=function()
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
288 {
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
289 inkscape.changeSymbolName(inkscape.current_symbol, $('#newsymbolname').val());
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
290 symboldialog.dialog('close')
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
291 }
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
292
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
293 Inkscape.prototype.refreshSymbolPanel=function(node)
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
294 {
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
295 var reg = new RegExp('(.*)\\((.*)\\)');
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
296 var m = reg.exec(node.textContent);
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
297 var val = m[2];
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
298 inkscape.current_symbol = node.textContent;
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
299 $('#newsymbolname').val(val);
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
300 }
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
301
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
302 Inkscape.prototype.editAnimation=function () {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
303 inkscape.fetchDocument(inkscape.editAnimationCallback);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
304 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
305
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
306 Inkscape.prototype.editAnimationCallback=function(mbsvg) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
307
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
308 inkscape.animation.edit(mbsvg);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
309 return;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
310
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
311
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
312 var sodi = mbsvg.getElementsByTag('sodipodi:namedview')[0];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
313
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
314 var layer=sodi.getAttribute('inkscape:current-layer');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
315 var animation = mbsvg.getElementsByTag('animationlist')[0];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
316 var alist = animation.getElementsByTag('animation');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
317 var len = alist.length;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
318 var dialog = $('animation');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
319 dialog.dialog('open');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
320 var html = new Array();
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
321 html.append('<ul>');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
322 for(i=0;i<alist.len;i++) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
323 html.append('<li><a href="#" onClick="">'+alist[i].getAttribute('name')+"</a></li>");
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
324 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
325 html.append('</ul>');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
326 $('animation_list').html(html.join("\n"));
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
327 dialog.show();
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
328 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
329
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
330
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
331 Inkscape.prototype.loadSymbolScreen=function (mbsvg) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
332 // Swap the left side to be the SVG element tree.
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
333 var i,l;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
334
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
335 symboldialog.dialog('open');
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
336 this.mbsvg = mbsvg;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
337 l = mbsvg.selected_objects.length;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
338 var jsonobj = []
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
339 for(i=0;i<l;i++) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
340 // Add symbol into the tree
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
341 var name = mbsvg.findSymbolName(mbsvg.selected_objects[i]);
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
342 var title=mbsvg.selected_objects[i]+"("+name+")";
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
343 var obj = { attributes: {id: 'sym'+i}, data : title};
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
344 if (i == 0) {
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
345 this.current_symbol = mbsvg.selected_objects[i];
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
346 $('#newsymbolname').val(name);
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
347 }
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
348 jsonobj.push(obj);
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
349 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
350 this.symboltree = $.tree_create();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
351 this.symboltree.init($("#symbollist"), {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
352 data: {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
353 type: "json",
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
354 json : jsonobj
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
355 },
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
356 callback : {
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
357 ondblclk : function(NODE,TREE_OBJ) { inkscape.refreshSymbolPanel(NODE);}
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
358 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
359
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
360 });
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
361 var s = $('#changename');
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
362 s.click(this.onChangeSymbolName);
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
363 // Swap the right side to be the symbol editor screen.
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
364 symboldialog.show();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
365 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
366
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
367 jQuery(document).ready(function() {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
368 symboldialog = jQuery('#symboldialog');
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
369 symboldialog.dialog({width:500,
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
370 modal: true,
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
371 autoOpen:false,
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
372 title:'Please select a file'});
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
373 symboldialog.hide();
381
29145d2affdb Add function to change the name of the symbol
wycc
parents: 376
diff changeset
374 symboldialog.append("<div id='symbollist'/>");
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
375 symboldialog.append("<div id='symbol'><input type='text' id='newsymbolname'> <input type='submit' value='change' id='changename'></div> ");
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
376 });
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
377
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
378 function MBSVG(file)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
379 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
380 var xmlDoc=document.implementation.createDocument("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","",null);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
381 xmlDoc.async=false;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
382 xmlDoc.load(file);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
383 MBSVG_loadFromDoc(this,xmlDoc);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
384
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
385 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
386 function MBSVGString(xml)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
387 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
388 var xmlParser = new DOMParser();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
389 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
390 MBSVG_loadFromDoc(this,xmlDoc);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
391 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
392
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
393
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
394
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
395 function MBSVG_loadFromDoc(self,xmlDoc)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
396 {
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
397 var top = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scenes")[0];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
398 self.current = top.getAttribute("current");
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
399 var scenesNode = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scene");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
400 if (scenesNode == null) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
401 alert('This is not a valid scene file');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
402 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
403 var len = scenesNode.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
404 var i,j;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
405 var max = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
406 var scenes = new Array();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
407
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
408 // Get the length of scenes
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
409 for(i=0;i<len;i++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
410 var s = scenesNode[i];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
411 var start = s.getAttribute("start");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
412 var end = s.getAttribute("end");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
413 var ref = s.getAttribute("ref");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
414 var ss = new Object();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
415
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
416 if (end == null) end = start
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
417 if (max <end) max = end;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
418 ss.node = s;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
419 ss.start = start;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
420 ss.end = end;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
421 ss.ref = ref;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
422 ss.layer = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
423 scenes.push(ss);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
424 }
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
425 if (max < 20) max = 30;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
426 // Collect all layers
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
427 var nodes = xmlDoc.getElementsByTagNameNS("http://www.w3.org/2000/svg","svg")[0].childNodes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
428 var layers = new Array();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
429 len = nodes.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
430 for(i=0;i<len;i++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
431 if (nodes[i].localName == 'g') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
432 var subnodes = nodes[i].childNodes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
433 for(j=0;j<subnodes.length;j++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
434 if (subnodes[j].localName == 'g') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
435 for(var k=0;k<scenes.length;k++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
436 if (scenes[k].ref == subnodes[j].getAttribute('id')) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
437 scenes[k].layer = nodes[i].getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
438 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
439 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
440 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
441 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
442 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
443 layers.push(nodes[i]);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
444 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
445 }
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
446 var select = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","select");
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
447 len = select.length;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
448 selectobjs = [];
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
449 for(i=0;i<len;i++) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
450 selectobjs.push(select[i].getAttribute('ref'));
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
451 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
452 self.selected_objects = selectobjs;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
453 self.layers = layers;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
454 self.scenes = scenes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
455 self.maxframe = max;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
456 self.doc = xmlDoc;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
457 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
458
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
459 MBSVGString.prototype=MBSVG.prototype;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
460 MBSVG.prototype.renderUI=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
461 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
462 var layers = this.layers;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
463 var scenes = this.scenes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
464 var max = this.maxframe;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
465 var cmd = "<table border=0>\n";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
466 cmd = cmd + "<tr><td></td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
467 for(var j=1;j<=max;j++)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
468 cmd = cmd + "<td>"+j+"</td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
469
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
470 for(var i=layers.length-1;i>=0;i--) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
471 var l = layers[i];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
472 var id = l.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
473 var label = l.getAttribute('inkscape:label');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
474 cmd = cmd + "<tr><td>"+label+"</td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
475 for(j=0;j<max;j++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
476 var empty = 1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
477 var n = j +1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
478 var id_str = id+"#"+n
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
479 for(var k=0;k<scenes.length;k++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
480 if (id != scenes[k].layer) continue;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
481 if (n == scenes[k].start) {
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
482 cmd = cmd + "<td><img class='normal' width='16' src=start.png id='"+id_str+"' onClick='selectCell(this)' /></td>";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
483 empty = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
484 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
485 } else if ((n>scenes[k].start)&&(n <= scenes[k].end)) {
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
486 cmd = cmd + "<td><img class='normal' width='16' src=fill.png id='"+id_str+"' onClick='selectCell(this)' /></td>";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
487 empty = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
488 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
489 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
490 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
491 if (empty) {
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
492 cmd = cmd + "<td><img class='normal' width='16' src=empty.png id='"+id_str+"'onClick='selectCell(this)' /></td>";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
493 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
494
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
495 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
496 cmd = cmd + "</tr>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
497 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
498 cmd = cmd + "</table>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
499 var frame = document.getElementById('frame');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
500 frame.innerHTML=cmd;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
501 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
502
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
503
384
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
504 MBSVG.prototype.findSymbolName=function(id)
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
505 {
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
506 var obj = this.doc.getElementById(id);
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
507 var name = obj.getAttribute('mbname');
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
508 return name;
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
509
7cbb364fd273 Show the old name in the input line
wycc
parents: 381
diff changeset
510 }
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
511
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
512
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
513 /**
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
514 * Return a new XML document that all objects which is not in the current scene are deleted.
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
515 *
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
516 * This function will traverse all scenes. For each scene which is not in the current scene, we will delete the reference group.
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
517 */
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
518
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
519 function deepcopy(obj)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
520 {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
521 var seenObjects = [];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
522 var mappingArray = [];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
523 var f = function(simpleObject) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
524 var indexOf = seenObjects.indexOf(simpleObject);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
525 if (indexOf == -1) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
526 switch (Ext.type(simpleObject)) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
527 case 'object':
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
528 seenObjects.push(simpleObject);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
529 var newObject = {};
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
530 mappingArray.push(newObject);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
531 for (var p in simpleObject)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
532 newObject[p] = f(simpleObject[p]);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
533 newObject.constructor = simpleObject.constructor;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
534 return newObject;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
535
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
536 case 'array':
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
537 seenObjects.push(simpleObject);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
538 var newArray = [];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
539 mappingArray.push(newArray);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
540 for(var i=0,len=simpleObject.length; i<len; i++)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
541 newArray.push(f(simpleObject[i]));
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
542 return newArray;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
543
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
544 default:
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
545 return simpleObject;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
546 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
547 } else {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
548 return mappingArray[indexOf];
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
549 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
550 };
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
551 return f(obj);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
552 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
553
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
554 MBSVG.prototype.generateCurrentSVG=function()
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
555 {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
556 var i;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
557 var scenes = this.scenes;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
558 var len = scenes.length;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
559 var newcopy = $(this.doc).clone();
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
560
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
561 for(i=0;i<len;i++) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
562 if (scenes[i].start > this.current || scenes[i].end < this.current) {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
563 var obj = newcopy.find('#'+scenes[i].ref);
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
564 obj.remove();
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
565 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
566 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
567 return newcopy;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
568 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
569
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
570
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
571 /**
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
572 * UI for madbuilder.html to build the scene editor
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
573 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
574
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
575 function selectCell(obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
576 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
577 var id = obj.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
578 var layer,n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
579 var f = id.split('#');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
580 layer=f[0];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
581 n = f[1];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
582 var img = obj.getAttribute('src');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
583 var f = img.split('-');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
584
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
585 if (f[0] == 'active')
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
586 return;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
587 else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
588 obj.setAttribute('src', 'active-'+img);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
589 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
590
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
591 if (last_select != null) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
592 f = last_select.getAttribute('src').split('-');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
593 last_select.setAttribute('src', f[1]);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
594 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
595 last_select = obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
596 currentScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
597 currentLayer = layer;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
598 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
599
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
600
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
601 function onButtonClick(obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
602 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
603 var id = obj.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
604 if (id == 'Jump') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
605 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
606 if (currentScene != 0)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
607 inkscape.gotoScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
608 } else if (id == 'InsertKey') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
609 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
610 inkscape.insertKey(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
611 } else if (id == 'ExtendScene') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
612 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
613 inkscape.extendScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
614 } else if (id == 'DeleteScene') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
615 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
616 inkscape.deleteScene(currentScene);
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
617 } else if (id == 'MakeSymbol') {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
618 if (inkscape.isInProgress != 0) return;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
619 inkscape.MakeSymbol();
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
620 } else if (id == 'Save') {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
621 project_save();
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
622 } else if (id == 'Test') {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
623 if (project_compile()) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
624 project_run();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
625 } else {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
626 }
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
627 } else if (id == 'Open') {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
628 filedialog = jQuery('#filedialog');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
629 filedialog.dialog({width:500,
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
630 modal: true,
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
631 autoOpen:false,
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
632 title:'Please select a file'});
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
633 filedialog.show();
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
634 filedialog.html('Please select the project file<br>');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
635 filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
636 filedialog.append('<input type=button value="Load" onclick="project_loadFile()">');
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
637 filedialog.dialog("open");
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
638 } else if (id == 'EditAnimation') {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
639 inkscape.editAnimation();
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
640 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
641 alert(id+' has not been implemented yet');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
642 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
643 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
644
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
645 function gotoScene_cb(resObj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
646 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
647
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
648 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
649 var nextScene;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
650 var currentScene = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
651 var currentLayer = '';
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
652
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
653
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
654 function dump(n)
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
655 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
656 cmd = "";
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
657 for(k in n) {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
658 cmd = cmd + k+"="+n[k]+"\n";
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
659 }
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
660 alert(cmd);
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
661 }
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
662
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
663
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
664
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
665
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
666
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
667
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
668 function loadInkscapeFile()
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
669 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
670 ele = $('#mbsvg');
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
671 file = ele.attr('value');
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
672 inkscape = new Inkscape("file://"+file);
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
673
352
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
674 file1_animation = [
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
675 {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
676 attributes: {id:"an1-1"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
677 data: "animation1"
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
678 },
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
679 {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
680 attributes: {id:"an1-2"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
681 data: "animation2"
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
682 }
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
683 ];
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
684 file1 = {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
685 attributes:{id:"file1"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
686 data: "scene1.mbsvg",
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
687 children: file1_animation
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
688 };
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
689 file2 = {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
690 attributes:{id:"file2"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
691 data: "scene2.mbsvg",
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
692 };
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
693 file3 = {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
694 attributes:{id:"file3"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
695 data: "scene3.mbsvg",
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
696 };
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
697
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
698 scenes = [ file1,file2,file3];
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
699 src1 = {attributes:{id:"src1"},data:"src1.c"};
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
700 src2 = {attributes:{id:"src1"},data:"src2.c"};
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
701 src3 = {attributes:{id:"src1"},data:"src3.c"};
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
702
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
703 sources = [src1,src2,src3];
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
704
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
705 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
706
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
707 function project_compile()
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
708 {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
709 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
710
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
711
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
712 function project_showFile(node)
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
713 {
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
714 var file = node.textContent;
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
715 if (endsWith(file,"mbsvg")) {
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
716 project_loadScene(node);
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
717 } else {
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
718 project_loadEditor(node);
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
719 }
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
720
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
721 }
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
722 function project_loadScene(node)
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
723 {
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
724 var file = node.textContent;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
725 if (file.substr(0,1) == '/')
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
726 inkscape = new Inkscape("file://"+file);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
727 else
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
728 inkscape = new Inkscape("file://"+project_dir+'/'+file);
361
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
729 }
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
730
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
731
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
732 function project_loadEditor(node)
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
733 {
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
734 var file = node.textContent;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
735 if (file.substr(0,1) == '/')
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
736 editor = new TextEditor("file://"+file);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
737 else
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
738 editor = new TextEditor("file://"+project_dir+'/'+file);
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
739 }
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
740
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
741 function project_parse(xml)
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
742 {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
743
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
744 var xmlParser = new DOMParser();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
745 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml');
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
746 var scenesNode = xmlDoc.getElementsByTagName("scene");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
747 if (scenesNode == null) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
748 alert('This is not a valid scene file');
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
749 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
750 var len = scenesNode.length;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
751 var i,j;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
752 var max = 0;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
753 var scenes = new Array();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
754
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
755 // Get the length of scenes
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
756 for(i=0;i<len;i++) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
757 var n = scenesNode[i];
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
758 var s = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
759 s.attributes = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
760 s.attributes.id = "scene"+i;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
761 s.state = "open";
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
762 s.data = n.getAttribute("src");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
763 scenes.push(s);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
764 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
765
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
766 var nodes = xmlDoc.getElementsByTagName("source");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
767 var len = nodes.length;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
768 var i,j;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
769 var max = 0;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
770 var sources = [];
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
771
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
772 // Get the length of scenes
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
773 for(i=0;i<len;i++) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
774 var n = nodes[i];
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
775 var s = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
776 s.attributes = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
777 s.attributes.id = "sources"+i;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
778 s.state = "open";
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
779 s.data = n.getAttribute("src");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
780 sources.push(s);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
781 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
782
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
783 var tree = $.tree_create();
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
784 project_tree = tree;
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
785 tree.init($("#filelist"), {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
786 data: {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
787 type: "json",
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
788 json : [
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
789 {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
790 attributes: {id: "prj"},
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
791 state: "open",
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
792 data: "Project",
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
793 children: [
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
794 { attributes:{id:"scenes"}, data:"scene", children: scenes},
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
795 { attributes:{id:"sources"},data:"sources",children: sources}
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
796 ]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
797 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
798 ],
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
799 },
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
800 callback : {
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
801 ondblclk : function(NODE,TREE_OBJ) { project_showFile(NODE); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);}
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
802 },
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
803 ui : {
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
804 context : [
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
805 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
806 id: "Open",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
807 label: "Open",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
808 icon: "open.png",
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
809 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return true;},
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
810 action: function(NODE,TREE_OBJ) { onTree_openFile(NODE,TREE_OBJ);}
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
811 },
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
812 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
813 id: "New",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
814 label: "New",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
815 icon: "create.png",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
816 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return NODE[0].id == "prj";},
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
817 action: function(NODE,TREE_OBJ) { alert("open is not support yet");}
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
818 },
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
819 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
820 id: "Rename",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
821 label: "Rename",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
822 icon: "rename.png",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
823 visible: function(NODE,TREE_OBJ) { if(NODE.length != 1) return false; return NODE[0].id == "prj";},
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
824 action: function(NODE,TREE_OBJ) { alert("open is not support yet");}
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
825 }
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
826 ]
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
827 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
828
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
829 });
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
830 }
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
831
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
832 function fileDialog_cb()
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
833 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
834 var file = $('#filedialogsrc').attr('value');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
835 filedialog.dialog('close');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
836 filedialog_cb(file,filedialog_arg);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
837 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
838
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
839 function openFileDialog(callback,arg)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
840 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
841 filedialog_cb = callback;
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
842 filedialog_arg = arg;
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
843 filedialog.html('Please select the scene file<br>');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
844 filedialog.append('<input type=file value="Select the scene file" id="filedialogsrc">');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
845 filedialog.append('<input type=button value="Load" onclick="fileDialog_cb()">');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
846 filedialog.show();
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
847 filedialog.dialog('open');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
848 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
849
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
850
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
851 function project_addScene(file,treeobj)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
852 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
853 if (file == '') {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
854 return;
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
855 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
856 treeobj.create(false,treeobj.selected,file);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
857 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
858
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
859 function onTree_addSceneFile(node,treeobj)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
860 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
861 openFileDialog(project_addScene,treeobj);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
862 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
863
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
864 function project_addSource(file,treeobj)
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
865 {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
866 treeobj.create(false,treeobj.selected,file);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
867 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
868
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
869 function onTree_addSourceFile(node,treeobj)
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
870 {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
871 openFileDialog(project_addSource,treeobj);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
872 }
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
873
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
874 function onTree_openFile(node,treeobj)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
875 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
876 if (node[0].id == "scenes") {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
877 onTree_addSceneFile(node,treeobj);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
878 } else if (node[0].id == "sources") {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
879 onTree_addSourceFile(node,treeobj);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
880 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
881 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
882
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
883 function system_open_read(fname) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
884 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
885 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
886 } catch (e) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
887 alert("Permission to read file was denied.");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
888 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
889 var file = Components.classes["@mozilla.org/file/local;1"]
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
890 .createInstance(Components.interfaces.nsILocalFile);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
891 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
892 file.initWithPath( fname );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
893 if ( file.exists() == false ) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
894 alert("File does not exist");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
895 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
896 var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
897 .createInstance( Components.interfaces.nsIFileInputStream );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
898 is.init( file,0x01, 00004, null);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
899 var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
900 .createInstance( Components.interfaces.nsIScriptableInputStream );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
901 sis.init( is );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
902 } catch(e) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
903 alert(fname+" does not exist");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
904 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
905 return sis;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
906 }
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
907
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
908 function system_read(fname) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
909 try {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
910 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
911 } catch (e) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
912 alert("Permission to read file was denied.");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
913 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
914 var file = Components.classes["@mozilla.org/file/local;1"]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
915 .createInstance(Components.interfaces.nsILocalFile);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
916 try {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
917 file.initWithPath( fname );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
918 if ( file.exists() == false ) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
919 alert("File does not exist");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
920 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
921 var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
922 .createInstance( Components.interfaces.nsIFileInputStream );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
923 is.init( file,0x01, 00004, null);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
924 var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
925 .createInstance( Components.interfaces.nsIScriptableInputStream );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
926 sis.init( is );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
927 var output = sis.read( sis.available() );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
928 sis.close();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
929 } catch(e) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
930 alert(fname+" does not exist");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
931 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
932 return output;
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
933 }
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
934 function system_open_write(fname) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
935 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
936 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
937 } catch (e) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
938 alert("Permission to read file was denied.");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
939 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
940 var file = Components.classes["@mozilla.org/file/local;1"]
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
941 .createInstance(Components.interfaces.nsILocalFile);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
942 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
943 file.initWithPath( fname );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
944 var fostream = Components.classes["@mozilla.org/network/file-output-stream;1"]
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
945 .createInstance( Components.interfaces.nsIFileOutputStream );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
946 fostream.init( file,0x02|0x8|0x20, 0666,0);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
947 } catch(e) {
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
948 alert('can not create '+fname);
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
949 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
950 return fostream;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
951 }
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
952 function system_write(fname,xml) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
953 try {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
954 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
955 } catch (e) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
956 alert("Permission to read file was denied.");
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
957 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
958 var file = Components.classes["@mozilla.org/file/local;1"]
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
959 .createInstance(Components.interfaces.nsILocalFile);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
960 try {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
961 file.initWithPath( fname );
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
962 var fostream = Components.classes["@mozilla.org/network/file-output-stream;1"]
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
963 .createInstance( Components.interfaces.nsIFileOutputStream );
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
964 fostream.init( file,0x02|0x8|0x20, 0666,0);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
965 fostream.write( xml,xml.length );
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
966 fostream.close();
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
967 } catch(e) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
968 alert(fname+" does not exist");
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
969 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
970 }
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
971
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
972 function system_mkdir(path)
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
973 {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
974 try {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
975 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
976 } catch (e) {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
977 alert("Permission to read file was denied.");
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
978 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
979 var file = Components.classes["@mozilla.org/file/local;1"]
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
980 .createInstance(Components.interfaces.nsILocalFile);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
981 try {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
982 file.initWithPath(path);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
983 if( !file.exists() || !file.isDirectory() ) { // if it doesn't exist, create
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
984 file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
985 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
986 } catch(e) {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
987 alert('Failed to create directopry '+path+e);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
988 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
989 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
990
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
991 function getPathDirectory(path)
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
992 {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
993 var s = path.lastIndexOf('/');
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
994 if (s == -1)
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
995 return '';
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
996 else
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
997 return path.substr(0,s);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
998 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
999
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1000 function project_loadFile()
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1001 {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1002 prjname = $('#mbsvg').attr('value');
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1003 project_name = prjname;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
1004 project_dir = getPathDirectory(prjname);
388
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1005 var f = system_open_write("/tmp/madbuilder.ws");
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1006 var s = "last="+prjname;
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1007 f.write(s,s.length);
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1008 f.close();
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1009 var prj = system_read(prjname);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1010 project_parse(prj);
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
1011 filedialog.dialog('close');
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1012 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
1013
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1014
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1015 function project_save()
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1016 {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1017 var i;
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1018
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1019 var xml = "<project>\n";
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1020 var scenes = $('#scenes');
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1021 var sources = $('#sources');
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1022 var list = project_tree.getJSON(scenes);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1023 var len = list.children.length;
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1024
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1025 for(i=0;i<len;i++) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1026 xml = xml + "\t<scene src='"+list.children[i].data+"' />\n";
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1027 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1028 list = project_tree.getJSON(sources);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1029 len = list.children.length;
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1030 for(i=0;i<len;i++) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1031 xml = xml + "\t<source src='"+list.children[i].data+"' />\n";
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1032 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1033 xml = xml + "</project>\n";
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1034 system_write(project_name,xml);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1035
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1036 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
1037
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1038
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1039 function onLoadProject(path)
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1040 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1041 project_name = path;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
1042 project_dir = getPathDirectory(project_name);
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1043 var prj = system_read(project_name);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1044 project_parse(prj);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1045 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
1046
388
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1047 function loadOldProject()
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1048 {
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents: 388
diff changeset
1049 return -1;
388
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1050 var f = system_open_read("/tmp/madbuilder.ws");
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1051 if (f == null) return -1;
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1052 var s = f.read(f.available());
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1053 f.close();
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1054
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1055 var pos = s.indexOf("last=");
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1056 if (pos == -1) return -1;
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1057 var m = s.match("last=([^\s]*)");
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1058 if (m[1]) {
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1059 var prj = system_read(m[1]);
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1060 project_dir = getPathDirectory(m[1]);
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1061 project_parse(prj);
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1062 $('#filedialog').dialog("close");
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1063 }
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1064 return 0;
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1065
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1066 }
f3e6ac47752c Load the last opened project automatically.
wycc
parents: 384
diff changeset
1067