Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
46bcd4c
Creacion de carpeta de imagenes
Natyushk Mar 15, 2024
18432ea
Imagenes de millonarios
Natyushk Mar 15, 2024
97f2c88
Imagenes de millonarios completo
Natyushk Mar 15, 2024
8fc1191
Imagenes de millonarios completo
Natyushk Mar 15, 2024
8194af7
Imagenes de millonarios completo
Natyushk Mar 15, 2024
abdf48c
Añadir urls
Natyushk Mar 15, 2024
6153934
Merge pull request #2 from Natyushk/Backend
Natyushk Mar 15, 2024
8ab0b7e
test de prompting correcto
sandymmora Mar 19, 2024
611a5b8
test de prompting correcto
sandymmora Mar 19, 2024
4d0c7f3
Merge pull request #3 from sandymmora/data
Natyushk Mar 19, 2024
2e0eeda
estructura HTML y view.js renderItems creacion ul y Li
sandymmora Mar 19, 2024
3dd336e
Merge pull request #1 from Natyushk/main
sandymmora Mar 19, 2024
1f86f49
Merge pull request #4 from sandymmora/data
Natyushk Mar 19, 2024
8c24619
Merge pull request #5 from Natyushk/data
Natyushk Mar 19, 2024
e7e4b4d
Cambios en la logica de view.js
Natyushk Mar 19, 2024
1082862
Actualizacion de main js
Natyushk Mar 19, 2024
bf25ee4
Cambios de foto de Bernard Arnault
Natyushk Mar 20, 2024
23910bc
Actualizacion de main js
Natyushk Mar 20, 2024
efb8235
Actualizacion de html y correccion de informacion en dataFunctions.js
Natyushk Mar 20, 2024
2959fb0
Actualizacion de logica de dataFunction y main
Natyushk Mar 20, 2024
7fbe678
correciones en archivos main.js,view.js e index.html para visualizaci…
sandymmora Mar 20, 2024
a03495d
eliminar logica de ul
Natyushk Mar 20, 2024
3c6b267
Se resolvio conflicto para correcciones en main.js view.js e index
sandymmora Mar 20, 2024
39d48fa
Merge branch 'data'
sandymmora Mar 20, 2024
dcdc9a6
Se terminaron los estilos y agregamos mas info en tarjetas
sandymmora Mar 21, 2024
c1ca92c
Estilos, se agrego descripción corta y padding
sandymmora Mar 21, 2024
ea883e6
Merge branch 'main' of https://github.com/Natyushk/DEV014-Dataverse i…
Natyushk Mar 21, 2024
46ae0ac
Merge branch 'main' into visualizarDatos
sandymmora Mar 21, 2024
9500b81
Merge pull request #8 from sandymmora/visualizarDatos
Natyushk Mar 21, 2024
0b00647
Cambios en main
Natyushk Mar 21, 2024
056d77a
cambios en el main
Natyushk Mar 21, 2024
4882e4a
Merge branch 'main' into VisualizarDatos
sandymmora Mar 21, 2024
c053ee8
Merge pull request #9 from Natyushk/VisualizarDatos
sandymmora Mar 21, 2024
2b11aaa
Funciones de filtrar y ordenar
sandymmora Mar 25, 2024
ca174eb
cambios en main.js para funciones
sandymmora Mar 25, 2024
c590b9c
Agregar funcion de calculo y promedio de la fortuna
Natyushk Mar 26, 2024
938f342
Actualizar funcion de calculo y promedio de la fortuna
Natyushk Mar 26, 2024
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
Binary file added IMAGENES/Alice Walton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Bernard Arnault.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Bill Gates.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Carlos Slim.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/François_Pinault.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Giovani Ferrero.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Jim_Walton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Larry Page.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Lei Jun.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Ma-Huateng.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Mark Zuckerberg.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Mike Bloomberg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Mukesh Ambani.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Sergey Brin.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Steve Ballmer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/Zhong Shanshan.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/charles koch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/elon-musk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/francoise-bettencourt-meyers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/jack Ma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/jeff-bezos.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/lakshmi-mittal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/larry ellison.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added IMAGENES/warren buffett.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13,949 changes: 13,949 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

