Section 1
//GroupReplacer (GroupReplacer)
package {
import flash.events.*;
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.external.*;
public class GroupReplacer extends MovieClip {
private var LIVE:Boolean;// = false
private var _bg:Sprite;
private var DEV:Boolean;// = false
private var _tf:TextField;
private var _decayingInterval:int;// = 2
private var IDE:Boolean;// = false
private var _URL:String;// = ""
private var objId:String;
private var _baseDomain:String;// = ""
private var _groupURL:String;// = ""
private var _ref:String;
public function GroupReplacer(){
var _local1:*;
IDE = false;
LIVE = false;
DEV = false;
_URL = "";
_baseDomain = "";
_groupURL = "";
_decayingInterval = 2;
super();
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
this._URL = stage.loaderInfo.url;
if (this._URL.indexOf("file:/") == 0){
this.IDE = true;
} else {
if (stage.loaderInfo.parameters["tagport"] != undefined){
this.DEV = true;
} else {
this.LIVE = true;
};
};
if (this.IDE){
this._baseDomain = stage.loaderInfo.parameters["base_domain"];
} else {
_local1 = "http";
if (this._URL.indexOf("https") == 0){
_local1 = "https";
};
this._baseDomain = this._URL.split((_local1 + "://st."))[1].split("/")[0];
};
this._groupURL = "";
if (this.IDE){
this._groupURL = stage.loaderInfo.parameters["groupURL"];
} else {
this._groupURL = stage.loaderInfo.parameters["gn"].split(".")[0];
};
if ((((((this._groupURL == "")) && (stage.loaderInfo.parameters["on_fb"]))) && (stage.loaderInfo.parameters["gpnm"]))){
this._groupURL = stage.loaderInfo.parameters["gpnm"];
};
this._groupURL = String(this._groupURL);
this._ref = stage.loaderInfo.parameters["ref"];
setTimeout(this._replaceGroups, this._decayingInterval);
setTimeout(this._makeWarning, 2000);
}
private function _makeWarning(){
var _local1:Array;
var _local2:*;
var _local3:*;
var _local4:String;
var _local5:String;
var _local6:*;
var _local7:*;
var _local8:*;
var _local9:*;
this._bg = new Sprite();
this.addChild(this._bg);
this._tf = new TextField();
this._tf.wordWrap = true;
this._tf.multiline = true;
this._tf.x = 5;
this._tf.width = (stage.stageWidth - 10);
_local1 = [];
_local2 = false;
for (_local4 in stage.loaderInfo.parameters) {
if ((((((((((((((((_local4 == "ref")) || ((_local4 == "gn")))) || ((_local4 == "cid")))) || ((_local4 == "ipc")))) || ((_local4 == "tagport")))) || ((_local4 == "aimport")))) || ((_local4 == "msnport")))) || ((_local4 == "iconport")))){
} else {
_local3 = stage.loaderInfo.parameters[_local4];
if (_local4 == "p"){
_local3 = Math.max(9, (Number(_local3) * 0.8));
_local2 = true;
};
_local1.push(((_local4 + ":") + _local3));
};
};
if (!_local2){
_local1.push("p:10");
};
_local1.push("usricon:.75");
_local1.push(("sizew:" + stage.stageWidth));
_local1.push(("sizeh:" + stage.stageHeight));
_local5 = _local1.join(",");
_local6 = (("http://" + this._groupURL) + ".chatango.com/clonegroup");
_local7 = (("http://" + this._groupURL) + ".chatango.com");
_local8 = true;
if (this._groupURL == ""){
_local6 = "http://chatango.com";
_local8 = false;
} else {
if (_local5 != ""){
_local6 = (_local6 + ("?style=" + _local5));
};
};
_local9 = (("This Chatango embed code is no longer valid. <u><a href=\"" + _local6) + "\" target=\"_blank\">Get new embed code here</a></u>.");
if (_local8){
_local9 = (_local9 + (("<br><u><a href=\"" + _local7) + "\" target=\"_blank\">Open the group full size</a></u>."));
};
this._tf.htmlText = _local9;
this.addChild(this._tf);
this._onResize(null);
stage.addEventListener(Event.RESIZE, this._onResize);
}
private function _replaceGroups():void{
var _local1:XML;
_local1 = <script>
<![CDATA[
function upgradeFlashEmbeds(bd, opt_ref){
// console.log('base domain: ' + bd);
var refVar = (opt_ref)? '&ref='+ opt_ref: '';
var objects = document.getElementsByTagName('object');
var embeds = document.getElementsByTagName('embed');
var handleRegEx = new RegExp(":\/\/(.*)." + bd);
// console.log(objects);
var replacements = [];
var i, len, o, params, j, pLen, isChatango, info;
len = objects.length;
// Find chatango objects
for(i=0; i < len; i++){
isChatango = false;
info = {};
o = objects[i];
// console.log('o:', o);
params = o.getElementsByTagName('param');
pLen = params.length;
// console.log('pLen: ' + pLen);
for(j = 0; j< pLen; j++){
// console.log('params[j]: ', params[j]);
if(params[j].getAttribute('name') == 'movie'){
// console.log('movie param: ', params[j].getAttribute('value') );
// console.log('bd: ', bd);
if(params[j].getAttribute('value').indexOf(bd) != -1){
// console.log('Found a Chatango object');
info.handle = params[j].getAttribute('value').match(handleRegEx)[1];
isChatango = true;
}
}
if(params[j].getAttribute('name') == 'flashvars'){
info.flashvars = params[j].getAttribute('value') + refVar;
}
}
if(isChatango){
info.el = o;
info.id = (o.id)? o.id.split('obj_').join('') : undefined;
// add this info object to the replacements array
replacements.push(info);
}
}
// Find chatango embeds - not wrapped in objects
len = embeds.length;
var emb;
for(i=0; i < len; i++){
emb = embeds[i];
var parentEl = emb.parentElement;
var parentIsAlreadyBeingReplaced = false;
for(j=0; j < replacements.length; j++){
if(parentEl == replacements[j].el) {
parentIsAlreadyBeingReplaced = true;
break;
}
}
//if(emb.parentElement.tagName.toLowerCase() != 'object'){
if(!parentIsAlreadyBeingReplaced){
if(emb.src && emb.src.indexOf(bd)!=-1){
// A Chatango embed - not wrapped in an object
info = {};
info.id = (emb.id)? emb.id.split('emb_').join('') : undefined;
info.flashvars = emb.attributes.flashvars.value + refVar;
info.el = emb;
info.handle = emb.src.match(handleRegEx)[1];
replacements.push(info);
}
}
}
// console.log('replacements: ', replacements);
//Write new script tags
len = replacements.length;
var s, info, id, w, h, content, styles, flashvars, fLen, pair, pairStr;
for (var i = 0; i < len; i++){
info = replacements[i];
w = info.el.width? info.el.width : info.el.style.width;
h = info.el.height? info.el.height : info.el.style.height;
if(!isNaN(w)) w = w+'px';
if(!isNaN(h)) h = h+'px';
// sid0020000076030432103
// obj_ 1266189183578
var defaultId = '0000000000000000000';
id = info.id? info.id : defaultId;
if(!(/^\d*$/).test(id)) id = defaultId; // check that the id is only digits
if(id.length == 13){id = '002000' + id};
s = document.createElement('script');
s.id = 'cid' + id;
s.style.cssText='width:'+w+';height:'+h+';';
flashvars = info.flashvars.split('&');
fLen = flashvars.length;
styles = [];
for(j = 0; j < fLen; j++){
pair = flashvars[j].split('=');
pairStr = '"'+ pair[0] +'"';
if(pair.length > 1) pairStr += ':"'+ pair[1] +'"';
// The rnded cnrs var 's' has been superceded by cnrs.
if(pairStr == '"s":"1"'){
pairStr = '"cnrs":0.35';
}
styles.push(pairStr);
}
var forceJS = false;
var archString = "";
if (forceJS){
archString = ',"arch":"js"';
}
content = '{"handle":"'+info.handle+'","styles":{'+styles.join(',') +'}'+archString+'}';
// console.log('content: ', content);
s.text = content;
var noCloudFlareCacheAttribute = document.createAttribute("data-cfasync");
noCloudFlareCacheAttribute.value = false;
s.setAttributeNode(noCloudFlareCacheAttribute);
s.src='http://st.'+bd+'/js/gz/emb_CLF.js';
info.el.parentNode.insertBefore(s, info.el);
info.el.parentNode.removeChild(info.el);
}
}
]]>
</script>
;
ExternalInterface.call(_local1, this._baseDomain, this._ref);
this._decayingInterval = Math.max(20, (this._decayingInterval * 2));
if (this._decayingInterval < 60000){
setTimeout(this._replaceGroups, this._decayingInterval);
};
}
private function _onResize(_arg1:Event){
var _local2:int;
var _local3:Number;
var _local4:int;
var _local5:TextFormat;
_local2 = 0xFFFFFF;
if (stage.loaderInfo.parameters["a"]){
_local2 = Number(("0x" + stage.loaderInfo.parameters["a"]));
};
_local3 = 0;
if (stage.loaderInfo.parameters["b"]){
_local3 = (Number(stage.loaderInfo.parameters["b"]) / 100);
};
_local4 = 0;
if (stage.loaderInfo.parameters["c"]){
_local4 = Number(("0x" + stage.loaderInfo.parameters["c"]));
};
this._bg.graphics.clear();
this._bg.graphics.beginFill(_local2, _local3);
this._bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
if (this._tf){
this._tf.autoSize = TextFieldAutoSize.LEFT;
_local5 = new TextFormat("_sans", 12, _local4);
this._tf.setTextFormat(_local5);
};
}
}
}//package