-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a8b1b8
commit e95f0b2
Showing
4 changed files
with
68 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
import {comments, photoValues, names, descriptions} from './until'; | ||
import { getRandomInteger } from './randomInteger'; | ||
const comments = [ | ||
'Всё отлично!', | ||
'В целом всё неплохо. Но не всё.', | ||
'Когда вы делаете фотографию, хорошо бы убирать палец из кадра. В конце концов это просто непрофессионально.', | ||
'Моя бабушка случайно чихнула с фотоаппаратом в руках и у неё получилась фотография лучше.', | ||
'Я поскользнулся на банановой кожуре и уронил фотоаппарат на кота и у меня получилась фотография лучше.', | ||
'Лица у людей на фотке перекошены, как будто их избивают. Как можно было поймать такой неудачный момент?!' | ||
]; | ||
|
||
let indexPhoto = 0; | ||
let indexComment = 0; | ||
const names = [ | ||
'Виктор Пупов', | ||
'Геннадий Изюмов', | ||
'Оксана Тетёхина', | ||
'Ваня Комментаторов', | ||
'Фотоспец3002' | ||
]; | ||
|
||
const createComments = () => { | ||
const randomAvatarIndex = getRandomInteger(photoValues.RANDOM_MIN_NUMBER_AVATAR, photoValues.RANDOM_MAX_NUMBER_AVATAR); | ||
const randomNameIndex = getRandomInteger(0, names.length - 1); | ||
const commentValue = comments[getRandomInteger(0, comments.length - 1)]; | ||
const commentValue2 = comments[getRandomInteger(0, comments.length - 1)]; | ||
const genMessage = commentValue !== commentValue2 ? `${commentValue} ${commentValue2}` : commentValue; | ||
const descriptions = [ | ||
'здесь мог быть lorem, но ты просто чилишь', | ||
'Русалка села на шпагат', | ||
'Колобок повесился' | ||
]; | ||
|
||
return { | ||
id: ++indexComment, | ||
avatar: `img/avatar-${randomAvatarIndex}.svg`, | ||
message: genMessage, | ||
name: names[randomNameIndex], | ||
}; | ||
const photoValues = { | ||
PHOTOS_COUNT: 25, | ||
RANDOM_MAX_NUMBER_AVATAR: 6, | ||
RANDOM_MIN_NUMBER_AVATAR: 1, | ||
RANDOM_MAX_NUMBER_COMMENTS: 30, | ||
RANDOM_MIN_NUMBER_COMMENTS: 0, | ||
RANDOM_MAX_NUMBER_LIKES: 200, | ||
RANDOM_MIN_NUMBER_LIKES: 15, | ||
}; | ||
|
||
const createImage = () => { | ||
const randomDescriptionIndex = getRandomInteger(0, descriptions.length - 1); | ||
const randomLikes = getRandomInteger(photoValues.RANDOM_MIN_NUMBER_LIKES, photoValues.RANDOM_MAX_NUMBER_LIKES); | ||
const randomCommentsCount = getRandomInteger(photoValues.RANDOM_MIN_NUMBER_COMMENTS, photoValues.RANDOM_MAX_NUMBER_COMMENTS); | ||
const commentsArray = Array.from({ length: randomCommentsCount }, createComments); | ||
|
||
return { | ||
id: ++indexPhoto, | ||
url: `photos/${indexPhoto}.jpg`, | ||
description: descriptions[randomDescriptionIndex], | ||
likes: randomLikes, | ||
comments: commentsArray, | ||
}; | ||
}; | ||
|
||
export {createComments, createImage}; | ||
export {comments, photoValues, names, descriptions}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
const getRandomInteger = (a, b) => { | ||
const lower = Math.ceil(Math.min(a, b)); | ||
const upper = Math.floor(Math.max(a, b)); | ||
return Math.floor(Math.random() * (upper - lower + 1)) + lower; | ||
}; | ||
|
||
export {getRandomInteger}; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,42 @@ | ||
const comments = [ | ||
'Всё отлично!', | ||
'В целом всё неплохо. Но не всё.', | ||
'Когда вы делаете фотографию, хорошо бы убирать палец из кадра. В конце концов это просто непрофессионально.', | ||
'Моя бабушка случайно чихнула с фотоаппаратом в руках и у неё получилась фотография лучше.', | ||
'Я поскользнулся на банановой кожуре и уронил фотоаппарат на кота и у меня получилась фотография лучше.', | ||
'Лица у людей на фотке перекошены, как будто их избивают. Как можно было поймать такой неудачный момент?!' | ||
]; | ||
import {comments, photoValues, names, descriptions} from './data'; | ||
|
||
const names = [ | ||
'Виктор Пупов', | ||
'Геннадий Изюмов', | ||
'Оксана Тетёхина', | ||
'Ваня Комментаторов', | ||
'Фотоспец3002' | ||
]; | ||
const getRandomInteger = (a, b) => { | ||
const lower = Math.ceil(Math.min(a, b)); | ||
const upper = Math.floor(Math.max(a, b)); | ||
return Math.floor(Math.random() * (upper - lower + 1)) + lower; | ||
}; | ||
|
||
let indexPhoto = 0; | ||
let indexComment = 0; | ||
|
||
const createComments = () => { | ||
const randomAvatarIndex = getRandomInteger(photoValues.RANDOM_MIN_NUMBER_AVATAR, photoValues.RANDOM_MAX_NUMBER_AVATAR); | ||
const randomNameIndex = getRandomInteger(0, names.length - 1); | ||
const commentValue = comments[getRandomInteger(0, comments.length - 1)]; | ||
const commentValue2 = comments[getRandomInteger(0, comments.length - 1)]; | ||
const genMessage = commentValue !== commentValue2 ? `${commentValue} ${commentValue2}` : commentValue; | ||
|
||
return { | ||
id: ++indexComment, | ||
avatar: `img/avatar-${randomAvatarIndex}.svg`, | ||
message: genMessage, | ||
name: names[randomNameIndex], | ||
}; | ||
}; | ||
|
||
const descriptions = [ | ||
'здесь мог быть lorem, но ты просто чилишь', | ||
'Русалка села на шпагат', | ||
'Колобок повесился' | ||
]; | ||
const createImage = () => { | ||
const randomDescriptionIndex = getRandomInteger(0, descriptions.length - 1); | ||
const randomLikes = getRandomInteger(photoValues.RANDOM_MIN_NUMBER_LIKES, photoValues.RANDOM_MAX_NUMBER_LIKES); | ||
const randomCommentsCount = getRandomInteger(photoValues.RANDOM_MIN_NUMBER_COMMENTS, photoValues.RANDOM_MAX_NUMBER_COMMENTS); | ||
const commentsArray = Array.from({ length: randomCommentsCount }, createComments); | ||
|
||
const photoValues = { | ||
PHOTOS_COUNT: 25, | ||
RANDOM_MAX_NUMBER_AVATAR: 6, | ||
RANDOM_MIN_NUMBER_AVATAR: 1, | ||
RANDOM_MAX_NUMBER_COMMENTS: 30, | ||
RANDOM_MIN_NUMBER_COMMENTS: 0, | ||
RANDOM_MAX_NUMBER_LIKES: 200, | ||
RANDOM_MIN_NUMBER_LIKES: 15, | ||
return { | ||
id: ++indexPhoto, | ||
url: `photos/${indexPhoto}.jpg`, | ||
description: descriptions[randomDescriptionIndex], | ||
likes: randomLikes, | ||
comments: commentsArray, | ||
}; | ||
}; | ||
|
||
export {comments, photoValues, names, descriptions}; | ||
export {createComments, createImage, getRandomInteger}; |