From c3c111a63bbcdbe6a937074c073d511b5cc1316e Mon Sep 17 00:00:00 2001 From: deniisolo Date: Wed, 21 Feb 2024 20:40:15 -0500 Subject: [PATCH 01/24] primer commit --- src/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.html b/src/index.html index 3f32ea9..fa16a9f 100644 --- a/src/index.html +++ b/src/index.html @@ -8,6 +8,7 @@ +

Hola Mundo

\ No newline at end of file From b949f495a27b5dfe6661e6c8d4a5ed15fc3640cd Mon Sep 17 00:00:00 2001 From: deniisolo Date: Thu, 22 Feb 2024 11:18:50 -0500 Subject: [PATCH 02/24] estructura Html Semantico --- src/index.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index fa16a9f..0da91e2 100644 --- a/src/index.html +++ b/src/index.html @@ -8,7 +8,13 @@ -

Hola Mundo

+
+

Analizador de texto

+
+
+ +
+
\ No newline at end of file From 4e01be214437498452db72d0e48911061ec3affe Mon Sep 17 00:00:00 2001 From: deniisolo Date: Thu, 22 Feb 2024 11:55:01 -0500 Subject: [PATCH 03/24] estructura Html --- src/index.html | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/index.html b/src/index.html index 0da91e2..67581e5 100644 --- a/src/index.html +++ b/src/index.html @@ -1,20 +1,34 @@ + + + Analizador de texto + + - - - Analizador de texto - - - - -
-

Analizador de texto

-
-
- -
-
- - - \ No newline at end of file + +
+

Analizador de texto

+ + + + +
+
+
    + +
  • Palabras:
  • +
  • Caracteres:
  • +
  • Caracteres sin espacios:
  • +
  • Números:
  • +
  • Suma de números:
  • +
  • Longitud de palabras:
  • +
+
+
+

Denis Alvarez - Deniisolo

+ +
+ + + From 6dc7f3ceb7910a9d6beb94201573699921075f16 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Thu, 22 Feb 2024 12:26:54 -0500 Subject: [PATCH 04/24] estructura Html --- src/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.html b/src/index.html index 67581e5..6992f91 100644 --- a/src/index.html +++ b/src/index.html @@ -17,12 +17,12 @@

Analizador de texto

    -
  • Palabras:
  • -
  • Caracteres:
  • -
  • Caracteres sin espacios:
  • -
  • Números:
  • -
  • Suma de números:
  • -
  • Longitud de palabras:
  • +
  • Palabras:
  • +
  • Caracteres:
  • +
  • Caracteres sin espacios:
  • +
  • Números:
  • +
  • Suma de números:
  • +
  • Longitud de palabras:
From ba3aa0537a81a97dd517535e72ce94ad5ea8ed62 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Thu, 22 Feb 2024 14:40:58 -0500 Subject: [PATCH 05/24] estructura CSS --- src/index.html | 13 +++++++-- src/style.css | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/src/index.html b/src/index.html index 6992f91..29034c2 100644 --- a/src/index.html +++ b/src/index.html @@ -3,6 +3,13 @@ Analizador de texto + + + + @@ -15,11 +22,11 @@

Analizador de texto

