import subDays from 'date-fns/subDays'; import renderPopup from './renderPopup'; import { generatePaginationItems, getContainerStyles } from './pagination'; import formatDate from './formatDate'; import { formatTribeURL } from './tribalwars'; const HISTORY_PAGINATION_CONTAINER_ID = 'historyPagination'; const addMathSymbol = (v) => { return v > 0 ? '+' + v : v; }; export default ( e, history, daily, { currentPage = 1, limit = 0, onPageChange = () => {}, tribe = false } = {} ) => { const paginationItems = generatePaginationItems({ total: history.total, limit, currentPage, }); const html = `
Date | ${tribe ? '' : 'Tribe | '}Points | Villages | ${tribe ? 'Members | ' : ''}OD | ODA | ODD | ${tribe ? '' : 'ODS | '}|
---|---|---|---|---|---|---|---|---|---|
${formatDate(history.createDate, { year: 'numeric', month: '2-digit', day: '2-digit', })} | `; if (!tribe && history.tribe) { rowHTML += `${ history.tribe.tag } | `; } else if (!tribe) { rowHTML += '- | '; } rowHTML += `${history.points.toLocaleString()} (${ history.rank }) | ${history.totalVillages.toLocaleString()} | ${ !tribe ? '' : `${history.totalMembers} | ` }${history.scoreTotal.toLocaleString()} (${ history.rankTotal }) | ${history.scoreAtt.toLocaleString()} (${ history.rankAtt }) | ${history.scoreDef.toLocaleString()} (${ history.rankDef }) | ${ tribe ? '' : `${history.scoreSup.toLocaleString()} (${ history.rankSup }) | ` } ` + '