MCPcopy Create free account
hub / github.com/error311/FileRise / getCombinedPageLayout

Function getCombinedPageLayout

public/js/fileListView.js:1989–2021  ·  view source on GitHub ↗
({ totalFolders, totalFiles, itemsPerPage, targetPage })

Source from the content-addressed store, hash-verified

1987}
1988
1989function getCombinedPageLayout({ totalFolders, totalFiles, itemsPerPage, targetPage }) {
1990 const folderCount = Number.isFinite(Number(totalFolders)) ? Math.max(0, Number(totalFolders)) : 0;
1991 const fileCount = Number.isFinite(Number(totalFiles)) ? Math.max(0, Number(totalFiles)) : 0;
1992 const itemsRaw = Number(itemsPerPage);
1993 const pageSize = Number.isFinite(itemsRaw) && itemsRaw > 0 ? Math.max(1, Math.floor(itemsRaw)) : 50;
1994 const totalRows = folderCount + fileCount;
1995 const totalPages = Math.max(1, Math.ceil(totalRows / pageSize) || 1);
1996 const targetRaw = Number(targetPage);
1997 const page = Number.isFinite(targetRaw)
1998 ? Math.max(1, Math.min(totalPages, Math.floor(targetRaw)))
1999 : 1;
2000 const startRow = (page - 1) * pageSize;
2001 const endRow = Math.min(totalRows, startRow + pageSize);
2002
2003 const folderStart = Math.min(folderCount, startRow);
2004 const folderEnd = Math.min(folderCount, endRow);
2005 const folderCountOnPage = Math.max(0, folderEnd - folderStart);
2006
2007 const fileStart = Math.max(0, startRow - folderCount);
2008 const fileEnd = Math.max(0, endRow - folderCount);
2009 const fileCountOnPage = Math.max(0, fileEnd - fileStart);
2010
2011 return {
2012 page,
2013 totalPages,
2014 pageSize,
2015 totalRows,
2016 folderStart,
2017 folderCount: folderCountOnPage,
2018 fileStart,
2019 fileCount: fileCountOnPage
2020 };
2021}
2022
2023function resolveServerPagingCursorForLoad({ pane, folder, sourceId, requestedCursor }) {
2024 if (requestedCursor != null) {

Callers 3

renderFileTableFunction · 0.85
goToCombinedServerPageFunction · 0.85
fileListView.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected