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

Функции возвращаются #5

Merged
Merged
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
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ <h2 class="data-error__title">Не удалось загрузить данны
</section>
</template>

<script src="/js/main.js" type="module"></script>
<script src="./js/main.js" type="module"></script>
<script src="./js/functions.js"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions js/data-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
let lastGeneratedId = getRandomInteger(min, max);

if(previousValues.length >= (max - min + 1)) {
console.log('Закончились уникальные идентификаторы');
console.error('Закончились уникальные идентификаторы');

Check failure on line 47 in js/data-generator.js

View workflow job for this annotation

GitHub Actions / Check

Unexpected console statement
return null;
}

Expand All @@ -61,15 +61,15 @@

const createCommentObject = () => ({
id: generateCommentId(),
avatar: 'img/avatar-' + getRandomInteger(1, 6) + '.svg',
avatar: `img/avatar-${getRandomInteger(1, 6)}.svg`,
message: getRandomArrayElement(MESSAGES),
name: getRandomArrayElement(NAMES),
});


const createPhotoObject = (_, index) => ({
id: index,
url: 'photos/' + index++ + '.jpg',
url: `photos/${index++}.jpg`,
description: getRandomArrayElement(DESCRIPTIONS),
likes: getRandomInteger(MIN_LIKES, MAX_LIKES),
comments: Array.from({length: getRandomInteger(MIN_COMMENTS, MAX_COMMENTS)}, createCommentObject)
Expand Down
14 changes: 11 additions & 3 deletions js/functions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
function isLesserOrEqual(string, maxLength) {
return string.length <= maxLength;
}
const isLesserOrEqual = (string, maxLength) => string.length <= maxLength;

Check failure on line 1 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isLesserOrEqual' is assigned a value but never used

function isPalindrome(string) {

Check failure on line 3 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isPalindrome' is defined but never used
const normalizedString = string.replaceAll(' ', '').toLowerCase();
const reversedString = normalizedString.split('').reverse().join('');

return normalizedString === reversedString;
}

function toPositiveNumber(string) {

Check failure on line 10 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'toPositiveNumber' is defined but never used
const normalizedString = string.toString().replaceAll(' ', '');
let result = '';

Expand All @@ -22,3 +20,13 @@
return parseInt(result, 10);
}

const timeToMinutesNumber = (arr) => Number(arr[0]) * 60 + Number(arr[1]);


function isMeetingInWorkingHours(timeStart, timeEnd, meetingTime, meetingDuration) {

Check failure on line 26 in js/functions.js

View workflow job for this annotation

GitHub Actions / Check

'isMeetingInWorkingHours' is defined but never used
const timeStartNormalized = timeToMinutesNumber(timeStart.split(':'));
const timeEndNormalized = timeToMinutesNumber(timeEnd.split(':'));
const meetingTimeNormalized = timeToMinutesNumber(meetingTime.split(':'));

return (meetingTimeNormalized >= timeStartNormalized && (meetingTimeNormalized + meetingDuration) <= timeEndNormalized);
}
Loading