# HG changeset patch # User wycc # Date 1239755667 -28800 # Node ID ebf83a50e1e1d100eb822d9aef1acbc9f16d52a7 # Parent 6e7909960f31509fff7614180d48898b83297235 Implement the MadSwatter integration diff -r 6e7909960f31 -r ebf83a50e1e1 inkscape/firefox/content/inkscape.js --- a/inkscape/firefox/content/inkscape.js Sun Apr 12 12:02:17 2009 +0800 +++ b/inkscape/firefox/content/inkscape.js Wed Apr 15 08:34:27 2009 +0800 @@ -97,7 +97,7 @@ this.callback = null; this.animation = new MadSwatter(this); - setTimeout("inkscape.fetchDocument()",4000); + setTimeout("inkscape.fetchDocument()",3000); } Inkscape.prototype.gotoScene = function (n) diff -r 6e7909960f31 -r ebf83a50e1e1 inkscape/firefox/content/madswatter.js --- a/inkscape/firefox/content/madswatter.js Sun Apr 12 12:02:17 2009 +0800 +++ b/inkscape/firefox/content/madswatter.js Wed Apr 15 08:34:27 2009 +0800 @@ -7,10 +7,32 @@ function MadSwatter_callback(mbsvg,self) { + var ch = $(mbsvg).find("channels"); + try { + var oldch = $(inkscape.mbsvg.doc).find("channels"); + var newch = $(mbsvg).find("channels"); + oldch.replaceWith(newch); + $('#display').tabs('select',0); + } catch(e) { + alert(e); + } + //self.inkscape.updateDocument(); +} - $(self.inkscape.mbsvg.doc).find("channels").replaceWith(mbsvg.find("channels")); - $('#display').tabs('select',0); - //self.inkscape.updateDocument(); + + +// Call MadSwatter, we will create file in the /tmp and then create an iframe inside thge madswatter div to +// load this file. After the MadSwatter finish the job, it should send an event editcb back to us. In this way, +// we can avoid the security issue. +function MadSwatter_invoke(dom,callback,self) +{ + var f = system_open_write("/tmp/swatter.tmp"); + var serializer = new XMLSerializer(); + var cont = serializer.serializeToString(dom[0]); + + f.write(cont,cont.length); + f.close(); + $('#madswatter').html(''); } MadSwatter.prototype.edit=function() @@ -18,10 +40,10 @@ // Generate a new document with the current scene // FIXME: Do we need to do animation filter here? // FIXME: Do we need to support hiearchical animation? + var kk = this.inkscape.mbsvg.generateCurrentSVG(); $('#display').tabs('select',2); - var kk = this.inkscape.mbsvg.generateCurrentSVG(); - //MadSwatter_invoke(kk,MadSwatter_callback,this); + MadSwatter_invoke(kk,MadSwatter_callback,this); // Simulate the MadSwatter - kk.find("metadata").append(""); - setTimeout(function () { MadSwatter_callback(kk,this);}, 3000); + //kk.find("metadata").append(""); + //setTimeout(function () { MadSwatter_callback(kk,this);}, 3000); }