").attr('id', this.id);
}
return this.domElement;
}
/**
* @function {public} load
* Attempts to load the FlashClient
*
* - {@link CP.FlashClient.beforeRender beforeRender()}
* - {@link CP.FlashClient.render render()}
* - {@link CP.FlashClient.afterRender afterRender()}
*
* @param {Boolean} forceLoad Pass through to {@link CP.FlashClient.beforeRender beforeRender}
* in order to accomodate bypassing flash checks
* @return {Object} A {@link CP.Result CP.Result} object;
*/
CP.FlashClient.prototype.load = function(forceLoad) {
var result = this.beforeRender(forceLoad);
if (!result.hasError) {
this.render();
this.afterRender();
}
return result;
};
/**
* @function {private} beforeRender
* Runs before rendering the Flash Client. Does the following:
*
* - {@link CP.FlashClient.validateFlashVersion validateFlashVersion(minimumVersion, recommendedVersion)}
* - load the swfaddress.js file into the <head>
* - tells the friendsClient to load
*
*
* @param {Boolean} forceLoad True if we should skip checking the flash version. False otherwise.
* @return {Object} A {@link CP.Result CP.Result} object;
*/
CP.FlashClient.prototype.beforeRender = function(forceLoad) {
var result = new CP.Result();
if (!forceLoad) {
result = CP.FlashClient.validateFlashVersion(this.options.minimumSwfVersion, this.options.recommendedSwfVersion);
}
if (!result.hasError) {
this.friendsClient.load();
}
this.loadContentVersion();
this.loadSwfAddressJS();
return result;
};
/**
* @function {private} loadContentVersion
* Load the version of the client to the class
*/
CP.FlashClient.prototype.loadContentVersion = function () {
jQuery.ajax({
url: 'https://media1.newcp.net/version.txt?v=' + new Date().getTime(),
type: 'GET',
async: false,
success: response => jQuery.extend(this.options, JSON.parse(response)),
error: function(jqXHR, textStatus, errorThrown) {}
});
};
/**
* @function {private} loadSwfAddressJS
* Load the SwfAddress into the <head> of the document.
* This is done like this because if we load it on the landing page, and then we change
* the hash to say '/login', swfaddress doesn't like that there is no swf yet, since we
* load the flash client dynamically and swfaddress will start saying, "oopz, errors!"
*/
CP.FlashClient.prototype.loadSwfAddressJS = function () {
console.log("loading swf address");
var attributes = {
'type' : 'text/javascript',
'src' : this.options.swfAddressUrl
}
var scriptElement = jQuery("