From OpenSocial Directory
| Thumbnail
|
|
|
|
|
| Screenshot
|
|
|
|
Image:Example.jpg==Reviews==
Add a Review
Template:Horoscopes Reviews
[edit] Comments
View Code
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Horoscopes" thumbnail="http://apps.rockyou.com/images/opensocial/icons/120x60/zodiac120.jpg" screenshot="http://www.rockyou.com/google_apps/zodiacHoroscopes/content/RYHoroscopesScreenShot.jpg" author="RockYou!" author_email="support@rockyou.com" description="Are the stars aligning for you? Find out with a RockYou horoscope and get regular updates for your sign." author_location="San Mateo, CA" author_affiliation="RockYou!" title_url="http://www.rockyou.com/" directory_title="Horoscopes" summary="" icon="http://apps.rockyou.com/images/opensocial/icons/16x/zodiac16.gif" height="1000" >
<Require feature="dynamic-height" />
<Require feature="opensocial-0.7" />
<Require feature="views" />
</ModulePrefs>
<Content type="html" view="profile">
<![CDATA[
<!-- Generated Mon Apr 14 14:05:57 PDT 2008 -->
<script src="http://opensocial.rockyou.com/google_apps/common/js/scriptaculous/prototype.js" type="text/javascript"></script><div id='ry-canvas-debug'></div>
<div class='page_skin'>
<style>
body{
padding: 0px;
margin: 0px;
}
.hand{
cursor: hand; cursor: pointer;
}
</style>
<div class='body' align='center'>
<div class='mainheader-l'></div><div class='mainheader-m'></div><div class='mainheader-r'></div>
<div style='clear:both;'></div>
<!-- Main Body -->
<div class='mainbody'>
<div class='div-horoscope' id='zodiac_horoscope_profile'>Loading...</div>
</div>
<!-- //Main Body -->
<div style='clear:both;'></div>
<div style='width:300px; background-color:#000' align='center'>
<a href='http://www.rockyou.com/' target='_blank'><img class='hand' style='border:none;' src='http://www.rockyou.com/google_apps/GenericHoroscopes/images/button_logo2.gif'/></a>
<img style='' class='hand' src='http://www.rockyou.com/google_apps/GenericHoroscopes/images/button_viewall2.gif' onclick='goto_canvas_page("zodiacHoroscopesViewAll")'/>
<img class='hand' id='but_getApp' src='http://www.rockyou.com/google_apps/GenericHoroscopes/images/button_createown.gif' onclick='gotoInstallAppPage()'/>
</div>
<div class='mainfooter-l'></div><div class='mainfooter-m'></div><div class='mainfooter-r'></div>
</div>
</div>
<script type="text/javascript">
Array.prototype.toJSON = null;
</script>
<script type="text/javascript">
var viewer_id;
var owner_id;
var url_params = gadgets.util.getUrlParameters();
viewer_id = url_params["gadgetViewer"];
owner_id = url_params["gadgetOwner"];
function goto_canvas_page(page_name)
{
var all_views = gadgets.views.getSupportedViews();
var canvas_view = all_views["canvas"];
var params = { "pagename" : encodeURIComponent(page_name) };
gadgets.views.requestNavigateTo(canvas_view, params);
}
function ry_debug(intext)
{
document.getElementById('ry-canvas-debug').innerHTML += '<br>'+intext;
}
// Define console.log to be empty if firebug is not available
if (typeof(console) == 'undefined')
console = new Object();
if (typeof(console.log) == 'undefined')
console.log = function() { };
// redefine encodeURIComponent to more closely match PHP's rawurlencode
var origEncodeURIComponent = encodeURIComponent;
encodeURIComponent = function(str) {
var escaped_str = origEncodeURIComponent(str);
escaped_str = escaped_str.replace("'", "%27");
return escaped_str;
};
function i18n_template(template, params)
{
// use prototype's template processing
var t = new Template(template);
return t.evaluate(params);
}
function genericJSONRequest(path, callback, opt_param_str)
{
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
var url = "http://opensocial.rockyou.com/" + path;
// console.log(url);
if (opt_param_str != "undefined" && opt_param_str)
url = url + "?" + opt_param_str;
gadgets.io.makeRequest(url, function(response)
{
if (typeof response.data == "undefined")
{
alert("JSON Error: NO Data");
if (response.errors)
{
alert("Errors from server " + response.errors);
}
return;
}
// console.log(response);
data = response.data;
if (data.success == false)
alert("Debug: JSON call failed, error_code=" + data.error_code + ", error_message " + data.error_message);
else
callback(data);
}, params);
}
function genericJSONPost(path, callback, opt_param_str)
{
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
var url = "http://opensocial.rockyou.com/" + path;
if (opt_param_str != "undefined" && opt_param_str)
params[gadgets.io.RequestParameters.POST_DATA] = opt_param_str;
gadgets.io.makeRequest(url, function(response)
{
if (typeof response.data == "undefined")
{
alert("JSON Error: NO Data");
if (response.errors)
{
alert("Errors from server " + response.errors);
}
return;
}
// console.log(response);
data = response.data;
if (data.success == false)
alert("Debug: JSON call failed, error_code=" + data.error_code + ", error_message " + data.error_message);
else
callback(data);
}, params);
}
function postToActivityStream(text, callback, priority, body) {
priority = (typeof(priority) != "undefined") ? priority : opensocial.CreateActivityPriority.LOW;
callback = (typeof(callback) != "undefined") ? callback : defaultActivityCallback;
var params = {};
params[opensocial.Activity.Field.TITLE] = text;
params[opensocial.Activity.Field.BODY] = body;
var activity = opensocial.newActivity(params);
opensocial.requestCreateActivity(activity, priority, callback);
}
function defaultActivityCallback(data) {
//output(data);
}
function ry_debug_response(content, error)
{
ry_debug(content);
debugger;
}
// js equivalent of /includes/trackevent.php
function createTrackEventUrl(event, url, value)
{
if (event == ""){
return url;
}
link = "http://opensocial.rockyou.com/events/track.php?event=" + event;
if ((typeof(value)!="undefined") && (value != ""))
link = link + "&value="+value;
if (url != "")
link = link + "&url=" + encodeURIComponent(url);
return link;
}
// app install tracking
function set_install()
{
// if viewer is not owner we dont even check if this is the first time after installation
if ( owner_id != viewer_id ){
return;
}
// query appdata for the install date
req = opensocial.newDataRequest();
req.add(req.newFetchPersonAppDataRequest("VIEWER","install_date"), "app_data");
req.send(handle_install);
}
function handle_install(data)
{
// debugger;
var do_update = false;
if (data.get("app_data").hadError())
{
do_update = true;
}
else
{
var viewer_data = data.get("app_data").getData();
if ( (viewer_data[viewer_id] == undefined) || (viewer_data[viewer_id].install_date == undefined) ) {
do_update = true;
}
}
if (do_update)
{
genericJSONRequest("google_apps/server/RYAppInstall.php",do_nothing_callback);
// set installation date
var curr_date = new Date();
var data = curr_date.toUTCString();
req = opensocial.newDataRequest();
req.add(req.newUpdatePersonAppDataRequest("VIEWER", "install_date", data), "app_data");
req.send(do_nothing);
}
}
function do_nothing_callback(data){
}
function do_nothing(data){
}
//////////////////
//Horoscope properties
var g_horoscopeType = "zodiac";
var g_arrSigns; //Array of horoscope signs or symbols
var g_arrSkins; //Array of horoscope skins
var g_arrHoroscopeImages = new Array(); //Multi-dimensional array of array of URLs for horoscope images
//To get a certain image, g_arrHoroscopeImages[skinIndex][signIndex]
var g_arrHoroscopeTexts = new Array(); //Array of horoscope texts
var g_arrHoroscopeDates = new Array(); //Array of horoscope dates
var g_horoscopeIndex = 0; //Index in image and texts array of owner's horoscope sign/symbol/etc.
var g_skinIndex = 0; //Index of skin in g_arrHoroscopeTexts (i.e. row index)
//Owner properties
var g_ownerName = "";
var g_ownerContainerID = "";
var g_ownerProfileURLID = "";
var g_owner_bdayMonth = "";
var g_owner_bdayDate = "";
var g_owner_bdayYear = "";
//Phone number data for Frengo horoscope integration (zodiac horoscope only)
var g_mobile_country = 0;
var g_mobile_number = "";
var g_mobile_isOn = true;
//Flags to indicate load completion for queries
var g_isLoaded_OwnerData = false;
var g_isLoaded_HoroscopeTexts = false;
var g_isLoaded_HoroscopeImages = false;
var g_isLoaded_HoroscopeDates = false;
var g_isLoaded_OwnerSignAndSkin = false;
//Current loaded page
var g_currentPage = "";
//URL of "Add application" page
var g_url_addAppPage = "";
//Container-specific flags
var g_autoNotify7Days = false; //Indicates whether a notification should be sent every 7 days (Currently used for Orkut)
var g_containerName = "";
//Friend selector object
var FS = "";
///////////COMMON HOROSCOPE FUNCTIONS//////////
function genericPageInit()
{
//Safety-check: Make sure non-owner does not go to EDIT page
if (g_currentPage == "edit")
{
if (!isOwner()) {
goto_canvas_page("zodiacHoroscopesViewAll");
//Note: ADD PARAMS TO URL TO DISPLAY NO-PERMISSION ERROR MSG
}
}
//Hi5 only: Check to see if this is post-invite install on viewAll page.
//If it is, redirect to the notify-friends page
if (g_currentPage == "viewAll"){
/************
if ("orkut.com" == "hi5.com"){
var prefs = gadgets.views.getParams();
if (typeof(prefs['invites_sent']) != 'undefined') {
goto_canvas_page("genericHoroscopesFriendSelectorPage");
}
else{
//Display viewAll page
document.getElementById('page_viewall').style.display = "";
}
}
else{
//Display viewAll page
document.getElementById('page_viewall').style.display = "";
}
**************/
document.getElementById('page_viewall').style.display = "";
}
//Get container-specific info, such as the URL of
//add-app page for this app for this container
initContainerSpecificVars();
//Hide EDIT tab if not the owner
if (!isOwner() && g_currentPage != "profile") {
document.getElementById('tabEdit_' + g_currentPage).style.display = "none";
document.getElementById('l-tabEdit_' + g_currentPage).style.display = "none";
document.getElementById('r-tabEdit_' + g_currentPage).style.display = "none";
}
//Set links appropriately for each page
var url;
if (g_currentPage == "profile")
{
//url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
//document.getElementById("linkEdit_profile").href = url;
//url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
//document.getElementById("linkViewAll_profile").href = url;
}
else if (g_currentPage == "edit")
{
document.getElementById("linkEdit_edit" ).href = "#";
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_edit").href = url;
//Reset form
//(Prevents global vars being empty issue due to user navigating via BACK button)
document.getElementById('but_reset').click();
}
else if (g_currentPage == "viewAll")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_viewAll").href = url;
document.getElementById("linkViewAll_viewAll").href = "#";
}
else if (g_currentPage == "crossSell")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_crossSell").href = url;
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_crossSell").href = url;
return; //Do not need any data or any dynamic processing on this page.
}
else if (g_currentPage == "crossSell_Hi5")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_crossSell_Hi5").href = url;
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_crossSell_Hi5").href = url;
return; //Do not need any data or any dynamic processing on this page.
}
else if (g_currentPage == "invite")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_invite").href = url;
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_invite").href = url;
return; //Do not need any data or any dynamic processing on this page.
}
//Get owner info from container
getOwnerData();
}
//Calls displayHoroscope() with the appropriate parameters.
function callDisplayHoroscope()
{
if (g_currentPage == "friendselector")
return;
//Only start displaying once all data is done loading.
if (!(g_isLoaded_OwnerData && g_isLoaded_HoroscopeTexts
&& g_isLoaded_HoroscopeImages && g_isLoaded_HoroscopeDates
&& g_isLoaded_OwnerSignAndSkin))
return;
//if "all" is specified, display all horoscopes
if (g_currentPage == "viewAll")
{
displayAllHoroscopes();
}
//Else display single horoscope
else {
var decodedText = g_arrHoroscopeTexts[g_horoscopeIndex];
if (g_horoscopeType != "zodiac")
decodedText = decodeURIComponent(decodedText);
displayHoroscope(g_arrHoroscopeImages[g_skinIndex][g_horoscopeIndex],
decodedText,
g_arrHoroscopeDates[g_horoscopeIndex],
g_ownerName,
"zodiac_horoscope_" + g_currentPage);
}
}
//Displays all Horoscopes. Displays to div "<DIV_HOROSCOPE>_0", "<DIV_HOROSCOPE>_1", ...
function displayAllHoroscopes()
{
var decodedText;
for (var i = 0; i < g_arrHoroscopeTexts.length; ++i)
{
decodedText = g_arrHoroscopeTexts[i];
if (g_horoscopeType != "zodiac")
decodedText = decodeURIComponent(decodedText);
displayHoroscope(g_arrHoroscopeImages[g_skinIndex][i],
decodedText,
g_arrHoroscopeDates[i],
"", //No owner name
"zodiac_horoscope_" + i);
}
//Remove "Loading..." when done loading
document.getElementById("div_loading").style.display = "none";
}
/*
* Displays horoscope to screen.
*
* Params:
* imgUrl - string URL of background image for horoscope for corresponding sign
* text - string of the horoscope text
* datesTxt - string of the dates for this sign
* ownerName - string of the owner's name (EXCLUDING the "'s")
* divName - string ID of DIV to print horoscope to.
*/
function displayHoroscope(imgUrl, text, datesTxt, ownerName, divName)
{
//Only start displaying once all data is done loading.
if (!(g_isLoaded_OwnerData && g_isLoaded_HoroscopeTexts
&& g_isLoaded_HoroscopeImages && g_isLoaded_HoroscopeDates
&& g_isLoaded_OwnerSignAndSkin))
return;
var html = "";
/**********
//Special case for Chinese horoscope -> use old image layout version
//instead of flash until we can create modified flash version
if ("zodiac" == "chinese") {
html += "<div style='float: left;height:163px;width:300px; background:url("+ imgUrl + ") no-repeat;'align='left'>";
html += "<div style='overflow-y:scroll;overflow:-moz-scrollbars-vertical;position:relative;top:80px;margin-left:23px;width:261px;height:65px;font:normal 12px Arial, Helvetica, sans-serif;color:#000' align='left'>";
html += "<div style='width:140px'>" + text + "</div>";
html += "</div>";
html += "</div>";
}
**********/
//Else flash version
//else {
html += "<embed src='" + imgUrl + "' ";
//if (g_currentPage == "profile")
html += "width='300' height='163' align='middle' ";
//else
// html += "width='430' height='190' align='middle' ";
html += "flashvars=\"mytext=" + text + "\" quality='high' allowScriptAccess='sameDomain' ";
html += "type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
//}
//Display on profile page
document.getElementById(divName).innerHTML = html;
}
//Returns true if current viewer is the page owner
function isOwner()
{
return (viewer_id == owner_id);
}
//Initializes values of globals that are container-specific
function initContainerSpecificVars(){
switch("orkut.com"){
case "myspace.com":
//Get URL of Add-App page
g_url_addAppPage = "http://www.myspace.com/ry_horoscopes";
g_autoNotify7Days = false;
g_containerName = "MySpace";
break;
case "orkut.com":
//Get URL of Add-App page
g_url_addAppPage = "AppInfo.aspx?appId=740672099669";
g_autoNotify7Days = true;
g_containerName = "Orkut";
break;
case "hi5.com":
g_supportsActivityStream = false;
g_containerName = "Hi5";
case "www.rockyou.com":
default:
}
}
function getOwnerData()
{
//Get owner's name & ownerID
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('OWNER'), 'owner');
req.send(function(response) {
var owner = response.get('owner').getData();
//Get owner ID
g_ownerContainerID = owner.getId();
//Get and store owner name
g_ownerName = owner.getDisplayName();
//Get owner bday
//Note: Not all containers (for example, Orkut) will give out bday information
var bday = owner.getField(opensocial.Person.Field.DATE_OF_BIRTH);
if (bday)
{
g_owner_bdayMonth = bday.getMonth() + 1; //getMonth returns month as 0 thru 11
g_owner_bdayDate = bday.getDate();
g_owner_bdayYear = bday.getFullYear();
}
g_isLoaded_OwnerData = true; //Indicate that owner data is done loading
//Get bday, sign, and skin info from RY database
genericJSONRequest("google_apps/zodiacHoroscopes/ZodiacHoroscopesLoadFromDB.php" +
"?ownerID=" + encodeURIComponent(g_ownerContainerID) + "&container=" + encodeURIComponent("orkut.com"),
function(response) {
var sign = "";
var skin = "";
var return_data = response['return_data'];
//If owner info exists in DB, use that info
//instead of container's bday info.
if (return_data['hasData'] == "true") {
sign = return_data['sign'];
skin = return_data['skin'];
g_owner_bdayMonth = trimLeadingZeroes(return_data['bday_month']);
g_owner_bdayDate = trimLeadingZeroes(return_data['bday_date']);
g_owner_bdayYear = trimLeadingZeroes(return_data['bday_year']);
}
//If no owner info exists in DB, and if the user is in ViewAll page,
//redirect them to Edit page instead.
//Note: If the user does not have the app installed, it will automatically redirect to
//the default canvas page, which should be the View All page (i.e. no page change occurs)
else if (g_currentPage == "viewAll" && isOwner()) {
goto_canvas_page("zodiacHoroscopesEdit");
}
g_horoscopeIndex = convertSignToIndex(sign);
g_skinIndex = convertSkinNameToIndex(skin);
g_isLoaded_OwnerSignAndSkin = true;
//Get all horoscope texts, image URLs, etc
//Note: Myspace chokes when making opensocial request concurrent
//with JSON requests. Therefore, we have the function calls done here AFTER
//the opensocial request returns.
initArrDates();
initArrSigns();
initArrSkins();
initArrHoroscopeTexts();
initArrImages();
//Attempt to display horoscope (if all params are loaded)
if (g_currentPage != "friendselector"){
callDisplayHoroscope();
}
//Pre-fill form info if it's the edit page
if (g_currentPage == "edit") {
fillEditPageForm();
}
}
);
/**************DEPRECATED**********
//Post to activity stream, if nothing's been posted in the last 7 days
//Note: Used for Orkut only currently
if (g_autoNotify7Days){
genericJSONRequest("google_apps/common/RYOpenSocialActivities.php", function(response){
var return_data = response["return_data"];
var sendActivity = return_data["sendActivity"];
if (sendActivity == "true") {
var stream_title = "";
//Note: No way to control owner vs non-owner activity feed at this point.
//Therefore, non-owner will see name automatically inserted, such as
//"<ownerName> has a new Horoscope!"
//whereas the owner will see, in his My Updates page,
//"has a new Horoscope!" with no name.
stream_title += " has a new Horoscope!";
var stream_body = "<table><tr>";
stream_body += "<td><!--ADD IMG HERE! <img src=\"" + this.emote_icon + "\" style=\"border: 1px solid #CCCCCC;padding: 3px;background-color: #FFFFFF;height:50px;width:50px;\" /> --></td>";
stream_body += "<td style=\"vertical-align:center;\"><span><a href='" + g_url_addAppPage + "' >Go get your own Horoscope!</a></span></td>";
stream_body += "</tr></table>";
//Post to activity stream, then redirect to View All page
postToActivityStream(stream_title, null, opensocial.CreateActivityPriority.HIGH, stream_body);
}
});
}
*****************/
});
}
//Pre-fills form data on EDIT page
function fillEditPageForm()
{
//Fill in hidden owner ID
document.getElementById('ownerId_edit').value = g_ownerContainerID;
//Pre-fill bday info
document.getElementById('bday_month_edit').value = g_owner_bdayMonth;
document.getElementById('bday_date_edit').value = g_owner_bdayDate;
document.getElementById('bday_year_edit').value = g_owner_bdayYear;
//Fill combo boxes
populateSignCB();
//Show skin CB only if more than one skin exists
if (g_arrSkins.length > 1)
populateSkinCB();
}
//Populates and displays sign/symbol combo box.
//Pre-selects value based on current data.
function populateSignCB()
{
//////////////////////////////////////////////////////////////
//Populate sign combo box to the form, with a sign pre-selected
//////////////////////////////////////////////////////////////
var strCBSigns = "<select name='cb_sign' onchange='g_horoscopeIndex = this.value; callDisplayHoroscope();' >";
for (var i = 0; i < g_arrSigns.length; ++i)
{
if (i == g_horoscopeIndex){
strCBSigns += "<option value='" + i + "' selected='true'>" + g_arrSigns[i] + "</option>";
}
else {
strCBSigns += "<option value='" + i + "'>" + g_arrSigns[i] + "</option>";
}
}
strCBSigns += "</select>";
document.getElementById('cb_sign_edit').innerHTML = strCBSigns;
}
//Populates and displays skin combo box.
//Pre-selects value based on current data.
function populateSkinCB()
{
//////////////////////////////////////////////////////////////
//Populate skin combo box to the form, with a sign pre-selected
//////////////////////////////////////////////////////////////
var strCBSkins = "<select name='cb_skin' onchange='g_skinIndex = this.value; callDisplayHoroscope();' >";
for (var i = 0; i < g_arrSkins.length; ++i)
{
if (i == g_skinIndex){
strCBSkins += "<option value='" + i + "' selected='true'>" + g_arrSkins[i] + "</option>";
}
else {
strCBSkins += "<option value='" + i + "'>" + g_arrSkins[i] + "</option>";
}
}
strCBSkins += "</select>";
document.getElementById('cb_skin_edit').innerHTML = strCBSkins;
}
//Validates current form input, prints out any error msgs, and recalculates/redisplays
// new horoscope sign
function validateForm()
{
var errorMsg = "";
if (!IsInteger(g_owner_bdayMonth) || g_owner_bdayMonth < 1 || g_owner_bdayMonth > 12) {
errorMsg = "Month must be an integer between 1 and 12, inclusive.\n";
}
if (!IsInteger(g_owner_bdayDate) || g_owner_bdayDate < 1 || g_owner_bdayDate > 31) {
errorMsg += "Day is invalid.\n";
}
else{
switch(g_owner_bdayMonth) {
case "2":
if (g_owner_bdayDate > 29)
errorMsg += "Day is invalid.\n";
break;
case "4":
case "6":
case "9":
case "11":
if (g_owner_bdayDate > 30)
errorMsg += "Day is invalid.\n";
break;
}
}
var currDate = new Date();
var currYear = currDate.getFullYear();
if (!IsInteger(g_owner_bdayYear) || g_owner_bdayYear < 1900 || g_owner_bdayYear > currYear)
{
errorMsg += "Year is invalid.\n";
}
//Check Frengo phone integration entries (Zodiac horoscopes only)
if ("zodiac" == "zodiac") {
//alert("country=" + g_mobile_country + ", number=" + g_mobile_number + ", length=" + g_mobile_number.length + ",isOn=" + g_mobile_isOn);
//Non-numeric phone number
if (g_mobile_number.length > 0 && !IsInteger(g_mobile_number)){
errorMsg += "Please enter a valid phone number with only numeric digits 0 through 9.\n";
}
//Numeric phone number entered but no country selected
if (g_mobile_country == "0" && g_mobile_number.length > 0 && IsInteger(g_mobile_number)){
errorMsg += "Please select a country.\n";
}
//Else length validation
if (g_mobile_number.length > 0 && g_mobile_number.length < 8) {
errorMsg += "The mobile number you have entered is too short.\n";
}
else if (g_mobile_number.length > 13) {
errorMsg += "The mobile number you have entered is too long.\n";
}
else if (g_mobile_country == "1" && g_mobile_number.length != 10) {
errorMsg += "US phone numbers should be 10 digits.\n";
}
}
if (errorMsg != "") {
document.getElementById("errorMsg_edit").innerHTML = errorMsg;
document.getElementById("errorMsg_edit").style.display ="block";
return false;
}
else {
var url = "google_apps/zodiacHoroscopes/ZodiacHoroscopesSaveToDB.php" +
"?ownerID=" + encodeURIComponent(g_ownerContainerID) +
"&container=" + encodeURIComponent("orkut.com") +
"&bday_month=" + encodeURIComponent(g_owner_bdayMonth) +
"&bday_date=" + encodeURIComponent(g_owner_bdayDate) +
"&bday_year=" + encodeURIComponent(g_owner_bdayYear) +
"&sign=" + encodeURIComponent(g_arrSigns[g_horoscopeIndex]) +
"&skin=" + encodeURIComponent(g_arrSkins[g_skinIndex]);
//Submit to RY database
genericJSONRequest(url,
function(response) {
//Frengo phone messaging (only on zodiac horoscope)
if ("zodiac" == "zodiac") {
if (g_mobile_number.length > 0) {
if (g_mobile_isOn == "1")
mobileNumber = g_mobile_country + g_mobile_number;
else
mobileNumber = ""; //Pass null number to unsubscribe
//alert("sending to frengo: number=" + mobileNumber);
var frengoMobileURL = "google_apps/zodiacHoroscopes/ZodiacHoroscopesSendToFrengo.php"
+ "?number=" + encodeURIComponent(mobileNumber)
+ "&sign=" + encodeURIComponent(g_arrSigns[g_horoscopeIndex])
+ "&container=" + encodeURIComponent(g_containerName)
+ "&uid=" + encodeURIComponent(g_ownerContainerID);
//alert(frengoMobileURL);
//Submit mobile number to Frengo
genericJSONRequest(frengoMobileURL,
function(response) {
//Do nothing? Error checks?
}
);
}
else{
//alert("NOT SENDING TO FRENGO"); //TEST!
}
}
//Send Notification + Activity Stream
//If Hi5, go to NOTIFICATION (friend selector) page
if ("orkut.com" == "hi5.com") {
//opensocial.requestShareApp(opensocial.DataRequest.Group.VIEWER_FRIENDS,opensocial.newMessage("Whose horoscopes do you want to see?"));
goto_canvas_page("genericHoroscopesFriendSelectorPage");
}
//Else call viral services directly
else{
callViralServices("");
}
}
);
}
}
function callViralServices(friendIDs)
{
if ("orkut.com" == "hi5.com"){
makeViralJSONRequest(friendIDs);
}
else {
makeViralJSONRequest("");
}
}
function makeViralJSONRequest(friendIDs){
var viralURL = "google_apps/zodiacHoroscopes/ZodiacHoroscopesViralService.php";
viralURL += "?ownerName=" + encodeURIComponent(g_ownerName);
viralURL += "&sign=" + encodeURIComponent(g_arrSigns[g_horoscopeIndex]);
viralURL += "&friends=" + friendIDs;
genericJSONRequest(viralURL,
function(response){
//If Myspace, redirect to Invite page
if ("orkut.com" == "myspace.com") {
goto_canvas_page("zodiacHoroscopesInvite?isUpdated=true");
}
//Else if Hi5, redirect to Hi5 Cross sell
else if ("orkut.com" == "hi5.com"){
goto_canvas_page("zodiacHoroscopesCrossSell_Hi5");
}
//Else if Orkut redirect to regular Cross Sell page
else if ("orkut.com" == "orkut.com"){
goto_canvas_page("zodiacHoroscopesCrossSell");
}
//Else default
else{
goto_canvas_page("zodiacHoroscopesViewAll");
}
}
);
}
//Recalculates and redisplays horoscope sign/symbol based on current bday entered
function recalculateAndRedisplayHoroscope()
{
var index = convertBirthdayToSignIndex();
if (index >= 0) {
g_horoscopeIndex = index;
populateSignCB();
callDisplayHoroscope();
}
}
//Initializes array of sign/symbol names
function initArrSigns()
{
g_arrSigns = new Array("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo",
"Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces");
}
//Initializes array of skin names
function initArrSkins()
{
g_arrSkins = new Array("Mystic", "Symbolic");
}
//Grabs all horoscope texts from database
function initArrHoroscopeTexts()
{
g_arrHoroscopeTexts.length = 0; //Clears array
//Make JSON call to function that retrieves all horoscope texts
var sourceURL = encodeURIComponent("http://data.rockyou.com/astrology/dailyzodiac.xml");
genericJSONRequest("google_apps/zodiacHoroscopes/ZodiacHoroscopes_GetFromXML.php" + "?url=" + sourceURL,
function(response) {
var return_data = response['return_data'];
g_arrHoroscopeTexts = return_data['arrHoroscopeTexts'];
//Indicate that horoscope texts are done loading
g_isLoaded_HoroscopeTexts = true;
//Attempt to display horoscope (if all params are loaded)
callDisplayHoroscope();
}
);
}
/*
*Fill in image URLs for array of horoscope images.
*/
function initArrImages()
{
var ext = "";
//if (g_currentPage == "profile")
ext = "300";
//else
//ext = "430";
g_arrHoroscopeImages.length = 0; //Clears global 2-D array
////////////////////SKIN 0//////////////////////////
//Initialize array of images for first skin
g_arrImagesSkin_0.length = 0; //Clear skin0 array
var skin0ImgPath = "http://apps.rockyou.com/images/opensocial/zodiacHoroscopes/content/mystic/";
g_arrImagesSkin_0.push(skin0ImgPath + "aries" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "taurus" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "gemini" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "cancer" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "leo" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "virgo" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "libra" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "scorpio" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "sagittarius" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "capricorn" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "aquarius" + ext + ".swf");
g_arrImagesSkin_0.push(skin0ImgPath + "pisces" + ext + ".swf");
g_arrHoroscopeImages.push(g_arrImagesSkin_0); //Push onto global 2-D array
///////////////////SKIN 1/////////////////////////////////
g_arrImagesSkin_1.length = 0; //Clear skin0 array
var skin1ImgPath = "http://apps.rockyou.com/images/opensocial/zodiacHoroscopes/content/symbolic/";
g_arrImagesSkin_1.push(skin1ImgPath + "aries-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "taurus-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "gemini-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "cancer-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "leo-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "virgo-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "libra-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "scorpio-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "sagittarius-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "capricorn-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "aquarius-symbolic" + ext + ".swf");
g_arrImagesSkin_1.push(skin1ImgPath + "pisces-symbolic" + ext + ".swf");
g_arrHoroscopeImages.push(g_arrImagesSkin_1); //Push onto global 2-D array
//Indicate that image URLs are done loading
g_isLoaded_HoroscopeImages = true;
//Attempt to display horoscope (if all params are loaded)
callDisplayHoroscope();
}
/*
* Fill array of dates (or some other info) pertaining to each sign/symbol.
*/
function initArrDates()
{
g_arrHoroscopeDates.length = 0; //Clear array
g_arrHoroscopeDates.push("March 21 ~ April 20");
g_arrHoroscopeDates.push("April 21 ~ May 21");
g_arrHoroscopeDates.push("May 22 ~ June 21");
g_arrHoroscopeDates.push("June 22 ~ July 23");
g_arrHoroscopeDates.push("July 24 ~ August 23");
g_arrHoroscopeDates.push("August 24 ~ September 23");
g_arrHoroscopeDates.push("September 24 ~ October 23");
g_arrHoroscopeDates.push("October 24 ~ November 22");
g_arrHoroscopeDates.push("November 23 ~ December 21");
g_arrHoroscopeDates.push("December 22 ~ January 20");
g_arrHoroscopeDates.push("January 21 ~ February 19");
g_arrHoroscopeDates.push("February 20 ~ March 20");
g_isLoaded_HoroscopeDates = true;
//Attempt to display horoscope (if all params are loaded)
callDisplayHoroscope();
}
/*
* Trims any leading '0' chars from string.
* Params:
* s - String to trim 0's from.
*/
function trimLeadingZeroes(s) {
while (s.substr(0,1) == '0' && s.length>1) { s = s.substr(1,9999); }
return s;
}
/*
* Returns true if sText is an integer.
* Param:
* sText - a string
*/
function IsInteger(sText)
{
var validChars = "0123456789";
var ch;
if (sText.length < 1)
return false;
for (i = 0; i < sText.length; i++)
{
ch = sText.charAt(i);
if (validChars.indexOf(ch) == -1)
{
return false;
}
}
return true;
}
/*
* Trims any leading and trailing whitespace from str.
* Params:
* str - a string
*/
function trim(str) {
str.replace(/^\s*/, '').replace(/\s*$/, '');
return str;
}
/*
*Copies text to clipboard.
*If not IE, then use hidden flash file to allow clipboard copy.
*Source: http://webchicanery.com/2006/11/14/clipboard-copy-javascript/
*/
function copyToClipboard(copytext) {
if (window.clipboardData) {
window.clipboardData.setData("Text",copytext);
} else {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="http://www.rockyou.com/google_apps/GenericHoroscopes/swf/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(copytext)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
}
}
//Go to app install page
var gotoInstallAppPage = function()
{
switch("orkut.com"){
case "myspace.com":
top.location.href='http://www.myspace.com/ry_horoscopes';
break;
case "orkut.com":
//parent.window.location='http://www.orkut.com/AppInfo.aspx?appId=740672099669';
top.location.href='http://www.orkut.com/' + g_url_addAppPage;
break;
case "hi5.com":
top.location.href='http://www.hi5.com/friend/apps/entry/opensocial.rockyou.com/google_apps/zodiacHoroscopes/ZodiacHoroscopes_hi5_XML.php';
break;
case "www.rockyou.com":
default:
}
}
var g_arrImagesSkin_0 = new Array(); //Array of img URLs for first skin
var g_arrImagesSkin_1 = new Array();
function convertSignToIndex(sign)
{
switch(sign)
{
case "aries":
case "Aries":
return 0;
case "taurus":
case "Taurus":
return 1;
case "gemini":
case "Gemini":
return 2;
case "cancer":
case "Cancer":
return 3;
case "leo":
case "Leo":
return 4;
case "virgo":
case "Virgo":
return 5;
case "libra":
case "Libra":
return 6;
case "scorpio":
case "Scorpio":
return 7;
case "sagittarius":
case "Sagittarius":
return 8;
case "capricorn":
case "Capricorn":
return 9;
case "aquarius":
case "Aquarius":
return 10;
case "pisces":
case "Pisces":
return 11;
default:
return 0;
}
}
function convertBirthdayToSign()
{
switch(convertBirthdayToSignIndex())
{
case 0:
return "Aries";
case 1:
return "Taurus";
case 2:
return "Gemini";
case 3:
return "Cancer";
case 4:
return "Leo";
case 5:
return "Virgo";
case 6:
return "Libra";
case 7:
return "Scorpio";
case 8:
return "Sagittarius";
case 9:
return "Capricorn";
case 10:
return "Aquarius";
case 11:
return "Pisces";
default:
return "Aries";
}
}
function convertBirthdayToSignIndex()
{
if (g_owner_bdayMonth < 1 || g_owner_bdayMonth > 12)
{
return -1; //error
}
else if (g_owner_bdayMonth == 1)
{
if (g_owner_bdayDate < 21 && g_owner_bdayDate > 0)
{
return 9; //return "capricorn";
}
else if (g_owner_bdayDate >= 21 && g_owner_bdayDate <= 31)
{
return 10; //return "aquarius";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 2)
{
if (g_owner_bdayDate < 20 && g_owner_bdayDate > 0)
{
return 10; //return "aquarius";
}
else if (g_owner_bdayDate >= 20 && g_owner_bdayDate <= 29)
{
return 11; //return "pisces";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 3)
{
if (g_owner_bdayDate < 21 && g_owner_bdayDate > 0)
{
return 11; //return "pisces";
}
else if (g_owner_bdayDate >= 21 && g_owner_bdayDate <= 31)
{
return 0; //return "aries";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 4)
{
if (g_owner_bdayDate < 21 && g_owner_bdayDate > 0)
{
return 0; //return "aries";
}
else if (g_owner_bdayDate >= 21 && g_owner_bdayDate <= 30)
{
return 1; //return "taurus";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 5)
{
if (g_owner_bdayDate < 22 && g_owner_bdayDate > 0)
{
return 1; //return "taurus";
}
else if (g_owner_bdayDate >= 22 && g_owner_bdayDate <= 31)
{
return 2; //return "gemini";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 6)
{
if (g_owner_bdayDate < 22 && g_owner_bdayDate > 0)
{
return 2; //return "gemini";
}
else if (g_owner_bdayDate >= 22 && g_owner_bdayDate <= 30)
{
return 3; //return "cancer";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 7)
{
if (g_owner_bdayDate < 24 && g_owner_bdayDate > 0)
{
return 3; //return "cancer";
}
else if (g_owner_bdayDate >= 24 && g_owner_bdayDate <= 31)
{
return 4; //return "leo";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 8)
{
if (g_owner_bdayDate < 24 && g_owner_bdayDate > 0)
{
return 4; //return "leo";
}
else if (g_owner_bdayDate >= 24 && g_owner_bdayDate <= 31)
{
return 5; //return "virgo";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 9)
{
if (g_owner_bdayDate < 24 && g_owner_bdayDate > 0)
{
return 5; //return "virgo";
}
else if (g_owner_bdayDate >= 24 && g_owner_bdayDate <= 30)
{
return 6; //return "libra";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 10)
{
if (g_owner_bdayDate < 24 && g_owner_bdayDate > 0)
{
return 6; //return "libra";
}
else if (g_owner_bdayDate >= 21 && g_owner_bdayDate <= 31)
{
return 7; //return "scorpio";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 11)
{
if (g_owner_bdayDate < 23 && g_owner_bdayDate > 0)
{
return 7; //return "scorpio";
}
else if (g_owner_bdayDate >= 23 && g_owner_bdayDate <= 30)
{
return 8; //return "sagittarius";
}
else
return -1; //error
}
else if (g_owner_bdayMonth == 12)
{
if (g_owner_bdayDate < 22 && g_owner_bdayDate > 0)
{
return 8; //return "sagittarius";
}
else if (g_owner_bdayDate >= 22 && g_owner_bdayDate <= 31)
{
return 9; //return "capricorn";
}
else
return -1; //error
}
}
function convertSkinNameToIndex(skin)
{
switch(skin)
{
case "Mystic":
case "mystic":
return 0;
case "Symbolic":
case "symbolic":
return 1;
default:
return 0;
}
}
var zodiacHoroscopesProfilePage = {
init : function() {
g_currentPage = "profile";
//Set window height
var currContainer = "orkut.com";
if (currContainer == "myspace.com")
{
gadgets.window.adjustHeight(190);
;
}
else if (currContainer == "orkut.com")
{
gadgets.window.adjustHeight(191);
}
else
{
gadgets.window.adjustHeight(190);
}
genericPageInit();
}
}
gadgets.util.registerOnLoadHandler(zodiacHoroscopesProfilePage.init.bind(zodiacHoroscopesProfilePage));
</script>
]]>
</Content>
<Content type="html" view="canvas">
<![CDATA[
<!-- Generated Mon Apr 14 14:05:57 PDT 2008 -->
<div id='ry-canvas-debug'></div>
<script src="http://opensocial.rockyou.com/google_apps/common/js/scriptaculous/prototype.js" type="text/javascript"></script>
<link href="http://opensocial.rockyou.com/google_apps/common/friendselector.css?v=20080403" rel="stylesheet" type="text/css"><script type="text/javascript">
Array.prototype.toJSON = null;
</script>
<div id='canvas-zodiacHoroscopesViewAll-id' style='display: none;'>
<style>
.viewAllBody {
overflow-x: hidden;
overflow-y: scroll;
height: 1000px;
}
</style>
<link href="http://www.rockyou.com/google_apps/GenericHoroscopes/styles-orkut.com.css" rel="stylesheet" type="text/css">
<div class='viewAllBody' id='page_viewall' style='display:none;'>
<div class='body'>
<!-- Tab Menu -->
<div class='tabmenu'>
<div class='l-inactive' id='l-tabEdit_viewAll'></div><div class='tabinactive' id='tabEdit_viewAll'><p><a href="#" id="linkEdit_viewAll">Edit</a></p></div><div class='r-inactive' id='r-tabEdit_viewAll'></div>
<div class='l-active'></div><div class='tabactive'><p><span id="linkViewAll_viewAll">View All</span></p></div><div class='r-active'></div>
</div>
<!-- // Tab Menu -->
<div class='mainheader-l'></div><div class='mainheader-m'></div><div class='mainheader-r'></div>
<div class='mainbodyviewall' align='center'>
<!-- Main Body -->
<div class='errorviewall' id='errorMsg_viewAll' style='display:none;'></div><br />
<div id='div_loading'>Loading...</div>
<span id='zodiac_horoscope_0'></span>
<span id='zodiac_horoscope_1'></span>
<span id='zodiac_horoscope_2'></span>
<span id='zodiac_horoscope_3'></span>
<span id='zodiac_horoscope_4'></span>
<span id='zodiac_horoscope_5'></span>
<span id='zodiac_horoscope_6'></span>
<span id='zodiac_horoscope_7'></span>
<span id='zodiac_horoscope_8'></span>
<span id='zodiac_horoscope_9'></span>
<span id='zodiac_horoscope_10'></span>
<span id='zodiac_horoscope_11'></span>
<div>
<a id='linkInvite' style='font-size: 12px;' href='javascript:goto_canvas_page("zodiacHoroscopesInvite");'>Invite other friends to use Horoscopes!</a>
</div>
<br /><br />
<div class='copyright'>© 2008 RockYou!</div><br />
</div> <!-- end mainbody -->
<div class='mainfooter-l'></div><div class='mainfooter-m'></div><div class='mainfooter-r'></div>
</div>
</div>
</div>
<div id='canvas-zodiacHoroscopesEdit-id' style='display: none;'>
<link href="http://www.rockyou.com/google_apps/GenericHoroscopes/styles-orkut.com.css" rel="stylesheet" type="text/css">
<div class='body'>
<!-- Tab Menu -->
<div class='tabmenu'>
<div class='l-active' id='l-tabEdit'></div><div class='tabactive' id='tabEdit_edit'><p><span id="linkEdit_edit">Edit</span></p></div><div class='r-active' id='r-tabEdit_edit'></div>
<div class='l-inactive'></div><div class='tabinactive'><p><a href="#" id="linkViewAll_edit">View All</a></p></div><div class='r-inactive'></div>
</div>
<!-- // Tab Menu -->
<div class='mainheader-l'></div><div class='mainheader-m'></div><div class='mainheader-r'></div>
<div class='mainbody'>
<!-- Main Body -->
<div class='subsection'>
<div class='subheader-l'></div><div class='subheader-m'></div><div class='subheader-r'></div><div style='clear:both'></div>
<div class='subbody'>
<form name='form-zodiac_horoscope' action='' onsubmit='validateForm(); return false;'>
<div class='error' id='errorMsg_edit' style='display:none;' ></div>
<div class='form'>
<input type='hidden' name='owner_id' id='ownerId_edit' value='' />
<h1 class="birthdaytitle">Your Birthday</h1>
<div class="month"><p><input id ='bday_month_edit' type='text' maxlength='2' onchange='g_owner_bdayMonth = trim(trimLeadingZeroes(this.value)); recalculateAndRedisplayHoroscope();' /><br>Month</p></div>
<div class="date"><p><input id ='bday_date_edit' name='' type='text' maxlength='2' onchange='g_owner_bdayDate = trim(trimLeadingZeroes(this.value)); recalculateAndRedisplayHoroscope();' /><br />Date</p></div>
<div class="year"><p><input id ='bday_year_edit' name='' type='text' maxlength='4' onchange='g_owner_bdayYear = trim(trimLeadingZeroes(this.value)); recalculateAndRedisplayHoroscope();' /><br />Year</p></div>
<div style='clear:both'></div>
<h1 class="zodiactitle">Your Zodiac Sign</h1>
<div id='cb_sign_edit'>
<select></select>
</div>
<h1 class="chooseskintitle">Choose Skin</h1>
<div id='cb_skin_edit'>
<select></select>
</div>
<h1 class='mobiletitle'>Get FREE Horoscopes <br/>sent to your phone!</h1>
<h2 class='mobilesubtitle'>Mobile Number:</h2>
<div class='mobilecountry'>
<select style="margin-bottom: 5px;" name="cb_mobilecountry" onchange='g_mobile_country=this.value;'>
<option value="0">Select country</option>
<option value="1" >USA (+1)</option>
<option value="44">UK (+44)</option>
<option value="43">Austria (+43)</option>
<option value="375">Belarus (+375)</option>
<option value="55">Brazil (+55)</option>
<option value="359">Bulgaria (+359)</option>
<option value="385">Croatia (+385)</option>
<option value="420">Czech Republic (+420)</option>
<option value="45">Denmark (+45)</option>
<option value="372">Estonia (+372)</option>
<option value="679">Fiji (+679)</option>
<option value="49">Germany (+49)</option>
<option value="233">Ghana (+233)</option>
<option value="30">Greece (+30)</option>
<option value="91">India (+91)</option>
<option value="39">Italy (+39)</option>
<option value="7">Kazakhstan/Russia (+7)</option>
<option value="254">Kenya (+254)</option>
<option value="60">Malaysia (+60)</option>
<option value="960">Maldives (+960)</option>
<option value="47">Norway (+47)</option>
<option value="92">Pakistan (+92)</option>
<option value="63">Philippines (+63)</option>
<option value="48">Poland (+48)</option>
<option value="65">Singapore (+65)</option>
<option value="386">Slovenia (+386)</option>
<option value="255">Tanzania (+255)</option>
<option value="868">Trinidad (+868)</option>
<option value="256">Uganda (+256)</option>
<option value="380">Ukraine (+380)</option>
</select>
</div>
<div class='mobilenumber'>
<input type='text' id='text_mobilenumber' onchange='g_mobile_number = trim(trimLeadingZeroes(this.value));' /><br />
Ex:<br /> USA - 6501234567,<br /> INDIA - 9845012345,<br /> UK - 787011234
</div>
<div class='mobileradio'>
<h2>Messages to phone: </h2>
<input type='radio' name='radio_mobile' value='1' checked onclick='g_mobile_isOn = true;' value='On'>On</input>
<input type='radio' name='radio_mobile' value='0' onclick='g_mobile_isOn = false;' value='Off'>Off</input>
<br />(To unsubscribe, enter your phone number and select "Off")
</div>
<div style='display:none;'><input type='reset' id='but_reset' /></div>
<br />
<br />
<input type='submit' value='Submit' class="nextbutton hand" ><img src='http://www.rockyou.com/google_apps/GenericHoroscopes/images/button-next.gif' /></input>
</div>
</form>
</div><!-- end subbody -->
<div class='subfooter-l'></div><div class='subfooter-m'></div><div class='subfooter-r'></div><div style='clear:both;margin-bottom:10px'></div>
</div><!-- end subsection -->
<div class='horoscope'>
<div id='zodiac_horoscope_edit'>Loading...</div>
</div>
<!-- //Main Body -->
<div style='clear:both'></div>
<div class='copyright'>© 2008 RockYou!</div>
</div> <!-- end mainbody -->
<div class='mainfooter-l'></div><div class='mainfooter-m'></div><div class='mainfooter-r'></div>
</div>
</div>
<div id='canvas-zodiacHoroscopesCrossSell-id' style='display: none;'>
<style>
.crossSellBody {
overflow-x: hidden;
overflow-y: hidden;;
height: 1000px;
}
</style>
<link href="http://www.rockyou.com/google_apps/GenericHoroscopes/styles-orkut.com.css" rel="stylesheet" type="text/css">
<div class='crossSellBody'>
<div class='body'>
<!-- Tab Menu -->
<div class='tabmenu'>
<div class='l-inactive' id='l-tabEdit_crossSell'></div><div class='tabinactive' id='tabEdit_crossSell'><p><a href="#" id="linkEdit_crossSell">Edit</a></p></div><div class='r-inactive' id='r-tabEdit_crossSell'></div>
<div class='l-inactive'></div><div class='tabinactive'><p><a href="#" id="linkViewAll_crossSell">View All</a></p></div><div class='r-inactive'></div>
</div>
<!-- // Tab Menu -->
<div class='mainheader-l'></div><div class='mainheader-m'></div><div class='mainheader-r'></div>
<div class='mainbodyviewall' align='center'>
<!-- Main Body -->
<iframe src='http://www.rockyou.com/ams/cross_sell_iframe.php?placeguid=55D9121901' style='width: 90%; height: 500px; border:none;'></iframe>
<div class='copyright'>© 2008 RockYou!</div><br />
</div> <!-- end mainbody -->
<div class='mainfooter-l'></div><div class='mainfooter-m'></div><div class='mainfooter-r'></div>
</div>
</div>
</div>
<div id='canvas-zodiacHoroscopesInvite-id' style='display: none;'>
<link href="http://www.rockyou.com/google_apps/GenericHoroscopes/styles-orkut.com.css" rel="stylesheet" type="text/css">
<div class='body'>
<!-- Tab Menu -->
<div class='tabmenu'>
<div class='l-inactive' id='l-tabEdit_invite'></div><div class='tabinactive' id='tabEdit_invite'><p><a href="#" id="linkEdit_invite">Edit</a></p></div><div class='r-inactive' id='r-tabEdit_invite'></div>
<div class='l-inactive'></div><div class='tabinactive'><p><a href="#" id="linkViewAll_invite">View All</a></p></div><div class='r-inactive'></div>
</div>
<!-- // Tab Menu -->
<div class='mainheader-l'></div><div class='mainheader-m'></div><div class='mainheader-r'></div>
<div class='mainbody' align='center'>
<div style="clear:both;"></div>
<div class='errorinvite' id='errorMsg_invite' style='color:red; display:none;'></div><br />
<!-- COPY THIS SECTION FOR INVITE CONTENT -->
<div>
<table>
<tr>
<td width='40%'><span align='center' style='font-size: x-large;'>Share Horoscopes with your friends!</span></td>
<td width='60%'>
<div style='padding-left:20px;'>
<textarea id='invite_text' disabled='true' rows='5' cols='40' value=''></textarea><br />
<!-- <input type="button" id="but_copy" onclick="copyToClipboard(document.getElementById('invite_text').value);" value='Copy to Clipboard'/> -->
<br /><br />
<input type="button" id="but_bulletin" onclick="copyToClipboard(document.getElementById('invite_text').value); window.open('http://bulletins.myspace.com/index.cfm?fuseaction=bulletin', 'Bulletins','top=200, screenY=200, scrollbars=yes, resizable=yes');" value="Copy to Clipboard and Open Bulletin"/>
</div>
</td>
</tr>
</table>
<!-- <div><input type="button" id="but_comments" onclick="window.open(url, 'Comments','top=200, screenY=200, scrollbars=yes, resizable=yes');" value="Open Comments"/> </div> -->
</div>
<!-- END INVITE CONTENT -->
<!-- Main Body -->
<div class='copyright'>© 2008 RockYou!</div><br />
</div> <!-- end mainbody -->
<div class='mainfooter-l'></div><div class='mainfooter-m'></div><div class='mainfooter-r'></div>
</div>
</div>
<div id='canvas-zodiacHoroscopesCrossSell_Hi5-id' style='display: none;'>
<style>
.crossSellBody {
overflow-x: hidden;
overflow-y: hidden;
height: 1000px;
}
</style>
<link href="http://www.rockyou.com/google_apps/GenericHoroscopes/styles-orkut.com.css" rel="stylesheet" type="text/css">
<div class='crossSellBody'>
<div class='body'>
<!-- Tab Menu -->
<div class='tabmenu'>
<div class='l-inactive' id='l-tabEdit_crossSell_Hi5'></div><div class='tabinactive' id='tabEdit_crossSell_Hi5'><p><a href="#" id="linkEdit_crossSell_Hi5">Edit</a></p></div><div class='r-inactive' id='r-tabEdit_crossSell_Hi5'></div>
<div class='l-inactive'></div><div class='tabinactive'><p><a href="#" id="linkViewAll_crossSell_Hi5">View All</a></p></div><div class='r-inactive'></div>
</div>
<!-- // Tab Menu -->
<div class='mainheader-l'></div><div class='mainheader-m'></div><div class='mainheader-r'></div>
<div class='mainbodyviewall' align='center'>
<!-- Main Body -->
<iframe id='iframe_crosssell_Hi5' src='http://www.rockyou.com/ams/cross_sell_iframe.php?placeguid=C307721687' style='width: 90%; height: 800px; border:none; overflow:hidden;' ></iframe>
<div class='copyright'>© 2008 RockYou!</div><br />
</div> <!-- end mainbody -->
<div class='mainfooter-l'></div><div class='mainfooter-m'></div><div class='mainfooter-r'></div>
</div>
</div>
</div>
<div id='canvas-genericHoroscopesFriendSelectorPage-id' style='display: none;'>
<link href="http://www.rockyou.com/google_apps/GenericHoroscopes/styles-orkut.com.css" rel="stylesheet" type="text/css">
<h2>Choose friends to share your horoscope with!</h2>
<div id='div-friendselector'></div><br />
<input type='submit' value='Tell your friends!' onclick='FS.submit();'></input>
</div>
<script type="text/javascript">
var thispage;
var viewer_id;
var owner_id;
function ry_init()
{
var url_params = gadgets.util.getUrlParameters();
viewer_id = url_params["gadgetViewer"];
owner_id = url_params["gadgetOwner"];
var default_page = "zodiacHoroscopesViewAll";
if (viewer_id == owner_id) {
$$('.owner-only').invoke('show');
set_install();
} else {
$$('.viewer-only').invoke('show');
}
var prefs = gadgets.views.getParams();
var page_params = {};
if (typeof(prefs["pagename"]) == "undefined")
{
curr_page = default_page;
}
else {
var page_url = prefs['pagename'];
var page_url_parts = page_url.split("?");
var curr_page = page_url_parts[0];
curr_page = curr_page.replace(/.php/i, "");
if (page_url_parts.length > 1) page_params = page_url_parts[1].toQueryParams(); // map of query parameters
}
switch (curr_page)
{
case "zodiacHoroscopesViewAll":
zodiacHoroscopesViewAllPage.init(page_params);
thispage = zodiacHoroscopesViewAllPage;
document.getElementById('canvas-zodiacHoroscopesViewAll-id').style.display='';
break;
case "zodiacHoroscopesEdit":
zodiacHoroscopesEditPage.init(page_params);
thispage = zodiacHoroscopesEditPage;
document.getElementById('canvas-zodiacHoroscopesEdit-id').style.display='';
break;
case "zodiacHoroscopesCrossSell":
zodiacHoroscopesCrossSellPage.init(page_params);
thispage = zodiacHoroscopesCrossSellPage;
document.getElementById('canvas-zodiacHoroscopesCrossSell-id').style.display='';
break;
case "zodiacHoroscopesInvite":
zodiacHoroscopesInvitePage.init(page_params);
thispage = zodiacHoroscopesInvitePage;
document.getElementById('canvas-zodiacHoroscopesInvite-id').style.display='';
break;
case "zodiacHoroscopesCrossSell_Hi5":
zodiacHoroscopesCrossSellPage_Hi5.init(page_params);
thispage = zodiacHoroscopesCrossSellPage_Hi5;
document.getElementById('canvas-zodiacHoroscopesCrossSell_Hi5-id').style.display='';
break;
case "genericHoroscopesFriendSelectorPage":
genericHoroscopesFriendSelectorPage.init(page_params);
thispage = genericHoroscopesFriendSelectorPage;
document.getElementById('canvas-genericHoroscopesFriendSelectorPage-id').style.display='';
break;
default:
if (viewer_id == owner_id) {
zodiacHoroscopesViewAllPage.init(page_params);
thispage = zodiacHoroscopesViewAllPage;
document.getElementById('canvas-zodiacHoroscopesViewAll-id').style.display='';
} else {
zodiacHoroscopesViewAllPage.init(page_params);
thispage = zodiacHoroscopesViewAllPage;
document.getElementById('canvas-zodiacHoroscopesViewAll-id').style.display='';
}
break;
}
}
function goto_canvas_page(page_name)
{
var all_views = gadgets.views.getSupportedViews();
var canvas_view = all_views["canvas"];
var params = { "pagename" : encodeURIComponent(page_name) };
gadgets.views.requestNavigateTo(canvas_view, params);
}
function goto_profile_page()
{
var all_views = gadgets.views.getSupportedViews();
var profile_view = all_views["profile"];
gadgets.views.requestNavigateTo(profile_view, {});
}
function ry_debug(intext)
{
document.getElementById('ry-canvas-debug').innerHTML += '<br>'+intext;
}
// Define console.log to be empty if firebug is not available
if (typeof(console) == 'undefined')
console = new Object();
if (typeof(console.log) == 'undefined')
console.log = function() { };
// redefine encodeURIComponent to more closely match PHP's rawurlencode
var origEncodeURIComponent = encodeURIComponent;
encodeURIComponent = function(str) {
var escaped_str = origEncodeURIComponent(str);
escaped_str = escaped_str.replace("'", "%27");
return escaped_str;
};
function i18n_template(template, params)
{
// use prototype's template processing
var t = new Template(template);
return t.evaluate(params);
}
function genericJSONRequest(path, callback, opt_param_str)
{
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
var url = "http://opensocial.rockyou.com/" + path;
// console.log(url);
if (opt_param_str != "undefined" && opt_param_str)
url = url + "?" + opt_param_str;
gadgets.io.makeRequest(url, function(response)
{
if (typeof response.data == "undefined")
{
alert("JSON Error: NO Data");
if (response.errors)
{
alert("Errors from server " + response.errors);
}
return;
}
// console.log(response);
data = response.data;
if (data.success == false)
alert("Debug: JSON call failed, error_code=" + data.error_code + ", error_message " + data.error_message);
else
callback(data);
}, params);
}
function genericJSONPost(path, callback, opt_param_str)
{
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
var url = "http://opensocial.rockyou.com/" + path;
if (opt_param_str != "undefined" && opt_param_str)
params[gadgets.io.RequestParameters.POST_DATA] = opt_param_str;
gadgets.io.makeRequest(url, function(response)
{
if (typeof response.data == "undefined")
{
alert("JSON Error: NO Data");
if (response.errors)
{
alert("Errors from server " + response.errors);
}
return;
}
// console.log(response);
data = response.data;
if (data.success == false)
alert("Debug: JSON call failed, error_code=" + data.error_code + ", error_message " + data.error_message);
else
callback(data);
}, params);
}
function postToActivityStream(text, callback, priority, body) {
priority = (typeof(priority) != "undefined") ? priority : opensocial.CreateActivityPriority.LOW;
callback = (typeof(callback) != "undefined") ? callback : defaultActivityCallback;
var params = {};
params[opensocial.Activity.Field.TITLE] = text;
params[opensocial.Activity.Field.BODY] = body;
var activity = opensocial.newActivity(params);
opensocial.requestCreateActivity(activity, priority, callback);
}
function defaultActivityCallback(data) {
//output(data);
}
function ry_debug_response(content, error)
{
ry_debug(content);
debugger;
}
// js equivalent of /includes/trackevent.php
function createTrackEventUrl(event, url, value)
{
if (event == ""){
return url;
}
link = "http://opensocial.rockyou.com/events/track.php?event=" + event;
if ((typeof(value)!="undefined") && (value != ""))
link = link + "&value="+value;
if (url != "")
link = link + "&url=" + encodeURIComponent(url);
return link;
}
// app install tracking
function set_install()
{
// if viewer is not owner we dont even check if this is the first time after installation
if ( owner_id != viewer_id ){
return;
}
// query appdata for the install date
req = opensocial.newDataRequest();
req.add(req.newFetchPersonAppDataRequest("VIEWER","install_date"), "app_data");
req.send(handle_install);
}
function handle_install(data)
{
// debugger;
var do_update = false;
if (data.get("app_data").hadError())
{
do_update = true;
}
else
{
var viewer_data = data.get("app_data").getData();
if ( (viewer_data[viewer_id] == undefined) || (viewer_data[viewer_id].install_date == undefined) ) {
do_update = true;
}
}
if (do_update)
{
genericJSONRequest("google_apps/server/RYAppInstall.php",do_nothing_callback);
// set installation date
var curr_date = new Date();
var data = curr_date.toUTCString();
req = opensocial.newDataRequest();
req.add(req.newUpdatePersonAppDataRequest("VIEWER", "install_date", data), "app_data");
req.send(do_nothing);
}
}
function do_nothing_callback(data){
}
function do_nothing(data){
}
//////////////////
//Horoscope properties
var g_horoscopeType = "zodiac";
var g_arrSigns; //Array of horoscope signs or symbols
var g_arrSkins; //Array of horoscope skins
var g_arrHoroscopeImages = new Array(); //Multi-dimensional array of array of URLs for horoscope images
//To get a certain image, g_arrHoroscopeImages[skinIndex][signIndex]
var g_arrHoroscopeTexts = new Array(); //Array of horoscope texts
var g_arrHoroscopeDates = new Array(); //Array of horoscope dates
var g_horoscopeIndex = 0; //Index in image and texts array of owner's horoscope sign/symbol/etc.
var g_skinIndex = 0; //Index of skin in g_arrHoroscopeTexts (i.e. row index)
//Owner properties
var g_ownerName = "";
var g_ownerContainerID = "";
var g_ownerProfileURLID = "";
var g_owner_bdayMonth = "";
var g_owner_bdayDate = "";
var g_owner_bdayYear = "";
//Phone number data for Frengo horoscope integration (zodiac horoscope only)
var g_mobile_country = 0;
var g_mobile_number = "";
var g_mobile_isOn = true;
//Flags to indicate load completion for queries
var g_isLoaded_OwnerData = false;
var g_isLoaded_HoroscopeTexts = false;
var g_isLoaded_HoroscopeImages = false;
var g_isLoaded_HoroscopeDates = false;
var g_isLoaded_OwnerSignAndSkin = false;
//Current loaded page
var g_currentPage = "";
//URL of "Add application" page
var g_url_addAppPage = "";
//Container-specific flags
var g_autoNotify7Days = false; //Indicates whether a notification should be sent every 7 days (Currently used for Orkut)
var g_containerName = "";
//Friend selector object
var FS = "";
///////////COMMON HOROSCOPE FUNCTIONS//////////
function genericPageInit()
{
//Safety-check: Make sure non-owner does not go to EDIT page
if (g_currentPage == "edit")
{
if (!isOwner()) {
goto_canvas_page("zodiacHoroscopesViewAll");
//Note: ADD PARAMS TO URL TO DISPLAY NO-PERMISSION ERROR MSG
}
}
//Hi5 only: Check to see if this is post-invite install on viewAll page.
//If it is, redirect to the notify-friends page
if (g_currentPage == "viewAll"){
/************
if ("orkut.com" == "hi5.com"){
var prefs = gadgets.views.getParams();
if (typeof(prefs['invites_sent']) != 'undefined') {
goto_canvas_page("genericHoroscopesFriendSelectorPage");
}
else{
//Display viewAll page
document.getElementById('page_viewall').style.display = "";
}
}
else{
//Display viewAll page
document.getElementById('page_viewall').style.display = "";
}
**************/
document.getElementById('page_viewall').style.display = "";
}
//Get container-specific info, such as the URL of
//add-app page for this app for this container
initContainerSpecificVars();
//Hide EDIT tab if not the owner
if (!isOwner() && g_currentPage != "profile") {
document.getElementById('tabEdit_' + g_currentPage).style.display = "none";
document.getElementById('l-tabEdit_' + g_currentPage).style.display = "none";
document.getElementById('r-tabEdit_' + g_currentPage).style.display = "none";
}
//Set links appropriately for each page
var url;
if (g_currentPage == "profile")
{
//url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
//document.getElementById("linkEdit_profile").href = url;
//url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
//document.getElementById("linkViewAll_profile").href = url;
}
else if (g_currentPage == "edit")
{
document.getElementById("linkEdit_edit" ).href = "#";
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_edit").href = url;
//Reset form
//(Prevents global vars being empty issue due to user navigating via BACK button)
document.getElementById('but_reset').click();
}
else if (g_currentPage == "viewAll")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_viewAll").href = url;
document.getElementById("linkViewAll_viewAll").href = "#";
}
else if (g_currentPage == "crossSell")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_crossSell").href = url;
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_crossSell").href = url;
return; //Do not need any data or any dynamic processing on this page.
}
else if (g_currentPage == "crossSell_Hi5")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_crossSell_Hi5").href = url;
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_crossSell_Hi5").href = url;
return; //Do not need any data or any dynamic processing on this page.
}
else if (g_currentPage == "invite")
{
url = "javascript:goto_canvas_page('zodiacHoroscopesEdit')";
document.getElementById("linkEdit_invite").href = url;
url = "javascript:goto_canvas_page('zodiacHoroscopesViewAll')";
document.getElementById("linkViewAll_invite").href = url;
return; //Do not need any data or any dynamic processing on this page.
}
//Get owner info from container
getOwnerData();
}
//Calls displayHoroscope() with the appropriate parameters.
function callDisplayHoroscope()
{
if (g_currentPage == "friendselector")
return;
//Only start displaying once all data is done loading.
if (!(g_isLoaded_OwnerData && g_isLoaded_HoroscopeTexts
&& g_isLoaded_HoroscopeImages && g_isLoaded_HoroscopeDates
&& g_isLoaded_OwnerSignAndSkin))
return;
//if "all" is specified, display all horoscopes
if (g_currentPage == "viewAll")
{
displayAllHoroscopes();
}
//Else display single horoscope
else {
var decodedText = g_arrHoroscopeTexts[g_horoscopeIndex];
if (g_horoscopeType != "zodiac")
decodedText = decodeURIComponent(decodedText);
displayHoroscope(g_arrHoroscopeImages[g_skinIndex][g_horoscopeIndex],
decodedText,
g_arrHoroscopeDates[g_horoscopeIndex],
g_ownerName,
"zodiac_horoscope_" + g_currentPage);
}
}
//Displays all Horoscopes. Displays to div "<DIV_HOROSCOPE>_0", "<DIV_HOROSCOPE>_1", ...
function displayAllHoroscopes()
{
var decodedText;
for (var i = 0; i < g_arrHoroscopeTexts.length; ++i)
{
decodedText = g_arrHoroscopeTexts[i];
if (g_horoscopeType != "zodiac")
decodedText = decodeURIComponent(decodedText);
displayHoroscope(g_arrHoroscopeImages[g_skinIndex][i],
decodedText,
g_arrHoroscopeDates[i],
"", //No owner name
"zodiac_horoscope_" + i);
}
//Remove "Loading..." when done loading
document.getElementById("div_loading").style.display = "none";
}
/*
* Displays horoscope to screen.
*
* Params:
* imgUrl - string URL of background image for horoscope for corresponding sign
* text - string of the horoscope text
* datesTxt - string of the dates for this sign
* ownerName - string of the owner's name (EXCLUDING the "'s")
* divName - string ID of DIV to print horoscope to.
*/
function displayHoroscope(imgUrl, text, datesTxt, ownerName, divName)
{
//Only start displaying once all data is done loading.
if (!(g_isLoaded_OwnerData && g_isLoaded_HoroscopeTexts
&& g_isLoaded_HoroscopeImages && g_isLoaded_HoroscopeDates
&& g_isLoaded_OwnerSignAndSkin))
return;
var html = "";
/**********
//Special case for Chinese horoscope -> use old image layout version
//instead of flash until we can create modified flash version
if ("zodiac" == "chinese") {
html += "<div style='float: left;height:163px;width:300px; background:url("+ imgUrl + ") no-repeat;'align='left'>";
html += "<div style='overflow-y:scroll;overflow:-moz-scrollbars-vertical;position:relative;top:80px;margin-left:23px;width:261px;height:65px;font:normal 12px Arial, Helvetica, sans-serif;color:#000' align='left'>";
html += "<div style='width:140px'>" + text + "</div>";
html += "</div>";
html += "</div>";
}
**********/
//Else flash version
//else {
html += "<embed src='" + imgUrl + "' ";
//if (g_currentPage == "profile")
html += "width='300' height='163' align='middle' ";
//else
// html += "width='430' height='190' align='middle' ";
html += "flashvars=\"mytext=" + text + "\" quality='high' allowScriptAccess='sameDomain' ";
html += "type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
//}
//Display on profile page
document.getElementById(divName).innerHTML = html;
}
//Returns true if current viewer is the page owner
function isOwner()
{
return (viewer_id == owner_id);
}
//Initializes values of globals that are container-specific
function initContainerSpecificVars(){
switch("orkut.com"){
case "myspace.com":
//Get URL of Add-App page
g_url_addAppPage = "http://www.myspace.com/ry_horoscopes";
g_autoNotify7Days = false;
g_containerName = "MySpace";
break;
case "orkut.com":
//Get URL of Add-App page
g_url_addAppPage = "AppInfo.aspx?appId=740672099669";
g_autoNotify7Days = true;
g_containerName = "Orkut";
break;
case "hi5.com":
g_supportsActivityStream = false;
g_containerName = "Hi5";
case "www.rockyou.com":
default:
}
}
function getOwnerData()
{
//Get owner's name & ownerID
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('OWNER'), 'owner');
req.send(function(response) {
var owner = response.get('owner').getData();
//Get owner ID
g_ownerContainerID = owner.getId();
//Get and store owner name
g_ownerName = owner.getDisplayName();
//Get owner bday
//Note: Not all containers (for example, Orkut) will give out bday information
var bday = owner.getField(opensocial.Person.Field.DATE_OF_BIRTH);
if (bday)
{
g_owner_bdayMonth = bday.getMonth() + 1; //getMonth returns month as 0 thru 11
g_owner_bdayDate = bday.getDate();
g_owner_bdayYear = bday.getFullYear();
}
g_isLoaded_OwnerData = true; //Indicate that owner data is done loading
//Get bday, sign, and skin info from RY database
genericJSONRequest("google_apps/zodiacHoroscopes/ZodiacHoroscopesLoadFromDB.php" +
"?ownerID=" + encodeURIComponent(g_ownerContainerID) + "&container=" + encodeURIComponent("orkut.com"),
function(response) {
var sign = "";
var skin = "";
var return_data = response['return_data'];
//If owner info exists in DB, use that info
//instead of container's bday info.
if (return_data['hasData'] == "true") {
sign = return_data['sign'];
skin = return_data['skin'];
g_owner_bdayMonth = trimLeadingZeroes(return_data['bday_month']);
g_owner_bdayDate = trimLeadingZeroes(return_data['bday_date']);
g_owner_bdayYear = trimLeadingZeroes(return_data['bday_year']);
}
//If no owner info exists in DB, and if the user is in ViewAll page,
//redirect them to Edit page instead.
//Note: If the user does not have the app installed, it will automatically redirect to
//the default canvas page, which should be the View All page (i.e. no page change occurs)
else if (g_currentPage == "viewAll" && isOwner()) {
goto_canvas_page("zodiacHoroscopesEdit");
}
g_horoscopeIndex = convertSignToIndex(sign);
g_skinIndex = convertSkinNameToIndex(skin);
g_isLoaded_OwnerSignAndSkin = true;
//Get all horoscope texts, image URLs, etc
//Note: Myspace chokes when making opensocial request concurrent
//with JSON requests. Therefore, we have the function calls done here AFTER
//the opensocial request returns.
initArrDates();
initArrSigns();
initArrSkins();
initArrHoroscopeTexts();
initArrImages();
//Attempt to display horoscope (if all params are loaded)
if (g_currentPage != "friendselector"){
callDisplayHoroscope();
}
//Pre-fill form info if it's the edit page
if (g_currentPage == "edit") {
fillEditPageForm();
}
}
);
/**************DEPRECATED**********
//Post to activity stream, if nothing's been posted in the last 7 days
//Note: Used for Orkut only currently
if (g_autoNotify7Days){
genericJSONRequest("google_apps/common/RYOpenSocialActivities.php", function(response){
var return_data = response["return_data"];
var sendActivity = return_data["sendActivity"];
if (sendActivity == "true") {
var stream_title = "";
//Note: No way to control owner vs non-owner activity feed at this point.
//Therefore, non-owner will see name automatically inserted, such as
//"<ownerName> has a new Horoscope!"
//whereas the owner will see, in his My Updates page,
//"has a new Horoscope!" with no name.
stream_title += " has a new Horoscope!";
var stream_body = "<table><tr>";
stream_body += "<td><!--ADD IMG HERE! <img src=\"" + this.emote_icon + "\" style=\"border: 1px solid #CCCCCC;padding: 3px;background-color: #FFFFFF;height:50px;width:50px;\" /> --></td>";
stream_body += "<td style=\"vertical-align:center;\"><span><a href='" + g_url_addAppPage + "' >Go get your own Horoscope!</a></span></td>";
stream_body += "</tr></table>";
//Post to activity stream, then redirect to View All page
postToActivityStream(stream_title, null, opensocial.CreateActivityPriority.HIGH, stream_body);
}
});
}
*****************/
});
}
//Pre-fills form data on EDIT page
function fillEditPageForm()
{
//Fill in hidden owner ID
document.getElementById('ownerId_edit').value = g_ownerContainerID;
//Pre-fill bday info
document.getElementById('bday_month_edit').value = g_owner_bdayMonth;
document.getElementById('bday_date_edit').value = g_owner_bdayDate;
document.getElementById('bday_year_edit').value = g_owner_bdayYear;
//Fill combo boxes
populateSignCB();
//Show skin CB only if more than one skin exists
if (g_arrSkins.length > 1)
populateSkinCB();
}
//Populates and displays sign/symbol combo box.
//Pre-selects value based on current data.
function populateSignCB()
{
//////////////////////////////////////////////////////////////
//Populate sign combo box to the form, with a sign pre-selected
//////////////////////////////////////////////////////////////
var strCBSigns = "<select name='cb_sign' onchange='g_horoscopeIndex = this.value; callDisplayHoroscope();' >";
for (var i = 0; i < g_arrSigns.length; ++i)
{
if (i == g_horoscopeIndex){
strCBSigns += "<option value='" + i + "' selected='true'>" + g_arrSigns[i] + "</option>";
}
else {
strCBSigns += "<option value='" + i + "'>" + g_arrSigns[i] + "</option>";
}
}
strCBSigns += "</select>";
document.getElementById('cb_sign_edit').innerHTML = strCBSigns;
}
//Populates and displays skin combo box.
//Pre-selects value based on current data.
function populateSkinCB()
{
//////////////////////////////////////////////////////////////
//Populate skin combo box to the form, with a sign pre-selected
//////////////////////////////////////////////////////////////
var strCBSkins = "<select name='cb_skin' onchange='g_skinIndex = this.value; callDisplayHoroscope();' >";
for (var i = 0; i < g_arrSkins.length; ++i)
{
if (i == g_skinIndex){
strCBSkins += "<option value='" + i + "' selected='true'>" + g_arrSkins[i] + "</option>";
}
else {
strCBSkins += "<option value='" + i + "'>" + g_arrSkins[i] + "</option>";
}
}
strCBSkins += "</select>";
document.getElementById('cb_skin_edit').innerHTML = strCBSkins;
}
//Validates current form input, prints out any error msgs, and recalculates/redisplays
// new horoscope sign
function validateForm()
{
var errorMsg = "";
if (!IsInteger(g_owner_bdayMonth) || g_owner_bdayMonth < 1 || g_owner_bdayMonth > 12) {
errorMsg = "Month must be an integer between 1 and 12, inclusive.\n";
}
if (!IsInteger(g_owner_bdayDate) || g_owner_bdayDate < 1 || g_owner_bdayDate > 31) {
errorMsg += "Day is invalid.\n";
}
else{
switch(g_owner_bdayMonth) {
case "2":
if (g_owner_bdayDate > 29)
errorMsg += "Day is invalid.\n";
break;
case "4":
case "6":
case "9":
case "11":
if (g_owner_bdayDate > 30)
errorMsg += "Day is invalid.\n";
break;
}
}
var currDate = new Date();
var currYear = currDate.getFullYear();
if (!IsInteger(g_owner_bdayYear) || g_owner_bdayYear < 1900 || g_owner_bdayYear > currYear)
{
errorMsg += "Year is invalid.\n";
}
//Check Frengo phone integration entries (Zodiac horoscopes only)
if ("zodiac" == "zodiac") {
//alert("country=" + g_mobile_country + ", number=" + g_mobile_number + ", length=" + g_mobile_number.length + ",isOn=" + g_mobile_isOn);
//Non-numeric phone number
if (g_mobile_number.length > 0 && !IsInteger(g_mobile_number)){
errorMsg += "Please enter a valid phone number with only numeric digits 0 through 9.\n";
}
//Numeric phone number entered but no country selected
if (g_mobile_country == "0" && g_mobile_number.length > 0 && IsInteger(g_mobile_number)){
errorMsg += "Please select a country.\n";
}
//Else length validation
if (g_mobile_number.length > 0 && g_mobile_number.length < 8) {
errorMsg += "The mobile number you have entered is too short.\n";
}
else if (g_mobile_number.length > 13) {
errorMsg += "The mobile number you have entered is too long.\n";
}
else if (g_mobile_country == "1" && g_mobile_number.length != 10) {
errorMsg += "US phone numbers should be 10 digits.\n";
}
}
if (errorMsg != "") {
document.getElementById("errorMsg_edit").innerHTML = errorMsg;
document.getElementById("errorMsg_edit").style.display ="block";
return false;
}
else {
var url = "google_apps/zodiacHoroscopes/ZodiacHoroscopesSaveToDB.php" +
"