annotate inkscape/firefox/content/inkscape.js @ 377:06b40e01cac4

merge
author wycc
date Sat, 04 Apr 2009 06:12:42 +0800
parents 7d244a85dd68
children 29145d2affdb
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
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
12 function dumpObj(obj, name, indent, depth) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
13 if (depth > MAX_DUMP_DEPTH) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
14 return indent + name + ": <Maximum Depth Reached>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
15 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
16 if (typeof obj == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
17 var child = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
18 var output = indent + name + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
19 indent += "\t";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
20 for (var item in obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
21 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
22 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
23 child = obj[item];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
24 } catch (e) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
25 child = "<Unable to Evaluate>";
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 child == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
28 output += dumpObj(child, item, indent, depth + 1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
29 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
30 output += indent + item + ": " + child + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
31 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
32 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
33 return output;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
34 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
35 return obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
36 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
37 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
38 function dumpObjItem(obj, name, indent, depth) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
39 if (depth > MAX_DUMP_DEPTH) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
40 return indent + name + ": <Maximum Depth Reached>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
41 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
42 if (typeof obj == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
43 var child = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
44 var output = indent + name + "\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
45 indent += "\t";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
46 for (var item in 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 try {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
49 child = obj[item];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
50 } catch (e) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
51 child = "<Unable to Evaluate>";
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 child == "object") {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
54 output += dumpObjItem(child, item, indent, depth + 1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
55 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
56 output += indent + item + ":\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
57 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
58 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
59 return output;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
60 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
61 return obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
62 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
63 }
361
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
64
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
65 /**
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
66 * TextEditor class
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
67 *
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
68 */
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
69
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
70 function TextEditor(file)
361
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
71 {
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
72 var editor = document.getElementById('inkscape');
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
73 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
74 this.isInProgress = 0;
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
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
77 /**
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
78 * Inkscape class
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
79 *
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
80 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
81 function Inkscape(file)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
82 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
83 var ink = document.getElementById('inkscape');
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
84 ink.innerHTML = "<embed src="+file+" width=900 height=700 />";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
85 this.isInProgress = 0;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
86 this.callback = null;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
87
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
88 setTimeout("inkscape.fetchDocument()",4000);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
89 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
90
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
91 Inkscape.prototype.gotoScene = function (n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
92 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
93 nextScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
94 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
95 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
96 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
97 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
98 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
99 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
100 Inkscape.prototype.gotoScene1 = function (resp,n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
101 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
102 var soapBody = new SOAPObject("SCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
103 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
104 v1.val(nextScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
105 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
106 var sr = new SOAPRequest("SCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
107 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
108 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene2(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
109 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
110 Inkscape.prototype.gotoScene2 = function (resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
111 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
112 var soapBody = new SOAPObject("PUBLISH");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
113 var sr = new SOAPRequest("PUBLISH", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
114 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
115 SOAPClient.SendRequest(sr, function (resp,arg) {arg.gotoScene3(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
116 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
117
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
118 Inkscape.prototype.gotoScene3 = function (resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
119 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
120 this.isInProgress--;
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.publishDocument= 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 mbsvg = new MBSVGString(resp.Body[0].GETDOCResponse[0].Result[0].Text);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
125 mbsvg.renderUI();
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
126 if (this.callback)
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
127 this.callback(mbsvg);
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
128
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
129 var soapBody = new SOAPObject("PUBLISH");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
130 var sr = new SOAPRequest("PUBLISH", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
131 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
132 SOAPClient.SendRequest(sr, function(resp,arg) {arg.operationDone(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
133 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
134
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
135 Inkscape.prototype.refreshDocument = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
136 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
137 var soapBody = new SOAPObject("GETDOC");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
138 var sr = new SOAPRequest("GETDOC", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
139 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
140 SOAPClient.SendRequest(sr, function(resp,arg) { arg.publishDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
141 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
142
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
143 Inkscape.prototype.operationDone = function (res)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
144 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
145 this.isInProgress--;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
146 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
147 Inkscape.prototype.insertKey= function(n)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
148 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
149 nextScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
150 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
151 var sr = new SOAPRequest("START", 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.insertKey1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
154 this.isInProgress++;
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.insertKey1 = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
157 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
158 var soapBody = new SOAPObject("INSERTKEY");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
159 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
160 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
161 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
162 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
163 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
164 v2.val(nextScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
165 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
166 var sr = new SOAPRequest("INSERTKEY", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
167 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
168 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
169 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
170
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
171 Inkscape.prototype.extendScene=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
172 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
173 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
174 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
175 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
176 SOAPClient.SendRequest(sr, function (resp,arg) {arg.extendScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
177 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
178 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
179
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
180
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
181 Inkscape.prototype.extendScene1 = function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
182 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
183 var soapBody = new SOAPObject("EXTENDSCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
184 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
185 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
186 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
187 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
188 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
189 v2.val(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
190 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
191 var sr = new SOAPRequest("EXTENDSCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
192 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
193 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
194 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
195
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
196
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
197 Inkscape.prototype.deleteScene=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
198 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
199 var soapBody = new SOAPObject("START");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
200 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
201 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
202 SOAPClient.SendRequest(sr, function (resp,arg) {arg.deleteScene1(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
203 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
204 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
205
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
206 Inkscape.prototype.deleteScene1=function(resp)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
207 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
208 var soapBody = new SOAPObject("DELETESCENE");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
209 var v1 = new SOAPObject("v1");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
210 v1.attr('type','string');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
211 v1.val(currentLayer);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
212 soapBody.appendChild(v1);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
213 var v2 = new SOAPObject("v2");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
214 v2.val(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
215 soapBody.appendChild(v2);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
216 var sr = new SOAPRequest("EXTENDSCENE", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
217 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
218 SOAPClient.SendRequest(sr, function (resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
219 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
220
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
221 Inkscape.prototype.fetchDocument = function(callback)
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
222 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
223 var soapBody = new SOAPObject("START");
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
224 this.callback = callback
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
225 var sr = new SOAPRequest("START", soapBody);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
226 SOAPClient.Proxy = "http://localhost:19192/";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
227 SOAPClient.SendRequest(sr,function(resp,arg) {arg.refreshDocument(resp);},this);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
228 this.isInProgress++;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
229 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
230
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
231 /*
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
232 * 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
233 * 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
234 *
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
235 */
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
236
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
237 Inkscape.prototype.MakeSymbol=function()
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
238 {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
239 function callback(mbsvg) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
240 this.loadSymbolScreen(mbsvg);
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
241 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
242 inkscape.fetchDocument(callback);
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
243 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
244
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
245 Inkscape.prototype.loadSymbolScreen=function (mbsvg) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
246 // 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
247 var i,l;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
248
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
249 symboldialog.dialog('open');
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
250 l = mbsvg.selected_objects.length;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
251 var jsonobj = []
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
252 for(i=0;i<l;i++) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
253 // Add symbol into the tree
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
254 var obj = { attributes: {id: 'sym'+i}, data : mbsvg.selected_objects[i]};
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
255 jsonobj.push(obj);
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
256 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
257 this.symboltree = $.tree_create();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
258 this.symboltree.init($("#symbollist"), {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
259 data: {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
260 type: "json",
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
261 json : jsonobj
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
262 },
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
263 callback : {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
264 ondblclk : function(NODE,TREE_OBJ) { this.refreshSymbolPanel(TREE_OBJ); TREE_OBJ.toggle_branch.call(TREE_OBJ, NODE); TREE_OBJ.select_branch.call(TREE_OBJ, NODE);}
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
265 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
266
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
267 });
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
268 // 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
269 symboldialog.show();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
270 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
271
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
272 jQuery(document).ready(function() {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
273 symboldialog = jQuery('#symboldialog');
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
274 symboldialog.dialog({width:500,
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
275 modal: true,
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
276 autoOpen:false,
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
277 title:'Please select a file'});
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
278 symboldialog.hide();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
279 symboldialog.append("<div id='symbollist'>");
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
280 symboldialog.append("<div id='symbol'>");
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
281 });
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
282
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
283 function MBSVG(file)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
284 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
285 var xmlDoc=document.implementation.createDocument("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","",null);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
286 xmlDoc.async=false;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
287 xmlDoc.load(file);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
288 MBSVG_loadFromDoc(this,xmlDoc);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
289
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
290 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
291 function MBSVGString(xml)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
292 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
293 var xmlParser = new DOMParser();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
294 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
295 MBSVG_loadFromDoc(this,xmlDoc);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
296 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
297
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
298
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
299
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
300 function MBSVG_loadFromDoc(self,xmlDoc)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
301 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
302 var scenesNode = xmlDoc.getElementsByTagNameNS("http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd","scene");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
303 if (scenesNode == null) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
304 alert('This is not a valid scene file');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
305 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
306 var len = scenesNode.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
307 var i,j;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
308 var max = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
309 var scenes = new Array();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
310
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
311 // Get the length of scenes
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
312 for(i=0;i<len;i++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
313 var s = scenesNode[i];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
314 var start = s.getAttribute("start");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
315 var end = s.getAttribute("end");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
316 var ref = s.getAttribute("ref");
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
317 var ss = new Object();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
318
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
319 if (end == null) end = start
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
320 if (max <end) max = end;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
321 ss.node = s;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
322 ss.start = start;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
323 ss.end = end;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
324 ss.ref = ref;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
325 ss.layer = null;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
326 scenes.push(ss);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
327 }
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
328 if (max < 20) max = 30;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
329 // Collect all layers
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
330 var nodes = xmlDoc.getElementsByTagNameNS("http://www.w3.org/2000/svg","svg")[0].childNodes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
331 var layers = new Array();
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
332 len = nodes.length;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
333 for(i=0;i<len;i++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
334 if (nodes[i].localName == 'g') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
335 var subnodes = nodes[i].childNodes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
336 for(j=0;j<subnodes.length;j++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
337 if (subnodes[j].localName == 'g') {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
338 for(var k=0;k<scenes.length;k++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
339 if (scenes[k].ref == subnodes[j].getAttribute('id')) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
340 scenes[k].layer = nodes[i].getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
341 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
342 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
343 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
344 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
345 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
346 layers.push(nodes[i]);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
347 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
348 }
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
349 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
350 len = select.length;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
351 selectobjs = [];
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
352 for(i=0;i<len;i++) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
353 selectobjs.push(select[i].getAttribute('ref'));
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
354 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
355 self.selected_objects = selectobjs;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
356 self.layers = layers;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
357 self.scenes = scenes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
358 self.maxframe = max;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
359 self.doc = xmlDoc;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
360 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
361
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
362 MBSVGString.prototype=MBSVG.prototype;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
363 MBSVG.prototype.renderUI=function()
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
364 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
365 var layers = this.layers;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
366 var scenes = this.scenes;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
367 var max = this.maxframe;
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
368 var cmd = "<table border=0>\n";
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
369 cmd = cmd + "<tr><td></td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
370 for(var j=1;j<=max;j++)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
371 cmd = cmd + "<td>"+j+"</td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
372
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
373 for(var i=layers.length-1;i>=0;i--) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
374 var l = layers[i];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
375 var id = l.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
376 var label = l.getAttribute('inkscape:label');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
377 cmd = cmd + "<tr><td>"+label+"</td>";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
378 for(j=0;j<max;j++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
379 var empty = 1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
380 var n = j +1;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
381 var id_str = id+"#"+n
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
382 for(var k=0;k<scenes.length;k++) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
383 if (id != scenes[k].layer) continue;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
384 if (n == scenes[k].start) {
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
385 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
386 empty = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
387 break;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
388 } 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
389 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
390 empty = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
391 break;
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 if (empty) {
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
395 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
396 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
397
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
398 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
399 cmd = cmd + "</tr>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
400 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
401 cmd = cmd + "</table>\n";
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
402 var frame = document.getElementById('frame');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
403 frame.innerHTML=cmd;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
404 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
405
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
406
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
407
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
408 /**
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
409 * UI for madbuilder.html to build the scene editor
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
410 */
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
411
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
412 function selectCell(obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
413 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
414 var id = obj.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
415 var layer,n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
416 var f = id.split('#');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
417 layer=f[0];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
418 n = f[1];
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
419 var img = obj.getAttribute('src');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
420 var f = img.split('-');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
421
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
422 if (f[0] == 'active')
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
423 return;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
424 else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
425 obj.setAttribute('src', 'active-'+img);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
426 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
427
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
428 if (last_select != null) {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
429 f = last_select.getAttribute('src').split('-');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
430 last_select.setAttribute('src', f[1]);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
431 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
432 last_select = obj;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
433 currentScene = n;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
434 currentLayer = layer;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
435 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
436
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
437
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
438 function onButtonClick(obj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
439 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
440 var id = obj.getAttribute('id');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
441 if (id == 'Jump') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
442 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
443 if (currentScene != 0)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
444 inkscape.gotoScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
445 } else if (id == 'InsertKey') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
446 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
447 inkscape.insertKey(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
448 } else if (id == 'ExtendScene') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
449 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
450 inkscape.extendScene(currentScene);
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
451 } else if (id == 'DeleteScene') {
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
452 if (inkscape.isInProgress != 0) return;
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
453 inkscape.deleteScene(currentScene);
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
454 } else if (id == 'MakeSymbol') {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
455 if (inkscape.isInProgress != 0) return;
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
456 inkscape.MakeSymbol();
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
457 } else if (id == 'Save') {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
458 project_save();
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
459 } else if (id == 'Test') {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
460 if (project_compile()) {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
461 project_run();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
462 } else {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
463 }
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
464 } else {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
465 alert(id+' has not been implemented yet');
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
466 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
467 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
468
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
469 function gotoScene_cb(resObj)
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
470 {
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
471
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
472 }
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
473 var nextScene;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
474 var currentScene = 0;
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
475 var currentLayer = '';
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
476
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
477
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
478 function dump(n)
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
479 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
480 cmd = "";
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
481 for(k in n) {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
482 cmd = cmd + k+"="+n[k]+"\n";
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
483 }
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
484 alert(cmd);
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
485 }
288
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
486
d5327265da1e Revert the firefox integration to 276
wycc
parents:
diff changeset
487
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
488
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
489
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
490
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
491
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
492 function loadInkscapeFile()
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
493 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
494 ele = $('#mbsvg');
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
495 file = ele.attr('value');
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
496 inkscape = new Inkscape("file://"+file);
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
497
352
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
498 file1_animation = [
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
499 {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
500 attributes: {id:"an1-1"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
501 data: "animation1"
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
502 },
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
503 {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
504 attributes: {id:"an1-2"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
505 data: "animation2"
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
506 }
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
507 ];
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
508 file1 = {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
509 attributes:{id:"file1"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
510 data: "scene1.mbsvg",
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
511 children: file1_animation
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
512 };
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
513 file2 = {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
514 attributes:{id:"file2"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
515 data: "scene2.mbsvg",
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
516 };
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
517 file3 = {
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
518 attributes:{id:"file3"},
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
519 data: "scene3.mbsvg",
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
520 };
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
521
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
522 scenes = [ file1,file2,file3];
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
523 src1 = {attributes:{id:"src1"},data:"src1.c"};
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
524 src2 = {attributes:{id:"src1"},data:"src2.c"};
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
525 src3 = {attributes:{id:"src1"},data:"src3.c"};
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
526
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
527 sources = [src1,src2,src3];
4350aa369149 Use jQuery UI components.
wycc
parents: 339
diff changeset
528
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
529 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
530
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
531 function project_compile()
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
532 {
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
533 }
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
534
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
535
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
536 function project_showFile(node)
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
537 {
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
538 var file = node.textContent;
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
539 if (endsWith(file,"mbsvg")) {
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
540 project_loadScene(node);
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
541 } else {
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
542 project_loadEditor(node);
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
543 }
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
544
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
545 }
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
546 function project_loadScene(node)
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
547 {
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
548 var file = node.textContent;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
549 if (file.substr(0,1) == '/')
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
550 inkscape = new Inkscape("file://"+file);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
551 else
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
552 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
553 }
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
554
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
555
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
556 function project_loadEditor(node)
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
557 {
8c4456190d9a Add text editor support to edit C source file inside the MadBuilder
wycc
parents: 359
diff changeset
558 var file = node.textContent;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
559 if (file.substr(0,1) == '/')
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
560 editor = new TextEditor("file://"+file);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
561 else
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
562 editor = new TextEditor("file://"+project_dir+'/'+file);
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
563 }
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
564
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
565 function project_parse(xml)
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
566 {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
567
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
568 var xmlParser = new DOMParser();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
569 var xmlDoc = xmlParser.parseFromString( xml, 'text/xml');
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
570 var scenesNode = xmlDoc.getElementsByTagName("scene");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
571 if (scenesNode == null) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
572 alert('This is not a valid scene file');
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
573 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
574 var len = scenesNode.length;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
575 var i,j;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
576 var max = 0;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
577 var scenes = new Array();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
578
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
579 // Get the length of scenes
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
580 for(i=0;i<len;i++) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
581 var n = scenesNode[i];
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
582 var s = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
583 s.attributes = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
584 s.attributes.id = "scene"+i;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
585 s.state = "open";
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
586 s.data = n.getAttribute("src");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
587 scenes.push(s);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
588 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
589
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
590 var nodes = xmlDoc.getElementsByTagName("source");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
591 var len = nodes.length;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
592 var i,j;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
593 var max = 0;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
594 var sources = [];
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
595
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
596 // Get the length of scenes
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
597 for(i=0;i<len;i++) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
598 var n = nodes[i];
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
599 var s = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
600 s.attributes = new Object();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
601 s.attributes.id = "sources"+i;
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
602 s.state = "open";
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
603 s.data = n.getAttribute("src");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
604 sources.push(s);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
605 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
606
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
607 var tree = $.tree_create();
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
608 project_tree = tree;
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
609 tree.init($("#filelist"), {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
610 data: {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
611 type: "json",
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
612 json : [
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
613 {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
614 attributes: {id: "prj"},
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
615 state: "open",
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
616 data: "Project",
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
617 children: [
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
618 { attributes:{id:"scenes"}, data:"scene", children: scenes},
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
619 { attributes:{id:"sources"},data:"sources",children: sources}
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
620 ]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
621 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
622 ],
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
623 },
359
b4bd4819091c Load mbsvg file when it is double clicked
wycc
parents: 358
diff changeset
624 callback : {
362
83cae12cf428 Load scene and source in different way.
wycc
parents: 361
diff changeset
625 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
626 },
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
627 ui : {
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
628 context : [
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
629 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
630 id: "Open",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
631 label: "Open",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
632 icon: "open.png",
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
633 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
634 action: function(NODE,TREE_OBJ) { onTree_openFile(NODE,TREE_OBJ);}
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
635 },
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
636 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
637 id: "New",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
638 label: "New",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
639 icon: "create.png",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
640 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
641 action: function(NODE,TREE_OBJ) { alert("open is not support yet");}
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
642 },
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
643 {
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
644 id: "Rename",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
645 label: "Rename",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
646 icon: "rename.png",
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
647 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
648 action: function(NODE,TREE_OBJ) { alert("open is not support yet");}
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
649 }
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
650 ]
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
651 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
652
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
653 });
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
654 }
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
655
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
656 function fileDialog_cb()
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
657 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
658 var file = $('#filedialogsrc').attr('value');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
659 filedialog.dialog('close');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
660 filedialog_cb(file,filedialog_arg);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
661 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
662
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
663 function openFileDialog(callback,arg)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
664 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
665 filedialog_cb = callback;
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
666 filedialog_arg = arg;
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
667 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
668 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
669 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
670 filedialog.show();
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
671 filedialog.dialog('open');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
672 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
673
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
674
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
675 function project_addScene(file,treeobj)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
676 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
677 if (file == '') {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
678 return;
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
679 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
680 treeobj.create(false,treeobj.selected,file);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
681 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
682
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
683 function onTree_addSceneFile(node,treeobj)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
684 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
685 openFileDialog(project_addScene,treeobj);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
686 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
687
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
688 function project_addSource(file,treeobj)
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
689 {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
690 treeobj.create(false,treeobj.selected,file);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
691 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
692
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
693 function onTree_addSourceFile(node,treeobj)
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
694 {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
695 openFileDialog(project_addSource,treeobj);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
696 }
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
697
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
698 function onTree_openFile(node,treeobj)
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
699 {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
700 if (node[0].id == "scenes") {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
701 onTree_addSceneFile(node,treeobj);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
702 } else if (node[0].id == "sources") {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
703 onTree_addSourceFile(node,treeobj);
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
704 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
705 }
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
706
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
707 function system_open_read(fname) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
708 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
709 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
710 } catch (e) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
711 alert("Permission to read file was denied.");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
712 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
713 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
714 .createInstance(Components.interfaces.nsILocalFile);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
715 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
716 file.initWithPath( fname );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
717 if ( file.exists() == false ) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
718 alert("File does not exist");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
719 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
720 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
721 .createInstance( Components.interfaces.nsIFileInputStream );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
722 is.init( file,0x01, 00004, null);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
723 var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
724 .createInstance( Components.interfaces.nsIScriptableInputStream );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
725 sis.init( is );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
726 } catch(e) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
727 alert(fname+" does not exist");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
728 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
729 return sis;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
730 }
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
731
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
732 function system_read(fname) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
733 try {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
734 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
735 } catch (e) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
736 alert("Permission to read file was denied.");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
737 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
738 var file = Components.classes["@mozilla.org/file/local;1"]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
739 .createInstance(Components.interfaces.nsILocalFile);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
740 try {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
741 file.initWithPath( fname );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
742 if ( file.exists() == false ) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
743 alert("File does not exist");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
744 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
745 var is = Components.classes["@mozilla.org/network/file-input-stream;1"]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
746 .createInstance( Components.interfaces.nsIFileInputStream );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
747 is.init( file,0x01, 00004, null);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
748 var sis = Components.classes["@mozilla.org/scriptableinputstream;1"]
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
749 .createInstance( Components.interfaces.nsIScriptableInputStream );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
750 sis.init( is );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
751 var output = sis.read( sis.available() );
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
752 sis.close();
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
753 } catch(e) {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
754 alert(fname+" does not exist");
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
755 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
756 return output;
357
6fd8da22a5ef Implement scene file load function.
wycc
parents: 352
diff changeset
757 }
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
758 function system_open_write(fname) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
759 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
760 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
761 } catch (e) {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
762 alert("Permission to read file was denied.");
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
763 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
764 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
765 .createInstance(Components.interfaces.nsILocalFile);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
766 try {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
767 file.initWithPath( fname );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
768 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
769 .createInstance( Components.interfaces.nsIFileOutputStream );
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
770 fostream.init( file,0x02|0x8|0x20, 0666,0);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
771 } catch(e) {
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
772 alert('can not create '+fname);
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
773 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
774 return fostream;
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
775 }
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
776 function system_write(fname,xml) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
777 try {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
778 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
779 } catch (e) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
780 alert("Permission to read file was denied.");
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
781 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
782 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
783 .createInstance(Components.interfaces.nsILocalFile);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
784 try {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
785 file.initWithPath( fname );
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
786 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
787 .createInstance( Components.interfaces.nsIFileOutputStream );
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
788 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
789 fostream.write( xml,xml.length );
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
790 fostream.close();
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
791 } catch(e) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
792 alert(fname+" does not exist");
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
793 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
794 }
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
795
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
796 function system_mkdir(path)
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
797 {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
798 try {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
799 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
800 } catch (e) {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
801 alert("Permission to read file was denied.");
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
802 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
803 var file = Components.classes["@mozilla.org/file/local;1"]
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
804 .createInstance(Components.interfaces.nsILocalFile);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
805 try {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
806 file.initWithPath(path);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
807 if( !file.exists() || !file.isDirectory() ) { // if it doesn't exist, create
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
808 file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0777);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
809 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
810 } catch(e) {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
811 alert('Failed to create directopry '+path+e);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
812 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
813 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
814
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
815 function getPathDirectory(path)
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
816 {
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
817 var s = path.lastIndexOf('/');
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
818 if (s == -1)
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
819 return '';
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
820 else
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
821 return path.substr(0,s);
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
822 }
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
823
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
824 function project_loadFile()
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
825 {
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
826 prjname = $('#mbsvg').attr('value');
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
827 project_name = prjname;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
828 project_dir = getPathDirectory(prjname);
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
829 var prj = system_read(prjname);
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
830 project_parse(prj);
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
831 filedialog.dialog('close');
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
832 }
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
833
365
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
834
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
835 function project_save()
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
836 {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
837 var i;
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
838
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
839 var xml = "<project>\n";
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
840 var scenes = $('#scenes');
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
841 var sources = $('#sources');
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
842 var list = project_tree.getJSON(scenes);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
843 var len = list.children.length;
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
844
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
845 for(i=0;i<len;i++) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
846 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
847 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
848 list = project_tree.getJSON(sources);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
849 len = list.children.length;
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
850 for(i=0;i<len;i++) {
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
851 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
852 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
853 xml = xml + "</project>\n";
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
854 system_write(project_name,xml);
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
855
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
856 }
6adb28388132 Add capability to add new scene and source into the project
wycc
parents: 364
diff changeset
857
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
858
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
859 function onLoadProject(path)
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
860 {
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
861 project_name = path;
371
3d21115297ba Add textmenu template
wycc
parents: 367
diff changeset
862 project_dir = getPathDirectory(project_name);
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
863 var prj = system_read(project_name);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
864 project_parse(prj);
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
865 }
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
866
358
50d33c3987ba Add loader for project file.
wycc
parents: 357
diff changeset
867 var last_select = null;
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
868 var wizard = new Wizard();
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
869 wizard.cb = onLoadProject;
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
870 $('#filedialog').dialog({ width:500});
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
871 jQuery(document).ready(function() {
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
872 filedialog = jQuery('#filedialog');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
873 filedialog.dialog({width:500,
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
874 modal: true,
367
e21e9447f545 Add wizard. We still need to add the template files.
wycc
parents: 365
diff changeset
875 autoOpen:false,
364
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
876 title:'Please select a file'});
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
877 filedialog.show();
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
878 filedialog.html('Please select the project file<br>');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
879 filedialog.append('<input type=file value="Select the project file" id="mbsvg" accept="image/png">');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
880 filedialog.append('<input type=button value="Load" onclick="project_loadFile()">');
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
881 filedialog.dialog("open");
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
882 });
a373b4743e63 Add file dialog to add a new scene file into the project.
wycc
parents: 362
diff changeset
883
376
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
884 $('#frame').draggable();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
885 $('#btns').draggable({cursor:'crosshair'});
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
886 $('#list').tabs();
7d244a85dd68 Change the screen layout to make it more like an usual IDE.
wycc
parents: 371
diff changeset
887 $('#display').tabs();