Skip to content

Commit

Permalink
updated internal jquery code
Browse files Browse the repository at this point in the history
Change-Id: I3e800d8ea0b0e4bea55aac81065f413cae0d5b28
  • Loading branch information
adufilie committed Feb 17, 2012
1 parent 23bc9bc commit d13aee2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8,391 deletions.
42 changes: 26 additions & 16 deletions WeaveData/src/weave/services/jquery/JQueryCaller.as
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ package weave.services.jquery
{
[Embed("jquery-caller.js", mimeType="application/octet-stream")]
private static const JQCaller:Class;
[Embed("jquery-1.5.2.js", mimeType="application/octet-stream")]
[Embed("jquery-1.7.1.min.js", mimeType="application/octet-stream")]
private static const JQ:Class;

/**
* uniqueIDToTokenMap
* This maps a unique ID (generated when a request is made to download from a URL through this class)
* to an AsyncToken associated with it.
* to a QueryToken associated with it.
*/
private static const uniqueIDToTokenMap:Dictionary = new Dictionary(true);
private static const uniqueIDToTokenMap:Object = new Object();

private static var _initialized:Boolean = false;

Expand Down Expand Up @@ -81,33 +80,44 @@ package weave.services.jquery
initialize();

var uniqueID:String = UIDUtil.createUID();
uniqueIDToTokenMap[uniqueID] = token;
uniqueIDToTokenMap[uniqueID] = new QueryToken(url, token);

ExternalInterface.call("WeaveJQueryCaller.getFile('"+url+"', '"+uniqueID+"')");

}

public static function jqueryResult(id:String, data:Object):void
{
trace("RESULT!", data);
var token:AsyncToken = uniqueIDToTokenMap[id] as AsyncToken;
var qt:QueryToken = uniqueIDToTokenMap[id] as QueryToken;

token.mx_internal::applyResult(ResultEvent.createEvent(data, token));
qt.asyncToken.mx_internal::applyResult(ResultEvent.createEvent(data, qt.asyncToken));

delete uniqueIDToTokenMap[id];
}

public static function jqueryFault(id:String, url:String):void
public static function jqueryFault(id:String, errorThrown:Object):void
{
var token:AsyncToken = uniqueIDToTokenMap[id] as AsyncToken;
var qt:QueryToken = uniqueIDToTokenMap[id] as QueryToken;

var fault:Fault = new Fault(SecurityErrorEvent.SECURITY_ERROR, SecurityErrorEvent.SECURITY_ERROR, "JQuery failed to download from url.");
token.mx_internal::applyFault(FaultEvent.createEvent(fault, token));
trace("FAULT! getting " + url);
var fault:Fault = new Fault(SecurityErrorEvent.SECURITY_ERROR, SecurityErrorEvent.SECURITY_ERROR, "JQuery failed to download from url.");
fault.rootCause = errorThrown;
qt.asyncToken.mx_internal::applyFault(FaultEvent.createEvent(fault, qt.asyncToken));
trace("FAULT! getting " + qt.url);

delete uniqueIDToTokenMap[id];
}

private static const staticDecoder:Base64Decoder = new Base64Decoder();
}
}
}
import mx.rpc.AsyncToken;

internal class QueryToken
{
public function QueryToken(url:String, asyncToken:AsyncToken)
{
this.url = url;
this.asyncToken = asyncToken;
}

public var url:String;
public var asyncToken:AsyncToken;
}
Loading

0 comments on commit d13aee2

Please sign in to comment.