use picocss
This commit is contained in:
parent
eaae9de31c
commit
9bab0c69af
4 changed files with 155 additions and 146 deletions
|
@ -6,76 +6,64 @@
|
|||
<title>{{ day }} - 44live</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="icon" href="calendar.svg" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="https://static.stevenalexander.org/picocss/css/pico.min.css">
|
||||
<base target="_blank">
|
||||
<style>*{margin:0;padding:0;scrollbar-width:none;}
|
||||
body,html{
|
||||
-webkit-text-size-adjust:100%;
|
||||
font:12px monospace;
|
||||
width:100%;
|
||||
<style>
|
||||
html,body{
|
||||
font-family:monospace;
|
||||
font-size:12px;
|
||||
height:100%;
|
||||
width:100%;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
table{
|
||||
background-color:black;
|
||||
min-width:100%;
|
||||
width:1600px;
|
||||
max-width:400%;
|
||||
border-collapse:separate;
|
||||
border-spacing:0;
|
||||
table-layout:fixed;
|
||||
overflow-x:clip;
|
||||
overflow:hidden;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
th,td{
|
||||
background-color:white;
|
||||
box-sizing:border-box;
|
||||
border-bottom:2px solid black;
|
||||
border-right:2px solid black;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
th,td:first-child{
|
||||
position:sticky;
|
||||
}
|
||||
|
||||
th:first-child,td:first-child{
|
||||
left:0;
|
||||
}
|
||||
|
||||
th{
|
||||
top:0;
|
||||
color:black;
|
||||
background-color:white;
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
top:0;
|
||||
}
|
||||
|
||||
th:first-child{
|
||||
z-index:1;
|
||||
}
|
||||
|
||||
a,span{
|
||||
white-space:nowrap;
|
||||
color:black;
|
||||
padding:2px;
|
||||
display:block;
|
||||
white-space:nowrap;
|
||||
overflow:hidden;
|
||||
text-overflow:ellipsis;
|
||||
}
|
||||
|
||||
a{
|
||||
display:block;
|
||||
text-decoration:none;
|
||||
color:black;
|
||||
}
|
||||
.closed>a{color:white;}
|
||||
a:hover{background-color:lightgray;color:black;}
|
||||
.closed{background-color:black;color:white;}
|
||||
[class="closed"],[class="closed"]>*{background-color:#13171f;color:white;}
|
||||
.available{background-color:lightgreen;}
|
||||
.other{background-color:white;}
|
||||
.class{background-color:darkgray;}
|
||||
.exam{background-color:gray;}
|
||||
.booked{background-color:coral;}
|
||||
.food{background-color:mediumpurple;}
|
||||
</style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
|
@ -85,98 +73,103 @@ a:hover{background-color:lightgray;color:black;}
|
|||
<tbody></tbody>
|
||||
</table>
|
||||
<script>
|
||||
const headRow = document.querySelector("tr");
|
||||
const bookBtn = headRow.querySelector("a");
|
||||
const tbody = document.querySelector("tbody");
|
||||
const headRow=document.querySelector("tr");
|
||||
const bookBtn=headRow.querySelector("a");
|
||||
const tbody=document.querySelector("tbody");
|
||||
|
||||
for (let hour = 8; hour < 23; hour++) {
|
||||
const th = document.createElement("th");
|
||||
th.setAttribute("colspan", 60);
|
||||
th.textContent = hour;
|
||||
for(let hour=8;hour<23;hour++){
|
||||
const th=document.createElement("th");
|
||||
th.setAttribute("colspan",60);
|
||||
th.textContent=hour;
|
||||
headRow.appendChild(th)
|
||||
}
|
||||
|
||||
let json=localStorage.getItem("{{ day }}");
|
||||
if (json) displayEvents(JSON.parse(json))
|
||||
let json=localStorage.getItem("{{day}}");
|
||||
if(json)displayEvents(JSON.parse(json))
|
||||
|
||||
fetch("{{ day }}.json").then(r => {
|
||||
bookBtn.innerText = "Book a Space";
|
||||
fetch("{{day}}.json").then(r=>{
|
||||
bookBtn.innerText="Book a Space";
|
||||
return r.json()
|
||||
}).then(json => {
|
||||
}).then(json=>{
|
||||
tbody.innerHTML="";
|
||||
displayEvents(json);
|
||||
try {
|
||||
localStorage.setItem("{{ day }}",JSON.stringify(json))
|
||||
} catch {
|
||||
try{
|
||||
localStorage.setItem("{{day}}",JSON.stringify(json))
|
||||
}catch{
|
||||
localStorage.clear();
|
||||
localStorage.setItem("{{ day }}",JSON.stringify(json))
|
||||
localStorage.setItem("{{day}}",JSON.stringify(json))
|
||||
}
|
||||
})
|
||||
|
||||
function createBox(row, length, type, name, link) {
|
||||
const td = document.createElement("td");
|
||||
if (link) {
|
||||
var e = document.createElement("a");
|
||||
e.href = link
|
||||
function createBox(row,length,name=null,link=null,type=null){
|
||||
const td=document.createElement("td");
|
||||
td.setAttribute("colspan",length);
|
||||
let e;
|
||||
if(link){
|
||||
e=document.createElement("a");
|
||||
e.href=link
|
||||
}else if(name){
|
||||
e=document.createElement("span")
|
||||
}
|
||||
if (name) {
|
||||
if (!e) var e = document.createElement("span")
|
||||
e.textContent = name;
|
||||
e.title = name;
|
||||
if(name&&e){
|
||||
e.textContent=name;
|
||||
e.title=name;
|
||||
td.appendChild(e)
|
||||
}
|
||||
if (type) {
|
||||
if (type != "closed" || length == 900) {row.firstChild.classList.add(type)}
|
||||
td.classList.add(type);
|
||||
if(type){
|
||||
row.firstChild?.classList.add(type);
|
||||
td.classList.add(type)
|
||||
}
|
||||
td.setAttribute("colspan", length);
|
||||
row.appendChild(td);
|
||||
row.appendChild(td)
|
||||
}
|
||||
|
||||
function displayEvents(json) {
|
||||
if (window.location.search) var has=new Set(new URLSearchParams(window.location.search).get("has").split(","))
|
||||
for (space in json) {
|
||||
const row = document.createElement("tr");
|
||||
let link = json[space].i;
|
||||
let defaultEmpty = "available";
|
||||
let defaultType = null;
|
||||
if (!json[space].i) {
|
||||
link = "https://louisville.campusdish.com/LocationsAndMenus/Belknap/"+space;
|
||||
defaultEmpty = "closed";
|
||||
defaultType = "food"
|
||||
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];
|
||||
let link=`https://louisville.campusdish.com/LocationsAndMenus/Belknap/${space}`;
|
||||
let defaultType="closed";
|
||||
if(info.i){
|
||||
link=info.i;
|
||||
defaultType="available"
|
||||
}
|
||||
createBox(row, 60, null, space, link);
|
||||
let now = 0;
|
||||
if (json[space].l) {
|
||||
for (e of json[space].l) {
|
||||
start=e.s
|
||||
end=e.e
|
||||
if (now < start) {
|
||||
createBox(row, start-now, defaultEmpty);
|
||||
now = start
|
||||
createBox(row,60,space,link);
|
||||
let time=0;
|
||||
if(Array.isArray(info.l)){
|
||||
for(const event of info.l){
|
||||
const {s:start,e:end,n:name,t:type="other",i:id}=event;
|
||||
if(time<start){
|
||||
createBox(row,start-time,null,null,defaultType);
|
||||
time=start;
|
||||
}
|
||||
if (now <= start && now < end) {
|
||||
type = defaultType ? defaultType : (e.i ? (e.t ? e.t : "other") : "closed");
|
||||
link = e.i ? "event/" + e.i : null;
|
||||
createBox(row, end-start, type, e.n, link)
|
||||
now = end
|
||||
if(time<=start&&time<end){
|
||||
const eventType=defaultType==="closed"?"food":(id===undefined?"closed":type);
|
||||
const eventLink=id?`event/${id}`:null;
|
||||
createBox(row,end-start,name,eventLink,eventType);
|
||||
time=end;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (now < 900) {
|
||||
createBox(row, 900-now, defaultEmpty)
|
||||
|
||||
if (time<900){
|
||||
createBox(row,900-time,null,null,defaultType);
|
||||
}
|
||||
if (typeof has === "undefined") {
|
||||
tbody.appendChild(row)
|
||||
} else {
|
||||
for (let i of row.firstChild.className.split(" ")) {
|
||||
if (has.has(i)) {
|
||||
tbody.appendChild(row)
|
||||
}
|
||||
|
||||
const firstCell=row.firstChild;
|
||||
if(!firstCell)continue;
|
||||
|
||||
if(filterClasses.size>0){
|
||||
if(firstCell.className.split(" ").some(cls=>filterClasses.has(cls))){
|
||||
tbody.appendChild(row);
|
||||
}
|
||||
}else{
|
||||
tbody.appendChild(row);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
document.querySelector("script").remove();
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue