Skip to content
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

Больше деталей #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<script src="js/functions.js"></script>
<script src="js/main.js"></script>
<title>Кекстаграм</title>
</head>

Expand Down
73 changes: 73 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,0 +1,73 @@
const description = [
'Озеро',
'Табличка',
'Море',
'Девушка',
'Обед',
'Черная машина',
'Клубника',
'Морс',
'Самолет',
'Обувь',
'Пляж',
'Белая машина',
'Салат',
'Котролл',
'Тапочки',
'Горы',
'Хор',
'Красная машина',
'Тапочки с фанариком',
'Пальмы',
'Завтрак',
'Закат',
'Краб',
'Концерт',
'Сафари',
];
const message = [
'Всё отлично!',
'В целом всё неплохо. Но не всё.',
'Когда вы делаете фотографию, хорошо бы убирать палец из кадра. В конце концов это просто непрофессионально.',
'Моя бабушка случайно чихнула с фотоаппаратом в руках и у неё получилась фотография лучше.',
'Я поскользнулся на банановой кожуре и уронил фотоаппарат на кота и у меня получилась фотография лучше.',
'Лица у людей на фотке перекошены, как будто их избивают. Как можно было поймать такой неудачный момент?!',
];
const nameСommentator = [
'Артём',
'Вася',
'Петя',
'Маша',
'Марина',
'Катя',
'Даша',
'Елена',
'Евгения',
'Екатерина',
];
const id = Array.from({length: 25}, (_, i) => i + 1);
const getRandomInteger = (a, b) => {
const lower = Math.ceil(Math.min(a, b));
const upper = Math.floor(Math.max(a, b));
const result = Math.random() * (upper - lower + 1) + lower;
return Math.floor(result);
};

const randomId = getRandomInteger(0, id.length - 1);
const comment = () => ({
id: getRandomInteger(1, 9999),
avatar: `img/avatar-${ getRandomInteger(1, 6) }.svg`,
message: message[getRandomInteger(0, message.length - 1)],
name: nameСommentator[getRandomInteger(0, nameСommentator.length - 1)],
});

const comments = Array.from({length: 31}, comment);
const commentsCount = getRandomInteger(0, comments.length - 1);

const photo = {

Check failure on line 67 in js/main.js

View workflow job for this annotation

GitHub Actions / Check

'photo' is assigned a value but never used
id: randomId,
url: `photos/${ randomId }.jpg`,
description: description[randomId - 1],
likes: getRandomInteger(15, 200),
comments: Array.from({length: commentsCount}, comment),
};
Loading