better error handling
This commit is contained in:
parent
9bab0c69af
commit
a974fbf429
1 changed files with 10 additions and 6 deletions
|
@ -68,7 +68,7 @@ a:hover{background-color:lightgray;color:black;}
|
||||||
<body>
|
<body>
|
||||||
<table>
|
<table>
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th colspan=60><a href="https://25live.collegenet.com/pro/louisville#!/home/event/form">Updating...</a></th>
|
<th colspan=60><a aria-busy="true" href="https://25live.collegenet.com/pro/louisville#!/home/event/form">Fetching</a></th>
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -85,12 +85,14 @@ for(let hour=8;hour<23;hour++){
|
||||||
}
|
}
|
||||||
|
|
||||||
let json=localStorage.getItem("{{day}}");
|
let json=localStorage.getItem("{{day}}");
|
||||||
if(json)displayEvents(JSON.parse(json))
|
if(json)displayEvents(JSON.parse(json));
|
||||||
|
|
||||||
fetch("{{day}}.json").then(r=>{
|
fetch("{{day}}.json").then(response=>{
|
||||||
bookBtn.innerText="Book a Space";
|
bookBtn.ariaBusy="false";
|
||||||
return r.json()
|
if(!response.ok){throw new Error(response.status)}
|
||||||
|
return response.json()
|
||||||
}).then(json=>{
|
}).then(json=>{
|
||||||
|
bookBtn.innerText="Book a Space";
|
||||||
tbody.innerHTML="";
|
tbody.innerHTML="";
|
||||||
displayEvents(json);
|
displayEvents(json);
|
||||||
try{
|
try{
|
||||||
|
@ -99,6 +101,9 @@ fetch("{{day}}.json").then(r=>{
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
localStorage.setItem("{{day}}",JSON.stringify(json))
|
localStorage.setItem("{{day}}",JSON.stringify(json))
|
||||||
}
|
}
|
||||||
|
}).catch(error=>{
|
||||||
|
bookBtn.innerText="Fetch Failed";
|
||||||
|
console.error(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
function createBox(row,length,name=null,link=null,type=null){
|
function createBox(row,length,name=null,link=null,type=null){
|
||||||
|
@ -125,7 +130,6 @@ function createBox(row,length,name=null,link=null,type=null){
|
||||||
|
|
||||||
function displayEvents(json){
|
function displayEvents(json){
|
||||||
const filterClasses=new Set(window.location.search.substring(1).split(",").filter(Boolean));
|
const filterClasses=new Set(window.location.search.substring(1).split(",").filter(Boolean));
|
||||||
|
|
||||||
for(const space in json){
|
for(const space in json){
|
||||||
const row=document.createElement("tr");
|
const row=document.createElement("tr");
|
||||||
const info=json[space];
|
const info=json[space];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue