comparison inkscape/firefox/content/madswatter.js @ 392:ebf83a50e1e1

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