-
Notifications
You must be signed in to change notification settings - Fork 0
phoneApp #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
phoneApp #19
Changes from 1 commit
15f323a
14228cb
4ff03c0
eee1fa2
283863e
7725d89
3b946f2
59872b9
ec0a97f
cbf117d
8baa4ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>homework_15</title> | ||
| <meta charset="utf-8" /> | ||
| <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
| <link rel="stylesheet" type="text/css" href="style.css"> | ||
| </head> | ||
| <body> | ||
| <script src="index.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| class UsersContacts { | ||
| constructor() { | ||
| this.dataUsers = [ | ||
| { | ||
| name: 'Иван', | ||
| lastName: 'Петров', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Сергей', | ||
| lastName: 'Сергей', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Иван', | ||
| lastName: 'Иванов', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Александр', | ||
| lastName: 'Александров', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Алекс', | ||
| lastName: 'Смирнов', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Сергей', | ||
| lastName: 'Волков', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Мария', | ||
| lastName: 'Шарапова', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Александр', | ||
| lastName: 'Винник', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Дарий', | ||
| lastName: 'Смирнов', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Елена', | ||
| lastName: 'Лещенко', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Ольга', | ||
| lastName: 'Новикова', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Наталья', | ||
| lastName: 'Шемякина', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Анна', | ||
| lastName: 'Донцова', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Влад', | ||
| lastName: 'Яма', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Кира', | ||
| lastName: 'Воробьева', | ||
| email: '[email protected]' | ||
| }, | ||
| { | ||
| name: 'Виктор', | ||
| lastName: 'Кривенко', | ||
| email: '[email protected]' | ||
| } | ||
| ]; | ||
| this.columnHeadings = ['Name', 'Last name', 'Email']; | ||
| }; | ||
|
|
||
| render() { | ||
|
|
||
| document.body.innerHTML += this.createHeader(); | ||
|
||
| document.body.innerHTML += this.createMain(); | ||
| let insert = document.querySelector('main > div'); | ||
| insert.appendChild(this.createTable()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretty sure you have to create table with inner HTML also |
||
| document.body.innerHTML += this.createFooter(); | ||
| }; | ||
|
|
||
| createNewElement(newElem) { | ||
| return document.createElement(newElem); | ||
| }; | ||
|
|
||
| createTable() { | ||
| let table = this.createNewElement('table'); | ||
| table.setAttribute('class', 'table table-hover contacts'); | ||
| table.appendChild(this.cteateTheadInTable()); | ||
| table.appendChild(this.cteateTbodyInTable()); | ||
| return table; | ||
| }; | ||
|
|
||
| cteateTheadInTable() { | ||
| let thead = this.createNewElement('thead'); | ||
| let tr = this.createNewElement('tr'); | ||
| thead.appendChild(tr); | ||
| this.columnHeadings.forEach((elem) => { | ||
| let th = this.createNewElement('th'); | ||
| th.textContent = elem; | ||
| tr.appendChild(th); | ||
| }); | ||
| return thead; | ||
| }; | ||
|
|
||
| cteateTbodyInTable() { | ||
| let tbody = this.createNewElement('tbody'); | ||
| //table.appendChild(tbody); | ||
| this.dataUsers.forEach((elem) => { | ||
| let tr = this.createNewElement('tr') | ||
| tbody.appendChild(tr); | ||
| let arrObjkeys = Object.keys(elem); | ||
| arrObjkeys.forEach((elemTd) => { | ||
| let td = this.createNewElement('td'); | ||
| td.textContent = elem[elemTd]; | ||
| tr.appendChild(td); | ||
| }); | ||
| }); | ||
| return tbody; | ||
| }; | ||
|
|
||
| createHeader() { | ||
| return ` | ||
| <header class = 'header'> | ||
| <div class = 'container top-radius'> | ||
| <h2>Contacts</h2> | ||
| </div> | ||
| </header> | ||
| ` | ||
| }; | ||
|
|
||
| createMain() { | ||
| return ` | ||
| <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> | ||
|
|
||
| </main> | ||
| ` | ||
| } | ||
|
|
||
| createFooter() { | ||
| return ` | ||
| <footer class="footer"> | ||
| <div class="container bottom-radius"> | ||
| <nav class="main-nav"> | ||
| <a href="index.html" class="tab active"> | ||
|
||
| <span class="glyphicon glyphicon-search" aria-hidden="true"></span> | ||
| <span class = "tab-text">Contacts</span> | ||
| </a> | ||
| <a href="keypad.html" class="tab"> | ||
| <span class="glyphicon glyphicon-th" aria-hidden="true"></span> | ||
| <span class = "tab-text">Keypad</span> | ||
| </a> | ||
| <a href="edit-contact.html" class="tab"> | ||
| <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> | ||
| <span class = "tab-text">Edit contact</span> | ||
| </a> | ||
| <a href="user.html" class="tab"> | ||
| <span class="glyphicon glyphicon-user" aria-hidden="true"></span> | ||
| <span class = "tab-text">User</span> | ||
| </a> | ||
| <a href="add-user.html" class="tab"> | ||
| <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> | ||
| <span class = "tab-text">Add user</span> | ||
| </a> | ||
| </nav> | ||
| </div> | ||
| </footer> | ||
| ` | ||
| } | ||
| }; | ||
|
|
||
| let usersContacts = new UsersContacts(); | ||
| usersContacts.render(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oyy!
as I see you updating innerHTML several times, it's better to update it only once