523 changes: 288 additions & 235 deletions src/data/dataset.js

Large diffs are not rendered by default.

48 changes: 43 additions & 5 deletions src/dataFunctions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
// Estas funciones son ejemplos, aquí puedes desarrollar tus propias funciones.

export const example = () => {
return 'example';
// Función para filtrar los datos por continente
export const filterByContinent = (data, continent) => {
if (continent === 'Todos') {
return data; // No aplicar ningún filtro si se selecciona 'Todos'
} else {
return data.filter(item => item.extraInfo.continent === continent);
}
};

export const anotherExample = () => {
return [];
// Función para ordenar los datos por fortuna (mayor a menor o menor a mayor) o por nombre
export const sortBy = (data, field, sortOrder) => {
if (field === 'fortune') {
return data.sort((a, b) => {
const fortuneA = parseFortune(a.facts.fortune);
const fortuneB = parseFortune(b.facts.fortune);
return sortOrder === 'asc' ? fortuneA - fortuneB : fortuneB - fortuneA;
});
} else if (field === 'name') {
return data.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
return sortOrder === 'asc' ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
});
}
};

// Función para calcular la fortuna total de los datos
export const calculateTotalFortune = (data) => {
return data.reduce((total, item) => {
return total + parseFortune(item.facts.fortune);
}, 0); // Agrega el valor inicial de total como 0
};

// Función para calcular la suma total y el promedio de las fortunas
export const calculateFortuneStats = (data) => {
const filteredFortunes = data.map(item => parseFortune(item.facts.fortune));
const totalFortune = filteredFortunes.reduce((total, fortune) => total + fortune, 0);
const averageFortune = totalFortune / filteredFortunes.length;
return { totalFortune, averageFortune };
};


// Función auxiliar para convertir la fortuna a un número
const parseFortune = (fortuneString) => {
return parseFloat(fortuneString.replace(/[^\d.-]/g, ''));
};
37 changes: 36 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,45 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dataverse</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<header>
<h1>Personas mas ricas del mundo</h1>
</header>
<main>
<h2></h2>
<section>
<label for="continente">Filtrar por continente:</label>
<select name="continente" id="continent-filter">
<option value="Todos">Todos</option>
<option value="Oceanía">Oceanía</option>
<option value="América">América</option>
<option value="Asia">Asia</option>
<option value="Africa">África</option>
<option value="Europa">Europa</option>
<option value="Antartida">Antártida</option>
</select>
<label for="sort-by">Ordenar por:</label>
<select name="sort-by" id="sort-by">
<option value="name-asc">Nombre (A-Z)</option>
<option value="name-desc">Nombre (Z-A)</option>
<option value="fortune-asc">Fortuna (Ascendente)</option>
<option value="fortune-desc">Fortuna (Descendente)</option>
</select>
<button id="reset-button">Limpiar</button>
<div id="fortune-stats">
<p id="total-fortune">Suma total de fortunas:</p>
<p id="average-fortune">Promedio de fortunas:</p>
</div>
</section>
<ul id="rich-people-list"></ul>
</main>
<footer>
<p>Creadoras.</p>
</footer>
<script src="main.js" type="module"></script>
</body>
</html>
</html>
53 changes: 50 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
import { example } from './dataFunctions.js';
import data from './data/dataset.js';

import { renderItems } from './view.js';

import data from './data/dataset.js';
// Importar funciones
import { filterByContinent, sortBy, calculateFortuneStats } from './dataFunctions.js';

// import { filterByContinent, sortBy, calculateTotalFortune } from './dataFunctions.js';

const richPeopleList = document.getElementById('rich-people-list');
const totalFortuneElement = document.getElementById('total-fortune');
const averageFortuneElement = document.getElementById('average-fortune');

//Renderizar los elementos inicialmente
richPeopleList.appendChild(renderItems(data));

// Referencias a elementos del DOM
const continentFilterSelect = document.getElementById('continent-filter');
const sortBySelect = document.getElementById('sort-by');
//const richPeopleList = document.getElementById('rich-people-list');