-
    +
    • Palabras:
    • -
    • Caracteres:
    • -
    • Caracteres sin espacios:
    • +
    • Caracteres:
    • +
    • Caracteres sin espacios:
    • Números:
    • Suma de números:
    • Longitud de palabras:
    • diff --git a/src/style.css b/src/style.css index e69de29..11eef0f 100644 --- a/src/style.css +++ b/src/style.css @@ -0,0 +1,79 @@ +:root { + --pig: #de6896; + --yellow: #f0cc56; + --purple-Soft: #e5dbfe; + --purple: #4f3d9f; + --black: #060012; + --white: #fefefe; +} +* { + font-family: "Lato"; +} +header { + background-color: #e5dbfe; + border-radius: 2rem; + display: grid; + grid-template-columns: 2; +} +footer { + font-weight: 600; +} + +textarea[name="user-input"] { + background-color: var(--white); +} +#reset-button { + background-color: #4f3d9f; + color: var(--white); +} +.containerCount { + background-color: var(--white); +} +.countWords { + background-color: var(--yellow); + border-radius: 1rem; + margin-top: 1rem; + margin-bottom: 1rem; + margin-left: 1rem; + margin-right: 1rem; +} +.countCharacters { + background-color: var(--pig); + border-radius: 1rem; + margin-top: 1rem; + margin-bottom: 1rem; + margin-left: 1rem; + margin-right: 1rem; +} +.countCharacterswtspaces { + background-color: var(--purple); + border-radius: 1rem; + margin-top: 1rem; + margin-bottom: 1rem; + margin-left: 1rem; + margin-right: 1rem; +} +.countNumber { + background-color: var(--yellow); + border-radius: 1rem; + margin-top: 1rem; + margin-bottom: 1rem; + margin-left: 1rem; + margin-right: 1rem; +} +.countSum { + background-color: var(--pig); + border-radius: 1rem; + margin-top: 1rem; + margin-bottom: 1rem; + margin-left: 1rem; + margin-right: 1rem; +} +.wordLength { + background-color: var(--purple); + border-radius: 1rem; + margin-top: 1rem; + margin-bottom: 1rem; + margin-left: 1rem; + margin-right: 1rem; +} From 604da6c941c30be965ea9806889e7147aef5b80e Mon Sep 17 00:00:00 2001 From: deniisolo Date: Thu, 22 Feb 2024 18:35:51 -0500 Subject: [PATCH 06/24] estructura css --- package-lock.json | 6 +-- package.json | 4 +- src/index.html | 21 ++++------ src/style.css | 103 ++++++++++++++++++++++++---------------------- 4 files changed, 65 insertions(+), 69 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef1c093..33d908c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "card-validation", + "name": "text-analyzer", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "card-validation", + "name": "text-analyzer", "version": "1.0.0", "license": "MIT", "devDependencies": { @@ -18,7 +18,7 @@ "eslint": "^8.3.0", "gh-pages": "^3.1.0", "htmlhint": "^1.0.0", - "jest": "^27.0.1", + "jest": "^27.5.1", "jsdom": "^21.1.1", "opener": "^1.5.1", "serve": "^13.0.2" diff --git a/package.json b/package.json index 53e5d22..31ad0f7 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "eslint": "^8.3.0", "gh-pages": "^3.1.0", "htmlhint": "^1.0.0", - "jest": "^27.0.1", + "jest": "^27.5.1", "jsdom": "^21.1.1", "opener": "^1.5.1", "serve": "^13.0.2" @@ -42,4 +42,4 @@ "version": "8.3.0", "commit": "bd8a1a73329ce2b8362a65193c9468240ac8d9c7" } -} \ No newline at end of file +} diff --git a/src/index.html b/src/index.html index 29034c2..da6674b 100644 --- a/src/index.html +++ b/src/index.html @@ -3,13 +3,6 @@ Analizador de texto - - - - @@ -22,14 +15,14 @@

      Analizador de texto

      -
        +
          -
        • Palabras:
        • -
        • Caracteres:
        • -
        • Caracteres sin espacios:
        • -
        • Números:
        • -
        • Suma de números:
        • -
        • Longitud de palabras:
        • +
        • Palabras:
        • +
        • Caracteres:
        • +
        • Caracteres sin espacios:
        • +
        • Números:
        • +
        • Suma de números:
        • +
        • Longitud de palabras:
      diff --git a/src/style.css b/src/style.css index 11eef0f..8ff1f95 100644 --- a/src/style.css +++ b/src/style.css @@ -7,73 +7,76 @@ --white: #fefefe; } * { - font-family: "Lato"; + font-family: "Open Sans", "Helvetica Neue", sans-serif; } header { background-color: #e5dbfe; border-radius: 2rem; display: grid; - grid-template-columns: 2; + grid-template-columns: 2fr 2fr; + grid-template-rows: 1fr; + gap: 1rem; + place-items: center; + height: 230px; } +#reset-button { + background-color: #4f3d9f; + color: var(--white); + height: 50px; + width: 100px; + border-radius: 20px; + border-style: none; + grid-column: 2; + justify-self: center; + margin-right: 30px; + margin-bottom: 30px; + } footer { + display: grid; + grid-template-rows: 500px; font-weight: 600; + font-size: 1.5rem; + place-items: end; } - textarea[name="user-input"] { background-color: var(--white); -} -#reset-button { - background-color: #4f3d9f; - color: var(--white); -} -.containerCount { - background-color: var(--white); -} -.countWords { - background-color: var(--yellow); border-radius: 1rem; - margin-top: 1rem; - margin-bottom: 1rem; - margin-left: 1rem; - margin-right: 1rem; + height: 100px; + width: 400px; + border-style: dashed; } -.countCharacters { - background-color: var(--pig); - border-radius: 1rem; - margin-top: 1rem; - margin-bottom: 1rem; - margin-left: 1rem; - margin-right: 1rem; -} -.countCharacterswtspaces { - background-color: var(--purple); - border-radius: 1rem; - margin-top: 1rem; - margin-bottom: 1rem; - margin-left: 1rem; - margin-right: 1rem; + +ul { + display: grid; + grid-template-rows: 100px; + grid-template-columns: 100px 100px 100px 100px 100px 100px; + gap: 200px; } -.countNumber { - background-color: var(--yellow); +.count1 { + display: block; + background: var(--yellow); border-radius: 1rem; - margin-top: 1rem; - margin-bottom: 1rem; - margin-left: 1rem; - margin-right: 1rem; + color: var(--white); + margin: 10%; + padding: 10; + height: 200px; + width: 200px; } -.countSum { - background-color: var(--pig); +.count2 { + background: var(--pig); border-radius: 1rem; - margin-top: 1rem; - margin-bottom: 1rem; - margin-left: 1rem; - margin-right: 1rem; + color: var(--white); + margin: 10%; + padding: 10; + height: 200px; + width: 200px; } -.wordLength { - background-color: var(--purple); +.count3 { + background: var(--purple); border-radius: 1rem; - margin-top: 1rem; - margin-bottom: 1rem; - margin-left: 1rem; - margin-right: 1rem; + color: var(--white); + margin: 10%; + padding: 10; + height: 200px; + width: 200px; } From ed02c7e3284f2d1bb9f9410ad96810f65554310c Mon Sep 17 00:00:00 2001 From: deniisolo Date: Thu, 22 Feb 2024 19:27:05 -0500 Subject: [PATCH 07/24] estructura css --- src/analyzer.js | 2 ++ src/index.js | 3 ++- src/style.css | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index 85797a8..41369e3 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -1,6 +1,8 @@ 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`. + //con iterar eso es con un buble + }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. diff --git a/src/index.js b/src/index.js index 58ba255..43deee5 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ import analyzer from './analyzer.js'; - +analyzer.getWordCount("hola") +console.log(analyzer.getWordCount("hola")) //TODO: escuchar eventos del DOM e invocar los métodos del objeto `analyzer` \ No newline at end of file diff --git a/src/style.css b/src/style.css index 8ff1f95..cc71038 100644 --- a/src/style.css +++ b/src/style.css @@ -17,7 +17,10 @@ header { grid-template-rows: 1fr; gap: 1rem; place-items: center; - height: 230px; + box-shadow: 0 0 10px #646365; + margin-top: 30px; + margin-left: 30px; + margin-right: 30px; } #reset-button { background-color: #4f3d9f; @@ -33,7 +36,7 @@ header { } footer { display: grid; - grid-template-rows: 500px; + grid-template-rows: 100px; font-weight: 600; font-size: 1.5rem; place-items: end; @@ -44,39 +47,58 @@ textarea[name="user-input"] { height: 100px; width: 400px; border-style: dashed; + margin-top: 10px; } ul { display: grid; - grid-template-rows: 100px; - grid-template-columns: 100px 100px 100px 100px 100px 100px; - gap: 200px; + grid-template-rows: 1fr; + grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr; + gap: 20px; + justify-self: center; + } +/* main{ + display: grid; + grid-template-rows: 100px; +} */ .count1 { display: block; background: var(--yellow); border-radius: 1rem; color: var(--white); margin: 10%; - padding: 10; + padding: 10px; height: 200px; width: 200px; + font-size: 1.5rem; + display: grid; + justify-items: center; + font-weight: 600; } .count2 { background: var(--pig); border-radius: 1rem; color: var(--white); margin: 10%; - padding: 10; + padding: 10px; height: 200px; width: 200px; + font-size: 1.5rem; + display: grid; + justify-items: center; + font-weight: 600; } .count3 { background: var(--purple); border-radius: 1rem; color: var(--white); margin: 10%; - padding: 10; + padding: 10px; height: 200px; width: 200px; + font-size: 1.5rem; + display: grid; + justify-items: center; + font-weight: 600; } From 4138c3d7add46efa5271b7e1ae7f9bb640594d33 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Fri, 23 Feb 2024 14:53:18 -0500 Subject: [PATCH 08/24] start 1 funcionalidad :D --- src/analyzer.js | 6 ++++-- src/index.html | 4 ++-- src/index.js | 12 +++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index 41369e3..2f28f03 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -1,8 +1,10 @@ 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`. - //con iterar eso es con un buble - + //con iterar eso es con un bucle + let cadena = text; + let palabras = cadena.split(" "); + console.log(palabras.length) }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. diff --git a/src/index.html b/src/index.html index da6674b..6029606 100644 --- a/src/index.html +++ b/src/index.html @@ -10,7 +10,7 @@

      Analizador de texto

      - +
      @@ -29,6 +29,6 @@

      Analizador de texto

      Denis Alvarez - Deniisolo

      - + diff --git a/src/index.js b/src/index.js index 43deee5..95fe79c 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,10 @@ import analyzer from './analyzer.js'; -analyzer.getWordCount("hola") -console.log(analyzer.getWordCount("hola")) -//TODO: escuchar eventos del DOM e invocar los métodos del objeto `analyzer` \ No newline at end of file + + +//TODO: escuchar eventos del DOM e invocar los métodos del objeto `analyzer` +const input = document.querySelector("textarea[name='user-input']"); +console.log(input) + +input.addEventListener('input', function(event) { + analyzer.getWordCount(input.value) +}); From 514019322b3219c4a6d70fe04870354ac9de6a0c Mon Sep 17 00:00:00 2001 From: deniisolo Date: Fri, 23 Feb 2024 18:20:51 -0500 Subject: [PATCH 09/24] start 1 funcionalidad :D --- src/analyzer.js | 5 ++--- src/index.html | 12 ++++++------ src/index.js | 17 +++++++++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index 2f28f03..068284b 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -2,9 +2,8 @@ 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`. //con iterar eso es con un bucle - let cadena = text; - let palabras = cadena.split(" "); - console.log(palabras.length) + const palabras = text.split(" "); + return palabras.length }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. diff --git a/src/index.html b/src/index.html index 6029606..fdbfe5f 100644 --- a/src/index.html +++ b/src/index.html @@ -17,12 +17,12 @@

      Analizador de texto

        -
      • Palabras:
      • -
      • Caracteres:
      • -
      • Caracteres sin espacios:
      • -
      • Números:
      • -
      • Suma de números:
      • -
      • Longitud de palabras:
      • +
      • Palabras:
      • +
      • Caracteres:
      • +
      • Caracteres sin espacios:
      • +
      • Números:
      • +
      • Suma de números:
      • +
      • Longitud de palabras:
      diff --git a/src/index.js b/src/index.js index 95fe79c..43fc601 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,15 @@ -import analyzer from './analyzer.js'; - +import analyzer from "./analyzer.js"; //TODO: escuchar eventos del DOM e invocar los métodos del objeto `analyzer` -const input = document.querySelector("textarea[name='user-input']"); -console.log(input) +const input = document.querySelector("textarea[name='user-input']"); -input.addEventListener('input', function(event) { - analyzer.getWordCount(input.value) +input.addEventListener("input", function () { + // Contar el numero de palabras + const wordcount = analyzer.getWordCount(input.value); + // tengo que acceder al ul + const uls = document.getElementsByTagName('ul') + // acceder a 1 li + const firstChild = uls[0].children[0]; + //asignarle el texto al li + firstChild.innerHTML='Palabras: '+ wordcount; }); From 3d19304ed82c638ea88996e9dc739d045ea70bb1 Mon Sep 17 00:00:00 2001 From: Deniisolo Date: Fri, 23 Feb 2024 18:37:42 -0500 Subject: [PATCH 10/24] organizando un poco --- src/analyzer.js | 8 +++---- src/index.html | 62 +++++++++++++++++++++++++------------------------ src/index.js | 8 +++---- src/style.css | 29 +++++++++++------------ 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index 068284b..3910fd6 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -1,9 +1,9 @@ -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`. - //con iterar eso es con un bucle + //con iterar eso es con un bucle const palabras = text.split(" "); - return palabras.length + return palabras.length; }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. @@ -11,7 +11,7 @@ const analyzer = { 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) => { + getAverageWordLength: (text) => { //TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`. }, getNumberCount: (text) => { diff --git a/src/index.html b/src/index.html index fdbfe5f..5d5ae1a 100644 --- a/src/index.html +++ b/src/index.html @@ -1,34 +1,36 @@ - - - Analizador de texto - - - -
      -

      Analizador de texto

      - - - - -
      -
      -
        - -
      • Palabras:
      • -
      • Caracteres:
      • -
      • Caracteres sin espacios:
      • -
      • Números:
      • -
      • Suma de números:
      • -
      • Longitud de palabras:
      • -
      -
      -
      -

      Denis Alvarez - Deniisolo

      + + + Analizador de texto + + + + +
      +

      Analizador de texto

      + + + + +
      +
      +
        -
      - - - +
    • Palabras:
    • +
    • Caracteres:
    • +
    • Caracteres sin espacios:
    • +
    • Números:
    • +
    • Suma de números:
    • +
    • Longitud de palabras:
    • +
    +
+
+

Denis Alvarez - Deniisolo

+ +
+ + + + \ No newline at end of file diff --git a/src/index.js b/src/index.js index 43fc601..84b46b1 100644 --- a/src/index.js +++ b/src/index.js @@ -6,10 +6,10 @@ const input = document.querySelector("textarea[name='user-input']"); input.addEventListener("input", function () { // Contar el numero de palabras const wordcount = analyzer.getWordCount(input.value); - // tengo que acceder al ul - const uls = document.getElementsByTagName('ul') - // acceder a 1 li + // tengo que acceder al ul + const uls = document.getElementsByTagName("ul"); + // acceder a 1 li const firstChild = uls[0].children[0]; //asignarle el texto al li - firstChild.innerHTML='Palabras: '+ wordcount; + firstChild.innerHTML = "Palabras: " + wordcount; }); diff --git a/src/style.css b/src/style.css index cc71038..70a01e4 100644 --- a/src/style.css +++ b/src/style.css @@ -17,23 +17,23 @@ header { grid-template-rows: 1fr; gap: 1rem; place-items: center; - box-shadow: 0 0 10px #646365; + box-shadow: 0 0 10px #646365; margin-top: 30px; margin-left: 30px; margin-right: 30px; } #reset-button { - background-color: #4f3d9f; - color: var(--white); - height: 50px; - width: 100px; - border-radius: 20px; - border-style: none; - grid-column: 2; - justify-self: center; - margin-right: 30px; - margin-bottom: 30px; - } + background-color: #4f3d9f; + color: var(--white); + height: 50px; + width: 100px; + border-radius: 20px; + border-style: none; + grid-column: 2; + justify-self: center; + margin-right: 30px; + margin-bottom: 30px; +} footer { display: grid; grid-template-rows: 100px; @@ -46,8 +46,8 @@ textarea[name="user-input"] { border-radius: 1rem; height: 100px; width: 400px; - border-style: dashed; - margin-top: 10px; + border-style: dashed; + margin-top: 10px; } ul { @@ -56,7 +56,6 @@ ul { grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr; gap: 20px; justify-self: center; - } /* main{ display: grid; From 47ac2fe6b62396d1da6fa023887eda35de5aa88b Mon Sep 17 00:00:00 2001 From: Deniisolo Date: Fri, 23 Feb 2024 18:54:14 -0500 Subject: [PATCH 11/24] 2 funtion start --- src/analyzer.js | 1 + src/index.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/analyzer.js b/src/analyzer.js index 3910fd6..bd54428 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -7,6 +7,7 @@ const analyzer = { }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. + return text.length }, 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`. diff --git a/src/index.js b/src/index.js index 84b46b1..1596031 100644 --- a/src/index.js +++ b/src/index.js @@ -12,4 +12,6 @@ input.addEventListener("input", function () { const firstChild = uls[0].children[0]; //asignarle el texto al li firstChild.innerHTML = "Palabras: " + wordcount; + const countCharacter = analyzer.getCharacterCount(input.value) + console.log(countCharacter) }); From 6ee4387dac3f90c66a1703689350da5fc8b5132a Mon Sep 17 00:00:00 2001 From: Deniisolo Date: Sat, 24 Feb 2024 13:54:19 -0500 Subject: [PATCH 12/24] =?UTF-8?q?2=20funci=C3=B3n=20terminada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.js | 11 ++++++++--- src/index.js | 13 +++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index bd54428..af3a495 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -1,13 +1,18 @@ 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`. - //con iterar eso es con un bucle const palabras = text.split(" "); - return palabras.length; + //no tener en cuenta el " " + let count = 0; + for (let i = 0; i < palabras.length; i++) { + if (palabras[i] !== "") { + count++ + } } + return count; }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. - return text.length + return text.length; }, 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`. diff --git a/src/index.js b/src/index.js index 1596031..bb1e837 100644 --- a/src/index.js +++ b/src/index.js @@ -4,14 +4,19 @@ import analyzer from "./analyzer.js"; const input = document.querySelector("textarea[name='user-input']"); input.addEventListener("input", function () { - // Contar el numero de palabras + // 1 función:Contar el numero de palabras const wordcount = analyzer.getWordCount(input.value); // tengo que acceder al ul const uls = document.getElementsByTagName("ul"); // acceder a 1 li const firstChild = uls[0].children[0]; - //asignarle el texto al li + //asignarle el texto al li 1 firstChild.innerHTML = "Palabras: " + wordcount; - const countCharacter = analyzer.getCharacterCount(input.value) - console.log(countCharacter) + + //2 función: Recuento de caracteres + const countCharacter = analyzer.getCharacterCount(input.value); + // acceder a 2 li + const secondChild= uls[0].children[1]; + //asignarle el texto al li 2 + secondChild.innerHTML = "Caracteres: " + countCharacter; }); From 79f041048d98046541db877e6c179e032c2a7a37 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Sat, 24 Feb 2024 13:59:35 -0500 Subject: [PATCH 13/24] test commit --- src/analyzer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/analyzer.js b/src/analyzer.js index af3a495..5988f3b 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -3,6 +3,7 @@ const analyzer = { //TODO: esta función debe retornar el recuento de palabras que se encuentran en el parámetro `text` de tipo `string`. const palabras = text.split(" "); //no tener en cuenta el " " + // Test comment let count = 0; for (let i = 0; i < palabras.length; i++) { if (palabras[i] !== "") { From b9c5bb8f309562ce4808e1963f72ead105ed6589 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Mon, 26 Feb 2024 11:11:24 -0500 Subject: [PATCH 14/24] =?UTF-8?q?funci=C3=B3n=20#3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.js | 30 +++++++++++++++++++++++++----- src/index.js | 7 ++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index 5988f3b..b5f535a 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -2,14 +2,15 @@ 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 palabras = text.split(" "); - //no tener en cuenta el " " + //no tener en cuenta el " " // Test comment let count = 0; for (let i = 0; i < palabras.length; i++) { - if (palabras[i] !== "") { - count++ - } } - return count; + if (palabras[i] !== "") { + count++; + } + } + return count; }, getCharacterCount: (text) => { //TODO: esta función debe retornar el recuento de caracteres que se encuentran en el parámetro `text` de tipo `string`. @@ -17,6 +18,25 @@ const analyzer = { }, 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`. + //contar caracteres excluyendo Espacios y signos puntuación . , ; : ¿? ! " " - () [] / + let countexcluding = text.replace(".", ""); + countexcluding = countexcluding.replace(" ", ""); + countexcluding = countexcluding.replace(",", ""); + countexcluding = countexcluding.replace(";", ""); + countexcluding = countexcluding.replace(":", ""); + countexcluding = countexcluding.replace("¿", ""); + countexcluding = countexcluding.replace("?", ""); + countexcluding = countexcluding.replace("!", ""); + countexcluding = countexcluding.replace('"', ""); + countexcluding = countexcluding.replace("-", ""); + countexcluding = countexcluding.replace("(", ""); + countexcluding = countexcluding.replace(")", ""); + countexcluding = countexcluding.replace("[", ""); + countexcluding = countexcluding.replace("]", ""); + countexcluding = countexcluding.replace("/", ""); + if (countexcluding.includes(".")) { + } + return countexcluding.length; }, getAverageWordLength: (text) => { //TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`. diff --git a/src/index.js b/src/index.js index bb1e837..670dac3 100644 --- a/src/index.js +++ b/src/index.js @@ -12,11 +12,16 @@ input.addEventListener("input", function () { const firstChild = uls[0].children[0]; //asignarle el texto al li 1 firstChild.innerHTML = "Palabras: " + wordcount; - //2 función: Recuento de caracteres const countCharacter = analyzer.getCharacterCount(input.value); // acceder a 2 li const secondChild= uls[0].children[1]; //asignarle el texto al li 2 secondChild.innerHTML = "Caracteres: " + countCharacter; + // 3 función: Recuento de caracteres excluyendo espacios y signos de puntuación: + const countCharacterwtout = analyzer.getCharacterCountExcludingSpaces(input.value); + // tengo que acceder a li 3 + const thirdChild = uls[0].children[2]; + //asignarle el texto al li 3 + thirdChild.innerHTML = "Caracteres sin espacios: " + countCharacterwtout; }); From 0bb8b6628a9cd80ed9971a3aa4b9c7f91e26826c Mon Sep 17 00:00:00 2001 From: deniisolo Date: Mon, 26 Feb 2024 15:18:06 -0500 Subject: [PATCH 15/24] =?UTF-8?q?3=20funci=C3=B3n=20terminada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.js | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index b5f535a..32c61e5 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -19,24 +19,30 @@ const analyzer = { 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`. //contar caracteres excluyendo Espacios y signos puntuación . , ; : ¿? ! " " - () [] / - let countexcluding = text.replace(".", ""); - countexcluding = countexcluding.replace(" ", ""); - countexcluding = countexcluding.replace(",", ""); - countexcluding = countexcluding.replace(";", ""); - countexcluding = countexcluding.replace(":", ""); - countexcluding = countexcluding.replace("¿", ""); - countexcluding = countexcluding.replace("?", ""); - countexcluding = countexcluding.replace("!", ""); - countexcluding = countexcluding.replace('"', ""); - countexcluding = countexcluding.replace("-", ""); - countexcluding = countexcluding.replace("(", ""); - countexcluding = countexcluding.replace(")", ""); - countexcluding = countexcluding.replace("[", ""); - countexcluding = countexcluding.replace("]", ""); - countexcluding = countexcluding.replace("/", ""); - if (countexcluding.includes(".")) { + const punctuation = [ + ".", + ",", + ";", + ":", + "¿", + "?", + "!", + '"', + "(", + ")", + "[", + "]", + "/", + "-", + ]; + let cleanText = ""; + for (let i = 0; i < text.length; i++) { + if (!punctuation.includes(text[i]) && text[i] !== " ") { + cleanText += text[i]; + } } - return countexcluding.length; + let characterCount = cleanText.length; + return characterCount; }, getAverageWordLength: (text) => { //TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`. From b348d6e70d79b82bacedc136bb39859d4512e3e5 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Mon, 26 Feb 2024 16:05:53 -0500 Subject: [PATCH 16/24] =?UTF-8?q?4=20funci=C3=B3n=20iniciada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 670dac3..76b3561 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ import analyzer from "./analyzer.js"; const input = document.querySelector("textarea[name='user-input']"); input.addEventListener("input", function () { - // 1 función:Contar el numero de palabras + // 1 Función:Contar el numero de palabras const wordcount = analyzer.getWordCount(input.value); // tengo que acceder al ul const uls = document.getElementsByTagName("ul"); @@ -12,16 +12,27 @@ input.addEventListener("input", function () { const firstChild = uls[0].children[0]; //asignarle el texto al li 1 firstChild.innerHTML = "Palabras: " + wordcount; - //2 función: Recuento de caracteres + + //2 Función: Recuento de caracteres const countCharacter = analyzer.getCharacterCount(input.value); // acceder a 2 li - const secondChild= uls[0].children[1]; + const secondChild = uls[0].children[1]; //asignarle el texto al li 2 secondChild.innerHTML = "Caracteres: " + countCharacter; - // 3 función: Recuento de caracteres excluyendo espacios y signos de puntuación: - const countCharacterwtout = analyzer.getCharacterCountExcludingSpaces(input.value); + + // 3 Función: Recuento de caracteres excluyendo espacios y signos de puntuación: + const countCharacterwtout = analyzer.getCharacterCountExcludingSpaces( + input.value + ); // tengo que acceder a li 3 const thirdChild = uls[0].children[2]; //asignarle el texto al li 3 thirdChild.innerHTML = "Caracteres sin espacios: " + countCharacterwtout; + + //4 Función: Recuento de números: + const countNumbers = analyzer.getNumberCount(input.value); + // tengo que acceder a li 4 + const fourthChild = uls[0].children[3]; + //asignarle el texto al li 4 + fourthChild.innerHTML = "Números: " + countNumbers; }); From c34369052f1598f9a2672cb691cda5d577a4f2ad Mon Sep 17 00:00:00 2001 From: deniisolo Date: Mon, 26 Feb 2024 16:38:21 -0500 Subject: [PATCH 17/24] =?UTF-8?q?4=20funci=C3=B3n=20terminada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/analyzer.js b/src/analyzer.js index 32c61e5..c9b83ad 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -48,7 +48,14 @@ const analyzer = { //TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`. }, getNumberCount: (text) => { - //TODO: esta función debe retornar cúantos números se encuentran en el parámetro `text` de tipo `string`. + //TODO: esta función debe retornar cuántos números se encuentran en el parámetro `text` de tipo `string`. + let total = 0; + for (let i = 0; i < text.length; i++) { + if (!isNaN(text[i]) && text[i] !== " ") { + total++; + } + } + return total; }, 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`. From d1903af7ad754f9ae61a12871392622a7699e185 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Tue, 27 Feb 2024 14:16:44 -0500 Subject: [PATCH 18/24] =?UTF-8?q?5=20funci=C3=B3n=20terminada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.js | 9 ++++++++- src/index.js | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/analyzer.js b/src/analyzer.js index c9b83ad..b767b90 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -41,7 +41,7 @@ const analyzer = { cleanText += text[i]; } } - let characterCount = cleanText.length; + const characterCount = cleanText.length; return characterCount; }, getAverageWordLength: (text) => { @@ -59,6 +59,13 @@ const analyzer = { }, 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`. + let sum = 0; + for (let i = 0; i < text.length; i++) { + if (!isNaN(text[i]) && text[i] !== " ") { + sum += parseInt(text[i]); + } + } + return sum; }, }; diff --git a/src/index.js b/src/index.js index 76b3561..c9ce795 100644 --- a/src/index.js +++ b/src/index.js @@ -35,4 +35,13 @@ input.addEventListener("input", function () { const fourthChild = uls[0].children[3]; //asignarle el texto al li 4 fourthChild.innerHTML = "Números: " + countNumbers; + + //5 función Suma total de números: + const sumNumber = analyzer.getNumberSum(input.value); + // tengo que acceder a li 5 + const fifthChild = uls[0].children[4]; + //asignarle el texto al li 5 + fifthChild.innerHTML = "Suma de números: " + sumNumber; + + }); From 9a8de9f659145d51b4699bf00900996a1895a03f Mon Sep 17 00:00:00 2001 From: deniisolo Date: Tue, 27 Feb 2024 14:28:57 -0500 Subject: [PATCH 19/24] =?UTF-8?q?6=20funci=C3=B3n=20inicio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index c9ce795..e32ebc4 100644 --- a/src/index.js +++ b/src/index.js @@ -43,5 +43,10 @@ input.addEventListener("input", function () { //asignarle el texto al li 5 fifthChild.innerHTML = "Suma de números: " + sumNumber; - + //6 función Longitud media de las palabras: + const lengthWord = analyzer.getAverageWordLength(input.value); + // tengo que acceder a li 6 + const sixthChild = uls[0].children[5] + //asignarle el texto al li 6 + sixthChild.innerHTML = "Longitud de palabras: " + lengthWord; }); From 6f38a79829c1e8f25a640c0bd06967b2c9e6ddbf Mon Sep 17 00:00:00 2001 From: deniisolo Date: Tue, 27 Feb 2024 17:16:07 -0500 Subject: [PATCH 20/24] =?UTF-8?q?6=20funci=C3=B3n=20inicio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.js | 16 +++++++++--- src/index.html | 69 ++++++++++++++++++++++++++----------------------- src/index.js | 24 +++++++++++------ 3 files changed, 65 insertions(+), 44 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index b767b90..2164fbd 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -1,12 +1,11 @@ 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 palabras = text.split(" "); + const word = text.split(" "); //no tener en cuenta el " " - // Test comment let count = 0; - for (let i = 0; i < palabras.length; i++) { - if (palabras[i] !== "") { + for (let i = 0; i < word.length; i++) { + if (word[i] !== "") { count++; } } @@ -46,6 +45,15 @@ const analyzer = { }, getAverageWordLength: (text) => { //TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`. + let wordL = text.split(" "); + wordL = wordL.filter((word) => word.trim() !== ""); + let totalLength = 0; + for (let word of wordL) { + totalLength += word.length; + } + const averageLength = totalLength / wordL.length; + return averageLength.toFixed(2) || 0; // si es NaN se pone en 0 + }, getNumberCount: (text) => { //TODO: esta función debe retornar cuántos números se encuentran en el parámetro `text` de tipo `string`. diff --git a/src/index.html b/src/index.html index 5d5ae1a..fce08db 100644 --- a/src/index.html +++ b/src/index.html @@ -1,36 +1,41 @@ + + + Analizador de texto + + - - - Analizador de texto - - - - -
-

Analizador de texto

- - - - -
-
-
    + +
    +

    Analizador de texto

    + + + + +
    +
    +
      + +
    • Palabras:
    • +
    • Caracteres:
    • +
    • + Caracteres sin espacios: +
    • +
    • Números:
    • +
    • Suma de números:
    • +
    • Longitud promedio palabra:
    • +
    +
    +
    +

    Denis Alvarez - Deniisolo

    -
  • Palabras:
  • -
  • Caracteres:
  • -
  • Caracteres sin espacios:
  • -
  • Números:
  • -
  • Suma de números:
  • -
  • Longitud de palabras:
  • -
-
-
-

Denis Alvarez - Deniisolo

- -
- - - - \ No newline at end of file +
+ + + diff --git a/src/index.js b/src/index.js index e32ebc4..6ba4a61 100644 --- a/src/index.js +++ b/src/index.js @@ -2,8 +2,7 @@ import analyzer from "./analyzer.js"; //TODO: escuchar eventos del DOM e invocar los métodos del objeto `analyzer` const input = document.querySelector("textarea[name='user-input']"); - -input.addEventListener("input", function () { +const inputFunction = function () { // 1 Función:Contar el numero de palabras const wordcount = analyzer.getWordCount(input.value); // tengo que acceder al ul @@ -43,10 +42,19 @@ input.addEventListener("input", function () { //asignarle el texto al li 5 fifthChild.innerHTML = "Suma de números: " + sumNumber; - //6 función Longitud media de las palabras: - const lengthWord = analyzer.getAverageWordLength(input.value); - // tengo que acceder a li 6 - const sixthChild = uls[0].children[5] - //asignarle el texto al li 6 - sixthChild.innerHTML = "Longitud de palabras: " + lengthWord; + //6 función Longitud media de las palabras: + const lengthWord = analyzer.getAverageWordLength(input.value); + // tengo que acceder a li 6 + const sixthChild = uls[0].children[5]; + //asignarle el texto al li 6 + sixthChild.innerHTML = "Longitud promedio palabra: " + lengthWord; +} +input.addEventListener("input",inputFunction); + +const button = document.getElementById("reset-button"); + +button.addEventListener("click", function () { + //Borrar lo que este en el input + input.value=""; + inputFunction() }); From fec050ba6641d7bb9d0fef073a8baccd8e7a1b99 Mon Sep 17 00:00:00 2001 From: deniisolo Date: Wed, 28 Feb 2024 18:04:27 -0500 Subject: [PATCH 21/24] proyecto terminado --- src/analyzer.js | 60 +++++++++++++++++++++++++++++++++++++------------ src/index.html | 4 +++- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/analyzer.js b/src/analyzer.js index 2164fbd..e478984 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -46,34 +46,66 @@ const analyzer = { getAverageWordLength: (text) => { //TODO: esta función debe retornar la longitud media de palabras que se encuentran en el parámetro `text` de tipo `string`. let wordL = text.split(" "); - wordL = wordL.filter((word) => word.trim() !== ""); + wordL = wordL.filter((word) => { + //función tipo lambda + return word !== ""; + }); //devuelve todo lo que no esta vacio let totalLength = 0; - for (let word of wordL) { + for (const word of wordL) { totalLength += word.length; } const averageLength = totalLength / wordL.length; - return averageLength.toFixed(2) || 0; // si es NaN se pone en 0 - + return parseFloat(averageLength.toFixed(2)) || 0; // si es NaN se pone en 0 }, getNumberCount: (text) => { //TODO: esta función debe retornar cuántos números se encuentran en el parámetro `text` de tipo `string`. - let total = 0; - for (let i = 0; i < text.length; i++) { - if (!isNaN(text[i]) && text[i] !== " ") { - total++; + if (!text.trim()) { + // Verificar si el texto está vacío o contiene solo espacios en blanco + return 0; + } + if (text[text.length - 1] === ".") { + // el ultimo caracter de mi texto. + text = text.substring(0, text.length - 1); + } + const words = text.split(" "); + let count = 0; + for (let i = 0; i < words.length; i++) { + const numero = parseFloat(words[i]); // Utilizar parseFloat para manejar números decimales + while (words[i].endsWith("0")) { + //mientras mi palabra termine en 0 esto va a ser true + words[i] = words[i].substring(0, words[i].length - 1); //substring retira lo solicitado + } + if (!isNaN(numero) && words[i] === numero.toString()) { + // Verificar si la conversión fue exitosa y no es NaN + count++; } } - return total; + 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`. - let sum = 0; - for (let i = 0; i < text.length; i++) { - if (!isNaN(text[i]) && text[i] !== " ") { - sum += parseInt(text[i]); + if (!text.trim()) { + // Verificar si el texto está vacío o contiene solo espacios en blanco + return 0; + } + if (text[text.length - 1] === ".") { + // el ultimo caracter de mi texto. + text = text.substring(0, text.length - 1); + } + const words = text.split(" "); + let count = 0; + for (let i = 0; i < words.length; i++) { + const numero = parseFloat(words[i]); // Utilizar parseFloat para manejar números decimales + while (words[i].endsWith("0")) { + //mientras mi palabra termine en 0 esto va a ser true + words[i] = words[i].substring(0, words[i].length - 1); //substring retira lo solicitado + } + if (!isNaN(numero) && words[i] === numero.toString()) { + // Verificar si la conversión fue exitosa y no es NaN + count = count + numero; } } - return sum; + return count; }, }; diff --git a/src/index.html b/src/index.html index fce08db..ca242a3 100644 --- a/src/index.html +++ b/src/index.html @@ -29,7 +29,9 @@

Analizador de texto

  • Números:
  • Suma de números:
  • -
  • Longitud promedio palabra:
  • +
  • + Longitud promedio palabra: +