// Newspaper Connector // -------------------------------------------- // Variables var newspaperHeight = 0; var initted = false; // Timeouts setInterval("sendNewspaperHeight()", 1000); // update the newspaper height every second /** Init */ function init() { sendNewspaperHeight(); setLocation(); initted = true; } window.onload = init; /** Embed the Connector SWF to the child page. **/ function initConnector() { // Deprecated } var retryCount = 0; /** Send page's height to host page for resize pusposes **/ function sendNewspaperHeight() { var marker = document.getElementById('marker'); if (marker == null) return; var newHeight = marker.offsetTop; if (retryCount < 20) { window.parent.onProperty("newspaperHeight", newHeight); retryCount++; } if(newspaperHeight != newHeight) { newspaperHeight = newHeight; retryCount = 0; } } /** Set the user's location based on child page's content. **/ function setLocation() { var url = window.location.href; window.parent.onProperty("setLocation", url); } /** A property has been recieved from the host page. **/ function onProperty(property, value) { switch(property) { case "purchaseComplete": // Function exists in emedding page onPurchaseComplete(); break; } } /** Embed the avatar selector widget. **/ function embedAvatarsWidget(url) { var flashvars = { configUrl: url }; var avatarsParams = { allowScriptAccess: "always", wmode: "transparent" }; swfobject.embedSWF("http://content.smallworlds.com/content-v2985/webassets/homepage/home_panel_avatar.swf", "AvatarSelector", "218", "265", "9.0.0","expressInstall.swf", flashvars, avatarsParams); } /** Embed the orientation XP widget. **/ function embedXpStatusWidget(url) { var flashvars = { configUrl: url }; var avatarsParams = { allowScriptAccess: "always", wmode: "transparent" }; swfobject.embedSWF("http://content.smallworlds.com/content-v2985/webassets/homepage/home_panel_xp.swf", "XpStatus", "218", "150", "9.0.0","expressInstall.swf", flashvars, avatarsParams); } /** User clicked Enter World button. **/ //function enterWorld(address) function setGlobalAddress(address) { // when connected, send request to host page to redirect sendProperty("globalAddress", address); } /** User clicked Enter World button and using community space ID. **/ //change to use enterWorld function navigateToSpace(spaceId) { // when connected, send request to host page to redirect sendProperty("spaceId", spaceId); } /** User clicked Enter World button and is going to newbie space. **/ function navigateToHomespace(avatarName) { // when connected, send request to host page to redirect sendProperty("avatarName", avatarName); } /** User changed their avatar in the avatar selector widget. **/ function selectedAvatarChanged(value) { sendProperty("selectedAvatarChanged", value); } /** User changed pet active in the avatar selector widget. **/ function petActiveChanged(value) { sendProperty("petActiveChanged", value); } /** User clicked Pay by Facebook button in payment process. **/ function payByFacebook(value) { sendProperty("payByFacebook", value); } /** Send a property over the connection to the host page. **/ function sendProperty(property, value) { window.parent.onProperty(property, value); }