// Newspaper Connector // -------------------------------------------- // Variables var newspaperConnectorDivId; var newspaperConnected = false; /** Embed the Newspaper Connector SWF to the host page. **/ function embedNewspaperConnector(divId) { this.newspaperConnectorDivId = divId; var flashvars = { connectionKey: 'NEWS_473088542', parent:'true', connectCallback : 'onNewspaperConnected', browserVersion : navigator.userAgent, dumpUri : 'http://www.smallworlds.com/swds/gateway' }; var params = { allowScriptAccess: 'always' }; var attributes = { id: newspaperConnectorDivId, name: newspaperConnectorDivId }; swfobject.embedSWF('http://www.smallworlds.com/smallworlds/common/swf/javascriptproxy.swf?rand=rand', newspaperConnectorDivId, '0', '0', '9.0.0','expressInstall.swf', flashvars, params, attributes); } /** Callback on successful connect to the newspaper. **/ function onNewspaperConnected() { newspaperConnected = true; if ('' == '1') pingGoogleAnalytics('/newspaper/loaded/first/'); else pingGoogleAnalytics('/newspaper/loaded/'); } /** A property has been recieved from the child page. **/ function onProperty(property, value) { switch(property) { case "newspaperHeight": setNewspaperHeight( value ); break; case "spaceId": navigateToSpace( value ); break; case "avatarName": navigateToHomespace( value ); break; case "globalAddress": setGlobalAddress( value ); break; case "selectedAvatarChanged": // Function exists in smallworldsjs.php selectedAvatarChanged(value == "true"); break; case "purchaseSubscription": // call OSConnector with the same params sendOSProperty(property, value); break; case "purchaseComplete": // Called from SN and passed to payments sendProperty( property, value ); break; case "closePaymentPages": // Called from subscription status page closePaymentPages(); break; } } /** Received page height so resize elements. **/ function setNewspaperHeight(height) { var iframeElement = document.getElementById("newspaperframe"); iframeElement.style.height = height + "px"; // pass the height up to the Open Social Container var swf = document.getElementById("OpenSocialConnector"); if(swf && (swf.nodeName === "OBJECT" || swf.nodeName === "EMBED")) swf.setIFrameHeight(parseInt(height) + 100); // add extra height for the header } /** Tells the Header swf to call getSpaceAddress, and then call navigateToSpace with the response **/ function navigateToSpace(spaceId) { var swf = document.getElementById('Base'); if (swf) swf.navigateToSpace(spaceId); } /** Tells the Header swf to call getSpaceAddress, and then call navigateToHomespace with the response **/ function navigateToHomespace( avatarName ) { var swf = document.getElementById('Base'); if (swf) swf.navigateToHomespace("http://www.smallworlds.com/home/" + avatarName); } function sendProperty(property, value) { var swf = document.getElementById(newspaperConnectorDivId); if(swf && (swf.nodeName === "OBJECT" || swf.nodeName === "EMBED")) swf.sendProperty(property, value); } // Open Social Connector // -------------------------------------------- // Variables var osConnectorDivId; /** Embed the Open Social Connector SWF to the host page. **/ function embedOpenSocialConnector(divId, osConnectionKey) { this.osConnectorDivId = divId; var flashvars = { connectionKey: osConnectionKey, parent: 'false', connectCallback : 'osConnected', browserVersion : navigator.userAgent, dumpUri : 'http://www.smallworlds.com/swds/gateway' }; var params = { allowScriptAccess: "always" }; swfobject.embedSWF("http://www.smallworlds.com/smallworlds/common/swf/javascriptproxy.swf", osConnectorDivId, "1", "1", "9.0.0","expressInstall.swf", flashvars, params); } /** Callback on successful connect to the network. **/ function osConnected() { setInterval("setApplicationHeight()", 1000); } /** Received page height so pass the height up to the Open Social Container. **/ var socialFrameHeight = 0; function setApplicationHeight() { // pass the height up to the Open Social Container var swf = document.getElementById(osConnectorDivId); var newHeight = document.body.scrollHeight; if(socialFrameHeight != newHeight && swf != null) { socialFrameHeight = newHeight swf.setIFrameHeight(newHeight); } } function sendOSProperty(property, value) { var swf = document.getElementById(osConnectorDivId); if(swf && (swf.nodeName === "OBJECT" || swf.nodeName === "EMBED")) swf.sendProperty(property, value); }