// Header // -------------------------------------------- var headerLoaded = false; /** Callback when header is successfully loaded. **/ function onHeaderLoaded() { headerLoaded = true; } /** Set the user's location base on the URL. */ function setLocation(url) { // Update the location on the header. if (headerLoaded) { var inHomeSpace = false; var inConsole = (url.match("homepage") != null); var inHelp = (url.match("help-tips") != null); document.getElementById("Base").setLocation(inConsole, inHomeSpace, inHelp); } } // Newspaper Connector // -------------------------------------------- // Variables var newspaperConnectorDivId; /** Embed the Newspaper Connector SWF to the host page. **/ function embedNewspaperConnector(divId) { // Depreciated } /** 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 "petActiveChanged": // Function exists in smallworldsjs.php petActiveChanged(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; case "setLocation": setLocation(value); break; case "payByFacebook": // Called from bundle confirm page in payments process. placeOrder(value); } } /** 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 newspaperframe = document.getElementById('newspaperframe'); if (newspaperframe == null) return; newspaperframe.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); }