annotate inkscape/firefox/content/madswatter.js @ 1311:e6bb9d00341f

Make content dom and comp_dock synchronized
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 20 Jan 2011 13:08:26 +0800
parents ebf83a50e1e1
children
rev   line source
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
1 asdasd=1;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
2 function MadSwatter(inkscape)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
3 {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
4 this.inkscape = inkscape;
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
5 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
6
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
7
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
8 function MadSwatter_callback(mbsvg,self)
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
9 {
392
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
10 var ch = $(mbsvg).find("channels");
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
11 try {
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
12 var oldch = $(inkscape.mbsvg.doc).find("channels");
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
13 var newch = $(mbsvg).find("channels");
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
14 oldch.replaceWith(newch);
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
15 $('#display').tabs('select',0);
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
16 } catch(e) {
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
17 alert(e);
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
18 }
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
19 //self.inkscape.updateDocument();
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
20 }
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
21
392
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
22
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
23
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
24 // Call MadSwatter, we will create file in the /tmp and then create an iframe inside thge madswatter div to
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
25 // load this file. After the MadSwatter finish the job, it should send an event editcb back to us. In this way,
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
26 // we can avoid the security issue.
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
27 function MadSwatter_invoke(dom,callback,self)
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
28 {
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
29 var f = system_open_write("/tmp/swatter.tmp");
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
30 var serializer = new XMLSerializer();
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
31 var cont = serializer.serializeToString(dom[0]);
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
32
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
33 f.write(cont,cont.length);
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
34 f.close();
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
35 $('#madswatter').html('<iframe width="900" height="700" src="chrome://madswatter/content/editor.xhtml"></iframe>');
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
36 }
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
37
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
38 MadSwatter.prototype.edit=function()
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
39 {
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
40 // Generate a new document with the current scene
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
41 // FIXME: Do we need to do animation filter here?
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
42 // FIXME: Do we need to support hiearchical animation?
392
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
43 var kk = this.inkscape.mbsvg.generateCurrentSVG();
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
44 $('#display').tabs('select',2);
392
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
45 MadSwatter_invoke(kk,MadSwatter_callback,this);
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
46 // Simulate the MadSwatter
392
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
47 //kk.find("metadata").append("<channels></channels>");
ebf83a50e1e1 Implement the MadSwatter integration
wycc
parents: 389
diff changeset
48 //setTimeout(function () { MadSwatter_callback(kk,this);}, 3000);
389
45e04408fc19 Implement stub functions for the MadSwatter integration.
wycc
parents:
diff changeset
49 }