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>
|
||||
<table>
|
||||
<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>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
|
@ -85,12 +85,14 @@ for(let hour=8;hour<23;hour++){
|
|||
}
|
||||
|
||||
let json=localStorage.getItem("{{day}}");
|
||||
if(json)displayEvents(JSON.parse(json))
|
||||
if(json)displayEvents(JSON.parse(json));
|
||||
|
||||
fetch("{{day}}.json").then(r=>{
|
||||
bookBtn.innerText="Book a Space";
|
||||
return r.json()
|
||||
fetch("{{day}}.json").then(response=>{
|
||||
bookBtn.ariaBusy="false";
|
||||
if(!response.ok){throw new Error(response.status)}
|
||||
return response.json()
|
||||
}).then(json=>{
|
||||
bookBtn.innerText="Book a Space";
|
||||
tbody.innerHTML="";
|
||||
displayEvents(json);
|
||||
try{
|
||||
|
@ -99,6 +101,9 @@ fetch("{{day}}.json").then(r=>{
|
|||
localStorage.clear();
|
||||
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){
|
||||
|
@ -125,7 +130,6 @@ function createBox(row,length,name=null,link=null,type=null){
|
|||
|
||||
function displayEvents(json){
|
||||
const filterClasses=new Set(window.location.search.substring(1).split(",").filter(Boolean));
|
||||
|
||||
for(const space in json){
|
||||
const row=document.createElement("tr");
|
||||
const info=json[space];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue