Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rpared committed Apr 14, 2024
1 parent d1ef2b7 commit cf48bf5
Showing 1 changed file with 156 additions and 121 deletions.
277 changes: 156 additions & 121 deletions script/animalstatspercountry2022-esp.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ async function fetchData() {
// console.log("World Fish:",worldData[
// "Fish and seafood | 00002960 || Production | 005511 || tonnes"].toLocaleString());

let noData = {
yearly: "No hay datos de esto 😔",
monthly: "No hay datos de esto 😔",
daily: "No hay datos de esto 😔",
hourly: "No hay datos de esto 😔",
perMinute: "No hay datos de esto 😔",
perSecond: "No hay datos de esto 😔",
};

let fetchHtml = {
/*Population*/
Population2020: 7840952880,
Expand All @@ -412,25 +421,29 @@ async function fetchData() {
/*COWS*/
cowsData: {
formatCowsData: function (cattle) {
return {
yearly: Number(cattle).toLocaleString(),
monthly: (cattle / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (cattle / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (cattle / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (cattle / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (cattle / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{ maximumFractionDigits: 2 }
),
};
if (cattle) {
return {
yearly: Number(cattle).toLocaleString(),
monthly: (cattle / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (cattle / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (cattle / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (cattle / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (cattle / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{ maximumFractionDigits: 2 }
),
};
} else if (cattle == 0) {
return noData;
}
},

buildCowsDataHTML: function (country, cowsData) {
Expand All @@ -451,26 +464,32 @@ async function fetchData() {
/*PIGS*/
pigsData: {
formatPigsData: function (pigs) {
return {
yearly: Number(pigs).toLocaleString(),
monthly: (pigs / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (pigs / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (pigs / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (pigs / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (pigs / (365 * 24 * 60 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 2,
}),
};
if (pigs) {
return {
yearly: Number(pigs).toLocaleString(),
monthly: (pigs / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (pigs / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (pigs / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (pigs / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (pigs / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
} else if (pigs == 0) {
return noData;
}
},

buildPigsDataHTML: function (country, pigsData) {
const formattedData = fetchHtml.pigsData.formatPigsData(pigsData);
return `
Expand All @@ -489,27 +508,31 @@ async function fetchData() {
/*SHEEP*/
sheepData: {
formatSheepData: function (sheep) {
return {
yearly: Number(sheep).toLocaleString(),
monthly: (sheep / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (sheep / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (sheep / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (sheep / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (sheep / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
if (sheep) {
return {
yearly: Number(sheep).toLocaleString(),
monthly: (sheep / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (sheep / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (sheep / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (sheep / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (sheep / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
} else if (sheep == 0) {
return noData;
}
},

buildSheepDataHTML: function (country, sheepData) {
Expand All @@ -530,27 +553,31 @@ async function fetchData() {
/*CHICKEN*/
chickenData: {
formatChickenData: function (chicken) {
return {
yearly: Number(chicken).toLocaleString(),
monthly: (chicken / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (chicken / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (chicken / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (chicken / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (chicken / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
if (chicken) {
return {
yearly: Number(chicken).toLocaleString(),
monthly: (chicken / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (chicken / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (chicken / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (chicken / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (chicken / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
} else if (chicken == 0) {
return noData;
}
},

buildChickenDataHTML: function (country, chickenData) {
Expand All @@ -572,27 +599,31 @@ async function fetchData() {
/*TURKEY*/
turkeyData: {
formatTurkeyData: function (turkey) {
return {
yearly: Number(turkey).toLocaleString(),
monthly: (turkey / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (turkey / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (turkey / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (turkey / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (turkey / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
if (turkey) {
return {
yearly: Number(turkey).toLocaleString(),
monthly: (turkey / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (turkey / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (turkey / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (turkey / (365 * 24 * 60)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perSecond: (turkey / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{
maximumFractionDigits: 2,
}
),
};
} else if (turkey == 0) {
return noData;
}
},

buildTurkeyDataHTML: function (country, turkeyData) {
Expand All @@ -614,26 +645,30 @@ async function fetchData() {
//Function to format HTML fish data per country
fishData: {
formatFishData: function (fishTonnes) {
return {
yearly: Number(fishTonnes).toLocaleString(),
monthly: (fishTonnes / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (fishTonnes / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (fishTonnes / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (fishTonnes / (365 * 24 * 60)).toLocaleString(
undefined,
{ maximumFractionDigits: 0 }
),
perSecond: (fishTonnes / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{ maximumFractionDigits: 2 }
),
};
if (fishTonnes) {
return {
yearly: Number(fishTonnes).toLocaleString(),
monthly: (fishTonnes / 12).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
daily: (fishTonnes / 365).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
hourly: (fishTonnes / (365 * 24)).toLocaleString(undefined, {
maximumFractionDigits: 0,
}),
perMinute: (fishTonnes / (365 * 24 * 60)).toLocaleString(
undefined,
{ maximumFractionDigits: 0 }
),
perSecond: (fishTonnes / (365 * 24 * 60 * 60)).toLocaleString(
undefined,
{ maximumFractionDigits: 2 }
),
};
} else if (fishTonnes == 0) {
return noData;
}
},

buildFishDataHTML: function (country, fishTonnesData) {
Expand Down

0 comments on commit cf48bf5

Please sign in to comment.