00002 로그파일 소팅방법 변경

웹페이지의 log files 는 파일들 나열이 지금 canlog_00000.bin이 제일 윗 상단에 있는데 반대로 해당파일이 제일 밑으로 최신(파일명숫자가 높은) 파일이 윗상단에 표시하게 sorting 방법을 바꾸어줘
This commit is contained in:
2025-10-04 17:34:20 +00:00
parent 4f0588c7d8
commit e39b6e4669

10
index.h
View File

@@ -396,6 +396,14 @@ const char index_html[] PROGMEM = R"rawliteral(
return;
}
// 파일명 기준으로 내림차순 정렬 (최신 파일이 위로)
files.sort((a, b) => {
// canlog_XXXXX.bin에서 숫자 부분 추출
const numA = parseInt(a.name.match(/\d+/)?.[0] || '0');
const numB = parseInt(b.name.match(/\d+/)?.[0] || '0');
return numB - numA; // 내림차순
});
fileList.innerHTML = '';
files.forEach(file => {
const fileItem = document.createElement('div');
@@ -410,7 +418,7 @@ const char index_html[] PROGMEM = R"rawliteral(
fileList.appendChild(fileItem);
});
console.log(` : ${files.length}`);
console.log(` : ${files.length} ()`);
}
function formatBytes(bytes) {