Public Access
Fix the dynamic page list JSON (missing comma between pages)
serializeJson() replaces the String's content, so the comma was lost and the web page could not load any list once a second page existed. Each list now loads on its own, so one failure doesn't empty the others. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0411804a2f
commit
fdffa73102
2 files changed
+8
-4
No files matched your search
@@ -181,7 +181,9 @@ function sysinfo(){if(!status)return;const r=[['Firmware',status.firmware],['Las
|
|||||||
['Storage',status.storage.available?Math.round(status.storage.used/1024)+' of '+Math.round(status.storage.total/1024)+' KB used':'not available']];
|
['Storage',status.storage.available?Math.round(status.storage.used/1024)+' of '+Math.round(status.storage.total/1024)+' KB used':'not available']];
|
||||||
$('sysinfo').innerHTML='';r.forEach(([k,v])=>{const a=document.createElement('label');a.textContent=k;const b=document.createElement('span');b.textContent=v;$('sysinfo').append(a,b)})}
|
$('sysinfo').innerHTML='';r.forEach(([k,v])=>{const a=document.createElement('label');a.textContent=k;const b=document.createElement('span');b.textContent=v;$('sysinfo').append(a,b)})}
|
||||||
// pages, bitmaps and fonts
|
// pages, bitmaps and fonts
|
||||||
async function loadLists(){const[b,p,f]=await Promise.all([api('/api/bitmaps'),api('/api/pages'),api('/api/fonts')]);
|
// each list on its own: one that fails to load doesn't empty the others
|
||||||
|
async function getList(p,key){try{const j=await api(p);if(Array.isArray(j[key]))return j}catch(e){}msg('Could not load '+p,true);return{[key]:[]}}
|
||||||
|
async function loadLists(){const[b,p,f]=await Promise.all([getList('/api/bitmaps','bitmaps'),getList('/api/pages','pages'),getList('/api/fonts','fonts')]);
|
||||||
bitmapList=b.bitmaps;pageList=p.pages;fontList=f.fonts;bitmapList.forEach(bm=>bm.bits=fromHex(bm.data));pageList.forEach(pg=>pg.bits=fromHex(pg.data));
|
bitmapList=b.bitmaps;pageList=p.pages;fontList=f.fonts;bitmapList.forEach(bm=>bm.bits=fromHex(bm.data));pageList.forEach(pg=>pg.bits=fromHex(pg.data));
|
||||||
$('storage').textContent=b.storage?'':'Storage not available: install the new flash layout (see README).';
|
$('storage').textContent=b.storage?'':'Storage not available: install the new flash layout (see README).';
|
||||||
const pages=$('pages'),offs=$('offpages'),bms=$('bitmaps'),dyn=$('dynpages');pages.innerHTML='';offs.innerHTML='';bms.innerHTML='';dyn.innerHTML='';
|
const pages=$('pages'),offs=$('offpages'),bms=$('bitmaps'),dyn=$('dynpages');pages.innerHTML='';offs.innerHTML='';bms.innerHTML='';dyn.innerHTML='';
|
||||||
@@ -218,7 +220,7 @@ function newEl(t){return{type:t,x:t=='clock'?27:0,y:t=='clock'?5:0,align:'left',
|
|||||||
function peShow(title,name){$('pe_title').textContent=title;$('pe_name').value=name;$('pe').style.display='block';peData=null;peBuild();pePreview();$('pe').scrollIntoView({behavior:'smooth'})}
|
function peShow(title,name){$('pe_title').textContent=title;$('pe_name').value=name;$('pe').style.display='block';peData=null;peBuild();pePreview();$('pe').scrollIntoView({behavior:'smooth'})}
|
||||||
function peOpen(pg,copy){pe={orig:copy?'':pg.name,page:JSON.parse(JSON.stringify(pg.page)),sel:-1,boxes:[],pos:[]};peShow(copy?'Copy of '+pg.name:'Edit '+pg.name,copy?'':pg.name)}
|
function peOpen(pg,copy){pe={orig:copy?'':pg.name,page:JSON.parse(JSON.stringify(pg.page)),sel:-1,boxes:[],pos:[]};peShow(copy?'Copy of '+pg.name:'Edit '+pg.name,copy?'':pg.name)}
|
||||||
function peNew(){pe={orig:'',page:{slots:[{start:'00:00',bitmap:''}],elements:[newEl('clock')]},sel:-1,boxes:[],pos:[]};peShow('New page','')}
|
function peNew(){pe={orig:'',page:{slots:[{start:'00:00',bitmap:''}],elements:[newEl('clock')]},sel:-1,boxes:[],pos:[]};peShow('New page','')}
|
||||||
function peClose(){pe=null;$('pe').style.display='none'}
|
function peClose(){pe=null;$('pe').style.display='none';$('t-pages').scrollIntoView({behavior:'smooth'})}
|
||||||
function peBuild(){peSlots();peElems()}
|
function peBuild(){peSlots();peElems()}
|
||||||
function field(label,input){return mk('label',{},label+' ',input)}
|
function field(label,input){return mk('label',{},label+' ',input)}
|
||||||
function inp(o,k,type,props){const i=mk('input',Object.assign({type:type||'text',value:o[k]},props||{}));i.oninput=()=>{o[k]=type=='number'?Math.round(+i.value||0):i.value;pePreview()};return i}
|
function inp(o,k,type,props){const i=mk('input',Object.assign({type:type||'text',value:o[k]},props||{}));i.oninput=()=>{o[k]=type=='number'?Math.round(+i.value||0):i.value;pePreview()};return i}
|
||||||
|
|||||||
@@ -288,8 +288,10 @@ static void handlePages()
|
|||||||
doc["builtin"] = info.builtin;
|
doc["builtin"] = info.builtin;
|
||||||
doc["data"] = hex;
|
doc["data"] = hex;
|
||||||
pageToJson(*page, doc["page"].to<JsonObject>());
|
pageToJson(*page, doc["page"].to<JsonObject>());
|
||||||
String item = first ? "" : ",";
|
String item;
|
||||||
serializeJson(doc, item);
|
serializeJson(doc, item); // replaces the string's content, so the comma is sent apart
|
||||||
|
if (!first)
|
||||||
|
server.sendContent(",");
|
||||||
server.sendContent(item);
|
server.sendContent(item);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user