Skip to content

Commit

Permalink
fin taller 1
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDDY committed Oct 23, 2023
1 parent 2ad4749 commit dd036b2
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.multiRootWorkspaceName": "TallerTypeScript"
}
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="container">
<div class="row">
<div class="col-lg-7 col-12">
<table class="table table-striped" id="tablaSeries">
<table class="table table-striped table-dark" id="tablaSeries">
<thead>
<tr>
<th scope="col">#</th>
Expand All @@ -42,15 +42,17 @@
<tbody id="cuerpo-Series">
</tbody>
</table>
<p id="averageSeasons">Average seasons: 0</p>
<p id="average">Average seasons: 0</p>
</div>
<div class="col-lg-6 col-12" id="contenido">
</div>
</div>
</div>

<script type="module" src = "lib/index.js"></script>
</body>
</html>





11 changes: 3 additions & 8 deletions lib/Serie.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Serie = void 0;
var Serie = /** @class */ (function () {
function Serie(id, nombre, canal, temporadas, descripcion, link, imagen) {
export class Serie {
constructor(id, nombre, canal, temporadas, descripcion, link, imagen) {
this.id = id;
this.nombre = nombre;
this.canal = canal;
Expand All @@ -11,6 +8,4 @@ var Serie = /** @class */ (function () {
this.link = link;
this.imagen = imagen;
}
return Serie;
}());
exports.Serie = Serie;
}
19 changes: 8 additions & 11 deletions lib/data.js

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

3 changes: 1 addition & 2 deletions lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ export const series = [

new Serie (6, "A Very English Scandal", "BBC", 2, "A Very English Scandal is a fact-based three-part British television comedy-drama miniseries based on John Preston's book of the same name.",
"https://www.bbc.co.uk/programmes/p065smy4", "https://i.imgur.com/D4y3DrQ.jpg"),
];

];
46 changes: 33 additions & 13 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var data_js_1 = require("./data.js");
var tabla = document.querySelector('.cuerpo-Series');
if (tabla) {
data_js_1.series.forEach(function (serie) {
var row = document.createElement('tr');
row.innerHTML = "\n <th scope=\"row\">".concat(serie.id, "</th>\n <th scope=\"row\">").concat(serie.nombre, "</td>\n <th scope=\"row\">").concat(serie.canal, "</td>\n <th scope=\"row\">").concat(serie.temporadas, "</td>");
tabla.appendChild(row);
});
import { series } from './data.js';
const tabla = document.getElementById('cuerpo-Series');
var sumatoria = 0;

function cargarTabla() {
if (tabla) {
series.forEach((serie) => {
const row = document.createElement('tr');
row.innerHTML = `
<th scope="row">${serie.id}</th>
<th scope="row">${serie.nombre}</td>
<th scope="row">${serie.canal}</td>
<th scope="row">${serie.temporadas}</td>`;
tabla.appendChild(row);
});
}
else {
console.error("No se encontró el elemento con la clase 'table'");
}
}
else {
console.error("No se encontró el elemento con la clase 'table'");

function promedioTemporadas() {
if (tabla) {
series.forEach((serie) => {
sumatoria += serie.temporadas;
});
}
const parrafo = document.getElementById('average');
var promedio = sumatoria / series.length;
parrafo.innerHTML = `Average seasons: ${promedio}`
}
document.getElementsByTagName("h1")[0].innerHTML = "Hola desde Typescript";


cargarTabla();
promedioTemporadas()
5 changes: 2 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { series } from './data.js';
import { Serie } from './Serie.js';

const tabla: HTMLElement | null = document.querySelector('.cuerpo-Series');
const tabla: HTMLElement | null = document.querySelector('table');

if (tabla) {
series.forEach((serie) => {
Expand All @@ -18,5 +18,4 @@ if (tabla) {

} else {
console.error("No se encontró el elemento con la clase 'table'");
}
document.getElementsByTagName("h1")[0].innerHTML = "Hola desde Typescript";
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
}

0 comments on commit dd036b2

Please sign in to comment.