Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified .DS_Store
Binary file not shown.
18 changes: 9 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ app.get("/test", (req, res) => {

app.get("/", async function(req, res) {
let objItem = await Item.find({});
// console.log(objItem);
console.log(objItem, 'first');
res.render("index", {
objItem
});
Expand All @@ -60,20 +60,20 @@ app.set("view engine", "hbs");
// app.use("/users", usersRouter);

mongoose.connect(
"mongodb+srv://artem:artem@cluster0-nnm84.mongodb.net/ozonItems",
"mongodb+srv://artem:artem@cluster0-nnm84.mongodb.net/ozon",
{
useNewUrlParser: true,
useUnifiedTopology: true
}
);

app.get("/", async function(req, res) {
let objItem = await Item.find({});
// console.log(objItem);
res.render("index", {
objItem
});
});
// app.get("/", async function(req, res) {
// let objItem = await Item.find({});
// console.log(objItem, 'here');
// res.render("index", {
// objItem
// });
// });

// Обработка ошибок.
app.use((req, res, next) => {
Expand Down
4 changes: 3 additions & 1 deletion model/itemModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const ItemSchema = new Schema({
size: String,
cameraResolution: Number,
internalMemory: String,
RAM: String
RAM: String,
rating: Number,
color: Array,
});


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "app.js",
"scripts": {
"start": "npx nodemon app.js",
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand Down
70 changes: 61 additions & 9 deletions seed/seed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Item = require('../model/itemModel');
const mongoose = require('mongoose');

const app = require('../app')


async function createUser() {
Expand All @@ -9,54 +9,106 @@ async function createUser() {

let item1 = await Item.create({
img: 'https://cdn1.ozone.ru/multimedia/c1200/1026952828.jpg',
name: 'Смартфон Honor 10 Lite 3/64GB, черный',
name: 'Смартфон Honor 10 Lite 3/64GB',
price: 10990,
guarantee: '1 год',
screenResolution: '2340x1080',
screenDiagonale: '6,21',
size: '154.8 x 73.6 x 8',
cameraResolution: 13,
internalMemory: '64 ГБ',
RAM: '3 ГБ'
color: ["black", "white", "red", "green"],
rating: 2
});

let item2 = await Item.create({
img: 'https://cdn1.ozone.ru/s3/multimedia-z/c1200/6005742539.jpg',
name: 'Смартфон Honor 9X Premium 6/128GB, черный',
name: 'Смартфон Honor 9X Premium 6/128GB',
price: 17382,
guarantee: 'Нет информации',
screenResolution: '2340x1080',
screenDiagonale: '6,59',
size: '163.5 × 77.3 × 8.8',
cameraResolution: 48,
internalMemory: 'Нет информации',
RAM: 'Нет информации'
RAM: 'Нет информации',
color: ["black", "white", "red", "green"],
rating: 3
});

let item3 = await Item.create({
img: 'https://cdn1.ozone.ru/multimedia/c1200/1028043675.jpg',
name: 'Смартфон Honor 10i 4/128GB, черный',
name: 'Смартфон Honor 10i 4/128GB',
price: 12990,
guarantee: '1 год',
screenResolution: '2340x1080',
screenDiagonale: '6,21',
size: 'Нет информации',
cameraResolution: 24,
internalMemory: '128 ГБ',
RAM: '4 ГБ'
RAM: '4 ГБ',
color: ["black", "white", "red", "green"],
rating: 1
});

let item4 = await Item.create({
img: 'https://cdn1.ozone.ru/multimedia/c1200/1034224013.jpg',
name: 'Смартфон Smartisan U3 4/64GB, бежевый',
name: 'Смартфон Smartisan U3 4/64GB',
price: 10495,
guarantee: 'Нет информации',
screenResolution: '2160х1080',
screenDiagonale: '5,99',
size: 'Нет информации',
cameraResolution: 13,
internalMemory: 'Нет информации',
RAM: 'Нет информации'
RAM: 'Нет информации',
color: ["black", "white", "red", "green"],
rating: 5
});

let item5 = await Item.create({
img: 'https://cdn1.ozone.ru/s3/multimedia-m/c1200/6005039950.jpg',
name: 'Смартфон realme XT 8/128GB',
price: 35000,
guarantee: '3 года',
screenResolution: '2340x1080',
screenDiagonale: '5,99',
size: 'Нет информации',
cameraResolution: 13,
internalMemory: '128 ГБ',
RAM: '8 ГБ',
color: ["black", "white", "red", "green"],
rating: 3
});

let item6 = await Item.create({
img: 'https://cdn1.ozone.ru/s3/multimedia-s/c1200/6006221044.jpg',
name: 'Смартфон Xiaomi Redmi Note 8T 4/64GB',
price: 25000,
guarantee: '2 года',
screenResolution: '2340x1080',
screenDiagonale: '5,99',
size: 'Нет информации',
cameraResolution: 13,
internalMemory: '512 ГБ',
RAM: '4 ГБ',
color: ["black", "white", "red", "green"],
rating: 5
});

let item6 = await Item.create({
img: 'https://cdn1.ozone.ru/s3/multimedia-q/c1200/6001501874.jpg',
name: 'Смартфон Xiaomi Redmi Note 7 4/64GB',
price: 12000,
guarantee: '2 года',
screenResolution: '2340x1080',
screenDiagonale: '5,99',
size: 'Нет информации',
cameraResolution: 13,
internalMemory: '64 ГБ',
RAM: '4 ГБ',
color: ["black", "white", "red", "green"],
rating: 4
});

await mongoose.disconnect();
Expand Down
153 changes: 2 additions & 151 deletions views/index.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container bootstrap snipets">
<h1 class="text-center text-muted">Phones</h1>
<h1 class="text-center text-muted">Телефоны</h1>
<div class="row flow-offset-1">
{{#each objItem}}
<div class="col-xs-8 col-md-6">
Expand Down Expand Up @@ -42,155 +42,6 @@
</div>
</div>

{{!-- table --}}
<div class="container">
<div class="btn-group btn-group-toggle mg-auto mt-2 mb-2" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="radio" name="options" id="option1" autocomplete="off" checked> Все характеристики
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="option2" autocomplete="off"> Только различия
</label>
</div>
{{#each objItem}}
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col"><img style="max-width:350px; max-height:350px" src="{{this.img}}" alt=""></th>
<th scope="col"><img style="max-width:350px; max-height:350px" src="{{this.img}}" alt=""></th>
<th scope="col"><img style="max-width:350px; max-height:350px" src="{{this.img}}" alt=""></th>
<th scope="col"><img style="max-width:350px; max-height:350px" src="{{this.img}}" alt=""></th>
<th scope="col"><img style="max-width:350px; max-height:350px" src="{{this.img}}" alt=""></th>


</tr>
</thead>
<tbody>
<tr>
<th scope="row">Название</th>
<td>{{this.name}}></td>
<td>{{this.name}}</td>
<td>{{this.name}}</td>
<td>{{this.name}}</td>
<td>{{this.name}}</td>


</tr>
<tr>
<th scope="row">Камера</th>
<td>{{this.cameraResolution}}</td>
<td>{{this.cameraResolution}}</td>
<td>{{this.cameraResolution}}</td>
<td>{{this.cameraResolution}}</td>
<td>{{this.cameraResolution}}</td>


</tr>
<tr>
<th scope="row">Цена</th>
<td>{{this.price}}</td>
<td>{{this.price}}</td>
<td>{{this.price}}</td>
<td>{{this.price}}</td>
<td>{{this.price}}</td>

</tr>
<tr>
<th scope="row">Память</th>
<td>{{this.internalMemory}}</td>
<td>{{this.internalMemory}}</td>
<td>{{this.internalMemory}}</td>
<td>{{this.internalMemory}}</td>
<td>{{this.internalMemory}}</td>


</tr>
<tr>
<th scope="row">RAM</th>
<td>{{this.RAM}}</td>
<td>{{this.RAM}}</td>
<td>{{this.RAM}}</td>
<td>{{this.RAM}}</td>
<td>{{this.RAM}}</td>


</tr>
<tr>
<th scope="row">Размер</th>
<td>{{this.size}}</td>
<td>{{this.size}}</td>
<td>{{this.size}}</td>
<td>{{this.size}}</td>
<td>{{this.size}}</td>


</tr>
<tr>
<th scope="row">Гарантия</th>
<td>{{this.guarantee}}</td>
<td>{{this.guarantee}}</td>
<td>{{this.guarantee}}</td>
<td>{{this.guarantee}}</td>
<td>{{this.guarantee}}</td>


</tr>
</tbody>
</table>
</div>
</div>
{{/each}}
{{!-- table-hover --}}
{{#each objItem}}
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="{{this.img}} alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="{{this.img}} alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="{{this.img}} alt="Third slide">
</div>
</div>
</div>
{{/each}}


<p style="text-align: center"><button class="showAll">Кнопка с текстом</button></p>



<p style="text-align: center">
<button class="showAll">Кнопка с текстом</button>
</p>

<form type='submit'>
<button class='start'>Poehali</button>
<div class="result">
<ul>
{{#each objItem}}
<li>
<img src="{{this.img}}" alt="альтернативный текст">
<li class="all firstly">{{this.name}}</li>
<li class="all firstly">{{this.price}}</li>
<li class="all firstly">{{this.guarantee}}</li>
<li class="all firstly">{{this.screenResolution}}</li>
<li class="all secondary invisible">{{this.screenDiagonale}}</li>
<li class="all secondary invisible">{{this.size}}</li>
<li class="all secondary invisible">{{this.cameraResolution}}</li>
<li class="all secondary invisible">{{this.internalMemory}}</li>
<li class="all secondary invisible">{{this.RAM}}</li>
</li>
<input name='{{this.name}}' class="radio" type="radio" value="1"
onMouseDown="this.isChecked=this.checked;"
onClick="this.checked=!this.isChecked;">Сравнить
{{/each}}
</ul>
</div>
</form> --}}

<!--Carousel Wrapper-->

4 changes: 2 additions & 2 deletions views/layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

{{{body}}}
</body>
</html>
{{!-- </html>
=======


Expand All @@ -46,5 +46,5 @@

</body>

</html>
</html> --}}

18 changes: 18 additions & 0 deletions views/second.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="container bootstrap snipets">
<h1 class="text-center text-muted">Phones</h1>
<div class="row flow-offset-1">
{{#each objItem}}
<div class="col-xs-8 col-md-6">
<div class="product tumbnail thumbnail-3"><a href="#"><img style="max-width:350px; max-height:350px" src="{{this.img}}" alt=""></a>
<div class="caption"><a href="#">{{this.name}}</a>
<div style="width: 20rem;> <span class="price">
Цена: {{this.price}} Руб</span></div>
<input name='{{this.name}}' class="radio" type="radio" value="1" onMouseDown="this.isChecked=this.checked;"
onClick="this.checked=!this.isChecked;" >
</div>
</div>
</div>
{{/each}}