diff --git a/TEF6686_ESP32.ino b/TEF6686_ESP32.ino index 086f763..59dc457 100644 --- a/TEF6686_ESP32.ino +++ b/TEF6686_ESP32.ino @@ -5355,177 +5355,128 @@ void toggleiMSEQ() { } void handleRoot() { + // Open the logbook file fs::File file = SPIFFS.open("/logbook.csv", "r"); if (!file) { webserver.send(500, "text/plain", "Failed to open logbook"); return; } + // Build HTML response String html = ""; html += ""; html += ""; - - // Add CSS styling html += ""; - - html += ""; - - // Add logo as a clickable link + html += "table {width: 90%; max-width: 1500px; margin: 0 auto; border-radius: 15px; overflow: auto; padding: 20px; background-color: #2e5049; border: 0; border-collapse: separate; border-spacing: 0;}"; + html += "thead th {font-size: 18px; cursor: pointer; position: relative; user-select: none; background-color: #3c7f6a;}"; + html += "th, td {padding: 10px; text-align: center;}"; + html += "thead th:first-child, tbody th:first-child {border-radius: 15px 0 0 15px;}"; + html += "thead th:nth-last-of-type(1), tbody th:nth-last-of-type(1) {border-radius: 0 15px 15px 0;}"; + html += "tbody td:nth-child(3) {font-weight: 700;}"; + html += "tbody td:nth-child(5) {color: #ddd;}"; + html += "tbody td:nth-child(6) {color: #5bd6ab; font-weight: bold;}"; + html += "thead th:nth-child(2), thead th:nth-child(8) {width: 5%;} thead th:nth-child(1), thead th:nth-child(4) {width: 10%;} thead th:nth-child(3) {width: 15%;}"; + html += "button {background-color: #4db691; font-family: 'Arial', sans-serif; border: 0; padding: 15px 20px; font-size: 14px; text-transform: uppercase; cursor: pointer; border-radius: 15px; font-weight: bold; color: rgb(32, 34, 40); display: block; margin: 20px auto; transition: 0.3s ease background-color;}"; + html += "button:hover {background-color: #5bd6ab;}"; + html += "a { text-decoration:none };"; + html += ".go-to-bottom {position: fixed; bottom: 30px; right: 30px; z-index: 100;}"; + html += ".sort-icon {position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: #ccc;}"; + html += "@media (max-width: 768px) {table {width: 100%;} th, td {font-size: 14px; padding: 8px;}}"; + html += ""; html += ""; - html += "\"FMDX"; + html += "\"FMDX"; html += ""; - html += "

" + String(myLanguage[language][286]) + "

"; html += ""; - html += ""; - - // JavaScript for scrolling and sorting + html += ""; html += ""; - html += ""; - - String header = ""; - if (file.available()) { - header = file.readStringUntil('\n'); - html += ""; + // Generate table header and body + html += "
"; + String header = file.available() ? file.readStringUntil('\n') : ""; + if (header.length() > 0) { int startIndex = 0; int columnIndex = 0; - - // Generate table headers with sorting functionality while (startIndex < header.length()) { int endIndex = header.indexOf(',', startIndex); if (endIndex == -1) endIndex = header.length(); String column = header.substring(startIndex, endIndex); - - // Add clickable headers for sorting html += ""; // Sorting icon placeholder - + html += ""; startIndex = endIndex + 1; columnIndex++; } - html += ""; + html += ""; } + // Generate table rows bool hasData = false; - int piCodeIndex = -1, frequencyIndex = -1; - - // Identify column indices for PI code and Frequency - int startIndex = 0, columnIndex = 0; + int piCodeIndex = -1; + int frequencyIndex = -1; + int startIndex = 0; + int columnIndex = 0; while (startIndex < header.length()) { int endIndex = header.indexOf(',', startIndex); if (endIndex == -1) endIndex = header.length(); String column = header.substring(startIndex, endIndex); - if (column.equalsIgnoreCase("PI code")) piCodeIndex = columnIndex; if (column.equalsIgnoreCase("Frequency")) frequencyIndex = columnIndex; - startIndex = endIndex + 1; columnIndex++; } - // Generate rows while (file.available()) { String line = file.readStringUntil('\n'); if (line.length() > 0) { hasData = true; html += ""; - - String piCode = "", frequency = ""; - startIndex = 0, columnIndex = 0; - + String piCode = ""; + String frequency = ""; + startIndex = 0; + columnIndex = 0; while (startIndex < line.length()) { int endIndex = line.indexOf(',', startIndex); if (endIndex == -1) endIndex = line.length(); String cell = line.substring(startIndex, endIndex); - - // Extract PI code and Frequency if (columnIndex == piCodeIndex) piCode = cell; if (columnIndex == frequencyIndex) frequency = cell; - html += ""; startIndex = endIndex + 1; columnIndex++; } - - // Remove " MHz" from Frequency frequency.replace(" MHz", ""); - - // Make row clickable - html += ""; - + html += ""; html += ""; } } + // Handle empty table case file.close(); - if (!hasData) { html += ""; } - html += "
" + column; - html += "
" + cell + "🌐
" + String(myLanguage[language][288]) + "
"; + html += ""; html += ""; - webserver.send(200, "text/html", html); }