use picocss

This commit is contained in:
steven 2025-04-10 01:17:42 -04:00
parent eaae9de31c
commit 9bab0c69af
4 changed files with 155 additions and 146 deletions

View file

@ -17,11 +17,13 @@
{%- endif %}
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="clock.svg" type="image/svg+xml">
<style>*{font-family:monospace;}</style>
<meta name="color-scheme" content="dark light">
<link rel="stylesheet" href="https://static.stevenalexander.org/picocss/css/pico.min.css">
</head>
<body>
<h1><a href="https://25live.collegenet.com/pro/louisville#!/home/event/{{ data.event_id }}/details">{{ data.event_name }}</a>{{ " ("+data.event_title+")" if data.event_title }}</h1>
<h2>
<main class="container">
<h2><a href="https://25live.collegenet.com/pro/louisville#!/home/event/{{ data.event_id }}/details">{{ data.event_name }}</a>{{ " ("+data.event_title+")" if data.event_title }}</h2>
<h3>
{%- if "Rsrv" in data.profile.profile_name %}
{%- if data.profile.reservation.append is defined %}
Start: {{ data.profile.reservation[0].event_start_dt }}<br>
@ -33,9 +35,9 @@
{%- else %}
{{ data.profile.profile_name }}
{%- endif %}
</h2>
</h3>
{%- if data.profile.append is not defined %}
<h2>
<h3>
{%- if data.profile.reservation.append is defined %}
{%- if data.profile.reservation[0].space_reservation.append is defined %}
{%- for space in data.profile.reservation[0].space_reservation %}
@ -53,23 +55,23 @@
<a href="{{ data.profile.reservation.space_reservation.space_id }}">{{ data.profile.reservation.space_reservation.space.formal_name }}</a>
{%- endif %}
{%- endif %}
</h2>
</h3>
{%- endif %}
{%- if data.event_text %}
<h2>Description</h2>
<h3>Description</h3>
{%- if data.event_text.append is defined %}
{%- for i in data.event_text %}
{%- if i.text_type_id == 1 %}
<h3>{{ i.text | safe }}</h3>
<h4>{{ i.text | safe }}</h4>
{%- endif %}
{%- endfor %}
{%- elif data.event_text.text_type_id == 1 %}
<h3>{{ data.event_text.text | safe }}</h3>
<h4>{{ data.event_text.text | safe }}</h4>
{%- endif %}
{%- endif %}
<h2>Contact(s)</h2>
<h3>Contact(s)</h3>
{%- for i in data.role %}
<h3>{{ i.role_name }}: {{ i.contact.contact_first_name }} {{ i.contact.contact_middle_name }} {{ i.contact.contact_last_name }}</h3>
<h4>{{ i.role_name }}: {{ i.contact.contact_first_name }} {{ i.contact.contact_middle_name }} {{ i.contact.contact_last_name }}</h4>
{%- if i.contact.email %}
<p>Email: {{ i.contact.email }}</p>
{%- endif %}
@ -81,17 +83,18 @@
{%- endif %}
{%- endfor %}
{%- if data.custom_attribute %}
<h2>Custom Attribute(s)</h2>
<h3>Custom Attribute(s)</h3>
{%- if data.custom_attribute.append is defined %}
{%- for i in data.custom_attribute %}
<h3>{{ i.attribute_name }}</h3>
<h4>{{ i.attribute_name }}</h4>
<p>{{ i.attribute_value }}</p>
{%- endfor %}
{%- else %}
<h3>{{ data.custom_attribute.attribute_name }}</h3>
<h4>{{ data.custom_attribute.attribute_name }}</h4>
<p>{{ data.custom_attribute.attribute_value }}</p>
{%- endif %}
{%- endif %}
<h2>Last modified at {{ data.last_mod_dt }} by {{ data.last_mod_user }}</h2>
</main>
<footer class=container>Last modified at {{ data.last_mod_dt }} by {{ data.last_mod_user }}</footer>
</body>
</html>

View file

