Commit 6aa4af44 authored by Traboulsi's avatar Traboulsi
Browse files

Update public/js/paperfiltersa.js, public/js/paperfilter.js

parent 7a9da174
Pipeline #8726 passed with stage
in 9 seconds
var state = 0; var state2020 = 0
var state2021 = 0
// Object to store the state for each year var state2022 = 0
var yearStates = { var state2023 = 0
"2020": 0, var state2019 = 0
"2021": 0, var state = 0
"2019": 0, var count = 0
"2022": 0, function filter(year){
"2023": 0, var new_row = document.getElementById("cont_paper")
};
function filter(year) {
var new_row = document.getElementById("cont_paper");
new_row.innerHTML = ""; new_row.innerHTML = "";
document.getElementById("nextblock").style.display = "none"; document.getElementById("nextblock").style.display = "none"
// Use the state from the yearStates object
state = yearStates[year];
if (state === 0) {
console.log("filter");
if (year == "2020") {
state = state2020
} else if (year == "2021"){
state = state2021
} else if (year == "2019"){
state = state2019
}else if (year == "2022"){
state = state2022
}else if (year == "2023"){
state = state2023
}
if (state == 0){
console.log("filter")
// Start loading/adding the paper content to the page here ..... // Start loading/adding the paper content to the page here .....
for (var j = 0; j < jsonContent.length; j++) { if (year == "2020"){
var filterString = jsonContent[j].item.conference.date.toString(); for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2020') || jsonContent[j].item.journal.year == 2020) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
//Do something
}
document.getElementById("filter2020").style.backgroundColor = "grey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2020").innerHTML = "2020 (" + count +")"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2019").innerHTML = "2019"
count = 0
} else if (year == "2021"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2021') || jsonContent[j].item.journal.year == 2021) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
// Check for the selected year
if (filterString.includes(year) || jsonContent[j].item.journal.year == year) { //Do something
addpaper(jsonContent[j]); }
count += 1; document.getElementById("filter2021").style.backgroundColor = "grey"
} document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2021").innerHTML = "2021 (" + count +")"
document.getElementById("filter2020").innerHTML = "2020"
document.getElementById("filter2019").innerHTML = "2019"
count = 0
} else if (year == "2019"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2019') || jsonContent[j].item.journal.year == 2019) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
state = 1;
} //Do something
}
document.getElementById("filter2019").style.backgroundColor = "grey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2019").innerHTML = "2019 (" + count +")"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2020").innerHTML = "2020"
count = 0
} else if (year == "2023"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2023') || jsonContent[j].item.journal.year == 2023) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
// Update the background color and count for the selected year
document.getElementById(`filter${year}`).style.backgroundColor = "grey"; //Do something
}
document.getElementById("filter2023").style.backgroundColor = "grey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2019").innerHTML = "2019"
document.getElementById("filter2023").innerHTML = "2023 (" + count +")"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2020").innerHTML = "2020"
count = 0
} else if (year == "2022"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2022') || jsonContent[j].item.journal.year == 2022) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
// Reset other buttons
Object.keys(yearStates).forEach((otherYear) => { //Do something
if (otherYear !== year) { }
yearStates[otherYear] = 0; document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById(`filter${otherYear}`).style.backgroundColor = "lightgrey"; document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById(`filter${otherYear}`).innerHTML = `${otherYear}`; document.getElementById("filter2020").style.backgroundColor = "lightgrey"
} document.getElementById("filter2023").style.backgroundColor = "lightgrey"
}); document.getElementById("filter2022").style.backgroundColor = "grey"
document.getElementById("filter2019").innerHTML = "2019"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2020").innerHTML = "2020"
document.getElementById("filter2022").innerHTML = "2022 (" + count +")"
count = 0
}
if (year == "2020") {
state2020 = 1
state2021 = 0
state2019 = 0
state2022 = 0
state2023 = 0
document.getElementById(`filter${year}`).innerHTML = `${year} (${count})`; } else if (year == "2021"){
count = 0; state2021 = 1
state2019 = 0
state2020 = 0
state2022 = 0
state2023 = 0
// Update the state for the selected year } else if (year == "2019"){
yearStates[year] = 1; state2019 = 1
} else if (state === 1) { state2020 = 0
// Reset the state and display the initial set of papers state2021 = 0
yearStates[year] = 0; state2022 = 0
document.getElementById(`filter${year}`).style.backgroundColor = "lightgrey"; state2023 = 0
document.getElementById("nextblock").style.display = "block";
}else if (year == "2022"){
state2019 = 0
state2020 = 0
state2021 = 0
state2022 = 1
state2023 = 0
} else if (year == "2023"){
state2019 = 0
state2020 = 0
state2021 = 0
state2022 = 0
state2023 = 1
}
} else if (state == 1) {
if (year == "2020") {
state2020 = 0
} else if (year == "2021"){
state2021 = 0
} else if (year == "2019"){
state2019 = 0
}
else if (year == "2022"){
state2022 = 0
}
else if (year == "2023"){
state2023 = 0
}
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("nextblock").style.display = "block"
for (var j = 0; j < 6; j++) { for (var j = 0; j < 6; j++) {
addpaper(jsonContent[j]); addpaper(jsonContent[j]);
//Do something
} }
state = 0
state = 0; document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
// Reset the display for all years document.getElementById("filter2020").style.backgroundColor = "lightgrey"
Object.keys(yearStates).forEach((otherYear) => { document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById(`filter${otherYear}`).style.backgroundColor = "lightgrey"; document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById(`filter${otherYear}`).innerHTML = `${otherYear}`; document.getElementById("filter2019").innerHTML = "2019"
}); document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2020").innerHTML = "2020"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2023").innerHTML = "2023"
} }
} }
var state2020 = 0
var state2021 = 0
var state2022 = 0
var state2023 = 0
var state2019 = 0
var state = 0
var count = 0
function filter(year){
var new_row = document.getElementById("cont_paper")
new_row.innerHTML = "";
document.getElementById("nextblock").style.display = "none"
if (year == "2020") {
state = state2020
} else if (year == "2021"){
state = state2021
} else if (year == "2019"){
state = state2019
}else if (year == "2022"){
state = state2022
}else if (year == "2023"){
state = state2023
}
if (state == 0){
console.log("filter")
// Start loading/adding the paper content to the page here .....
if (year == "2020"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2020') || jsonContent[j].item.journal.year == 2020) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
//Do something
}
document.getElementById("filter2020").style.backgroundColor = "grey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2020").innerHTML = "2020 (" + count +")"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2019").innerHTML = "2019"
count = 0
} else if (year == "2021"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2021') || jsonContent[j].item.journal.year == 2021) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
//Do something
}
document.getElementById("filter2021").style.backgroundColor = "grey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2021").innerHTML = "2021 (" + count +")"
document.getElementById("filter2020").innerHTML = "2020"
document.getElementById("filter2019").innerHTML = "2019"
count = 0
} else if (year == "2019"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2019') || jsonContent[j].item.journal.year == 2019) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
//Do something
}
document.getElementById("filter2019").style.backgroundColor = "grey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2019").innerHTML = "2019 (" + count +")"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2020").innerHTML = "2020"
count = 0
} else if (year == "2023"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2023') || jsonContent[j].item.journal.year == 2023) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
//Do something
}
document.getElementById("filter2023").style.backgroundColor = "grey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2019").innerHTML = "2019"
document.getElementById("filter2023").innerHTML = "2023 (" + count +")"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2020").innerHTML = "2020"
count = 0
} else if (year == "2022"){
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString()
if ( filterString.includes('2022') || jsonContent[j].item.journal.year == 2022) {
addpaper(jsonContent[j]);
count += 1
}
state = 1
//Do something
}
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "grey"
document.getElementById("filter2019").innerHTML = "2019"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2023").innerHTML = "2023"
document.getElementById("filter2020").innerHTML = "2020"
document.getElementById("filter2022").innerHTML = "2022 (" + count +")"
count = 0
}
if (year == "2020") {
state2020 = 1
state2021 = 0
state2019 = 0
state2022 = 0
state2023 = 0
} else if (year == "2021"){
state2021 = 1
state2019 = 0
state2020 = 0
state2022 = 0
state2023 = 0
} else if (year == "2019"){
state2019 = 1
state2020 = 0
state2021 = 0
state2022 = 0
state2023 = 0
}else if (year == "2022"){
state2019 = 0
state2020 = 0
state2021 = 0
state2022 = 1
state2023 = 0
} else if (year == "2023"){
state2019 = 0
state2020 = 0
state2021 = 0
state2022 = 0
state2023 = 1
}
} else if (state == 1) {
if (year == "2020") {
state2020 = 0
} else if (year == "2021"){
state2021 = 0
} else if (year == "2019"){
state2019 = 0
}
else if (year == "2022"){
state2022 = 0
}
else if (year == "2023"){
state2023 = 0
}
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("nextblock").style.display = "block"
for (var j = 0; j < 6; j++) {
addpaper(jsonContent[j]);
//Do something
}
state = 0
document.getElementById("filter2019").style.backgroundColor = "lightgrey"
document.getElementById("filter2021").style.backgroundColor = "lightgrey"
document.getElementById("filter2020").style.backgroundColor = "lightgrey"
document.getElementById("filter2022").style.backgroundColor = "lightgrey"
document.getElementById("filter2023").style.backgroundColor = "lightgrey"
document.getElementById("filter2019").innerHTML = "2019"
document.getElementById("filter2021").innerHTML = "2021"
document.getElementById("filter2020").innerHTML = "2020"
document.getElementById("filter2022").innerHTML = "2022"
document.getElementById("filter2023").innerHTML = "2023"
}
}
var state = 0;
// Object to store the state for each year
var yearStates = {
"2020": 0,
"2021": 0,
"2019": 0,
"2022": 0,
"2023": 0,
};
function filter(year) {
var new_row = document.getElementById("cont_paper");
new_row.innerHTML = "";
document.getElementById("nextblock").style.display = "none";
// Use the state from the yearStates object
state = yearStates[year];
if (state === 0) {
console.log("filter");
// Start loading/adding the paper content to the page here .....
for (var j = 0; j < jsonContent.length; j++) {
var filterString = jsonContent[j].item.conference.date.toString();
// Check for the selected year
if (filterString.includes(year) || jsonContent[j].item.journal.year == year) {
addpaper(jsonContent[j]);
count += 1;
}
state = 1;
}
// Update the background color and count for the selected year
document.getElementById(`filter${year}`).style.backgroundColor = "grey";
// Reset other buttons
Object.keys(yearStates).forEach((otherYear) => {
if (otherYear !== year) {
yearStates[otherYear] = 0;
document.getElementById(`filter${otherYear}`).style.backgroundColor = "lightgrey";
document.getElementById(`filter${otherYear}`).innerHTML = `${otherYear}`;
}
});
document.getElementById(`filter${year}`).innerHTML = `${year} (${count})`;
count = 0;
// Update the state for the selected year
yearStates[year] = 1;
} else if (state === 1) {
// Reset the state and display the initial set of papers
yearStates[year] = 0;
document.getElementById(`filter${year}`).style.backgroundColor = "lightgrey";
document.getElementById("nextblock").style.display = "block";
for (var j = 0; j < 6; j++) {
addpaper(jsonContent[j]);
}
state = 0;
// Reset the display for all years
Object.keys(yearStates).forEach((otherYear) => {
document.getElementById(`filter${otherYear}`).style.backgroundColor = "lightgrey";
document.getElementById(`filter${otherYear}`).innerHTML = `${otherYear}`;
});
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment