Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e68ed8b
Index js modificado
Jun 12, 2023
acd39c2
actualizacion con cosas previsas
Jun 12, 2023
b568de4
prueba
Jun 12, 2023
0d3b55e
test ok css y html
Jun 12, 2023
132818b
Create node.js.yml
Bernidelpino Jun 12, 2023
f4e80f3
funciones
Jun 13, 2023
527f074
Merge branch 'main' of https://github.com/Bernidelpino/DEV009-text-an…
Jun 13, 2023
b01f91f
Arreglos menores
Jun 14, 2023
27c1af3
prueba
Jun 14, 2023
fecc0fd
Cambios de legibilidad en todos los archivos
Jun 14, 2023
5ea6cde
Update README.md
Bernidelpino Jun 14, 2023
a384c76
Update README.md
Bernidelpino Jun 14, 2023
d056e86
Update README.md
Bernidelpino Jun 14, 2023
be9d2af
imagenes
Bernidelpino Jun 14, 2023
04d13c1
Update README.md
Bernidelpino Jun 14, 2023
1e49dc5
imagenes
Bernidelpino Jun 14, 2023
f49af00
Update README.md
Bernidelpino Jun 14, 2023
019cdd2
Create gif analyzer
Bernidelpino Jun 15, 2023
686692f
Update README.md
Bernidelpino Jun 15, 2023
7bb4e2f
Update README.md
Bernidelpino Jun 15, 2023
212458c
Update README.md
Bernidelpino Jun 15, 2023
f7db803
Update README.md
Bernidelpino Jun 15, 2023
11cadcd
Update README.md
Bernidelpino Jun 16, 2023
ebd824a
Update README.md
Bernidelpino Jun 16, 2023
9b803d3
cambios finales
Jun 18, 2023
9236c3d
Merge branch 'main' of https://github.com/Bernidelpino/DEV009-text-an…
Jun 18, 2023
7e151e0
cambios
Bernidelpino Jun 18, 2023
35b46a9
readme final
Bernidelpino Jun 18, 2023
1691c83
css final
Bernidelpino Jun 18, 2023
76ccff6
js final
Bernidelpino Jun 18, 2023
b80d8ea
subir
Bernidelpino Jun 18, 2023
5c43cdf
orden
Bernidelpino Jun 18, 2023
de65288
Merge branch 'main' of https://github.com/Bernidelpino/DEV009-text-an…
Bernidelpino Jun 18, 2023
3ba6a63
Update README.md
Bernidelpino Jun 18, 2023
333c35c
readme
Bernidelpino Jun 19, 2023
c23ba17
readme1
Bernidelpino Jun 19, 2023
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
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
722 changes: 34 additions & 688 deletions README.md

Large diffs are not rendered by default.

Binary file added baja fidelidad cuaderno.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions gif analyzer
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions imagenes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"babel-jest": "^27.0.1",
"css": "^3.0.0",
"eslint": "^8.3.0",
"gh-pages": "^3.1.0",
"gh-pages": "^3.2.3",
"htmlhint": "^1.0.0",
"jest": "^27.0.1",
"jsdom": "^21.1.1",
Expand All @@ -42,4 +42,4 @@
"version": "6.3.0",
"commit": "a942adeb868f1fe54b86e34cc4fc4ddb0601700d"
}
}
}
2 changes: 1 addition & 1 deletion read-only/test/e2e/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ test.describe('Botón:', () => {
await textarea.click();
await textarea.type(TEST_TEXT_NO_NUMBERS);
});

test('Limpia caja de texto', async ({ page }) => {
const TEST_TEXT_EMPTY = '';
const textarea = await page.locator('textarea[name="user-input"]');
await expect(textarea).toHaveValue(TEST_TEXT_NO_NUMBERS);
const button = await page.locator('id=reset-button')
Expand Down
46 changes: 36 additions & 10 deletions src/analyzer.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
const analyzer = {
const analyzer = {
getWordCount: (text) => {
//TODO: esta función debe retornar el recuento de palabras que se encuentran en el parámetro `text` de tipo `string`.
const palabrasSeparadas = text.split(" ");
const resultadoTexto = palabrasSeparadas.length;
return resultadoTexto;
},
getCharacterCount: (text) => {
//TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`.
const cantidadDeLetras = text.length;
return cantidadDeLetras;
},
getCharacterCountExcludingSpaces: (text) => {
//TODO: esta función debe retornar el recuento de caracteres excluyendo espacios y signos de puntuación que se encuentran en el parámetro `text` de tipo `string`.
},
getAverageWordLength: (text) => {
//TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`.
const cantidadDeCaracteres = (text.replace(/\s/g,''));
const sinEspacio = cantidadDeCaracteres.replace(/[^a-zA-Z0-9]/g,'');
return sinEspacio.length;
},
getNumberCount: (text) => {
//TODO: esta función debe retornar cúantos números se encuentran en el parámetro `text` de tipo `string`.
const numeros = text.match(/\b\d+(\.\d+)?\b/g) || [];
let count = 0;
numeros.forEach((Number) => {
const parseNumber=parseFloat(Number);
if(!isNaN (parseNumber) && isFinite(parseNumber)) {
count++;}
});
return count;
},
getNumberSum: (text) => {
//TODO: esta función debe retornar la suma de todos los números que se encuentran en el parámetro `text` de tipo `string`.
const numbers = text.match(/\b\d+(\.\d+)?\b/g) || [];
let sum = 0;
numbers.forEach((number) => {
const parseNumber = parseFloat(number);
if (!isNaN(parseNumber) && isFinite(parseNumber)){
sum += parseNumber;
}
});
return sum;
},
getAverageWordLength: (text) => {
const cantidadDePalabras = text.split(' ');
let sumaLargos = 0;
for (let i = 0; i < cantidadDePalabras.length; i++) {
sumaLargos += cantidadDePalabras[i].length;
}
const largoPromedio = sumaLargos / cantidadDePalabras.length;
return Number(largoPromedio.toFixed(2));
},
};

export default analyzer;

31 changes: 24 additions & 7 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Analizador de texto</title>
<title>Proyecto1</title>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<script src="index.js" type="module"></script>
</body>
</html>
<body class="colorDeFondo">
<header>
<h1> Analizador de texto </h1>
</header>
<ul class="ulEstilo">
<li class="liEstilo">Recuento de caracteres: <span id="contarCaracteres" class="cuadroResultado"></span> </li>
<li class="liEstilo">Sin caracteres: <span id="sinCaracteres" class="cuadroResultado"></span> </li>
<li class="liEstilo">Recuento de palabras: <span id="contarPalabras" class="cuadroResultado"></span> </li>
<li class="liEstilo">Recuento de numeros: <span id="contarNumeros" class="cuadroResultado"></span> </li>
<li class="liEstilo">Suma de numeros: <span id="sumaNumeros" class="cuadroResultado"></span> </li>
<li class="liEstilo">Promedio de longitud: <span id="longitudPromedio" class="cuadroResultado"></span> </li>
</ul>
<textarea name="user-input" type="text">
</textarea>
<div>
<button type="button" id="reset-button">Limpiar texto</button>
</div>
<footer>
<p>Creado por Bernardita del Pino Villaseca</p>
</footer>
<script src="index.js" type="module"></script>
</body>
</html>
28 changes: 26 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
import analyzer from './analyzer.js';

//TODO: escuchar eventos del DOM e invocar los métodos del objeto `analyzer`
const textarea = document.querySelector("textarea[name='user-input']");
textarea.addEventListener("keyup", function () {
const text = textarea.value;
const contarCaracteres = analyzer.getCharacterCount(text);
document.getElementById("contarCaracteres").innerHTML = contarCaracteres;
const sinCaracteres = analyzer.getCharacterCountExcludingSpaces(text);
document.getElementById("sinCaracteres").innerHTML = sinCaracteres;
const contarPalabras = analyzer.getWordCount(text);
document.getElementById("contarPalabras").innerHTML = contarPalabras;
const contarNumeros = analyzer.getNumberCount(text);
document.getElementById("contarNumeros").innerHTML = contarNumeros;
const sumaNumeros = analyzer.getNumberSum(text);
document.getElementById("sumaNumeros").innerHTML = sumaNumeros;
const longitudPromedio = analyzer.getAverageWordLength(text);
document.getElementById("longitudPromedio").innerHTML = longitudPromedio;
})
const button = document.getElementById("reset-button");
button.addEventListener("click", function () {
textarea.value = '';
document.getElementById("contarCaracteres").innerHTML = '';
document.getElementById("sinCaracteres").innerHTML = '';
document.getElementById("contarPalabras").innerHTML = '';
document.getElementById("contarNumeros").innerHTML = '';
document.getElementById("sumaNumeros").innerHTML = '';
document.getElementById("longitudPromedio").innerHTML = '';
});
94 changes: 94 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
header {
text-align: -webkit-center;
font-family: math;
color: rgb(47, 40, 40);
background-color: #fabfb7;
max-width: -webkit-fill-available;
margin: 50px;
border: dashed 2px;
border-radius: 50px;
border-color: white;
width: 100%;
}
.colorDeFondo {
background-image: url('https://i.blogs.es/6e7601/paige-cody--esaigzemqu-unsplash/840_560.jpeg');
background-size: cover;
}

.ulEstilo {
position: relative;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: flex-start;
justify-content: center;
align-items: baseline;
justify-content: center;
margin: 9px;
}

.liEstilo {
background-color: #fabfb7;
border-radius: 10px;
border: solid 2px white;
width: 186px;
height: 42px;
font-family: math;
font-size: 14px;
padding: 9px;
margin: 9px;
}

.cuadroResultado {
border: solid 2px;
border-color: antiquewhite;
background-color: #ffda9e;
color: rgb(47, 40, 40);
width: 80px;
height: 30px;
}

textarea[name="user-input"] {
text-align: -webkit-center;
font-family: math;
margin: 50px;
width: 1000px;
height: 137px;
resize: none;
margin-top: 0px;
margin-left: 150px;
font-size: 18px;
color: rgb(47, 40, 40);
font-family: math;
border: solid 3px;
border-radius: 24px;
border-color: #f19b8f;
background-color: #ffda9e;
}
#reset-button {
border: dashed 2px;
border-radius: 20px;
border-color: #f19b8f;
background-color: #ffda9e;
width: 93px;
height: 50px;
font-family: math;
font-size: 14px;
padding: 9px;
margin: 9px;
margin-left: auto;
margin-right: auto;
display: grid;
}
footer {
text-align: -webkit-center;
font-family: math;
color: rgb(47, 40, 40);
background-color: #f19b8f;
max-width: -webkit-fill-available;
margin: 50px;
border: dashed 2px;
border-radius: 10px;
border-color: white;
width: 100%;
}