remove lodash, validator, date-fns-tz from dependencies | add prettier and its configuration
This commit is contained in:
parent
731bee69e8
commit
0f87bd804a
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"arrowParens": "avoid",
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
}
|
16
package.json
16
package.json
|
@ -8,23 +8,25 @@
|
|||
"scripts": {
|
||||
"build:tamper": "parcel build ./src/*.js --no-minify --no-source-maps",
|
||||
"build:quickbar": "parcel build ./src/*.js --out-dir dist/quickbar --no-source-maps",
|
||||
"build": "npm-run-all build:*"
|
||||
"build": "npm-run-all build:*",
|
||||
"git:add": "git add .",
|
||||
"format": "prettier --write \"src/*.{js,jsx,ts,tsx,json,md}\""
|
||||
},
|
||||
"dependencies": {
|
||||
"date-fns": "^2.14.0",
|
||||
"date-fns-tz": "^1.0.10",
|
||||
"lodash": "^4.17.19",
|
||||
"parcel": "^1.12.4",
|
||||
"validator": "^13.1.1"
|
||||
"parcel": "^1.12.4"
|
||||
},
|
||||
"browserslist": [
|
||||
"since 2017-06"
|
||||
],
|
||||
"devDependencies": {
|
||||
"npm-run-all": "^4.1.5",
|
||||
"pre-commit": "^1.2.2"
|
||||
"pre-commit": "^1.2.2",
|
||||
"prettier": "^2.2.1"
|
||||
},
|
||||
"pre-commit": [
|
||||
"build"
|
||||
"format",
|
||||
"build",
|
||||
"git:add"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ const buildReqOptions = (bonus, offset) => {
|
|||
};
|
||||
};
|
||||
|
||||
const loadBonusVillages = async (bonus) => {
|
||||
const loadBonusVillages = async bonus => {
|
||||
const { villages } = await requestCreator(buildReqOptions(bonus, 0));
|
||||
for (let i = villages.length; i < villages.total; i += 1000) {
|
||||
const data = await requestCreator(buildReqOptions(bonus, 0));
|
||||
|
@ -60,14 +60,14 @@ const loadBonusVillages = async (bonus) => {
|
|||
return villages;
|
||||
};
|
||||
|
||||
const searchBonusBarbarianVillages = async (e) => {
|
||||
const searchBonusBarbarianVillages = async e => {
|
||||
e.preventDefault();
|
||||
|
||||
const villages = await loadBonusVillages(parseInt(e.target[0].value));
|
||||
const coords = TWMap.pos;
|
||||
|
||||
villages.items = villages.items
|
||||
.map((item) => {
|
||||
.map(item => {
|
||||
return {
|
||||
...item,
|
||||
distance: calcDistanceBetweenTwoPoints(
|
||||
|
@ -96,7 +96,7 @@ const getBonuses = () => {
|
|||
return bonuses;
|
||||
};
|
||||
|
||||
const buildTableBodyHTML = (villages) => {
|
||||
const buildTableBodyHTML = villages => {
|
||||
return `
|
||||
<tbody>
|
||||
<tr>
|
||||
|
@ -114,7 +114,7 @@ const buildTableBodyHTML = (villages) => {
|
|||
Array.isArray(villages)
|
||||
? villages
|
||||
.map(
|
||||
(village) => `<tr>
|
||||
village => `<tr>
|
||||
<td>
|
||||
<a href="${twutils.buildVillageURL(village.id)}">
|
||||
${twutils.buildVillageName(
|
||||
|
@ -154,7 +154,7 @@ const renderUI = () => {
|
|||
<select>
|
||||
${getBonuses()
|
||||
.map(
|
||||
(bonus) =>
|
||||
bonus =>
|
||||
`<option value="${bonus.value}">${bonus.text}</option>`
|
||||
)
|
||||
.join('')}
|
||||
|
|
|
@ -15,7 +15,7 @@ import wait from './utils/wait';
|
|||
|
||||
const translations = getTranslations();
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
const handleSubmit = async e => {
|
||||
e.preventDefault();
|
||||
const name = e.target[0].value;
|
||||
if (!name) return;
|
||||
|
|
|
@ -3,7 +3,7 @@ import isNil from '../utils/isNil';
|
|||
|
||||
const translations = getTranslations();
|
||||
|
||||
const getTodaysStatsTdStyle = (value) => {
|
||||
const getTodaysStatsTdStyle = value => {
|
||||
const statIncreaseStyle = 'color: #000; background-color: #0f0';
|
||||
const statDecreaseStyle = 'color: #000; background-color: #f00';
|
||||
const defaultStyle = 'color: #000; background-color: #808080';
|
||||
|
|
|
@ -54,7 +54,7 @@ export default (
|
|||
</th>
|
||||
</tr>
|
||||
${ennoblements.items
|
||||
.map((ennoblement) => {
|
||||
.map(ennoblement => {
|
||||
let rowHTML =
|
||||
'<tr>' + `<td>${formatDate(ennoblement.ennobledAt)}</td>`;
|
||||
if (ennoblement.village) {
|
||||
|
@ -94,7 +94,7 @@ export default (
|
|||
|
||||
document
|
||||
.querySelectorAll('#' + PAGINATION_CONTAINER_ID + ' a')
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
el.addEventListener('click', onPageChange);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as twutils from '../utils/tribalwars';
|
|||
const PAGINATION_CONTAINER_ID = 'historyPagination';
|
||||
const translations = getTranslations();
|
||||
|
||||
const addMathSymbol = (v) => {
|
||||
const addMathSymbol = v => {
|
||||
return v > 0 ? '+' + v : v;
|
||||
};
|
||||
|
||||
|
@ -56,12 +56,12 @@ export default (
|
|||
${tribe ? '' : `<th>${translations.ods}</th>`}
|
||||
</tr>
|
||||
${history.items
|
||||
.map((history) => {
|
||||
.map(history => {
|
||||
const subtracted =
|
||||
subDays(new Date(history.createDate), 1)
|
||||
.toISOString()
|
||||
.split('.')[0] + 'Z';
|
||||
const stats = daily.items.find((stats) => {
|
||||
const stats = daily.items.find(stats => {
|
||||
return stats.createDate === subtracted;
|
||||
});
|
||||
|
||||
|
@ -142,7 +142,7 @@ export default (
|
|||
|
||||
document
|
||||
.querySelectorAll('#' + PAGINATION_CONTAINER_ID + ' a')
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
el.addEventListener('click', onPageChange);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -97,7 +97,7 @@ const cacheServerConfig = (data = {}) => {
|
|||
setItem(SERVER_CONFIG_LOCAL_STORAGE_KEY, data);
|
||||
};
|
||||
|
||||
const isConfigExpired = (date) => {
|
||||
const isConfigExpired = date => {
|
||||
return Math.abs(date.getTime() - new Date().getTime()) > 1000 * 60 * 60 * 24;
|
||||
};
|
||||
|
||||
|
@ -166,7 +166,7 @@ const getAvailableUnits = (unitCfg = {}) => {
|
|||
return units;
|
||||
};
|
||||
|
||||
const getUnitTdBgColor = (index) => (index % 2 === 0 ? '#f8f4e8' : '#ded3b9;');
|
||||
const getUnitTdBgColor = index => (index % 2 === 0 ? '#f8f4e8' : '#ded3b9;');
|
||||
|
||||
const buildUnitHeader = (unit, index) => {
|
||||
return `
|
||||
|
@ -295,13 +295,13 @@ const renderAdditionalInfo = (id, data, { config, unitConfig }) => {
|
|||
`;
|
||||
};
|
||||
|
||||
const createLoadVillageHandler = (cfg) => async (e) => {
|
||||
const createLoadVillageHandler = cfg => async e => {
|
||||
TWMap.popup._loadVillage(e);
|
||||
const data = await loadVillageData(parseInt(e));
|
||||
renderAdditionalInfo(parseInt(e), data, cfg);
|
||||
};
|
||||
|
||||
const createDisplayForVillageHandler = (cfg) => async (e, a, t) => {
|
||||
const createDisplayForVillageHandler = cfg => async (e, a, t) => {
|
||||
TWMap.popup._displayForVillage(e, a, t);
|
||||
const data = await loadVillageData(parseInt(e.id), {
|
||||
cacheOnly: window.game_data.features.Premium.active,
|
||||
|
|
|
@ -280,7 +280,7 @@ const renderTr = ({ title, data, id }) => {
|
|||
tr.children[1].innerHTML = data;
|
||||
};
|
||||
|
||||
const renderPlayerServers = (player) => {
|
||||
const renderPlayerServers = player => {
|
||||
let playerServers = document.querySelector('#playerServers');
|
||||
if (!playerServers) {
|
||||
playerServers = document.createElement('table');
|
||||
|
@ -305,7 +305,7 @@ const renderPlayerServers = (player) => {
|
|||
playerServers.querySelector('td').innerHTML = player.servers
|
||||
.sort()
|
||||
.map(
|
||||
(server) =>
|
||||
server =>
|
||||
`<a target="_blank" style="margin-right: 5px" href="${twhelputils.buildPlayerURL(
|
||||
VERSION,
|
||||
server,
|
||||
|
@ -315,7 +315,7 @@ const renderPlayerServers = (player) => {
|
|||
.join('');
|
||||
};
|
||||
|
||||
const renderPlayerOtherNames = (player) => {
|
||||
const renderPlayerOtherNames = player => {
|
||||
let playerOtherNames = document.querySelector('#playerOtherNames');
|
||||
if (!playerOtherNames) {
|
||||
playerOtherNames = document.createElement('div');
|
||||
|
@ -338,7 +338,7 @@ const renderPlayerOtherNames = (player) => {
|
|||
</th>
|
||||
</tr>
|
||||
${player.nameChanges
|
||||
.map((nameChange) => {
|
||||
.map(nameChange => {
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -363,7 +363,7 @@ const renderPlayerOtherNames = (player) => {
|
|||
`;
|
||||
};
|
||||
|
||||
const renderInADayRanks = (player) => {
|
||||
const renderInADayRanks = player => {
|
||||
let inADayRanks = document.querySelector('#inADayRanks');
|
||||
if (!inADayRanks) {
|
||||
inADayRanks = document.createElement('div');
|
||||
|
@ -486,7 +486,7 @@ const render = ({ player, dailyPlayerStats }) => {
|
|||
player.mostVillages + ' ' + `(${formatDate(player.mostVillagesAt)})`,
|
||||
id: 'most_villages',
|
||||
},
|
||||
].forEach((data) => {
|
||||
].forEach(data => {
|
||||
renderTr(data);
|
||||
});
|
||||
|
||||
|
@ -526,7 +526,7 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
</th>
|
||||
</tr>
|
||||
${tribeChanges.items
|
||||
.map((tribeChange) => {
|
||||
.map(tribeChange => {
|
||||
let rowHTML =
|
||||
'<tr>' + `<td>${formatDate(tribeChange.createdAt)}</td>`;
|
||||
if (tribeChange.newTribe) {
|
||||
|
@ -559,12 +559,12 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
|
||||
document
|
||||
.querySelectorAll('#' + TRIBE_CHANGES_PAGINATION_CONTAINER_ID + ' a')
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
el.addEventListener('click', handleShowTribeChangesButtonClick);
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowTribeChangesButtonClick = async (e) => {
|
||||
const handleShowTribeChangesButtonClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -584,7 +584,7 @@ const handleShowTribeChangesButtonClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleShowPlayerHistoryClick = async (e) => {
|
||||
const handleShowPlayerHistoryClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -615,7 +615,7 @@ const handleShowPlayerHistoryClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleShowPlayerEnnoblementsClick = async (e) => {
|
||||
const handleShowPlayerEnnoblementsClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -642,7 +642,7 @@ const handleShowPlayerEnnoblementsClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleExportPlayerVillagesButtonClick = (e) => {
|
||||
const handleExportPlayerVillagesButtonClick = e => {
|
||||
e.preventDefault();
|
||||
|
||||
Dialog.show(
|
||||
|
@ -654,7 +654,7 @@ const handleExportPlayerVillagesButtonClick = (e) => {
|
|||
);
|
||||
};
|
||||
|
||||
const wrapAction = (action) => {
|
||||
const wrapAction = action => {
|
||||
const actionWrapperTd = document.createElement('td');
|
||||
actionWrapperTd.colSpan = '2';
|
||||
actionWrapperTd.append(action);
|
||||
|
|
|
@ -217,7 +217,7 @@ const cacheTribeData = (data = {}) => {
|
|||
|
||||
const getMemberIDs = () => {
|
||||
const ids = [];
|
||||
membersContainer.querySelectorAll('a').forEach((a) => {
|
||||
membersContainer.querySelectorAll('a').forEach(a => {
|
||||
const href = a.getAttribute('href');
|
||||
if (href.includes('info_player')) {
|
||||
ids.push(getIDFromURL(href));
|
||||
|
@ -228,7 +228,7 @@ const getMemberIDs = () => {
|
|||
|
||||
const getMemberNames = () => {
|
||||
const ids = [];
|
||||
membersContainer.querySelectorAll('a').forEach((a) => {
|
||||
membersContainer.querySelectorAll('a').forEach(a => {
|
||||
if (a.getAttribute('href').includes('info_player')) {
|
||||
ids.push(a.innerText.trim());
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ const renderTr = ({ title, data, id }) => {
|
|||
tr.children[1].innerHTML = data;
|
||||
};
|
||||
|
||||
const extendMembersData = (players) => {
|
||||
const extendMembersData = players => {
|
||||
membersContainer.parentElement.style.width = '100%';
|
||||
const heading = membersContainer.querySelector('tr:first-child');
|
||||
if (heading.children.length !== 11) {
|
||||
|
@ -282,19 +282,19 @@ const extendMembersData = (players) => {
|
|||
translations.od,
|
||||
translations.dailyGrowth,
|
||||
translations.playerLinks,
|
||||
].forEach((v) => {
|
||||
].forEach(v => {
|
||||
const th = document.createElement('th');
|
||||
th.innerHTML = v;
|
||||
heading.appendChild(th);
|
||||
});
|
||||
}
|
||||
membersContainer.querySelectorAll('tr').forEach((tr) => {
|
||||
membersContainer.querySelectorAll('tr').forEach(tr => {
|
||||
const a = tr.querySelector('a');
|
||||
if (!a) {
|
||||
return;
|
||||
}
|
||||
const playerID = getIDFromURL(a.getAttribute('href'));
|
||||
const player = players.items.find((p) => p.id === playerID);
|
||||
const player = players.items.find(p => p.id === playerID);
|
||||
if (player) {
|
||||
[
|
||||
[player.scoreAtt, player.rankAtt],
|
||||
|
@ -369,7 +369,7 @@ const render = ({ tribe, dailyTribeStats, players }) => {
|
|||
data: tribe.mostVillages + ' ' + `(${formatDate(tribe.mostVillagesAt)})`,
|
||||
id: 'most_villages',
|
||||
},
|
||||
].forEach((data) => {
|
||||
].forEach(data => {
|
||||
renderTr(data);
|
||||
});
|
||||
|
||||
|
@ -382,7 +382,7 @@ const render = ({ tribe, dailyTribeStats, players }) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleShowTribeEnnoblementsClick = async (e) => {
|
||||
const handleShowTribeEnnoblementsClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -409,7 +409,7 @@ const handleShowTribeEnnoblementsClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleShowTribeHistoryClick = async (e) => {
|
||||
const handleShowTribeHistoryClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -440,7 +440,7 @@ const handleShowTribeHistoryClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const getMembersGrowthTdStyle = (value) => {
|
||||
const getMembersGrowthTdStyle = value => {
|
||||
const statIncreaseStyle = 'color: #000; background-color: #0f0';
|
||||
const statDecreaseStyle = 'color: #000; background-color: #f00';
|
||||
const defaultStyle = 'color: #000; background-color: #808080';
|
||||
|
@ -452,7 +452,7 @@ const getMembersGrowthTdStyle = (value) => {
|
|||
: defaultStyle;
|
||||
};
|
||||
|
||||
const mapMembersGrowthTdValue = (i) => {
|
||||
const mapMembersGrowthTdValue = i => {
|
||||
switch (MEMBERS_GROWTH_MODE) {
|
||||
case 'points':
|
||||
return i.points;
|
||||
|
@ -471,9 +471,9 @@ const mapMembersGrowthTdValue = (i) => {
|
|||
}
|
||||
};
|
||||
|
||||
const buildMembersGrowthTBody = (stats) => {
|
||||
const buildMembersGrowthTBody = stats => {
|
||||
const dates = [
|
||||
...new Set(stats.items.map((item) => item.createDate)),
|
||||
...new Set(stats.items.map(item => item.createDate)),
|
||||
].reverse();
|
||||
|
||||
return `
|
||||
|
@ -481,7 +481,7 @@ const buildMembersGrowthTBody = (stats) => {
|
|||
<tr>
|
||||
<th>${translations.player}</th>
|
||||
${dates
|
||||
.map((date) => {
|
||||
.map(date => {
|
||||
return `<th>${formatDate(date, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
|
@ -492,9 +492,9 @@ const buildMembersGrowthTBody = (stats) => {
|
|||
<th>${translations.total}</th>
|
||||
</tr>
|
||||
${getMemberIDs()
|
||||
.map((id) => {
|
||||
.map(id => {
|
||||
const filtered = stats.items
|
||||
.filter((item) => item.player && item.player.id === id)
|
||||
.filter(item => item.player && item.player.id === id)
|
||||
.reverse();
|
||||
let player = undefined;
|
||||
if (filtered.length > 0) {
|
||||
|
@ -503,7 +503,7 @@ const buildMembersGrowthTBody = (stats) => {
|
|||
const tds = [];
|
||||
let total = 0;
|
||||
for (let date of dates) {
|
||||
const i = filtered.find((i) => i.createDate === date);
|
||||
const i = filtered.find(i => i.createDate === date);
|
||||
let val = 0;
|
||||
if (i) {
|
||||
val = mapMembersGrowthTdValue(i);
|
||||
|
@ -537,7 +537,7 @@ const buildMembersGrowthTBody = (stats) => {
|
|||
const MEMBERS_GROWTH_TABLE_ID = 'membersGrowth';
|
||||
const MEMBERS_GROWTH_FORM = MEMBERS_GROWTH_TABLE_ID + 'Form';
|
||||
|
||||
const createChangeTypeHandler = (stats) => (e) => {
|
||||
const createChangeTypeHandler = stats => e => {
|
||||
e.preventDefault();
|
||||
MEMBERS_GROWTH_MODE = e.target[0].value;
|
||||
document.querySelector(
|
||||
|
@ -554,7 +554,7 @@ const renderMembersGrowthPopup = (e, stats) => {
|
|||
['odd', translations.opponentsDefeatedAsDefender],
|
||||
['ods', translations.opponentsDefeatedAsSupporter],
|
||||
].map(
|
||||
(v) =>
|
||||
v =>
|
||||
`<option ${
|
||||
MEMBERS_GROWTH_MODE === v[0] ? 'selected="selected"' : ''
|
||||
} value="${v[0]}">${v[1]}</option>`
|
||||
|
@ -604,7 +604,7 @@ const loadMembersGrowthData = async ({ createDateLTE, createDateGT } = {}) => {
|
|||
return data;
|
||||
};
|
||||
|
||||
const handleShowMembersGrowthClick = async (e) => {
|
||||
const handleShowMembersGrowthClick = async e => {
|
||||
e.preventDefault();
|
||||
const createDateGT = new Date();
|
||||
createDateGT.setDate(createDateGT.getDate() - 7);
|
||||
|
@ -640,7 +640,7 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
</th>
|
||||
</tr>
|
||||
${tribeChanges.items
|
||||
.map((tribeChange) => {
|
||||
.map(tribeChange => {
|
||||
let rowHTML =
|
||||
'<tr>' + `<td>${formatDate(tribeChange.createdAt)}</td>`;
|
||||
if (tribeChange.player) {
|
||||
|
@ -671,12 +671,12 @@ const renderTribeChanges = (e, currentPage, tribeChanges) => {
|
|||
|
||||
document
|
||||
.querySelectorAll('#' + TRIBE_CHANGES_PAGINATION_CONTAINER_ID + ' a')
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
el.addEventListener('click', handleShowTribeChangesClick);
|
||||
});
|
||||
};
|
||||
|
||||
const handleShowTribeChangesClick = async (e) => {
|
||||
const handleShowTribeChangesClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -699,7 +699,7 @@ const handleShowTribeChangesClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const handleGenerateMailingListClick = (e) => {
|
||||
const handleGenerateMailingListClick = e => {
|
||||
e.preventDefault();
|
||||
|
||||
const members = getMemberNames();
|
||||
|
@ -758,7 +758,7 @@ const showLoadingDialog = (current = 0, total = 0) => {
|
|||
);
|
||||
};
|
||||
|
||||
const handleExportTribeVillagesFormSubmit = async (e) => {
|
||||
const handleExportTribeVillagesFormSubmit = async e => {
|
||||
e.preventDefault();
|
||||
let limit = parseInt(e.target[4].value);
|
||||
const variables = {
|
||||
|
@ -798,13 +798,13 @@ const handleExportTribeVillagesFormSubmit = async (e) => {
|
|||
'exportTribeVillages',
|
||||
`
|
||||
<textarea cols=60 rows=8 readonly>${items
|
||||
.map((item) => `${item.x}|${item.y}`)
|
||||
.map(item => `${item.x}|${item.y}`)
|
||||
.join(' ')}</textarea>
|
||||
`
|
||||
);
|
||||
};
|
||||
|
||||
const handleExportTribeVillagesClick = (e) => {
|
||||
const handleExportTribeVillagesClick = e => {
|
||||
e.preventDefault();
|
||||
const FORM_ID = 'etvForm';
|
||||
|
||||
|
@ -843,7 +843,7 @@ const handleExportTribeVillagesClick = (e) => {
|
|||
.addEventListener('submit', handleExportTribeVillagesFormSubmit);
|
||||
};
|
||||
|
||||
const wrapAction = (action) => {
|
||||
const wrapAction = action => {
|
||||
const actionWrapperTd = document.createElement('td');
|
||||
actionWrapperTd.colSpan = '2';
|
||||
actionWrapperTd.append(action);
|
||||
|
|
|
@ -138,7 +138,7 @@ const cacheServerConfig = (data = {}) => {
|
|||
setItem(SERVER_CONFIG_LOCAL_STORAGE_KEY, data);
|
||||
};
|
||||
|
||||
const isConfigExpired = (date) => {
|
||||
const isConfigExpired = date => {
|
||||
return Math.abs(date.getTime() - new Date().getTime()) > 1000 * 60 * 60 * 24;
|
||||
};
|
||||
|
||||
|
@ -177,7 +177,7 @@ const loadPageData = async () => {
|
|||
return data;
|
||||
};
|
||||
|
||||
const handleShowTribeEnnoblementsClick = async (e) => {
|
||||
const handleShowTribeEnnoblementsClick = async e => {
|
||||
e.preventDefault();
|
||||
const page = getPage(e.target);
|
||||
if (!isNaN(page)) {
|
||||
|
@ -201,7 +201,7 @@ const handleShowTribeEnnoblementsClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const buildCellsForIncSupport = (units) => {
|
||||
const buildCellsForIncSupport = units => {
|
||||
const cells = [];
|
||||
let pop = 0;
|
||||
for (let unit in units) {
|
||||
|
@ -212,14 +212,14 @@ const buildCellsForIncSupport = (units) => {
|
|||
return cells;
|
||||
};
|
||||
|
||||
const handleCountIncomingSupportClick = async (e) => {
|
||||
const handleCountIncomingSupportClick = async e => {
|
||||
e.preventDefault();
|
||||
|
||||
const ids = [];
|
||||
const allyCommand = {};
|
||||
document
|
||||
.querySelectorAll('span.command_hover_details[data-command-type="support"]')
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
const id = parseInt(el.getAttribute('data-command-id'));
|
||||
if (el.classList.contains('commandicon-ally')) {
|
||||
allyCommand[id] = true;
|
||||
|
@ -328,7 +328,7 @@ const handleCountIncomingSupportClick = async (e) => {
|
|||
}
|
||||
};
|
||||
|
||||
const wrapAction = (action) => {
|
||||
const wrapAction = action => {
|
||||
const actionWrapperTd = document.createElement('td');
|
||||
actionWrapperTd.colSpan = '2';
|
||||
actionWrapperTd.append(action);
|
||||
|
@ -423,7 +423,7 @@ const renderAdditionalInfo = ({ config, ennoblements } = {}) => {
|
|||
tr.style.textAlign = 'center';
|
||||
tr.style.fontWeight = 'bold';
|
||||
tr.appendChild(document.createElement('td'));
|
||||
units.forEach((count) => {
|
||||
units.forEach(count => {
|
||||
const td = document.createElement('td');
|
||||
td.innerHTML = count;
|
||||
tr.appendChild(td);
|
||||
|
|
|
@ -35,17 +35,15 @@ const addTribe = () => {
|
|||
container.appendChild(div);
|
||||
};
|
||||
|
||||
const handleFormSubmit = async (e) => {
|
||||
const handleFormSubmit = async e => {
|
||||
e.preventDefault();
|
||||
const limit = parseInt(document.querySelector('#' + LIMIT_INPUT_ID).value);
|
||||
const tribes = [];
|
||||
const type =
|
||||
new URLSearchParams(window.location.search).get('type') || 'kill_att';
|
||||
document
|
||||
.querySelectorAll('#' + TRIBE_CONTAINER_ID + ' input')
|
||||
.forEach((el) => {
|
||||
if (el.value) tribes.push(el.value.trim());
|
||||
});
|
||||
document.querySelectorAll('#' + TRIBE_CONTAINER_ID + ' input').forEach(el => {
|
||||
if (el.value) tribes.push(el.value.trim());
|
||||
});
|
||||
|
||||
let players = [];
|
||||
let page = 0;
|
||||
|
|
|
@ -92,9 +92,9 @@ const loadLatestEnnoblements = () => {
|
|||
limit: 50,
|
||||
sort: ['ennobledAt DESC'],
|
||||
},
|
||||
}).then((data) => {
|
||||
}).then(data => {
|
||||
cacheEnnoblements(data);
|
||||
return new Promise((resolve) => resolve(data));
|
||||
return new Promise(resolve => resolve(data));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -115,7 +115,7 @@ const filterEnnoblements = (
|
|||
ennoblements = [],
|
||||
{ newOwner, newOwnerTribe, oldOwner, oldOwnerTribe } = {}
|
||||
) => {
|
||||
return ennoblements.filter((ennoblement) => {
|
||||
return ennoblements.filter(ennoblement => {
|
||||
if (newOwner && !isValidPlayer(ennoblement.newOwner, newOwner)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -156,14 +156,12 @@ const applyFilters = (e, ennoblements) => {
|
|||
};
|
||||
|
||||
const addEventListeners = (ennoblements = []) => {
|
||||
document
|
||||
.querySelector('#' + FILTER_FORM_ID)
|
||||
.addEventListener('submit', (e) => {
|
||||
applyFilters(e, ennoblements);
|
||||
});
|
||||
document.querySelector('#' + FILTER_FORM_ID).addEventListener('submit', e => {
|
||||
applyFilters(e, ennoblements);
|
||||
});
|
||||
};
|
||||
|
||||
const getPlayerHTML = (player) => {
|
||||
const getPlayerHTML = player => {
|
||||
return player && player.name
|
||||
? `<a href="${twutils.buildPlayerURL(player.id)}">${player.name}</a> (${
|
||||
player.tribe && player.tribe.tag
|
||||
|
@ -175,14 +173,14 @@ const getPlayerHTML = (player) => {
|
|||
: '-';
|
||||
};
|
||||
|
||||
const getVillageHTML = (village) => {
|
||||
const getVillageHTML = village => {
|
||||
return `<a href="${twutils.buildVillageURL(
|
||||
village.id
|
||||
)}">${twutils.buildVillageName(village.name, village.x, village.y)}</a>`;
|
||||
};
|
||||
|
||||
const buildEnnoblementsRows = (ennoblements) => {
|
||||
return ennoblements.map((ennoblement) => {
|
||||
const buildEnnoblementsRows = ennoblements => {
|
||||
return ennoblements.map(ennoblement => {
|
||||
return `<tr>
|
||||
<td>${getVillageHTML(ennoblement.village)}</td>
|
||||
<td>${getPlayerHTML(ennoblement.newOwner)}</td>
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class InADayParser {
|
|||
if (
|
||||
this.filters.tribes &&
|
||||
Array.isArray(this.filters.tribes) &&
|
||||
!this.filters.tribes.some((tribe) => tribe === row.tribe)
|
||||
!this.filters.tribes.some(tribe => tribe === row.tribe)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ export default ({ query, variables = {} } = {}) => {
|
|||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
.then(res => {
|
||||
return res.json();
|
||||
})
|
||||
.then(({ data, errors }) => {
|
||||
if (errors && Array.isArray(errors) && errors.length > 0) {
|
||||
throw new Error(errors[0].message);
|
||||
}
|
||||
return new Promise((resolve) => resolve(data));
|
||||
return new Promise(resolve => resolve(data));
|
||||
});
|
||||
};
|
||||
|
|
|
@ -55,11 +55,11 @@ const setVillageBorder = (x, y, color = 'transparent') => {
|
|||
}
|
||||
};
|
||||
|
||||
const deleteVillageFromOtherGroups = (key) => {
|
||||
const deleteVillageFromOtherGroups = key => {
|
||||
for (let name in config.groups) {
|
||||
if (name === config.selectedGroup) return;
|
||||
config.groups[name].villages = config.groups[name].villages.filter(
|
||||
(village) => village.key !== key
|
||||
village => village.key !== key
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -69,12 +69,12 @@ const handleMapClick = (x, y, e) => {
|
|||
|
||||
const key = `${x}|${y}`;
|
||||
const selected = config.groups[config.selectedGroup].villages.some(
|
||||
(village) => village.key === key
|
||||
village => village.key === key
|
||||
);
|
||||
if (selected) {
|
||||
config.groups[config.selectedGroup].villages = config.groups[
|
||||
config.selectedGroup
|
||||
].villages.filter((village) => village.key !== key);
|
||||
].villages.filter(village => village.key !== key);
|
||||
setVillageBorder(x, y, 'transparent');
|
||||
} else {
|
||||
config.groups[config.selectedGroup].villages = [
|
||||
|
@ -114,7 +114,7 @@ const renderForm = (container, group) => {
|
|||
|
||||
const form = document.createElement('form');
|
||||
form.innerHTML = html;
|
||||
form.addEventListener('submit', (e) => {
|
||||
form.addEventListener('submit', e => {
|
||||
e.preventDefault();
|
||||
if (group) {
|
||||
if (group.name === config.selectedGroup)
|
||||
|
@ -148,7 +148,7 @@ const renderForm = (container, group) => {
|
|||
|
||||
const selectButton = form.querySelector('.selectButton');
|
||||
if (selectButton) {
|
||||
selectButton.addEventListener('click', (e) => {
|
||||
selectButton.addEventListener('click', e => {
|
||||
config.selectedGroup = group.name;
|
||||
renderGroups();
|
||||
});
|
||||
|
@ -173,7 +173,7 @@ const handleExportVillages = () => {
|
|||
groups.push(`<div style="margin-bottom: 30px;">
|
||||
<h3>${name}</h3>
|
||||
<textarea cols=30 rows=8 readonly>${config.groups[name].villages
|
||||
.map((village) => village.key)
|
||||
.map(village => village.key)
|
||||
.join(' ')
|
||||
.trim()}</textarea>
|
||||
</div>`);
|
||||
|
@ -240,7 +240,7 @@ const handleButtonClick = () => {
|
|||
};
|
||||
|
||||
const colorizeGroupVillages = (name, bgColor = '') => {
|
||||
config.groups[name].villages.forEach((village) => {
|
||||
config.groups[name].villages.forEach(village => {
|
||||
setVillageBorder(
|
||||
village.x,
|
||||
village.y,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { buildImgURL } from './tribalwars';
|
||||
|
||||
export default (unit) => {
|
||||
export default unit => {
|
||||
return buildImgURL(`unit/unit_${unit}.png`);
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default (url) => parseInt(new URLSearchParams(url).get('id'));
|
||||
export default url => parseInt(new URLSearchParams(url).get('id'));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default (str) => {
|
||||
export default str => {
|
||||
const arr = str.split(/[_-]/);
|
||||
let newStr = '';
|
||||
for (let i = 1; i < arr.length; i++) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default (v) => v === undefined || v === null;
|
||||
export default v => v === undefined || v === null;
|
||||
|
|
|
@ -15,7 +15,7 @@ export const setPage = (el, page = 1) => {
|
|||
el.setAttribute(ATTRIBUTE, page + '');
|
||||
};
|
||||
|
||||
export const getPage = (el) => {
|
||||
export const getPage = el => {
|
||||
if (!el instanceof HTMLElement) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const buildTribeURL = (id) => {
|
||||
export const buildTribeURL = id => {
|
||||
return (
|
||||
window.location.origin +
|
||||
TribalWars.buildURL('', {
|
||||
|
@ -8,7 +8,7 @@ export const buildTribeURL = (id) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const buildPlayerURL = (id) => {
|
||||
export const buildPlayerURL = id => {
|
||||
return (
|
||||
window.location.origin +
|
||||
TribalWars.buildURL('', {
|
||||
|
@ -18,7 +18,7 @@ export const buildPlayerURL = (id) => {
|
|||
);
|
||||
};
|
||||
|
||||
export const buildVillageURL = (id) => {
|
||||
export const buildVillageURL = id => {
|
||||
return (
|
||||
window.location.origin +
|
||||
TribalWars.buildURL('', {
|
||||
|
@ -37,6 +37,6 @@ export const calcAttackDuration = (distance, baseSpeed) => {
|
|||
return Math.round(distance * baseSpeed);
|
||||
};
|
||||
|
||||
export const buildImgURL = (img) => {
|
||||
export const buildImgURL = img => {
|
||||
return image_base + img;
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default (t) => new Promise((resolve) => setTimeout(resolve, t));
|
||||
export default t => new Promise(resolve => setTimeout(resolve, t));
|
||||
|
|
|
@ -67,7 +67,7 @@ const showResult = (sideOne = 0, sideTwo = 0) => {
|
|||
document.querySelector('#' + RESULT_CONTAINER_ID).innerHTML = html;
|
||||
};
|
||||
|
||||
const createAddTribeHandler = (container) => {
|
||||
const createAddTribeHandler = container => {
|
||||
return () => {
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = `
|
||||
|
@ -82,21 +82,21 @@ const createAddTribeHandler = (container) => {
|
|||
};
|
||||
};
|
||||
|
||||
const handleFormSubmit = async (e) => {
|
||||
const handleFormSubmit = async e => {
|
||||
e.preventDefault();
|
||||
|
||||
const sideOneTags = [];
|
||||
const sideTwoTags = [];
|
||||
e.target
|
||||
.querySelectorAll(`#${SIDE_ONE_INPUT_CONTAINER_ID} input`)
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
if (el.value.trim()) {
|
||||
sideOneTags.push(el.value.trim());
|
||||
}
|
||||
});
|
||||
e.target
|
||||
.querySelectorAll(`#${SIDE_TWO_INPUT_CONTAINER_ID} input`)
|
||||
.forEach((el) => {
|
||||
.forEach(el => {
|
||||
if (el.value.trim()) {
|
||||
sideTwoTags.push(el.value.trim());
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ const handleFormSubmit = async (e) => {
|
|||
if (toInputs.length === 2 && toInputs[0].value && toInputs[1].value) {
|
||||
ennobledAtLTE = new Date(`${toInputs[0].value}T${toInputs[1].value}:00`);
|
||||
}
|
||||
e.target.querySelectorAll('button').forEach((button) => {
|
||||
e.target.querySelectorAll('button').forEach(button => {
|
||||
button.disabled = true;
|
||||
});
|
||||
|
||||
|
@ -139,11 +139,11 @@ const handleFormSubmit = async (e) => {
|
|||
},
|
||||
});
|
||||
const sideOneTribes = tribes.items
|
||||
.filter((item) => sideOneTags.some((tag) => item.tag === tag))
|
||||
.map((tribe) => tribe.id);
|
||||
.filter(item => sideOneTags.some(tag => item.tag === tag))
|
||||
.map(tribe => tribe.id);
|
||||
const sideTwoTribes = tribes.items
|
||||
.filter((item) => sideTwoTags.some((tag) => item.tag === tag))
|
||||
.map((tribe) => tribe.id);
|
||||
.filter(item => sideTwoTags.some(tag => item.tag === tag))
|
||||
.map(tribe => tribe.id);
|
||||
|
||||
const { sideOneEnnoblements, sideTwoEnnoblements } = await requestCreator({
|
||||
query: ENNOBLEMENTS_QUERY,
|
||||
|
@ -174,12 +174,12 @@ const handleFormSubmit = async (e) => {
|
|||
} catch (error) {
|
||||
console.log('handleFormSubmit', error);
|
||||
}
|
||||
e.target.querySelectorAll('button').forEach((button) => {
|
||||
e.target.querySelectorAll('button').forEach(button => {
|
||||
button.disabled = false;
|
||||
});
|
||||
};
|
||||
|
||||
const showWarStatsForm = (e) => {
|
||||
const showWarStatsForm = e => {
|
||||
const html = `
|
||||
<form>
|
||||
<h1 style="margin-bottom: 0px; text-align: center;"><a href="${twhelputils.buildURLToServerPage(
|
||||
|
|
15
yarn.lock
15
yarn.lock
|
@ -1879,11 +1879,6 @@ data-urls@^1.1.0:
|
|||
whatwg-mimetype "^2.2.0"
|
||||
whatwg-url "^7.0.0"
|
||||
|
||||
date-fns-tz@^1.0.10:
|
||||
version "1.0.10"
|
||||
resolved "https://registry.yarnpkg.com/date-fns-tz/-/date-fns-tz-1.0.10.tgz#30fef0038f80534fddd8e133a6b8ca55ba313748"
|
||||
integrity sha512-cHQAz0/9uDABaUNDM80Mj1FL4ODlxs1xEY4b0DQuAooO2UdNKvDkNbV8ogLnxLbv02Ru1HXFcot0pVvDRBgptg==
|
||||
|
||||
date-fns@^2.14.0:
|
||||
version "2.14.0"
|
||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
|
||||
|
@ -4171,6 +4166,11 @@ prelude-ls@~1.1.2:
|
|||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
|
||||
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
|
||||
|
||||
prettier@^2.2.1:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
|
||||
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
|
||||
|
||||
process-nextick-args@~2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
|
@ -5246,11 +5246,6 @@ validate-npm-package-license@^3.0.1:
|
|||
spdx-correct "^3.0.0"
|
||||
spdx-expression-parse "^3.0.0"
|
||||
|
||||
validator@^13.1.1:
|
||||
version "13.1.1"
|
||||
resolved "https://registry.yarnpkg.com/validator/-/validator-13.1.1.tgz#f8811368473d2173a9d8611572b58c5783f223bf"
|
||||
integrity sha512-8GfPiwzzRoWTg7OV1zva1KvrSemuMkv07MA9TTl91hfhe+wKrsrgVN4H2QSFd/U/FhiU3iWPYVgvbsOGwhyFWw==
|
||||
|
||||
vendors@^1.0.0:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/vendors/-/vendors-1.0.4.tgz#e2b800a53e7a29b93506c3cf41100d16c4c4ad8e"
|
||||
|
|
Reference in New Issue