// Manejador de evento para cambio en select
continentFilterSelect.addEventListener('change', () => {
const continent = continentFilterSelect.value;
const filteredData = filterByContinent(data, continent);
const sortedData = sortBy(filteredData, 'fortune', 'asc');
richPeopleList.innerHTML = '';
richPeopleList.appendChild(renderItems(sortedData));
updateFortuneStats(sortedData);
});

// Manejador de evento para el botón de ordenar
sortBySelect.addEventListener('change', () => {
const [field, order] = sortBySelect.value.split('-');
const sortedData = sortBy(data, field, order);
richPeopleList.innerHTML = '';
richPeopleList.appendChild(renderItems(sortedData));
});

// Función para actualizar y mostrar la fortuna total y el promedio
const updateFortuneStats = (data) => {
const { totalFortune, averageFortune } = calculateFortuneStats(data);
totalFortuneElement.textContent = `Suma total de fortunas: ${formatFortune(totalFortune)}`;
averageFortuneElement.textContent = `Promedio de fortunas: ${formatFortune(averageFortune)}`;
};

// Función para formatear la fortuna
const formatFortune = (fortune) => {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(fortune);
};

console.log(example, renderItems(data), data);
// Actualizar las estadísticas de fortuna inicialmente
updateFortuneStats(data);
69 changes: 69 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body{
background-color: #333333;
font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
color: white;
min-height: 100vh;
position: relative;
}
header{
display: inline;
text-align: center;
}
h1{
margin: 24px;
align-self: center;
font-size: 50px;
}
main {
text-align: center;
}
section {
font-size: 28px;
}
select {
font-size: 32px;
}
ul{
padding: 24px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.card {
width: 380px;
height: 550px;
margin: 12px;
padding: 0 12px 0 12px;
border-radius: 8px ;
background-color: #FFAC46;
display: flex;
flex-direction: column;
align-items: center;
list-style: none;
flex-grow: 1;
color: #922B21;
}

p:nth-child(2){
font-size: 32px;
}
p:nth-child(4), p:nth-child(5) {
margin-top: 12px;
}
img {
width: 300px;
height: 300px;
margin: 24px;
border-radius: 100%;
}
footer{
width: 100%;
background-color: #922B21;
position: absolute;
bottom: 0;
}
56 changes: 51 additions & 5 deletions src/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,52 @@
export const renderItems = (data) => {
console.log(data)
// Aquí comienza tu código y puedes retornar lo que tu necesites
return 'example';
};
// Definición de la función renderItems corregida
export const renderItems = (dataArray) => {
// Verificar si dataArray es un array
if (!Array.isArray(dataArray)) {
console.error("Data debe ser un array.");
return;
}

// Crear un nuevo ul
const newUl = document.createElement("ul");
// Iterar sobre cada elemento en el array
dataArray.forEach(element => {
// Crear un nuevo li para cada elemento
const newLi = document.createElement("li");
newLi.classList.add("card");
newUl.appendChild(newLi);


// Crear y configurar la imagen
const nodoImg = document.createElement("img");
nodoImg.src = element.imageUrl;
newLi.appendChild(nodoImg);

// Crear y configurar el párrafo con el nombre
const newPName = document.createElement("p");

newPName.textContent = `Nombre: ${element.name}`
newLi.appendChild(newPName);
//newPName.innerHTML = element.name;

const newPContinent = document.createElement("p");
//newPContinent.textContent = `Continente: ${element.extraInfo.continent}`
newLi.appendChild(newPContinent);
newPContinent.innerHTML = element.extraInfo.continent;

const newPFortune = document.createElement("p");
//newPFortune.textContent = `Fortuna: ${element.facts.fortune}`
newLi.appendChild(newPFortune);
newPFortune.innerHTML = element.facts.fortune;

const newPshortDescription = document.createElement("p");
//newPFortune.textContent = `Fortuna: ${element.facts.fortune}`
newLi.appendChild(newPshortDescription);
newPshortDescription.innerHTML = element.shortDescription;

//newP.innerHTML = element.name + element.extraInfo.continent;

});

return newUl;

};