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

enable eslint #499

Merged
merged 2 commits into from
Nov 28, 2023
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
1 change: 0 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ jobs:
- run: yarn install
- run: npx webpack
- run: yarn run lint
continue-on-error: true # should be removed if all the issues are fixed
- run: yarn run test
- uses: codecov/codecov-action@v3
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"grunt-postcss": "0.9.0",
"grunt-run": "^0.8.1",
"grunt-sass": "3.1.0",
"highcharts": "^11.2.0",
"jest": "^29.7.0",
"jquery": "^3.7.1",
"load-grunt-config": "4.0.1",
"load-grunt-tasks": "5.1.0",
"octokit": "^3.1.2",
Expand Down
14 changes: 9 additions & 5 deletions routes/views/account/post/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ let flash = {};
let request = require('request');
const {check, validationResult} = require('express-validator');

function promiseRequest(url) {
function promiseRequest(url, req) {
return new Promise(function (resolve, reject) {
request(url, function (error, res, body) {
request(url, {
headers: {
'Authorization': 'Bearer ' + req.user.data.attributes.token,
}
}, function (error, res, body) {
if (!error && res.statusCode < 300) {
resolve(body);
} else {
reject(error);
reject(error || new Error('report failed with status' + res.statusCode));
}
});
});
Expand Down Expand Up @@ -78,7 +82,7 @@ exports = module.exports = async function (req, res) {
const userFetchRoute = process.env.API_URL+'/data/player?filter='+filter+'&fields[player]=login&page[size]='+offenders.length;
let apiUsers;
try {
const userFetch = await promiseRequest(userFetchRoute);
const userFetch = await promiseRequest(userFetchRoute, req);
apiUsers = JSON.parse(userFetch);
}
catch(e){
Expand Down Expand Up @@ -126,7 +130,7 @@ exports = module.exports = async function (req, res) {
if (isGameReport){
const gameFetchRoute = process.env.API_URL+'/data/game?filter=id=='+req.body.game_id+'&fields[game]='; /* empty field here to fetch nothing but ID */
try {
const gameFetch = await promiseRequest(gameFetchRoute);
const gameFetch = await promiseRequest(gameFetchRoute, req);
const gameData = JSON.parse(gameFetch);
}
catch(e){
Expand Down
147 changes: 1 addition & 146 deletions src/frontend/js/entrypoint/clans.js
Original file line number Diff line number Diff line change
@@ -1,146 +1 @@
//Variables used across the board
let pageNumber = 0;
let lastPage = 5;
let clanList = [];
let timedOutPlayers = [];
let currentClan = '';

let clanListDivided = clanList.length / 100;
// This decides the time filter
let d = new Date();
let timeFilter = 6; // 6 Months is the default value
let minusTimeFilter = d.setMonth(d.getMonth() - timeFilter);
let currentDate = new Date(minusTimeFilter).toISOString();


//Names of buttons
async function clanOneJSON() {
//Check which category is active
const response = await fetch(`js/app/members/getAllClans.json`);

const data = await response.json();

clanList = data;

return await data;
}

clanOneJSON();


//Updates the clan according to what is needed
function clanUpdate() {
// We convert clanList into a string to find out how many pages we have. We can find so by checking the first two digits. In other words, if we have 1349 players, then we have 13 pages. However, if we have 834, we have 8 pages (only take the first digit).
clanListDivided = clanList.length / 100;
lastPage = Math.floor(clanListDivided);

//Deletes everything with the class clanDelete, we do it to delete all the previous clan and add the new one back in.
let clanDelete = document.querySelectorAll('.clanDelete');
clanDelete.forEach(clanDelete => {
clanDelete.remove();
});

//determines the current page, whether to add or substract the missing players in case we pressed next or previous then it will add or substract players
let clanIndex = (clanList.length - 100) - (pageNumber * 100); //- addNextPlayer;
let next100Players = clanList.length - (pageNumber * 100);

for (clanIndex; clanIndex < next100Players; clanIndex++) {
if (clanIndex < 0) {
clanIndex = 0;
console.log('There are no more players left.');
}
// Gets the player data and inserts it into the li element


document.getElementById('clanPlayer').insertAdjacentHTML('afterbegin', `<li class='clanDelete ' > ${clanList[clanIndex][0].leaderName}</li>`);
document.getElementById('clanName').insertAdjacentHTML('afterbegin', `<li class='clanDelete ' > ${clanList[clanIndex][1].name}</li>`);
document.getElementById('clanTAG').insertAdjacentHTML('afterbegin', `<li class='clanDelete ' > ${clanList[clanIndex][1].tag}</li>`);

document.getElementById('clanPopulation').insertAdjacentHTML('afterbegin', `<li class='clanDelete '> ${clanList[clanIndex][1].population}</li>`);

}
}

//This function triggers when the next, previous, first or last button are clicked
let pageButton = document.querySelectorAll('.pageButton');

function pageChange(newPageNumber) {
pageNumber = newPageNumber;
pageButton.forEach(element => element.classList.remove(`exhaustedButton`));
if (pageNumber === 0) {
//You see 4-7 pageButton because there are a total of 8 buttons counting the ones at the bottom of the page
pageButton[0].classList.add('exhaustedButton');
pageButton[2].classList.add('exhaustedButton');
pageButton[4].classList.add('exhaustedButton');
pageButton[6].classList.add('exhaustedButton');
}
if (pageNumber === lastPage) {
pageButton[1].classList.add('exhaustedButton');
pageButton[3].classList.add('exhaustedButton');
pageButton[5].classList.add('exhaustedButton');
pageButton[7].classList.add('exhaustedButton');
}
clanUpdate();
}

// Don't know why but the code refuses to run correctly unless it is delayed by at least 1/10 of a second/100ms. Not really an issue but idk why its doing this
setTimeout(() => {
clanUpdate();
}, 1000);


// SEARCH BAR


//Gets called from the HTML search input form
function pressEnter(event) {
let inputText = event.target.value;
// this regex grabs the current input and due to the ^, it selects whatever starts with the input, so if you type Te, Tex will show up.
if (inputText === '') {
document.querySelectorAll('.removeOldSearch').forEach(element => element.remove());
} else {
let regex = `^${inputText.toLowerCase()}`;
let searchName = clanList.filter(element => element[1].tag.toLowerCase().match(regex));

document.querySelectorAll('.removeOldSearch').forEach(element => element.remove());
for (let player of searchName.slice(0, 5)) {
document.querySelector('#placeMe').insertAdjacentHTML('afterend', `<li class="removeOldSearch"> ${player[1].tag} </li>`);
}

if (event.key === 'Enter') {

findPlayer(inputText);
}
}
document.querySelector('#errorLog').innerText = '';

}

function findPlayer(userInput) {
clanOneJSON(currentClan)
.then(() => {
//input from the searchbar becomes clanName and then searchClan is their index number
let searchClan = clanList.findIndex(element => element[1].tag.toLowerCase() === userInput.toLowerCase());
if (searchClan !== -1) {
window.location.href = `/clans/${userInput}`;
} else {
throw new Error('clan couldnt be found');
}


document.querySelector('#errorLog').innerText = ``;
}).catch(() => {
document.querySelector('#errorLog').innerText = `Clan "${userInput}" couldn't be found`;
});
}

// SEACRH AND CLEAR BUTTONS
document.querySelector('#clearSearch').addEventListener('click', () => {
document.querySelector('#searchResults').classList.add('appearWhenSearching');
document.querySelector('#clearSearch').classList.add('appearWhenSearching');
let clanDelete = document.querySelectorAll('.clanDeleteSearch');
clanDelete.forEach(element => element.remove());
});



// noop while clan-refactoring is in progress
14 changes: 7 additions & 7 deletions src/frontend/js/entrypoint/content-creators.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
async function getWordpress() {
const response = await fetch('/data/content-creators.json');
const data = await response.json();
let insertWordpress = document.getElementById('contentCreatorWordpress');
insertWordpress.insertAdjacentHTML('beforeend', `${data[0].content}`);
return await data;
async function getWordpress () {
const response = await fetch('/data/content-creators.json')
const data = await response.json()
const insertWordpress = document.getElementById('contentCreatorWordpress')
insertWordpress.insertAdjacentHTML('beforeend', `${data[0].content}`)
return await data
}
getWordpress();
getWordpress()
137 changes: 68 additions & 69 deletions src/frontend/js/entrypoint/donation.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
import Highcharts from 'highcharts'

Highcharts.chart('container', {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: true,
backgroundColor: 'transparent',
type: 'pie',
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: true,
backgroundColor: 'transparent',
type: 'pie'

},
credits: {
enabled: false
},
exporting: {
enabled: false
},
title: {
text: 'How FAF Uses Donations',
style: {
color: '#ffffff',
fontSize: '30px',
fontFamily: 'electrolize'
}
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: false,
cursor: 'pointer',

dataLabels: {
color: '#ffffff',
font: '20px electrolize',
enabled: true,
format: '<h2>{point.name}</h2>: {point.percentage:.1f} %',
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
title: {
text: 'How FAF Uses Donations',
style: {
color: '#ffffff',
fontSize: '30px',
fontFamily: 'electrolize'
}
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
enabled: false
},
plotOptions: {
pie: {
allowPointSelect: false,
cursor: 'pointer',

dataLabels: {
color: '#ffffff',
font: '20px electrolize',
enabled: true,
format: '<h2>{point.name}</h2>: {point.percentage:.1f} %',
style: {
fontSize: '18px',
fontFamily: 'electrolize'
}
}
}
},
dataLabels: {
style: {
fontSize: '18px',
fontFamily: 'electrolize'
},
}
}
},
dataLabels: {
style: {
color: '#ffffff'
}
},
series: [{
name: 'Expenses',
colorByPoint: true,
color: '#ffffff',

data: [{
name: 'Infrastructure Costs',
y: 56,
sliced: true,
color: '#7376a8',
selected: true

}, {
name: 'Tournament Prizes',
y: 44,
color: '#dadada',
selected: true
color: '#ffffff'
}
},
series: [{
name: 'Expenses',
colorByPoint: true,
color: '#ffffff',

data: [{
name: 'Infrastructure Costs',
y: 56,
sliced: true,
color: '#7376a8',
selected: true

}, {
name: 'Tournament Prizes',
y: 44,
color: '#dadada',
selected: true
}]
}]
}]
});
})
Loading