@ -7,37 +7,47 @@
<meta name="description" content="Find events at the University of Louisville">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="calendar.svg" type="image/svg+xml">
<style>*{font-family:monospace;font-size:0.8cm;}input[type="checkbox"],input[type="radio"]{width:0.7cm;height:0.7cm;}</style>
<meta name="color-scheme" content="dark light">
<link rel="stylesheet" href="https://static.stevenalexander.org/picocss/css/pico.jade.min.css">
</head>
<body>
<h1>Choose a day:</h1>
<header class="container">
<h2>UofL Events</h2>
</header>
<main class="container">
<fieldset>
<legend><strong>Date to display</strong></legend>
<input id="today" type="radio" name="date" checked>
<label for="today">today</label><br>
<input id="tomorrow" type="radio" name="date">
<label for="tomorrow">tomorrow</label><br>
<input id="custom" type="radio" name="date">
<label for="custom"><input id="date" type="date" min="{{today}}" max="{{later}}" value="{{dayafter}}" onchange="noClear(event)"></label>
<h1>[Optional] Select types of events to find:</h1>
{%- for i in ["available","class","exam","booked","food"] %}
</fieldset>
<fieldset>
<legend><strong>Filter rooms by event type</strong></legend>
{%- for i in ["closed","available","class","exam","booked","food"] %}
<input id="{{i}}" type="checkbox">
<label for="{{i}}">{{i}}</label><br>
{%- endfor %}
<p><button onclick="changeURL()">Show me the events!</button></p>
</fieldset>
<fieldset>
<button class="outline" onclick="doFilters()">Show the events!</button>
</fieldset>
<script>
function noClear(e) {
function noClear(e){
val=e.target.value
if(val===""||val<"{{today}}"||val>"{{later}}"){e.target.value="{{dayafter}}"}
if(!val||val<"{{today}}"||val>"{{later}}"){e.target.value="{{dayafter}}"}
document.getElementById("custom").click()
}
function changeURL(){
has=[]
document.querySelectorAll('input[type="checkbox"]:checked').forEach(i=>has.push(i.id))
if(has.length>0){has="?has="+has.join(",")
}else{has=""}
date=document.querySelector('input[type="radio"]:checked').id
if(date=="custom"){date=document.querySelector('input[type="date"]').value}
document.location.href=date+has
function doFilters(){
d=document.querySelector('input[type="radio"]:checked').id;
if(d=="custom"){document.querySelector('input[type="date"]').value}
f=Array.from(document.querySelectorAll('input[type="checkbox"]:checked')).map(c=>c.id);
f=f.length?"?"+f.join(","):"";
document.location.href=d+f
}
</script>
</main>
</body>
</html>

View file

@ -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>

View file

@ -6,38 +6,41 @@
<title>{{ data.space_name }}{{ " ("+data.building_name+")" if data.building_name }}</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="location.svg" type="image/svg+xml">
<style>*{font-family:monospace;}b{white-space:pre-wrap;}img{max-width:100%;}</style>
<meta name="color-scheme" content="dark light">
<link rel="stylesheet" href="https://static.stevenalexander.org/picocss/css/pico.min.css">
</head>
<body>
<h1><a href="https://25live.collegenet.com/pro/louisville#!/home/location/{{ data.space_id }}/availability/daily">{{ data.space_name }}</a>{{ " ("+data.building_name+")" if data.building_name }}</h1>
<h2>Hours</h2>
<h3>
<main class="container">
<h2><a href="https://25live.collegenet.com/pro/louisville#!/home/location/{{ data.space_id }}/availability/daily">{{ data.space_name }}</a>{{ " ("+data.building_name+")" if data.building_name }}</h2>
<h3>Hours</h3>
<h4>
{%- for i in data.hours %}
{{ i.day_name[:3] }}: {{ i.open }} - {{ i.close }}<br>
{%- endfor %}
</h3>
</h4>
{% if data.instructions %}
<h2>Instructions</h2>
<h3>{{ data.instructions|safe }}</h3>
<h3>Instructions</h3>
<h4>{{ data.instructions|safe }}</h4>
{% endif %}
{%- if data.comments %}
<h2>Comments</h2>
<h3>{{ data.comments|safe }}</h3>
<h3>Comments</h3>
<h4>{{ data.comments|safe }}</h4>
{%- endif %}
<h2>Layout(s)</h2>
<h3>Layout(s)</h3>
{%- if data.layout %}
{%- if data.layout.append is defined %}
{%- for i in data.layout %}
{%- if i.layout_photo_id %}
<h3>{{ i.layout_name }} ({{ i.layout_capacity }} capacity)</h3>
<h4>{{ i.layout_name }} ({{ i.layout_capacity }} capacity)</h4>
<img src="https://25live.collegenet.com/25live/data/louisville/run/image?image_id={{ i.layout_photo_id }}">
{%- endif %}
{%- endfor %}
{%- elif data.layout.layout_photo_id %}
<h3>{{ data.layout.layout_name }} ({{ data.layout.layout_capacity }} capacity)</h3>
<h4>{{ data.layout.layout_name }} ({{ data.layout.layout_capacity }} capacity)</h4>
<img src="https://25live.collegenet.com/25live/data/louisville/run/image?image_id={{ data.layout.layout_photo_id }}">
{%- endif %}
{%- endif %}
<h2>Last modified at {{ data.last_mod_dt }} by {{ data.last_mod_user }}</h2>
</main>
<footer class="container">Last modified at {{ data.last_mod_dt }} by {{ data.last_mod_user }}</footer>
</body>
</html>