2020-08-30 12:24:11 +00:00
|
|
|
let sideMenuCounter = 0
|
|
|
|
function manageSideMenu() {
|
2020-09-21 17:20:17 +00:00
|
|
|
if(window.innerWidth < 1101 && sideMenuCounter === 0){
|
|
|
|
sideBar.style.marginLeft = '-100%'
|
2020-08-30 12:24:11 +00:00
|
|
|
sideMenuCounter = 1
|
2020-09-21 17:20:17 +00:00
|
|
|
} else if(window.innerWidth < 1101 && sideMenuCounter === 1){
|
|
|
|
sideBar.style.marginLeft = '0'
|
2020-08-30 12:24:11 +00:00
|
|
|
sideMenuCounter = 0
|
2020-09-21 17:20:17 +00:00
|
|
|
} else if(window.innerWidth > 1100 && sideMenuCounter === 0){
|
|
|
|
sideBar.style.marginLeft = '-100%'
|
2020-08-30 12:24:11 +00:00
|
|
|
sideMenuCounter = 1
|
2020-09-21 17:20:17 +00:00
|
|
|
} else if(window.innerWidth > 1100 && sideMenuCounter === 1) {
|
|
|
|
sideBar.style.marginLeft = '0'
|
2020-08-30 12:24:11 +00:00
|
|
|
sideMenuCounter = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function manageExtraSearchOptions() {
|
|
|
|
if(extraSearchOptions.classList.contains('disable')) {
|
|
|
|
hideSuggestWords()
|
2020-09-19 22:44:09 +00:00
|
|
|
showExtraSearchOptions()
|
|
|
|
} else hideExtraSearchOptions()
|
|
|
|
}
|
|
|
|
function showExtraSearchOptions() {
|
|
|
|
extraSearchOptions.classList.remove('disable')
|
|
|
|
mainSearchInput.style.borderBottomLeftRadius = '0'
|
|
|
|
mainSearchInput.style.borderBottomRightRadius = '0'
|
|
|
|
extOptIcon.style.transform = 'rotate(180deg)'
|
|
|
|
if(!indexTimeSelect.classList.contains('disable')) indexTimeSelect.classList.add('disable')
|
|
|
|
}
|
|
|
|
function hideExtraSearchOptions() {
|
|
|
|
extraSearchOptions.classList.add('disable')
|
|
|
|
mainSearchInput.style.borderBottomLeftRadius = '6px'
|
|
|
|
mainSearchInput.style.borderBottomRightRadius = '6px'
|
|
|
|
extOptIcon.style.transform = 'rotate(0deg)'
|
2020-08-30 12:24:11 +00:00
|
|
|
}
|
|
|
|
function resetExtraSearchOptions() {
|
|
|
|
indexTimeLabel.innerHTML = 'Anytime'
|
|
|
|
for(let i = 0; i < 3; i++)
|
|
|
|
document.querySelectorAll('.extra-search-options > div > input')[i].value = ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function manageTimeOptionSelect() {
|
|
|
|
if(indexTimeSelect.classList.contains('disable')){
|
|
|
|
indexTimeSelect.classList.remove('disable')
|
|
|
|
let selectedValue = -32 * showTimeOptionSelect()
|
|
|
|
indexTimeSelect.style.top = `${selectedValue}px`
|
|
|
|
}
|
|
|
|
else indexTimeSelect.classList.add('disable')
|
|
|
|
}
|
|
|
|
function showTimeOptionSelect() {
|
|
|
|
let selectedValue
|
|
|
|
for(let i = 0; i < 4; i++) {
|
|
|
|
if(indexTimeSelect.children[i].innerHTML === indexTimeLabel.innerHTML) {
|
|
|
|
indexTimeSelect.children[i].classList.add('selected-option')
|
|
|
|
selectedValue = i
|
|
|
|
}
|
|
|
|
indexTimeSelect.children[i].onmouseenter = () => { eventHandelerForTimeOptionSelect(indexTimeSelect.children[i],'enter') }
|
|
|
|
indexTimeSelect.children[i].onmouseleave = () => { eventHandelerForTimeOptionSelect(indexTimeSelect.children[i],'leave') }
|
|
|
|
}
|
|
|
|
return selectedValue
|
|
|
|
}
|
|
|
|
|
|
|
|
let timeOptionSelectValueArray = []
|
|
|
|
function eventHandelerForTimeOptionSelect(element,command) {
|
|
|
|
timeOptionSelectValueArray.push(command)
|
|
|
|
removeEveryChildsClass(element.parentElement,'selected-option')
|
|
|
|
if(command == 'enter' || timeOptionSelectValueArray[timeOptionSelectValueArray.length - 1] == 'leave') element.classList.add('selected-option')
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeEveryChildsClass(parent,className) {
|
|
|
|
for(let i = 0; i < parent.children.length; i++)
|
|
|
|
parent.children[i].classList.remove(className)
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectValue(selectedElement) {
|
|
|
|
event.stopPropagation()
|
|
|
|
indexTimeLabel.innerHTML = selectedElement.innerHTML
|
|
|
|
selectedElement.parentElement.classList.add('disable')
|
|
|
|
}
|
|
|
|
|
|
|
|
function showSuggestWords() {
|
|
|
|
mainSearchInput.style.borderBottomLeftRadius = '0'
|
|
|
|
mainSearchInput.style.borderBottomRightRadius = '0'
|
|
|
|
suggestMainInput.classList.remove('disable')
|
|
|
|
}
|
|
|
|
function hideSuggestWords() {
|
|
|
|
mainSearchInput.style.borderBottomLeftRadius = '6px'
|
|
|
|
mainSearchInput.style.borderBottomRightRadius = '6px'
|
|
|
|
suggestMainInput.classList.add('disable')
|
2020-09-16 08:00:31 +00:00
|
|
|
suggest.removeAllSuggestWordBoxes()
|
2020-08-30 12:24:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideSelectCountry() {
|
|
|
|
selectCountryDiv.classList.remove('active')
|
|
|
|
overlay.classList.remove('active')
|
|
|
|
searchCountriesInput.value = ''
|
|
|
|
}
|
|
|
|
|
|
|
|
function showSelectCountry() {
|
|
|
|
selectCountryDiv.classList.add('active')
|
|
|
|
overlay.classList.add('active')
|
|
|
|
elementAdjustmentsSearchCountries()
|
|
|
|
generateCountries()
|
|
|
|
}
|
|
|
|
function hideSelectCountry() {
|
|
|
|
selectCountryDiv.classList.remove('active')
|
|
|
|
overlay.classList.remove('active')
|
|
|
|
searchCountriesInput.value = ''
|
|
|
|
selectedC = null
|
|
|
|
}
|
|
|
|
|
|
|
|
function manageLoginOptions() {
|
|
|
|
if(!logInOptions.classList.contains('active')) {
|
|
|
|
logInOptions.classList.add('active')
|
|
|
|
overlay.classList.add('active')
|
|
|
|
} else {
|
|
|
|
logInOptions.classList.remove('active')
|
|
|
|
overlay.classList.remove('active')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetExtraSearchOptions() {
|
|
|
|
indexTimeLabel.innerHTML = 'Anytime'
|
|
|
|
for(let i = 0; i < 3; i++)
|
|
|
|
document.querySelectorAll('.extra-search-options > div > input')[i].value = ''
|
2020-09-16 08:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function sidebarCategorySelect(selectedElement) {
|
2020-09-21 17:20:17 +00:00
|
|
|
if(selectedElement.classList.contains('active')) return
|
|
|
|
selectedElement.classList.add('active')
|
|
|
|
selectedElement.firstElementChild.classList.add('active')
|
2020-09-16 08:00:31 +00:00
|
|
|
/* Search news articles */
|
|
|
|
}
|
|
|
|
function removeActiveSidebarCategory() {
|
2020-09-21 17:20:17 +00:00
|
|
|
let oldSelectedElements = document.querySelectorAll('sidebar-category.active')
|
2020-09-16 08:00:31 +00:00
|
|
|
for(let i = 0; i < oldSelectedElements.length; i++)
|
2020-09-21 17:20:17 +00:00
|
|
|
oldSelectedElements[i].classList.remove('active')
|
2020-09-16 08:00:31 +00:00
|
|
|
}
|