Skip to content

Commit e2a64ff

Browse files
authored
Merge pull request #6 from rnt-code/code-refactoring
new button
2 parents 7600d4a + 5433238 commit e2a64ff

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ <h1>Aplicación para el paginado de datos</h1>
3131
<input type="button" value="Lista 2" id="refresh-button2">
3232
<input type="button" value="Lista 3" id="refresh-button3">
3333
<input type="button" value="Lista 4" id="refresh-button4">
34+
<input type="button" value="Limpiar" id="cleanUp" style="color:rgb(0, 0, 255); background-color: rgb(255, 0, 0);">
3435
</nav>
3536
<section>
3637
<div id="list-title"><h2 id="title"></h2></div>

main.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { buildDataTable } from './buildDataTable.js'
22

33
const title = document.getElementById('title');
4-
const refresh_button1 = document.getElementById('refresh-button1');
5-
const refresh_button2 = document.getElementById('refresh-button2');
6-
const refresh_button3 = document.getElementById('refresh-button3');
7-
const refresh_button4 = document.getElementById('refresh-button4');
4+
const refresh_button1_el = document.getElementById('refresh-button1');
5+
const refresh_button2_el = document.getElementById('refresh-button2');
6+
const refresh_button3_el = document.getElementById('refresh-button3');
7+
const refresh_button4_el = document.getElementById('refresh-button4');
8+
const cleanUp_el = document.getElementById('cleanUp');
89

910
const data1 = [
1011
{
@@ -4765,19 +4766,25 @@ const data4 = []
47654766

47664767
const number_of_buttons = 6;
47674768

4768-
refresh_button1.addEventListener('click', function() {
4769+
refresh_button1_el.addEventListener('click', function() {
47694770
buildDataTable(data1, number_of_buttons, custom_head_titles1);
47704771
title.textContent = 'Lista 1'
47714772
})
4772-
refresh_button2.addEventListener('click', function() {
4773+
refresh_button2_el.addEventListener('click', function() {
47734774
buildDataTable(data2, number_of_buttons, custom_head_titles2);
47744775
title.textContent = 'Lista 2'
47754776
})
4776-
refresh_button3.addEventListener('click', function() {
4777+
refresh_button3_el.addEventListener('click', function() {
47774778
buildDataTable(data3, number_of_buttons, custom_head_titles3);
47784779
title.textContent = 'Lista 3'
47794780
})
4780-
refresh_button4.addEventListener('click', function() {
4781+
refresh_button4_el.addEventListener('click', function() {
47814782
buildDataTable(data4, number_of_buttons, );
47824783
title.textContent = 'Lista 4'
4784+
})
4785+
cleanUp_el.addEventListener('click', function() {
4786+
const place_for_list_el = document.getElementById('place-for-list');
4787+
const title_el = document.getElementById('title');
4788+
place_for_list_el.innerHTML = ''
4789+
title_el.innerHTML = ''
47834790
})

0 commit comments

Comments
 (0)