Skip to content

Commit

Permalink
Merge pull request #14 from Aleksandr-Anokhin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Jan 17, 2025
2 parents d88f856 + d12b162 commit b06f9a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const MASSAGE_TIME = 5000;
export const GET_URL = 'https://31.javascript.htmlacademy.pro/kekstagram/data';
export const POST_URL = 'https://31.javascript.htmlacademy.pro/kekstagram';

export const EFFECTS = {
export const Effects = {
NONE: 'none',
CHROME: 'chrome',
SEPIA: 'sepia',
Expand All @@ -25,42 +25,42 @@ export const EFFECTS = {
};

export const EffectsSettings = {
[EFFECTS.NONE]: {
[Effects.NONE]: {
min: 0,
max: 1,
step: 0.1,
style: '',
units: ''
},
[EFFECTS.CHROME]: {
[Effects.CHROME]: {
min: 0,
max: 1,
step: 0.1,
style: 'grayscale',
units: ''
},
[EFFECTS.SEPIA]: {
[Effects.SEPIA]: {
min: 0,
max: 1,
step: 0.1,
style: 'sepia',
units: ''
},
[EFFECTS.MARVIN]: {
[Effects.MARVIN]: {
min: 0,
max: 100,
step: 1,
style: 'invert',
units: '%'
},
[EFFECTS.PHOBOS]: {
[Effects.PHOBOS]: {
min: 0,
max: 3,
step: 0.1,
style: 'blur',
units: 'px'
},
[EFFECTS.HEAT]: {
[Effects.HEAT]: {
min: 1,
max: 3,
step: 0.1,
Expand All @@ -69,14 +69,14 @@ export const EffectsSettings = {
},
};

export const DEFAULT_EFFECT = EFFECTS.NONE;
export const DEFAULT_EFFECT = Effects.NONE;

export const POPUPS_TYPES = {
export const PopupType = {
SUCCESS: 'success',
ERROR: 'error'
};

export const FILTERS = {
export const Filter = {
DEFAULT: 'filter-default',
RANDOM: 'filter-random',
DISCUSSED: 'filter-discussed'
Expand Down
10 changes: 5 additions & 5 deletions js/filter.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { FILTERS } from './constants.js';
import { Filter } from './constants.js';
import { renderCards } from './thumbnail.js';
import { debounce } from './utils.js';

const filtersSection = document.querySelector('.img-filters');
const formFilter = document.querySelector('.img-filters__form');

let localPhotos;
let currentFilter = FILTERS.DEFAULT;
let currentFilter = Filter.DEFAULT;

const FiltersAction = {
[FILTERS.DEFAULT]: () => localPhotos,
[FILTERS.RANDOM]: () => [...localPhotos].sort(() => Math.random() - 0.5).slice(0, 10),
[FILTERS.DISCUSSED]: () => [...localPhotos].sort((a, b) => b.comments.length - a.comments.length),
[Filter.DEFAULT]: () => localPhotos,
[Filter.RANDOM]: () => [...localPhotos].sort(() => Math.random() - 0.5).slice(0, 10),
[Filter.DISCUSSED]: () => [...localPhotos].sort((a, b) => b.comments.length - a.comments.length),
};

const setActiveButton = (button) => {
Expand Down
6 changes: 3 additions & 3 deletions js/form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isValid, reset as resetValidation } from './validation.js';
import { reset as resetScale } from './scale.js';
import { reset as resetEffects } from './effects.js';
import { POPUPS_TYPES, SubmitButtonTexts } from './constants.js';
import { PopupType, SubmitButtonTexts } from './constants.js';
import { showPopup } from './popup.js';
import { sendData } from './api.js';
import { removeEscControl, setEscControl } from './escape-control.js';
Expand Down Expand Up @@ -73,10 +73,10 @@ form.addEventListener('submit', (evt) => {
}
closeModal();
removeEscControl();
showPopup(POPUPS_TYPES.SUCCESS);
showPopup(PopupType.SUCCESS);
})
.catch(() => {
showPopup(POPUPS_TYPES.ERROR);
showPopup(PopupType.ERROR);
})
.finally(() => {
disableSubmitButton(false);
Expand Down
6 changes: 3 additions & 3 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { POPUPS_TYPES } from './constants.js';
import { PopupType } from './constants.js';
import { removeEscControl, setEscControl } from './escape-control.js';

const successTemplate = document.querySelector('#success').content.querySelector('.success');
const errorTemplate = document.querySelector('#error').content.querySelector('.error');
const body = document.body;

const templates = {
[POPUPS_TYPES.SUCCESS]: successTemplate,
[POPUPS_TYPES.ERROR]: errorTemplate
[PopupType.SUCCESS]: successTemplate,
[PopupType.ERROR]: errorTemplate
};

export const showPopup = (type) => {
Expand Down

0 comments on commit b06f9a4

Please sign in to comment.