Merge pull request #28 from jpirnay/feat-showextension
feat: Show file extensions in browser (user option)
This commit is contained in:
@@ -87,6 +87,7 @@ STR_PARA_ALIGNMENT: "Reader Paragraph Alignment"
|
||||
STR_HYPHENATION: "Hyphenation"
|
||||
STR_TIME_TO_SLEEP: "Time to Sleep"
|
||||
STR_SHOW_HIDDEN_FILES: "Show Hidden Files"
|
||||
STR_SHOW_FILE_EXTENSIONS: "Show File Extensions"
|
||||
STR_USE_CLOCK: "Use Clock"
|
||||
STR_CLOCK_SETTINGS: "Clock Settings"
|
||||
STR_CLOCK_SETTINGS_WARNING: "Uses more battery; clock may drift"
|
||||
|
||||
@@ -300,6 +300,7 @@ STR_IMAGES_DISPLAY: "Darstellung"
|
||||
STR_IMAGES_PLACEHOLDER: "Platzhalter"
|
||||
STR_IMAGES_SUPPRESS: "Unterdrücken"
|
||||
STR_SHOW_HIDDEN_FILES: "Versteckte Dateien anzeigen"
|
||||
STR_SHOW_FILE_EXTENSIONS: "Dateierweiterungen anzeigen"
|
||||
STR_PAGE_OVERLAY: "Seiten-Overlay"
|
||||
STR_RECENTS: "Zuletzt"
|
||||
STR_MAPPING_REMOTE: "Externe Position zuordnen..."
|
||||
|
||||
@@ -231,6 +231,8 @@ class CrossPointSettings {
|
||||
uint8_t embeddedStyle = 1;
|
||||
// Show hidden files/directories (starting with '.') in the file browser (0 = hidden, 1 = show)
|
||||
uint8_t showHiddenFiles = 0;
|
||||
// Show file extensions in the file browser (0 = hidden, 1 = show)
|
||||
uint8_t showFileExtensions = 0;
|
||||
// Image rendering mode in EPUB reader
|
||||
uint8_t imageRendering = IMAGES_DISPLAY;
|
||||
// Dithering mode for decoded images (EPUB/JPG/PNG)
|
||||
|
||||
@@ -92,6 +92,8 @@ inline const std::vector<SettingInfo>& getSettingsList() {
|
||||
"sleepTimeout", StrId::STR_CAT_SYSTEM),
|
||||
SettingInfo::Toggle(StrId::STR_SHOW_HIDDEN_FILES, &CrossPointSettings::showHiddenFiles, "showHiddenFiles",
|
||||
StrId::STR_CAT_SYSTEM),
|
||||
SettingInfo::Toggle(StrId::STR_SHOW_FILE_EXTENSIONS, &CrossPointSettings::showFileExtensions,
|
||||
"showFileExtensions", StrId::STR_CAT_SYSTEM),
|
||||
SettingInfo::Enum(StrId::STR_CLOCK_FORMAT, &CrossPointSettings::clockFormat12h, {StrId::STR_24H, StrId::STR_12H},
|
||||
"clockFormat12h", StrId::STR_CAT_SYSTEM),
|
||||
SettingInfo::Enum(StrId::STR_TIMEZONE, &CrossPointSettings::timeZone,
|
||||
|
||||
@@ -263,6 +263,9 @@ std::string getFileName(std::string filename) {
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
if (SETTINGS.showFileExtensions) {
|
||||
return filename;
|
||||
}
|
||||
const auto pos = filename.rfind('.');
|
||||
return filename.substr(0, pos);
|
||||
}
|
||||
|
||||
@@ -2109,8 +2109,9 @@
|
||||
}
|
||||
|
||||
async function hydrate() {
|
||||
// Fetch CrossPoint version
|
||||
// Fetch CrossPoint version and file extension setting
|
||||
fetchVersion();
|
||||
await fetchShowFileExtensions();
|
||||
|
||||
// Close modals when clicking overlay - call proper cleanup functions
|
||||
document.querySelectorAll('.modal-overlay').forEach(function (overlay) {
|
||||
@@ -2207,7 +2208,7 @@
|
||||
fileTableContent += `<tr class="${file.isEpub ? 'epub-file' : ''}">`;
|
||||
fileTableContent += `<td><input type="checkbox" class="select-item" data-path="${encodeURIComponent(filePath)}" data-name="${escapeHtml(file.name)}" data-type="file"></td>`;
|
||||
fileTableContent += `<td><span class="file-icon">${file.isEpub ? '📗' : '📄'}</span>`;
|
||||
fileTableContent += `<a rel="noopener noreferrer" target="_blank" href="/download?path=${encodeURIComponent(filePath)}" class="file-link">${escapeHtml(file.name)}</a>`;
|
||||
fileTableContent += `<a rel="noopener noreferrer" target="_blank" href="/download?path=${encodeURIComponent(filePath)}" class="file-link">${escapeHtml(displayFileName(file.name))}</a>`;
|
||||
if (file.isEpub) fileTableContent += '<span class="epub-badge">EPUB</span>';
|
||||
fileTableContent += '</td>';
|
||||
fileTableContent += `<td>${file.name.split('.').pop().toUpperCase()}</td>`;
|
||||
@@ -3292,6 +3293,28 @@
|
||||
const logContainer = document.getElementById('log-container');
|
||||
const exportLogCheckbox = document.getElementById('export-log-checkbox');
|
||||
|
||||
// Show file extensions setting (fetched from API)
|
||||
let showFileExtensions = false;
|
||||
|
||||
async function fetchShowFileExtensions() {
|
||||
try {
|
||||
const response = await fetch('/api/settings');
|
||||
if (response.ok) {
|
||||
const settings = await response.json();
|
||||
const entry = settings.find(s => s.key === 'showFileExtensions');
|
||||
if (entry) showFileExtensions = !!entry.value;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch settings:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function displayFileName(name) {
|
||||
if (showFileExtensions) return name;
|
||||
const dot = name.lastIndexOf('.');
|
||||
return dot > 0 ? name.substring(0, dot) : name;
|
||||
}
|
||||
|
||||
// CrossPoint version (fetched from API)
|
||||
let crosspointVersion = 'Unknown';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user