-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.js
More file actions
61 lines (51 loc) · 1.49 KB
/
Copy pathcontext.js
File metadata and controls
61 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
PhoneApp.prototype.createElement = function(value, key, index){
let td = document.createElement('td');
let rtById = document.getElementById(`tr_${index}`)
rtById.appendChild(td)
td.textContent = value[key]
}
PhoneApp.prototype.outputDataArray = function() {
let tabelBody = document.getElementById("tbody_id")
this.dataBase.forEach((value, index, arr) => {
let tr = document.createElement('tr')
tr.setAttribute('id', `tr_${index}`);
tabelBody.appendChild(tr);
this.createElement(value, 'name', index)
this.createElement(value, 'surname', index)
this.createElement(value, 'numb', index)
})
}
let createTh = (arr) => {
const innerTr = arr.map(value =>
`<td>${value}</td>`
).join('');
return `<thead><tr>
${innerTr}
</tr></thead>`
}
let buildHtmlTags = () => {
// let body = document.body;
let main = document.getElementById('app')
main.innerHTML += `<header class="header">
<div class="container top-radius">
<h2>Contacts</h2>
</div>
</header>
<main>
<div class="container">
<form class="form-inline search-form">
<div class="form-group">
<label class="sr-only" for="search">Search</label>
<input type="text" class="form-control" id= "search" placeholder="Search">
</div>
</form>
<table class="table table-hover contacts">
${createTh(['Name',"Last name", "Number"])}
<tbody id="tbody_id">
</tbody>
</table>
</div>
</main>`
}
buildHtmlTags()
myApp.outputDataArray();