(function() {
'use strict';
const formItems = document.querySelectorAll('.form .form__item');
const formRadios = formItems.forEach(item => item.querySelectorAll('.form__label'))
const formProgressLine = document.querySelector('.form .form__progress .form__progress-line');
const formProgressStart = 100 / formItems.length;
const result = document.querySelector('.result');
setTimeout(() => {
formProgressLine.style.width = `${formProgressStart}%`;
}, 0);
formRadios.slice(0, 2).forEach((formRadio, formRadioIndex) => {
formRadios.forEach(radio => {
radio.addEventListener('click', () => {
setTimeout(() => {
formItems[formRadioIndex].classList.remove('form__item--active');
formItems[formRadioIndex + 1].classList.add('form__item--active');
}, 1000);
formProgressLine.style.width = `${formProgressStart * (formRadioIndex + 2)}%`;
});
});
})
formRadios[2].forEach(radio => {
radio.addEventListener('click', () => {
setTimeout(() => {
form.style.display = 'none'
result.classList.add('result--active');
}, 1000);
});
});
})();
{
items: [],
settings: {
key1: { filter: {}, sort: {}, page: 2 },
key2: { filter: {}, sort: {}, page: 1 },
}
}
genome = 'aaaabbcaa'
cnt = 0
res = ''
for i in range(len(genome)):
newSymb = i == 0 or genome[i] != genome[i - 1]
if newSymb:
if cnt > 0: g += str(cnt)
res += genome[i]
cnt = 1
else:
cnt += 1
res += str(cnt)
print(res)
const wrapFilters = ',1,2,3'.split(',').map(v => document.querySelector('.wrap__filter' + v))
const filters = Array.from(['one', 'two', 'three', 'four'],
(v, ind) => document.querySelector('.filter__' + v).addEventListener('click', () => {
wrapFilters.forEach((wrapFilter, wrapIndex) => {
const methodName = index === wrapIndex ? 'toggle' : 'remove'
wrapFilter.classList[methodName]('opened')
})
}))
const wrapFilters = document.querySelectorAll('.wrap__filter')
const filters = Array.from(document.querySelector('.filter')).forEach((el, ind) => {
el.addEventListener('click', () => {
wrapFilters.forEach((wrapFilter, wrapIndex) => {
const methodName = index === wrapIndex ? 'toggle' : 'remove'
wrapFilter.classList[methodName]('opened')
})
})
})
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.myRef = React.createRef();
}
render() {
return <div className={"someClass"} ref={this.myRef} />;
}
}
http.get()
в вашем случае это и есть промис. http.get().then(a => http.get().then(b => {
// Здесь дальнейший код
}))
const p = (resolve, reject) => {
setTimeout(() => resolve(new Date()), 2000)
}
const syncFn = () => {
new Promise(p).then(console.log)
new Promise(p).then(console.log)
}
const asyncFn = async () => {
const a = await new Promise(p).then(console.log)
const b = await new Promise(p).then(console.log)
}
syncFn()
// Tue Jul 14 2020 15:17:19
// Tue Jul 14 2020 15:17:19
asyncFn()
// Tue Jul 14 2020 15:17:49
// Tue Jul 14 2020 15:17:51
SELECT field1, field2, field3 FROM tableName as tMain
INNER JOIN (
SELECT field1, MIN(field2) as field2 FROM tableName GROUP BY field1
) as minTotals ON tMain.field1 = minTotals.field1 AND tMain.field2 = minTotals.field2
const getTopIndexes = (arr, count) => {
return arr.reduce((topIndexes, v, i, arr) => {
let insertIndex = topIndexes.length
for (let ind = topIndexes.length - 1; ind >= 0; ind --)
if (v > arr[topIndexes[ind]]) insertIndex = ind
else break
topIndexes.splice(insertIndex, 0, i)
return topIndexes.slice(0, count)
}, [])
}
console.log(getTopIndexes([-7, 2, 7, 5, 1, 4, -5, 7], 3)) // 2, 7, 3
const index = state.tasksData.findIndex(({ ID }) => ID === payload.ID)
if (index > -1) return {
...state,
tasksData:
state.tasksData.slice(0, index).concat(
state.tasksData.slice(index + 1))
}
select ids.id, t1.deal_id, t2.track_id, t3.waybill_id from
(select '9014' as id) as ids
left join table_1 as t1 on ids.id = t1.item_id
left join table_2 as t2 on ids.id = t2.item_id
left join table_3 as t3 on ids.id = t3.item_id
select ids.id, t1.deal_id, t2.track_id, t3.waybill_id from
(select t1.item_id as id from table_1 union t2.item_id from table_2 union t3.item_id from table_3) as ids
left join table_1 as t1 on ids.id = t1.item_id
left join table_2 as t2 on ids.id = t2.item_id
left join table_3 as t3 on ids.id = t3.item_id