Skip to content

Commit

Permalink
Added more Planet Info
Browse files Browse the repository at this point in the history
  • Loading branch information
HitanshuPrasad committed Jan 8, 2024
1 parent f3814c8 commit 1969a6d
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 17 deletions.
18 changes: 11 additions & 7 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","Day","Gravity", "Mass", "Temperature", "Moons", "Radius", "SunDistance"];
var planet = planets;

//Containers
Expand Down Expand Up @@ -94,8 +94,8 @@ 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);
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);
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].day,planet[i].gravity);
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,planet[i].day,planet[i].gravity);

// Switch to fullscreen mode on click
document.getElementById("fullscreen-button").addEventListener('click', function() {
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,day,gravity){

//Url of planet files
var toload = {};
Expand Down Expand Up @@ -327,7 +327,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
camera.position.z = 5;


for (var i = 0; i < 8; i++){
for (var i = 0; i < 10; i++){
var information = document.createElement('div');
information.id = infoType[i];
information.className = 'info';
Expand All @@ -337,6 +337,8 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "
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>';
document.getElementById("Day").innerHTML = '<p>' + l10n.get("DayLength") + '</p><p>' + l10n.get("EarthHours", {day:day}) + '</p>';
document.getElementById("Gravity").innerHTML = '<p>' + l10n.get("Gravity") + '</p><p>' + gravity + '</p>';
document.getElementById("Mass").innerHTML = '<p>' + l10n.get("Mass") + '</p><p>' + mass + '</p>';
document.getElementById("Temperature").innerHTML = '<p>' + l10n.get("SurfaceTemperature") + '</p><p>' + temperature + '</p>';
document.getElementById("Moons").innerHTML = '<p>' + l10n.get("NumberOfMoons") + '</p><p>' + moons + '</p>';
Expand Down Expand Up @@ -506,7 +508,7 @@ define(["sugar-web/activity/activity", "sugar-web/env", "sugar-web/datastore", "

}

function initPosition(name, type, year, mass, temperature, moons, radius, sunDistance){
function initPosition(name, type, year, mass, temperature, moons, radius, sunDistance,day,gravity){

//Url of planet map files
var toload = {};
Expand Down Expand Up @@ -672,6 +674,8 @@ 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.day=day;
planetMesh.userData.gravity=gravity;

//Show planet position and distance from Sun
document.getElementById("position-button").addEventListener("click", function(e){
Expand Down Expand Up @@ -809,7 +813,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,day,gravity);
}

requestAnim = false;
Expand Down
32 changes: 24 additions & 8 deletions activities/Planets.activity/js/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ 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",
"day":"1408",
"gravity":"3.7 m/s&sup2",
},
{
"name": "Venus",
Expand All @@ -17,7 +19,9 @@ var planets = [
"year": "225",
"temperature": "462&#176;C",
"radius": "6,051.8 km",
"distancefromsun": "108,000,000 km"
"distancefromsun": "108,000,000 km",
"day": "5832",
"gravity":"8.8 m/s&sup2",
},
{
"name": "Earth",
Expand All @@ -27,7 +31,9 @@ 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",
"day":"24",
"gravity":"9.8 m/s&sup2",
},
{
"name": "Mars",
Expand All @@ -37,7 +43,9 @@ 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",
"day":"25",
"gravity":"3.7 m/s&sup2",
},
{
"name": "Jupiter",
Expand All @@ -47,7 +55,9 @@ var planets = [
"year": "4,333",
"temperature": "No Data",
"radius": "69,911 km",
"distancefromsun": "778,000,000 km"
"distancefromsun": "778,000,000 km",
"day":"10",
"gravity":"24.8 m/s&sup2",
},
{
"name": "Saturn",
Expand All @@ -57,7 +67,9 @@ var planets = [
"year": "10,759",
"temperature": "No Data",
"radius": "58,232 km",
"distancefromsun": "1,400,000,000 km"
"distancefromsun": "1,400,000,000 km",
"day":"11",
"gravity":"10.4 m/s&sup2",
},
{
"name": "Uranus",
Expand All @@ -67,7 +79,9 @@ var planets = [
"year": "30,687",
"temperature": "No Data",
"radius": "25,362 km",
"distancefromsun": "2,900,000,000 km"
"distancefromsun": "2,900,000,000 km",
"day":"17",
"gravity":"8.9 m/s&sup2",
},
{
"name": "Neptune",
Expand All @@ -77,6 +91,8 @@ var planets = [
"year": "60,190",
"temperature": "No Data",
"radius": "24,622 km",
"distancefromsun": "4,500,000,000 km"
"distancefromsun": "4,500,000,000 km",
"day":"16",
"gravity":"11.1 m/s&sup2",
},
]
11 changes: 9 additions & 2 deletions activities/Planets.activity/locale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ Terrestrial=Terrestrial
IceGiant=Ice Giant
GasGiant=Gas Giant
YearLength=Year Length:
DayLength=Day Length:
EarthDays={{year}} Earth days
EarthHours={{day}} Earth Hours
Gravity=Surface Gravity:
Mass=Mass:
SurfaceTemperature=Surface Temperature:
NumberOfMoons=Number of Moons:
Expand Down Expand Up @@ -63,6 +66,8 @@ IceGiant=Ice Giant
GasGiant=Gas Giant
YearLength=Year Length:
EarthDays={{year}} Earth days
EarthHours={{day}} Earth Hours
Gravtiy=Surface Gravity:
Mass=Mass:
SurfaceTemperature=Surface Temperature:
NumberOfMoons=Number of Moons:
Expand Down Expand Up @@ -110,8 +115,10 @@ PlanetType=Type de planète:
Terrestrial=Terrestre
IceGiant=Géante de glace
GasGiant=Géante gazeuse
YearLength=Durée de l'année:
EarthDays={{year}} Jours Terrestre
YearLength=Durée de lannée:
EarthDays={{year}} Jours Terrestre:
EarthHours={{day}} heures terrestres:
Gravtiy=Gravité de surface:
Mass=Masse:
SurfaceTemperature=Température de surface:
NumberOfMoons=Nombre de lunes:
Expand Down
11 changes: 11 additions & 0 deletions activities/Planets.activity/po/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ msgctxt "EarthDays"
msgid "{{year}} Earth days"
msgstr "{{year}} Earth days"

#. Do not translate {{days}}
#: EarthHours
msgctxt "EarthHours"
msgid "{{day}} Earth Hours"
msgstr "{{day}} Earth Hours"

#: Gravtiy
msgctxt "Gravtiy"
msgid "Surface Gravtiy:"
msgstr "Surface Gravity:"

#: Mass
msgctxt "Mass"
msgid "Mass:"
Expand Down
11 changes: 11 additions & 0 deletions activities/Planets.activity/po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ msgctxt "EarthDays"
msgid "{{year}} Earth days"
msgstr "{{year}} Jours Terrestre"

#. Do not translate {{days}}
#: EarthHours
msgctxt "EarthHours"
msgid "{{day}} Earth Hours"
msgstr "{{day}} Heures terrestres"

#: Gravtiy
msgctxt "Gravtiy"
msgid "Surface Gravtiy:"
msgstr "Gravité de surface:"

#: Mass
msgctxt "Mass"
msgid "Mass:"
Expand Down
11 changes: 11 additions & 0 deletions activities/Planets.activity/po/template.pot
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ msgctxt "EarthDays"
msgid "{{year}} Earth days"
msgstr "{{year}} Earth days"

#. Do not translate {{days}}
#: EarthHours
msgctxt "EarthHours"
msgid "{{day}} Earth Hours"
msgstr "{{day}} Earth Hours"

#: Gravtiy
msgctxt "Gravtiy"
msgid "Surface Gravtiy:"
msgstr "Surface Gravity:"

#: Mass
msgctxt "Mass"
msgid "Mass:"
Expand Down

0 comments on commit 1969a6d

Please sign in to comment.