update functions

This commit is contained in:
TreetopFlyer 2021-03-22 10:31:35 -04:00
parent 14cadbef04
commit e68dca926c

View File

@ -64,7 +64,7 @@ let ElemPager = ({count, active}) =>
let output = []; let output = [];
for(let i=inStart; i<=inStop; i++) for(let i=inStart; i<=inStop; i++)
{ {
output.push(h("button", {key:i, onClick:e=>App.Update("page", i)}, i+1)); output.push(h("button", {key:i, onClick:e=>App.Update.Page(i)}, i+1));
} }
return output; return output;
} }
@ -86,7 +86,7 @@ let ElemPager = ({count, active}) =>
{ {
if( (hitLeft && hitRight) || count < 7) if( (hitLeft && hitRight) || count < 7)
{ {
children = renderRange(_.head(blockIntro), _.last(blockOutro)) children = renderRange(_.head(blockIntro), _.last(blockOutro)) /* merge all */
} }
else if(!hitLeft && hitRight) else if(!hitLeft && hitRight)
{ {
@ -125,7 +125,7 @@ let ElemTopics = props =>
let children = App.State.Topics.All.map( t=> let children = App.State.Topics.All.map( t=>
{ {
return h(ElemTopic, { return h(ElemTopic, {
onClick:e=>App.Update("topic-toggle", t), onClick:e=>App.Update.Topic(t),
key:t.id, key:t.id,
label:t.display, label:t.display,
active:t.active active:t.active
@ -224,14 +224,11 @@ var App = {
App.State.Pages.All = _.chunk(App.State.Items.Active, 10); App.State.Pages.All = _.chunk(App.State.Items.Active, 10);
App.State.Pages.Active = 0; App.State.Pages.Active = 0;
}, },
Update:(...action)=> Update:
{ {
if(action) Load:(file)=>
{ {
switch(action[0]) fetch(file)
{
case "load":
fetch(action[1])
.then(inAccept=>inAccept.text()) .then(inAccept=>inAccept.text())
.then(inAccept=> .then(inAccept=>
{ {
@ -251,10 +248,9 @@ var App = {
App.Render(); App.Render();
} }
); );
break; },
Topic:(topic)=>
case "topic-toggle" : {
let topic = action[1];
if(topic.active) if(topic.active)
{ {
topic.active = false; topic.active = false;
@ -267,21 +263,18 @@ var App = {
} }
App.ApplyFilters(); App.ApplyFilters();
App.Render(); App.Render();
break; },
Page:(page)=>
case "page" :
if(action[1] !== false)
{ {
App.State.Pages.Active = action[1]; if(page !== false)
{
App.State.Pages.Active = page;
App.Render(); App.Render();
} }
} }
} }
}
}; };
App.Update.Load("data-flat.csv");
App.Update("load", "data-flat.csv");
</script> </script>