summaryrefslogtreecommitdiff
path: root/includes/js/dojox/flash/DojoExternalInterface.as
diff options
context:
space:
mode:
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>2008-11-14 15:39:19 +0000
commit1c5685d68f1b73270fb814fe04cbb490eb90ba5f (patch)
tree3d3ada08a934b96fc31531f1327690d7edc6f766 /includes/js/dojox/flash/DojoExternalInterface.as
parent104d59099e048688c4dbac37d72137006e396558 (diff)
downloadsemanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.gz
semanticscuttle-1c5685d68f1b73270fb814fe04cbb490eb90ba5f.tar.bz2
Minor fix: Remove DOJO library (60Mo) replaced by link to Google CDN (online DOJO library)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@159 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/flash/DojoExternalInterface.as')
-rw-r--r--includes/js/dojox/flash/DojoExternalInterface.as168
1 files changed, 0 insertions, 168 deletions
diff --git a/includes/js/dojox/flash/DojoExternalInterface.as b/includes/js/dojox/flash/DojoExternalInterface.as
deleted file mode 100644
index d857968..0000000
--- a/includes/js/dojox/flash/DojoExternalInterface.as
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- A wrapper around Flash 8's ExternalInterface; this is needed
- because ExternalInterface has a number of serialization bugs that we
- need to correct for.
-
- @author Brad Neuberg
-*/
-
-import flash.external.ExternalInterface;
-
-class DojoExternalInterface{
- public static var available:Boolean;
- public static var dojoPath = "";
-
- public static function initialize(){
- //trace("DojoExternalInterface.initialize");
-
- // extract the dojo base path
- DojoExternalInterface.dojoPath = DojoExternalInterface.getDojoPath();
-
- // see if we need to do an express install
- var install:ExpressInstall = new ExpressInstall();
- if(install.needsUpdate){
- install.init();
- }
-
- // set whether communication is available
- DojoExternalInterface.available = ExternalInterface.available;
- }
-
- /** Called when we are finished adding methods through addCallback. */
- public static function done(){
- //trace("done");
- DojoExternalInterface.call("dojox.flash.loaded");
- }
-
- public static function addCallback(methodName:String, instance:Object,
- method:Function):Boolean{
- //trace("addCallback");
- ExternalInterface.addCallback(methodName, instance, function(){
- instance = (instance) ? instance : null;
- var params = [];
- if(arguments && arguments.length){
- for(var i = 0; i < arguments.length; i++){
- params[i] = DojoExternalInterface.decodeData(arguments[i]);
- }
- }
-
- var results = method.apply(instance, params);
- results = DojoExternalInterface.encodeData(results);
-
- return results;
- });
-
- // tell JavaScript about DojoExternalInterface new method so we can create a proxy
- ExternalInterface.call("dojox.flash.comm._addExternalInterfaceCallback",
- methodName);
-
- return true;
- }
-
- public static function call(methodName:String):Void{
- // we might have any number of optional arguments, so we have to
- // pass them in dynamically; strip out the results callback
- var parameters = new Array();
- for(var i = 0; i < arguments.length; i++){
- parameters.push(arguments[i]);
- }
-
- // FIXME: Should we be encoding or decoding the data to get
- // around Flash's serialization bugs?
-
- var results = ExternalInterface.call.apply(ExternalInterface, parameters);
-
- return results;
- }
-
- /**
- Called by Flash to indicate to JavaScript that we are ready to have
- our Flash functions called. Calling loaded()
- will fire the dojox.flash.loaded() event, so that JavaScript can know that
- Flash has finished loading and adding its callbacks, and can begin to
- interact with the Flash file.
- */
- public static function loaded(){
- DojoExternalInterface.call("dojox.flash.loaded");
- }
-
- /**
- Utility trace implementation that prints out to console.debug.
- */
- public static function trace(msg){
- DojoExternalInterface.call("console.debug", "FLASH: " + msg);
- }
-
- private static function decodeData(data):String{
- if(!data || typeof data != "string"){
- return data;
- }
-
- // we have to use custom encodings for certain characters when passing
- // them over; for example, passing a backslash over as //// from JavaScript
- // to Flash doesn't work
- data = replaceStr(data, "&custom_backslash;", "\\");
-
- data = replaceStr(data, "\\\'", "\'");
- data = replaceStr(data, "\\\"", "\"");
-
- return data;
- }
-
- private static function encodeData(data):String{
- if(!data || typeof data != "string"){
- return data;
- }
-
- // certain XMLish characters break Flash's wire serialization for
- // ExternalInterface; encode these into a custom encoding, rather than
- // the standard entity encoding, because otherwise we won't be able to
- // differentiate between our own encoding and any entity characters
- // that are being used in the string itself
- data = replaceStr(data, '<', '&custom_lt;');
- data = replaceStr(data, '>', '&custom_gt;');
-
- // needed for IE
- data = replaceStr(data, '\\', '&custom_backslash;');
-
- // encode control characters and JavaScript delimiters
- data = replaceStr(data, "\n", "\\n");
- data = replaceStr(data, "\r", "\\r");
- data = replaceStr(data, "\f", "\\f");
- data = replaceStr(data, "'", "\\'");
- data = replaceStr(data, '"', '\"');
-
- return data;
- }
-
- /**
- Flash ActionScript has no String.replace method or support for
- Regular Expressions! We roll our own very simple one.
- */
- public static function replaceStr(inputStr:String, replaceThis:String,
- withThis:String):String{
- var splitStr = inputStr.split(replaceThis);
- if(!splitStr){
- return inputStr;
- }
-
- inputStr = splitStr.join(withThis);
- return inputStr;
- }
-
- private static function getDojoPath(){
- var url = _root._url;
- var start = url.indexOf("baseUrl=") + "baseUrl=".length;
- var path = url.substring(start);
- var end = path.indexOf("&");
- if(end != -1){
- path = path.substring(0, end);
- }
-
- // some browsers append a junk string at the end: '%20'%20quality=
- if(path.indexOf("'%20'%20quality=") != -1){
- path = path.substring(0, path.indexOf("'%20'%20quality="));
- }
- return path;
- }
-}