Spaces:
Sleeping
Sleeping
Commit
·
cad3e75
1
Parent(s):
b705e5e
Upd file previewer
Browse files- static/script.js +19 -4
- static/styles.css +76 -0
static/script.js
CHANGED
|
@@ -167,13 +167,18 @@
|
|
| 167 |
list.innerHTML = '<div class="muted">No files in this project.</div>';
|
| 168 |
return;
|
| 169 |
}
|
| 170 |
-
list.innerHTML = files.map(f => `
|
| 171 |
-
<div class="file-card">
|
| 172 |
<div class="file-card-head">
|
| 173 |
<div class="file-name">${f.filename}</div>
|
| 174 |
-
<button class="file-del" data-fn="${encodeURIComponent(f.filename)}" title="Delete">🗑️</button>
|
| 175 |
</div>
|
| 176 |
-
<div class="file-summary">${(f.summary || '').replace(/</g,'<')}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
</div>
|
| 178 |
`).join('');
|
| 179 |
// bind deletes
|
|
@@ -194,6 +199,16 @@
|
|
| 194 |
} catch {}
|
| 195 |
});
|
| 196 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
}
|
| 198 |
|
| 199 |
// Expose show files section
|
|
|
|
| 167 |
list.innerHTML = '<div class="muted">No files in this project.</div>';
|
| 168 |
return;
|
| 169 |
}
|
| 170 |
+
list.innerHTML = files.map((f, idx) => `
|
| 171 |
+
<div class="file-card" data-idx="${idx}">
|
| 172 |
<div class="file-card-head">
|
| 173 |
<div class="file-name">${f.filename}</div>
|
|
|
|
| 174 |
</div>
|
| 175 |
+
<div class="file-summary" id="file-summary-${idx}">${(f.summary || '').replace(/</g,'<')}</div>
|
| 176 |
+
<div class="file-card-actions">
|
| 177 |
+
<button class="see-more-btn" data-idx="${idx}">… See more</button>
|
| 178 |
+
<div class="file-actions-right">
|
| 179 |
+
<button class="btn-danger file-del" data-fn="${encodeURIComponent(f.filename)}" title="Delete">Delete</button>
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
</div>
|
| 183 |
`).join('');
|
| 184 |
// bind deletes
|
|
|
|
| 199 |
} catch {}
|
| 200 |
});
|
| 201 |
});
|
| 202 |
+
// bind see more/less
|
| 203 |
+
list.querySelectorAll('.see-more-btn').forEach(btn => {
|
| 204 |
+
btn.addEventListener('click', () => {
|
| 205 |
+
const idx = btn.getAttribute('data-idx');
|
| 206 |
+
const summary = document.getElementById(`file-summary-${idx}`);
|
| 207 |
+
if (!summary) return;
|
| 208 |
+
const expanded = summary.classList.toggle('expanded');
|
| 209 |
+
btn.textContent = expanded ? 'See less' : '… See more';
|
| 210 |
+
});
|
| 211 |
+
});
|
| 212 |
}
|
| 213 |
|
| 214 |
// Expose show files section
|
static/styles.css
CHANGED
|
@@ -1171,4 +1171,80 @@
|
|
| 1171 |
opacity: 1;
|
| 1172 |
transform: none;
|
| 1173 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1174 |
}
|
|
|
|
| 1171 |
opacity: 1;
|
| 1172 |
transform: none;
|
| 1173 |
}
|
| 1174 |
+
}
|
| 1175 |
+
|
| 1176 |
+
/* Files Page Cards */
|
| 1177 |
+
.file-card {
|
| 1178 |
+
background: var(--card);
|
| 1179 |
+
border: 1px solid var(--border);
|
| 1180 |
+
border-radius: var(--radius);
|
| 1181 |
+
box-shadow: var(--shadow);
|
| 1182 |
+
padding: 16px;
|
| 1183 |
+
margin-bottom: 16px;
|
| 1184 |
+
display: flex;
|
| 1185 |
+
flex-direction: column;
|
| 1186 |
+
gap: 12px;
|
| 1187 |
+
}
|
| 1188 |
+
|
| 1189 |
+
.file-card-head {
|
| 1190 |
+
display: flex;
|
| 1191 |
+
align-items: center;
|
| 1192 |
+
justify-content: space-between;
|
| 1193 |
+
gap: 12px;
|
| 1194 |
+
}
|
| 1195 |
+
|
| 1196 |
+
.file-name {
|
| 1197 |
+
font-weight: 600;
|
| 1198 |
+
font-size: 16px;
|
| 1199 |
+
color: var(--text);
|
| 1200 |
+
overflow: hidden;
|
| 1201 |
+
text-overflow: ellipsis;
|
| 1202 |
+
white-space: nowrap;
|
| 1203 |
+
}
|
| 1204 |
+
|
| 1205 |
+
.file-summary {
|
| 1206 |
+
color: var(--text-secondary);
|
| 1207 |
+
line-height: 1.6;
|
| 1208 |
+
text-align: justify;
|
| 1209 |
+
display: -webkit-box;
|
| 1210 |
+
-webkit-line-clamp: 3;
|
| 1211 |
+
-webkit-box-orient: vertical;
|
| 1212 |
+
overflow: hidden;
|
| 1213 |
+
}
|
| 1214 |
+
|
| 1215 |
+
.file-summary.expanded {
|
| 1216 |
+
display: block;
|
| 1217 |
+
-webkit-line-clamp: unset;
|
| 1218 |
+
overflow: visible;
|
| 1219 |
+
}
|
| 1220 |
+
|
| 1221 |
+
.file-card-actions {
|
| 1222 |
+
display: flex;
|
| 1223 |
+
align-items: center;
|
| 1224 |
+
justify-content: space-between;
|
| 1225 |
+
gap: 12px;
|
| 1226 |
+
}
|
| 1227 |
+
|
| 1228 |
+
.file-actions-right {
|
| 1229 |
+
margin-left: auto;
|
| 1230 |
+
}
|
| 1231 |
+
|
| 1232 |
+
.btn-danger {
|
| 1233 |
+
background: #ef4444;
|
| 1234 |
+
color: #fff;
|
| 1235 |
+
border: none;
|
| 1236 |
+
padding: 8px 12px;
|
| 1237 |
+
border-radius: var(--radius);
|
| 1238 |
+
cursor: pointer;
|
| 1239 |
+
transition: filter 0.2s ease;
|
| 1240 |
+
}
|
| 1241 |
+
|
| 1242 |
+
.btn-danger:hover { filter: brightness(1.1); }
|
| 1243 |
+
|
| 1244 |
+
.see-more-btn {
|
| 1245 |
+
background: transparent;
|
| 1246 |
+
color: var(--accent);
|
| 1247 |
+
border: none;
|
| 1248 |
+
cursor: pointer;
|
| 1249 |
+
font-weight: 600;
|
| 1250 |
}
|