Folder move, multiple items move
This commit is contained in:
@@ -998,13 +998,6 @@ void CrossPointWebServer::handleMove() const {
|
|||||||
server->send(403, "text/plain", "Cannot move protected item");
|
server->send(403, "text/plain", "Cannot move protected item");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (destPath != "/") {
|
|
||||||
const String destName = destPath.substring(destPath.lastIndexOf('/') + 1);
|
|
||||||
if (isProtectedItemName(destName)) {
|
|
||||||
server->send(403, "text/plain", "Cannot move into protected folder");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Storage.exists(itemPath.c_str())) {
|
if (!Storage.exists(itemPath.c_str())) {
|
||||||
server->send(404, "text/plain", "Item not found");
|
server->send(404, "text/plain", "Item not found");
|
||||||
@@ -1210,9 +1203,9 @@ void CrossPointWebServer::handleSettingsPage() const {
|
|||||||
void CrossPointWebServer::handleGetSettings() const {
|
void CrossPointWebServer::handleGetSettings() const {
|
||||||
const auto& settings = getSettingsList();
|
const auto& settings = getSettingsList();
|
||||||
|
|
||||||
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
String result;
|
||||||
server->send(200, "application/json", "");
|
result.reserve(4096);
|
||||||
server->sendContent("[");
|
result += "[";
|
||||||
|
|
||||||
char output[512];
|
char output[512];
|
||||||
constexpr size_t outputSize = sizeof(output);
|
constexpr size_t outputSize = sizeof(output);
|
||||||
@@ -1226,6 +1219,8 @@ void CrossPointWebServer::handleGetSettings() const {
|
|||||||
doc["key"] = s.key;
|
doc["key"] = s.key;
|
||||||
doc["name"] = I18N.get(s.nameId);
|
doc["name"] = I18N.get(s.nameId);
|
||||||
doc["category"] = I18N.get(s.category);
|
doc["category"] = I18N.get(s.category);
|
||||||
|
doc["subcategory"] = s.subcategory != StrId::STR_NONE_OPT ? I18N.get(s.subcategory) : "";
|
||||||
|
doc["submenu"] = s.submenu != StrId::STR_NONE_OPT ? I18N.get(s.submenu) : "";
|
||||||
|
|
||||||
switch (s.type) {
|
switch (s.type) {
|
||||||
case SettingType::TOGGLE: {
|
case SettingType::TOGGLE: {
|
||||||
@@ -1278,15 +1273,15 @@ void CrossPointWebServer::handleGetSettings() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (seenFirst) {
|
if (seenFirst) {
|
||||||
server->sendContent(",");
|
result += ",";
|
||||||
} else {
|
} else {
|
||||||
seenFirst = true;
|
seenFirst = true;
|
||||||
}
|
}
|
||||||
server->sendContent(output);
|
result += output;
|
||||||
}
|
}
|
||||||
|
|
||||||
server->sendContent("]");
|
result += "]";
|
||||||
server->sendContent("");
|
server->send(200, "application/json", result);
|
||||||
LOG_DBG("WEB", "Served settings API");
|
LOG_DBG("WEB", "Served settings API");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+122
-34
@@ -159,6 +159,14 @@
|
|||||||
background-color: #d68910;
|
background-color: #d68910;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.move-action-btn {
|
||||||
|
background-color: #2980b9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.move-action-btn:hover {
|
||||||
|
background-color: #2471a3;
|
||||||
|
}
|
||||||
|
|
||||||
.delete-action-btn {
|
.delete-action-btn {
|
||||||
background-color: #e74c3c;
|
background-color: #e74c3c;
|
||||||
}
|
}
|
||||||
@@ -167,6 +175,11 @@
|
|||||||
background-color: #c0392b;
|
background-color: #c0392b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.action-btn:disabled {
|
||||||
|
opacity: 0.35;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
/* Drag & drop overlay */
|
/* Drag & drop overlay */
|
||||||
.drop-overlay {
|
.drop-overlay {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -1786,7 +1799,8 @@
|
|||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button class="action-btn upload-action-btn" onclick="openUploadModal()">📤 Upload</button>
|
<button class="action-btn upload-action-btn" onclick="openUploadModal()">📤 Upload</button>
|
||||||
<button class="action-btn folder-action-btn" onclick="openFolderModal()">📁 New Folder</button>
|
<button class="action-btn folder-action-btn" onclick="openFolderModal()">📁 New Folder</button>
|
||||||
<button class="action-btn delete-action-btn" onclick="openDeleteSelectedModal()">🗑️ Delete Selected</button>
|
<button id="moveActionBtn" class="action-btn move-action-btn" onclick="openMoveSelectedModal()" disabled>➡️ Move</button>
|
||||||
|
<button id="deleteActionBtn" class="action-btn delete-action-btn" onclick="openDeleteSelectedModal()" disabled>🗑️ Delete</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -2042,12 +2056,10 @@
|
|||||||
<div class="modal-overlay" id="moveModal">
|
<div class="modal-overlay" id="moveModal">
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<button class="modal-close" onclick="closeMoveModal()">×</button>
|
<button class="modal-close" onclick="closeMoveModal()">×</button>
|
||||||
<h3>📂 Move File</h3>
|
<h3>➡️ Move File</h3>
|
||||||
<div class="folder-form">
|
<div class="folder-form">
|
||||||
<p class="file-info">Moving <strong id="moveItemName"></strong></p>
|
<p class="file-info">Moving <strong id="moveItemName"></strong></p>
|
||||||
<input type="text" id="moveDestPath" class="folder-input" list="moveFolderOptions"
|
<select id="moveDestPath" class="folder-input"></select>
|
||||||
placeholder="/Destination/Folder">
|
|
||||||
<datalist id="moveFolderOptions"></datalist>
|
|
||||||
<input type="hidden" id="moveItemPath">
|
<input type="hidden" id="moveItemPath">
|
||||||
<button class="move-btn-confirm" onclick="confirmMove()">Move</button>
|
<button class="move-btn-confirm" onclick="confirmMove()">Move</button>
|
||||||
<button class="delete-btn-cancel" onclick="closeMoveModal()">Cancel</button>
|
<button class="delete-btn-cancel" onclick="closeMoveModal()">Cancel</button>
|
||||||
@@ -2093,6 +2105,8 @@
|
|||||||
if (!notification) {
|
if (!notification) {
|
||||||
notification = document.createElement('div');
|
notification = document.createElement('div');
|
||||||
notification.id = 'notification';
|
notification.id = 'notification';
|
||||||
|
notification.setAttribute('role', 'status');
|
||||||
|
notification.setAttribute('aria-live', 'polite');
|
||||||
notification.style.cssText = `
|
notification.style.cssText = `
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
@@ -2109,6 +2123,9 @@
|
|||||||
document.body.appendChild(notification);
|
document.body.appendChild(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel any in-flight hide timer so a new message is not prematurely dismissed
|
||||||
|
clearTimeout(notification._hideTimeout);
|
||||||
|
|
||||||
// Set styles based on type
|
// Set styles based on type
|
||||||
const styles = {
|
const styles = {
|
||||||
'success': 'background-color: #27ae60;',
|
'success': 'background-color: #27ae60;',
|
||||||
@@ -2124,7 +2141,7 @@
|
|||||||
notification.style.transform = 'translateX(0)';
|
notification.style.transform = 'translateX(0)';
|
||||||
|
|
||||||
// Auto-hide after 5 seconds
|
// Auto-hide after 5 seconds
|
||||||
setTimeout(() => {
|
notification._hideTimeout = setTimeout(() => {
|
||||||
notification.style.opacity = '0';
|
notification.style.opacity = '0';
|
||||||
notification.style.transform = 'translateX(100%)';
|
notification.style.transform = 'translateX(100%)';
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -2226,14 +2243,17 @@
|
|||||||
if (!folderPath.endsWith("/")) folderPath += "/";
|
if (!folderPath.endsWith("/")) folderPath += "/";
|
||||||
folderPath += file.name;
|
folderPath += file.name;
|
||||||
|
|
||||||
|
const isProtected = file.name.startsWith('.');
|
||||||
// Checkbox cell + folder row
|
// Checkbox cell + folder row
|
||||||
fileTableContent += `<tr class="folder-row">`;
|
fileTableContent += `<tr class="folder-row">`;
|
||||||
fileTableContent += `<td><input type="checkbox" class="select-item" data-path="${encodeURIComponent(folderPath)}" data-name="${escapeHtml(file.name)}" data-type="folder"></td>`;
|
fileTableContent += isProtected
|
||||||
|
? '<td style="text-align:center"></td>'
|
||||||
|
: `<td style="text-align:center"><input type="checkbox" class="select-item" data-path="${encodeURIComponent(folderPath)}" data-name="${escapeHtml(file.name)}" data-type="folder"></td>`;
|
||||||
fileTableContent += `<td><span class="file-icon">📁</span><a href="/files?path=${encodeURIComponent(folderPath)}" class="folder-link">${escapeHtml(file.name)}</a><span class="folder-badge">FOLDER</span></td>`;
|
fileTableContent += `<td><span class="file-icon">📁</span><a href="/files?path=${encodeURIComponent(folderPath)}" class="folder-link">${escapeHtml(file.name)}</a><span class="folder-badge">FOLDER</span></td>`;
|
||||||
fileTableContent += '<td>Folder</td>';
|
fileTableContent += '<td>Folder</td>';
|
||||||
fileTableContent += '<td>-</td>';
|
fileTableContent += '<td>-</td>';
|
||||||
fileTableContent += `<td class="actions-col"><div class="action-icon-group">`;
|
fileTableContent += `<td class="actions-col"><div class="action-icon-group">`;
|
||||||
fileTableContent += `<button class="move-btn" onclick="openMoveModal('${file.name.replaceAll("'", "\\'")}', '${folderPath.replaceAll("'", "\\'")}', true)" title="Move folder">📂</button>`;
|
fileTableContent += `<button class="move-btn" onclick="openMoveModalForItem('${file.name.replaceAll("'", "\\'")}', '${folderPath.replaceAll("'", "\\'")}', true)" title="Move folder">📂</button>`;
|
||||||
fileTableContent += `<button class="rename-btn" onclick="openRenameModal('${file.name.replaceAll("'", "\\'")}', '${folderPath.replaceAll("'", "\\'")}', true)" title="Rename folder">✏️</button>`;
|
fileTableContent += `<button class="rename-btn" onclick="openRenameModal('${file.name.replaceAll("'", "\\'")}', '${folderPath.replaceAll("'", "\\'")}', true)" title="Rename folder">✏️</button>`;
|
||||||
fileTableContent += `<button class="delete-btn" onclick="openDeleteModal('${file.name.replaceAll("'", "\\'")}', '${folderPath.replaceAll("'", "\\'")}', true)" title="Delete folder">🗑️</button>`;
|
fileTableContent += `<button class="delete-btn" onclick="openDeleteModal('${file.name.replaceAll("'", "\\'")}', '${folderPath.replaceAll("'", "\\'")}', true)" title="Delete folder">🗑️</button>`;
|
||||||
fileTableContent += `</div></td>`;
|
fileTableContent += `</div></td>`;
|
||||||
@@ -2253,7 +2273,7 @@
|
|||||||
fileTableContent += `<td>${file.name.split('.').pop().toUpperCase()}</td>`;
|
fileTableContent += `<td>${file.name.split('.').pop().toUpperCase()}</td>`;
|
||||||
fileTableContent += `<td>${formatFileSize(file.size)}</td>`;
|
fileTableContent += `<td>${formatFileSize(file.size)}</td>`;
|
||||||
fileTableContent += `<td class="actions-col"><div class="action-icon-group">`;
|
fileTableContent += `<td class="actions-col"><div class="action-icon-group">`;
|
||||||
fileTableContent += `<button class="move-btn" onclick="openMoveModal('${file.name.replaceAll("'", "\\'")}', '${filePath.replaceAll("'", "\\'")}' )" title="Move file">📂</button>`;
|
fileTableContent += `<button class="move-btn" onclick="openMoveModalForItem('${file.name.replaceAll("'", "\\'")}', '${filePath.replaceAll("'", "\\'")}', false)" title="Move file">📂</button>`;
|
||||||
fileTableContent += `<button class="rename-btn" onclick="openRenameModal('${file.name.replaceAll("'", "\\'")}', '${filePath.replaceAll("'", "\\'")}' )" title="Rename file">✏️</button>`;
|
fileTableContent += `<button class="rename-btn" onclick="openRenameModal('${file.name.replaceAll("'", "\\'")}', '${filePath.replaceAll("'", "\\'")}' )" title="Rename file">✏️</button>`;
|
||||||
fileTableContent += `<button class="delete-btn" onclick="openDeleteModal('${file.name.replaceAll("'", "\\'")}', '${filePath.replaceAll("'", "\\'")}', false)" title="Delete file">🗑️</button>`;
|
fileTableContent += `<button class="delete-btn" onclick="openDeleteModal('${file.name.replaceAll("'", "\\'")}', '${filePath.replaceAll("'", "\\'")}', false)" title="Delete file">🗑️</button>`;
|
||||||
fileTableContent += `</div></td>`;
|
fileTableContent += `</div></td>`;
|
||||||
@@ -2263,6 +2283,10 @@
|
|||||||
|
|
||||||
fileTableContent += '</table>';
|
fileTableContent += '</table>';
|
||||||
fileTable.innerHTML = fileTableContent;
|
fileTable.innerHTML = fileTableContent;
|
||||||
|
document.getElementById('file-table').addEventListener('change', function(e) {
|
||||||
|
if (e.target.classList.contains('select-item')) updateToolbarState();
|
||||||
|
});
|
||||||
|
updateToolbarState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3195,6 +3219,7 @@
|
|||||||
document.querySelectorAll('.select-item').forEach(cb => {
|
document.querySelectorAll('.select-item').forEach(cb => {
|
||||||
cb.checked = checked;
|
cb.checked = checked;
|
||||||
});
|
});
|
||||||
|
updateToolbarState();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedItems() {
|
function getSelectedItems() {
|
||||||
@@ -3209,6 +3234,14 @@
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateToolbarState() {
|
||||||
|
const items = getSelectedItems();
|
||||||
|
const fileCount = items.filter(it => !it.isFolder).length;
|
||||||
|
const folderCount = items.filter(it => it.isFolder).length;
|
||||||
|
document.getElementById('deleteActionBtn').disabled = items.length === 0;
|
||||||
|
document.getElementById('moveActionBtn').disabled = fileCount === 0 || folderCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Open delete modal for currently selected checkboxes
|
// Open delete modal for currently selected checkboxes
|
||||||
function openDeleteSelectedModal() {
|
function openDeleteSelectedModal() {
|
||||||
const items = getSelectedItems();
|
const items = getSelectedItems();
|
||||||
@@ -5545,6 +5578,8 @@
|
|||||||
options.add('/');
|
options.add('/');
|
||||||
const parent = getParentPath(currentPath);
|
const parent = getParentPath(currentPath);
|
||||||
if (parent) options.add(parent);
|
if (parent) options.add(parent);
|
||||||
|
options.add('/.sleep');
|
||||||
|
options.add('/.crosspoint');
|
||||||
|
|
||||||
async function fetchFolders(path) {
|
async function fetchFolders(path) {
|
||||||
try {
|
try {
|
||||||
@@ -5575,25 +5610,70 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataList = document.getElementById('moveFolderOptions');
|
const select = document.getElementById('moveDestPath');
|
||||||
dataList.innerHTML = '';
|
const prevValue = select.value;
|
||||||
Array.from(options).sort().forEach(path => {
|
select.innerHTML = '';
|
||||||
|
|
||||||
|
const currentNormalized = currentPath === '/' ? '/' : currentPath;
|
||||||
|
const normalFolders = Array.from(options).filter(p => !p.startsWith('/.'));
|
||||||
|
const currentFolder = normalFolders.find(p => p === currentNormalized);
|
||||||
|
const otherFolders = normalFolders.filter(p => p !== currentNormalized);
|
||||||
|
const protectedFolders = Array.from(options).filter(p => p === '/.crosspoint' || p === '/.sleep');
|
||||||
|
|
||||||
|
if (currentFolder !== undefined) {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = currentFolder;
|
||||||
|
option.textContent = currentFolder + ' (current)';
|
||||||
|
option.disabled = true;
|
||||||
|
option.selected = true;
|
||||||
|
select.appendChild(option);
|
||||||
|
}
|
||||||
|
otherFolders.sort().forEach(path => {
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.value = path;
|
option.value = path;
|
||||||
dataList.appendChild(option);
|
option.textContent = path;
|
||||||
|
select.appendChild(option);
|
||||||
|
});
|
||||||
|
if (protectedFolders.length > 0) {
|
||||||
|
const sep = document.createElement('option');
|
||||||
|
sep.disabled = true;
|
||||||
|
sep.textContent = '── System ──';
|
||||||
|
select.appendChild(sep);
|
||||||
|
protectedFolders.sort().forEach(path => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = path;
|
||||||
|
option.textContent = path;
|
||||||
|
select.appendChild(option);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openMoveModal(name, path, isFolder = false) {
|
select.value = prevValue;
|
||||||
const icon = isFolder ? '📁' : '📄';
|
if (!select.value || select.options[select.selectedIndex] && select.options[select.selectedIndex].disabled) {
|
||||||
document.getElementById('moveItemName').textContent = icon + ' ' + name;
|
for (let i = 0; i < select.options.length; i++) {
|
||||||
document.getElementById('moveItemPath').value = path;
|
if (!select.options[i].disabled) { select.value = select.options[i].value; break; }
|
||||||
document.getElementById('moveDestPath').value = currentPath === '/' ? '/' : currentPath;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMoveModal(items) {
|
||||||
|
const label = items.length === 1
|
||||||
|
? '📄 ' + items[0].name
|
||||||
|
: `📄 ${items.length} files`;
|
||||||
|
document.getElementById('moveItemName').textContent = label;
|
||||||
|
document.getElementById('moveItemPath').value = JSON.stringify(items.map(it => it.path));
|
||||||
document.getElementById('moveModal').classList.add('open');
|
document.getElementById('moveModal').classList.add('open');
|
||||||
loadMoveFolderOptions();
|
loadMoveFolderOptions();
|
||||||
setTimeout(() => {
|
}
|
||||||
document.getElementById('moveDestPath').focus();
|
|
||||||
}, 50);
|
function openMoveSelectedModal() {
|
||||||
|
const items = getSelectedItems().filter(it => !it.isFolder);
|
||||||
|
if (items.length === 0) return;
|
||||||
|
openMoveModal(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openMoveModalForItem(name, path, isFolder) {
|
||||||
|
const icon = isFolder ? '📁' : '📄';
|
||||||
|
openMoveModal([{ name: icon + ' ' + name, path: path, isFolder: !!isFolder }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeMoveModal() {
|
function closeMoveModal() {
|
||||||
@@ -5601,37 +5681,45 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function confirmMove() {
|
function confirmMove() {
|
||||||
const path = document.getElementById('moveItemPath').value;
|
const paths = JSON.parse(document.getElementById('moveItemPath').value);
|
||||||
const destPath = normalizePath(document.getElementById('moveDestPath').value);
|
const destPath = normalizePath(document.getElementById('moveDestPath').value);
|
||||||
|
|
||||||
if (!destPath) {
|
if (!destPath) {
|
||||||
alert('Please enter a destination folder.');
|
showNotification('Please select a destination folder.', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeMoveModal();
|
||||||
|
let hasErrors = false;
|
||||||
|
|
||||||
|
function moveNext(index) {
|
||||||
|
if (index >= paths.length) {
|
||||||
|
if (!hasErrors) window.location.reload();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('path', path);
|
formData.append('path', paths[index]);
|
||||||
formData.append('dest', destPath);
|
formData.append('dest', destPath);
|
||||||
|
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open('POST', '/move', true);
|
xhr.open('POST', '/move', true);
|
||||||
|
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
if (xhr.status === 200) {
|
if (xhr.status !== 200) {
|
||||||
window.location.reload();
|
hasErrors = true;
|
||||||
} else {
|
showNotification('Failed to move ' + paths[index] + ': ' + xhr.responseText, 'error');
|
||||||
alert('Failed to move: ' + xhr.responseText);
|
|
||||||
}
|
}
|
||||||
closeMoveModal();
|
moveNext(index + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
alert('Failed to move - network error');
|
hasErrors = true;
|
||||||
closeMoveModal();
|
showNotification('Failed to move ' + paths[index] + ' - network error', 'error');
|
||||||
|
moveNext(index + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moveNext(0);
|
||||||
|
}
|
||||||
hydrate();
|
hydrate();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -72,6 +72,19 @@
|
|||||||
background-color: var(--accent-hover-color);
|
background-color: var(--accent-hover-color);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
.section-header {
|
||||||
|
font-size: 0.75em;
|
||||||
|
font-weight: 700;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
color: var(--accent-color);
|
||||||
|
padding: 14px 0 4px;
|
||||||
|
border-bottom: 1px solid var(--accent-color);
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
.section-header:first-child {
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
.setting-row {
|
.setting-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -369,7 +382,15 @@
|
|||||||
|
|
||||||
for (const category in groups) {
|
for (const category in groups) {
|
||||||
html += '<div class="card"><h2>' + escapeHtml(category) + '</h2>';
|
html += '<div class="card"><h2>' + escapeHtml(category) + '</h2>';
|
||||||
|
let lastSection = null;
|
||||||
groups[category].forEach(function(s) {
|
groups[category].forEach(function(s) {
|
||||||
|
// Each item carries either a subcategory or a submenu label as its section heading.
|
||||||
|
// Both are treated identically: a new label triggers a section header row.
|
||||||
|
const section = s.subcategory || s.submenu || null;
|
||||||
|
if (section && section !== lastSection) {
|
||||||
|
html += '<div class="section-header">' + escapeHtml(section) + '</div>';
|
||||||
|
lastSection = section;
|
||||||
|
}
|
||||||
html += '<div class="setting-row">' +
|
html += '<div class="setting-row">' +
|
||||||
'<span class="setting-name">' + escapeHtml(s.name) + '</span>' +
|
'<span class="setting-name">' + escapeHtml(s.name) + '</span>' +
|
||||||
'<span class="setting-control">' + renderControl(s) + '</span>' +
|
'<span class="setting-control">' + renderControl(s) + '</span>' +
|
||||||
|
|||||||
Reference in New Issue
Block a user