Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated planet info #1615

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions activities/Planets.activity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<div id = "planet-pos"></div>
<div id ="planet-container">
<div class = "interactive" id = "planet-info"></div>
<div id="DayLength" class="info"></div>
<div id="SurfaceGravity" class="info"></div>
<div id="Nickname" class="info"></div>
<div class = "interactive" id = "planet-display"></div>
</div>

Expand Down
40 changes: 34 additions & 6 deletions activities/Planets.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
controls.target.set(0,0,0);

//Planet Information
var infoType = ["Name", "Type", "Year", "Mass", "Temperature", "Moons", "Radius", "SunDistance"];
var infoType = ["Name", "Type", "Year", "Mass", "Temperature", "Moons", "Radius", "SunDistance", "DayLength", "SurfaceGravity", "Nickname"];
var planet = planets;

//Containers
Expand Down Expand Up @@ -94,7 +94,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
document.getElementById("planet-" + planet[i].name).appendChild(planetName);

//Init planet info and planet position view
initPlanet(planet[i].name, planet[i].type, planet[i].year, planet[i].mass, planet[i].temperature, planet[i].moons, planet[i].radius, planet[i].distancefromsun);
initPlanet(planet[i].name, planet[i].type, planet[i].year, planet[i].mass, planet[i].temperature, planet[i].moons, planet[i].radius, planet[i].distancefromsun, planet[i].dayLength, planet[i].surfaceGravity, planet[i].nickname);
initPosition(planet[i].name, planet[i].type, planet[i].year, planet[i].mass, planet[i].temperature, planet[i].moons, planet[i].radius, planet[i].distancefromsun);

// Switch to fullscreen mode on click
Expand Down Expand Up @@ -182,7 +182,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "


