-
Notifications
You must be signed in to change notification settings - Fork 0
Phone app #17
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?
Phone app #17
Changes from 1 commit
4b321a5
868b14d
314b6a1
bc2c99e
6228af2
7ea8c7a
5d8cc42
f874edd
84f468d
ce0a090
8a17850
7041908
37e75e9
390e16a
b3debda
9f21e51
1b3876b
7309c63
f567994
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,42 @@ | ||
| class Footer { | ||
| constructor(){ | ||
| this.renderFooter(); | ||
| } | ||
|
|
||
| renderFooter() { | ||
| document.body.innerHTML += this.createFooter(); | ||
| } | ||
|
|
||
| createFooter(){ | ||
| return `<footer class="footer"> | ||
|
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. you can just place such html-layout inside render |
||
| <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>` | ||
| } | ||
|
|
||
| } | ||
|
|
||
| const footer = new Footer(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <title>Keypad</title> | ||
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
| <link href="https://fonts.googleapis.com/css?family=Oxygen" rel="stylesheet"> | ||
| <!-- <link href="css/bootstrap.css" rel="stylesheet"> --> | ||
| <link rel="stylesheet" href="css/main.css"> | ||
| </head> | ||
| <body> | ||
|
|
||
|
|
||
| <script type="text/javascript" src="keypad.js"></script> | ||
| <!-- <script type="text/javascript" src="./common/footer.js"></script> --> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| //Нужно визуализировать keypad.html - keypad.js | ||
|
|
||
| //Структура виртуализации: | ||
| // ------ Это 2 разных класса KeypadPage, ContactsPage ----- | ||
|
|
||
| //innerHTML по максимуму | ||
| //https://aleksandra-maslennikova.github.io/telephone-book/keypad.html | ||
|
|
||
| //Сделайте чтобы при нажатии на кнопку цифра отобразилась | ||
| //в <span class="numbers"> | ||
|
|
||
| //https://aleksandra-maslennikova.github.io/telephone-book/index.html | ||
| //По клику по заголовку таблицы, | ||
| //таблица сортировалась по соответствующему свойству | ||
|
|
||
| class KeypadPage { | ||
| constructor(){ | ||
| this.title = 'Keypad'; | ||
| this.buttonsValues = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '0', '#', '']; | ||
|
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. please move all content specifiec part to innerHTML it's better to omit such data inside |
||
| this.render(); | ||
| //this.buttonsHandler(); | ||
| } | ||
|
|
||
| renderHeader(){ | ||
| return `<header class="header"> | ||
| <div class="container top-radius"> | ||
| <h2>${this.title}</h2> | ||
| </div> | ||
| </header>`; | ||
| } | ||
|
|
||
| renderMain(){ | ||
| let buttons = this.renderButtons(); | ||
|
|
||
| return `<main> | ||
| <div class="container"> | ||
| <div class="number"> | ||
| <span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> | ||
| <span class="numbers"></span> | ||
| <span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span> | ||
| </div> | ||
| <div class="keypad-holder"> | ||
| ${buttons} | ||
| </div> | ||
| </div> | ||
| </main>`; | ||
| } | ||
|
|
||
| renderButtons(){ | ||
| let buttonsArray = this.buttonsValues.map((item, i, arr) => { | ||
|
|
||
| if ( i == arr.length - 1) { | ||
| return `<button class="key"> | ||
| <span class="glyphicon glyphicon-earphone" aria-hidden="true"></span> | ||
| ${item} | ||
| </button>`; | ||
| }; | ||
|
|
||
| return `<button class="key">${item}</button>`; | ||
| }); | ||
|
|
||
| return buttonsArray.join(''); | ||
| } | ||
|
|
||
|
|
||
| buttonsHandler(){ | ||
| let buttonsParent = document.querySelector('.keypad-holder'); | ||
|
|
||
| buttonsParent.addEventListener('click', this.clickHandler) | ||
|
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. are you sure it works correctly? |
||
|
|
||
| } | ||
|
|
||
|
|
||
| clickHandler(e){ | ||
| let target = e.target; | ||
| let placeToInsertNumbers = document.querySelector('.numbers'); | ||
|
|
||
| if (target.classList.contains('key')) { | ||
| placeToInsertNumbers.innerHTML += target.textContent; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| renderFooter(){ | ||
| return `<footer class="footer"> | ||
| <div class="container bottom-radius"> | ||
| <nav class="main-nav"> | ||
| <a href="contacts.html" class="tab active"> | ||
|
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. please create reusable "component" to render links |
||
| <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> | ||
|
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. this.renderLink({glyphicon:'pencil', href:'keypad.html'})
this.renderLink({glyphicon:'th', href:'contacts'})
this.renderLink({glyphicon:'pencil', href})
this.renderLink({glyphicon:'pencil', href}) |
||
| <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>` | ||
| } | ||
| setEvents(){ | ||
| this.buttonsHandler(); | ||
| } | ||
|
|
||
| render(){ | ||
| document.body.innerHTML = this.renderHeader() + this.renderMain() + this.renderFooter(); | ||
|
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. please move all HTML specific content to render, and remove additional properties |
||
| this.setEvents(); | ||
| } | ||
| } | ||
|
|
||
| const keypad = new KeypadPage(); | ||
|
|
||
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.
please do not use document.body :)
create an additional tag and work inside it.
You can meet some unpredictable behavior if you rewrite the whole body content. It will be very hard to debug it and found a mistake