Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 15 additions & 150 deletions phoneApp/index.html
Original file line number Diff line number Diff line change
@@ -1,153 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<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>Contacts</title>
<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>
<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">
<thead>
<tr>
<th>Name</th>
<th>Last name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>Иван</td>
<td>Петров</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Сергей</td>
<td>Сергеев</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Иван</td>
<td>Иванов</td>
<td >[email protected]</td>
</tr>
<tr>
<td>Александр</td>
<td>Александров</td>
<td >[email protected]</td>
</tr>
<tr>
<td>Алекс</td>
<td>Смирнов</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Сергей</td>
<td>Волков</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Мария</td>
<td>Шарапова</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Александр</td>
<td>Винник</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Дарий</td>
<td>Смирнов</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Елена</td>
<td>Лещенко</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Ольга</td>
<td>Новикова</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Наталья</td>
<td>Шемякина</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Анна</td>
<td>Донцова</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Влад</td>
<td>Яма</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Кира</td>
<td>Воробьева</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Виктор</td>
<td>Кривенко</td>
<td>[email protected]</td>
</tr>
</tbody>
</table>
</div>
</main>
<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>




<script src="js/main.js"></script>
</body>
<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>Contacts</title>
<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 src="src/js/model.js"></script>
<script src="src/js/view.js"></script>
<script src="src/js/controller.js"></script>
<script src="src/js/app.js"></script>
</body>
</html>
19 changes: 14 additions & 5 deletions phoneApp/src/js/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
class App(){
constructor(model,view,controller){
class App{
constructor(){
this.state = "contacts"
this.model = new Model(state)
this.view = new View(state)
this.controller = new Controller(model,view)
this.model = new Model(this.state)
this.view = new View(this.state)
this.controller = new Controller(this.model,this.view)
}
render(){
this.view.createStructure()
}
}

let app = new App()
app.render()




79 changes: 31 additions & 48 deletions phoneApp/src/js/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,36 @@ class Contacts{
this.body = document.body;
}

createHeader(){
return `
<div class="app-header">
My Phone App
</div>
`
}
createFooter(){
return `
<div class="app-footer">
<div></div>
</div>
`
}
createContentBlock(){
return `<div class="app-content">
<table class="contact-table" cellspacing="0" cellpadding="0">
</table>
</div>`
}

createStructure(){
render(users){
document.body.innerHTML =`
<div class="main">
${this.createHeader()}
${this.createContentBlock()}
${this.createFooter()}
</div>
<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">
<thead>
<tr>
<th>Name</th>
<th>Last name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
${createUsersListView(users)}
</tbody>
</table>
`
}

render(users){
console.log(users)
this.createStructure();
this.createUsersList(users);
}
createUsersListView(users){
return `${users.map(elem => {
createUserTR(elem)
})}`
}


createUsersList(users){
let tableBlock = document.querySelector(".contact-table");
Expand All @@ -49,23 +43,12 @@ class Contacts{
}

createUserTR(user){
return `
<tr class="borderdered" onclick="window.location.href = 'contact.html'">
<td class="app-contact-avatar">
<div class="round-avatar">
<img src="img/${user.avatar}.png">
</div>
</td>
<td class="app-contact-name">
<p>${user.name}</p>
<p>${user.phone}</p>
</td>
<td class="app-contact-buttons">
<a href="contact.html?do=edit" class="icon-link">
<i class="far fa-edit"></i>
</a>
</td>
</tr>
return `
<tr>
<td>${user.name.split(' ')[0]}</td>
<td>${user.name.split(' ')[1]}</td>
<td>${user.email}</td>
</tr>
`
}
renderUsersList(elem){
Expand Down
3 changes: 2 additions & 1 deletion phoneApp/src/js/controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Controller{
constructor(model, view){
this.model = modell
this.model = model
this.view = view
}

}
57 changes: 55 additions & 2 deletions phoneApp/src/js/view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,59 @@
class View{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not required to name it View. it could be a "mental abstraction" in your head.

On complex projects, MVC could be hidden, but from the relationships between classes/functions you would feel MVC :)
"it's smell like MVC"

constructor(state){

this.baseContainer = document.body
}
createHeader(){
return `
<header class="header">
<div class="container top-radius">
<h2>Contacts</h2>
</div>
</header>
`
}

createContentBlock(){
return `<main>
<div class="container">
</div>
</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>
`
}

createStructure(){
this.baseContainer.innerHTML += this.createHeader()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks weird, no need to create different blocks for it. just paste a html layout is fine

this.baseContainer.innerHTML += this.createContentBlock()
this.baseContainer.innerHTML += this.createFooter()
}
render()
}