//Show planet function
function initPlanet(name, type, year, mass, temperature, moons, radius, sunDistance){
function initPlanet(name, type, year, mass, temperature, moons, radius, sunDistance, dayLength, surfaceGravity, nickname){

//Url of planet files
var toload = {};
Expand Down Expand Up @@ -331,9 +331,32 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
var information = document.createElement('div');
information.id = infoType[i];
information.className = 'info';
information.style.padding = "10px";
information.style.margin = "5px";
information.style.borderBottom = "1px solid #ccc"; // subtle line between items
information.style.fontFamily = "Arial, sans-serif"; // better font
information.style.color = "#333"; // Dark gray text
planetInfo.appendChild(information);
}

var earthMass = 5.972e24;
var massWithoutCommas = mass.replace(/,/g, '');
var massInKg = parseFloat(massWithoutCommas);
var earthMasses = (massInKg / earthMass).toPrecision(4);

document.getElementById("Name").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Planet Name</p><p>' + l10n.get(name) + '</p>';
document.getElementById("Type").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Planet Type</p><p>' + l10n.get(type.replace(/\s+/g, '')) + '</p>';
document.getElementById("Year").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Year Length</p><p>' + l10n.get("EarthDays", {year:year}) + '</p>';
document.getElementById("Mass").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Mass</p><p>' + mass + ' (' + earthMasses + ' Earth masses)</p>';'</p>';
document.getElementById("Temperature").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Surface Temperature</p><p>' + temperature + '</p>';
document.getElementById("Moons").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Number Of Moons</p><p>' + moons + '</p>';
document.getElementById("Radius").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Planet Radius</p><p>' + radius + '</p>';
document.getElementById("SunDistance").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Distance from Sun</p><p>' + sunDistance + '</p>';
document.getElementById("DayLength").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Length of Day</p><p>' + dayLength + '</p>';
document.getElementById("SurfaceGravity").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Surface Gravity</p><p>' + surfaceGravity + '</p>';
document.getElementById("Nickname").innerHTML = '<p style="font-weight: bold; color: #0173F2;">Nickname</p><p>' + nickname + '</p>';

/*
document.getElementById("Name").innerHTML = '<p>' + l10n.get("PlanetName") + '</p><p>' + l10n.get(name) + '</p>';
document.getElementById("Type").innerHTML = '<p>' + l10n.get("PlanetType") + '</p><p>' + l10n.get(type.replace(/\s+/g, '')) + '</p>';
document.getElementById("Year").innerHTML = '<p>' + l10n.get("YearLength") + '</p><p>' + l10n.get("EarthDays", {year:year}) + '</p>';
Expand All @@ -342,7 +365,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
document.getElementById("Moons").innerHTML = '<p>' + l10n.get("NumberOfMoons") + '</p><p>' + moons + '</p>';
document.getElementById("Radius").innerHTML = '<p>' + l10n.get("PlanetRadius") + '</p><p>' + radius + '</p>';
document.getElementById("SunDistance").innerHTML = '<p>' + l10n.get("SunDistance") + '</p><p>' + sunDistance + '</p>';

*/
saveImage = function(){

var mimetype = 'image/jpeg';
Expand Down Expand Up @@ -672,6 +695,9 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
planetMesh.userData.moons = moons;
planetMesh.userData.radius = radius;
planetMesh.userData.sunDistance = sunDistance;
//planetMesh.userData.dayLength = dayLength;
//planetMesh.userData.surfaceGravity = surfaceGravity;
//planetMesh.userData.nickname = nickname;

//Show planet position and distance from Sun
document.getElementById("position-button").addEventListener("click", function(e){
Expand Down Expand Up @@ -748,7 +774,9 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
intersects[i].object.name, intersects[i].object.userData.typeOfPlanet,
intersects[i].object.userData.year, intersects[i].object.userData.mass,
intersects[i].object.userData.temperature, intersects[i].object.userData.moons,
intersects[i].object.userData.radius, intersects[i].object.userData.sunDistance
intersects[i].object.userData.radius, intersects[i].object.userData.sunDistance,
intersects[i].object.userData.dayLength, intersects[i].object.userData.surfaceGravity,
intersects[i].object.userData.nickname
);
}

Expand Down Expand Up @@ -809,7 +837,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
//There was a bug where the planets rotate faster and faster on each click
//By setting requestAnim to false, initPlanet will stop initializaing, as it causes the bug
if (requestAnim){
initPlanet(name, type, year, mass, temperature, moons, radius, sunDistance);
initPlanet(name, type, year, mass, temperature, moons, radius, sunDistance, dayLength, surfaceGravity, nickname);
}

requestAnim = false;
Expand Down
40 changes: 32 additions & 8 deletions activities/Planets.activity/js/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ var planets = [
"year": "88",
"temperature": "-173 to 427&#176;C",
"radius": "2,439.7 km",
"distancefromsun": "58,000,000 km"
"distancefromsun": "58,000,000 km",
"dayLength": "4222.6 hours",
"surfaceGravity": "3.7 m/s^2",
"nickname": "The Swiftest Planet"
},
{
"name": "Venus",
Expand All @@ -17,7 +20,10 @@ var planets = [
"year": "225",
"temperature": "462&#176;C",
"radius": "6,051.8 km",
"distancefromsun": "108,000,000 km"
"distancefromsun": "108,000,000 km",
"dayLength": "2802.0 hours",
"surfaceGravity": "8.9 m/s^2",
"nickname": "Earth's Superheated Twin Sister"
},
{
"name": "Earth",
Expand All @@ -27,7 +33,10 @@ var planets = [
"year": "365",
"temperature": "-88 to 58&#176;C",
"radius": "6,371.00 km",
"distancefromsun": "150,000,000 km"
"distancefromsun": "150,000,000 km",
"dayLength": "24.0 hours",
"surfaceGravity": "9.8 m/s^2",
"nickname": "Our Homeworld"
},
{
"name": "Mars",
Expand All @@ -37,7 +46,10 @@ var planets = [
"year": "687",
"temperature": "-153 to 20&#176;C",
"radius": "3,389.5 km",
"distancefromsun": "228,000,000 km"
"distancefromsun": "228,000,000 km",
"dayLength": "24.7",
"surfaceGravity": "3.7 m/s^2",
"nickname": "The Red Planet"
},
{
"name": "Jupiter",
Expand All @@ -47,7 +59,10 @@ var planets = [
"year": "4,333",
"temperature": "No Data",
"radius": "69,911 km",
"distancefromsun": "778,000,000 km"
"distancefromsun": "778,000,000 km",
"dayLength": "9.9 hours",
"surfaceGravity": "23.1 m/s^2",
"nickname": "King of the Planets"
},
{
"name": "Saturn",
Expand All @@ -57,7 +72,10 @@ var planets = [
"year": "10,759",
"temperature": "No Data",
"radius": "58,232 km",
"distancefromsun": "1,400,000,000 km"
"distancefromsun": "1,400,000,000 km",
"dayLength": "10.7 hours",
"surfaceGravity": "9.0 m/s^2",
"nickname": "Jewel of the Solar System"
},
{
"name": "Uranus",
Expand All @@ -67,7 +85,10 @@ var planets = [
"year": "30,687",
"temperature": "No Data",
"radius": "25,362 km",
"distancefromsun": "2,900,000,000 km"
"distancefromsun": "2,900,000,000 km",
"dayLength": "17.2 hours",
"surfaceGravity": "8.7 m/s^2",
"nickname": "The Original Ice Giant"
},
{
"name": "Neptune",
Expand All @@ -77,6 +98,9 @@ var planets = [
"year": "60,190",
"temperature": "No Data",
"radius": "24,622 km",
"distancefromsun": "4,500,000,000 km"
"distancefromsun": "4,500,000,000 km",
"dayLength": "16.1 hours",
"surfaceGravity": "11.0 m/s^2",
"nickname": "The Farthest Planet"
},
]