파일 분할 코멘트 추가
This commit is contained in:
37
web_html.h
37
web_html.h
@@ -91,6 +91,7 @@ tr:active{background:rgba(233,69,96,0.1);}
|
||||
.cba,.cbf{width:18px;height:18px;accent-color:var(--btn);}
|
||||
.fl{color:var(--rx);text-decoration:none;}
|
||||
.fs{color:#888;}
|
||||
.fc{color:var(--ok);cursor:pointer;font-size:12px;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
||||
|
||||
/* ===== STATUS BAR ===== */
|
||||
.sbar{display:flex;align-items:center;padding:3px 10px;background:var(--panel);border-top:1px solid var(--border);font-size:10px;color:#777;gap:10px;flex-shrink:0;flex-wrap:wrap;}
|
||||
@@ -119,6 +120,7 @@ tr:active{background:rgba(233,69,96,0.1);}
|
||||
.ftool{gap:4px;}
|
||||
.ftool button{padding:5px 10px;font-size:10px;}
|
||||
th,td{padding:5px 6px;font-size:11px;}
|
||||
.fc{max-width:100px;font-size:10px;}
|
||||
.sbar{font-size:9px;gap:6px;padding:2px 6px;}
|
||||
}
|
||||
|
||||
@@ -253,7 +255,7 @@ tr:active{background:rgba(233,69,96,0.1);}
|
||||
<div class="ftable">
|
||||
<table><thead><tr>
|
||||
<th style="width:32px;"><input type="checkbox" class="cba" onchange="togAll(this)"></th>
|
||||
<th>File</th><th>Size</th><th>Date</th>
|
||||
<th>File</th><th>Size</th><th>Date</th><th>Comment</th>
|
||||
</tr></thead><tbody id="fList"></tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -536,23 +538,52 @@ function loadFiles(){
|
||||
fetch('/api/files').then(r=>r.json()).then(d=>{
|
||||
const tb=document.getElementById('fList');tb.innerHTML='';
|
||||
if(!d.files||!d.files.length){
|
||||
tb.innerHTML='<tr><td colspan="4" style="text-align:center;color:#666;padding:20px;">No files</td></tr>';
|
||||
tb.innerHTML='<tr><td colspan="5" style="text-align:center;color:#666;padding:20px;">No files</td></tr>';
|
||||
document.getElementById('fInfo').textContent='0 files';return;
|
||||
}
|
||||
let tot=0;
|
||||
d.files.forEach(f=>{
|
||||
tot+=f.size;
|
||||
let cmt=f.comment||'';
|
||||
let tr=document.createElement('tr');
|
||||
tr.innerHTML='<td><input type="checkbox" class="cbf" value="'+esc(f.name)+'"></td>'
|
||||
+'<td><a class="fl" href="/download?file='+encodeURIComponent(f.name)+'">'+esc(f.name)+'</a></td>'
|
||||
+'<td class="fs">'+fB(f.size)+'</td>'
|
||||
+'<td class="fs">'+(f.modified||'').slice(5)+'</td>';
|
||||
+'<td class="fs">'+(f.modified||'').slice(5)+'</td>'
|
||||
+'<td class="fc" onclick="editCmt(this,\''+esc(f.name)+'\')" title="Click to edit">'
|
||||
+(cmt?esc(cmt):'<span style="color:#555;font-style:italic;">+memo</span>')+'</td>';
|
||||
tb.appendChild(tr);
|
||||
});
|
||||
document.getElementById('fInfo').textContent=d.files.length+' files ('+fB(tot)+')';
|
||||
if(d.totalMB!==undefined){
|
||||
let free=d.totalMB-d.usedMB;
|
||||
document.getElementById('fInfo').textContent+=
|
||||
' | SD: '+d.usedMB+'MB/'+d.totalMB+'MB ('+free+'MB free)';
|
||||
}
|
||||
}).catch(()=>addSys('[File list error]'));
|
||||
}
|
||||
|
||||
function editCmt(td,fname){
|
||||
if(td.querySelector('input')) return; // already editing
|
||||
let old=td.textContent.trim();
|
||||
if(old==='+memo') old='';
|
||||
let inp=document.createElement('input');
|
||||
inp.type='text';inp.value=old;inp.maxLength=100;
|
||||
inp.style.cssText='width:100%;background:var(--term-bg);color:var(--text);border:1px solid var(--ok);padding:2px 4px;font-size:12px;border-radius:3px;';
|
||||
inp.placeholder='Add comment...';
|
||||
td.innerHTML='';td.appendChild(inp);inp.focus();
|
||||
function save(){
|
||||
let v=inp.value.trim();
|
||||
fetch('/api/comment',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({file:fname,comment:v})})
|
||||
.then(r=>r.json()).then(()=>{
|
||||
td.innerHTML=v?esc(v):'<span style="color:#555;font-style:italic;">+memo</span>';
|
||||
}).catch(()=>{td.textContent=old||'+memo';});
|
||||
}
|
||||
inp.onblur=save;
|
||||
inp.onkeydown=function(e){if(e.key==='Enter'){e.preventDefault();inp.blur();}if(e.key==='Escape'){td.innerHTML=old?esc(old):'<span style="color:#555;font-style:italic;">+memo</span>';}};
|
||||
}
|
||||
|
||||
function togAll(cb){document.querySelectorAll('.cbf').forEach(c=>c.checked=cb.checked);}
|
||||
function getSel(){return Array.from(document.querySelectorAll('.cbf:checked')).map(c=>c.value);}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user