Self-contained XHTML bundles (Shift Log, Tool Library, Gratitude Wall) that mount through the real upload/publish path and use the window.commons SDK. Published to /api/blob and verified mounting + executing in a real browser.
101 lines
4.2 KiB
HTML
101 lines
4.2 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<style>
|
|
.commons-app { font-family: system-ui, sans-serif; max-width: 560px; margin: 0 auto; padding: 16px; color: #1f2329; }
|
|
.commons-app h2 { font-size: 20px; margin: 0 0 4px; }
|
|
.commons-app .sub { color: #6b7280; font-size: 13px; margin: 0 0 16px; }
|
|
.commons-app .row { display: flex; gap: 8px; margin-bottom: 8px; }
|
|
.commons-app input, .commons-app select { flex: 1; padding: 10px; border: 1px solid #d0d5dd; border-radius: 8px; font-size: 14px; }
|
|
.commons-app button { background: #1677FF; color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
|
|
.commons-app button:hover { background: #0f5ed6; }
|
|
.commons-app .meta { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; }
|
|
.commons-app .meta h3 { font-size: 15px; margin: 0; }
|
|
.commons-app .pill { background: #eef4ff; color: #1677FF; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
|
|
.commons-app ul { list-style: none; padding: 0; margin: 0; }
|
|
.commons-app li { border: 1px solid #eef0f3; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; font-size: 14px; }
|
|
.commons-app li .who { color: #6b7280; font-size: 12px; }
|
|
.commons-app .empty { color: #9aa1ab; font-size: 13px; padding: 12px 0; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="commons-app">
|
|
<h2>Shift Log</h2>
|
|
<p class="sub">Log the civic shifts you cover in the Hollow. Every entry is a signed event on your own log.</p>
|
|
<div class="row">
|
|
<select id="role">
|
|
<option value="Pump watch">Pump watch</option>
|
|
<option value="Tunnel sweep">Tunnel sweep</option>
|
|
<option value="Kitchen">Kitchen</option>
|
|
<option value="Clinic desk">Clinic desk</option>
|
|
<option value="Night watch">Night watch</option>
|
|
</select>
|
|
<input id="hours" type="number" min="0" step="0.5" placeholder="hours" />
|
|
</div>
|
|
<div class="row">
|
|
<input id="note" type="text" placeholder="note (e.g. covering the east pump)" />
|
|
<button id="log-btn" type="button">Log shift</button>
|
|
</div>
|
|
<div class="meta">
|
|
<h3>Recent shifts</h3>
|
|
<span class="pill"><span id="total-hours">0</span> hrs logged</span>
|
|
</div>
|
|
<ul id="list"></ul>
|
|
<p id="empty" class="empty">No shifts logged yet. Log your first above.</p>
|
|
</div>
|
|
<script>
|
|
<![CDATA[
|
|
(function () {
|
|
var api = window.commons;
|
|
var listEl = document.getElementById("list");
|
|
var emptyEl = document.getElementById("empty");
|
|
var totalEl = document.getElementById("total-hours");
|
|
|
|
function render(entries) {
|
|
var shifts = [];
|
|
var total = 0;
|
|
for (var i = 0; i < entries.length; i++) {
|
|
var p = entries[i].payload;
|
|
if (p && p.type === "shiftlog.entry") {
|
|
shifts.push(p);
|
|
total += Number(p.hours) || 0;
|
|
}
|
|
}
|
|
totalEl.textContent = String(total);
|
|
emptyEl.style.display = shifts.length === 0 ? "block" : "none";
|
|
listEl.innerHTML = "";
|
|
shifts.slice().reverse().forEach(function (s) {
|
|
var li = document.createElement("li");
|
|
var strong = document.createElement("strong");
|
|
strong.textContent = s.role + " - " + (Number(s.hours) || 0) + "h";
|
|
var who = document.createElement("div");
|
|
who.className = "who";
|
|
who.textContent = s.note ? s.note : "no note";
|
|
li.appendChild(strong);
|
|
li.appendChild(who);
|
|
listEl.appendChild(li);
|
|
});
|
|
}
|
|
|
|
function refresh() {
|
|
api.eventlog.readAll().then(render);
|
|
}
|
|
|
|
document.getElementById("log-btn").addEventListener("click", function () {
|
|
var role = document.getElementById("role").value;
|
|
var hours = document.getElementById("hours").value;
|
|
var note = document.getElementById("note").value;
|
|
if (!hours || Number(hours) <= 0) { return; }
|
|
api.eventlog.append({ type: "shiftlog.entry", role: role, hours: Number(hours), note: note }).then(function () {
|
|
document.getElementById("hours").value = "";
|
|
document.getElementById("note").value = "";
|
|
refresh();
|
|
});
|
|
});
|
|
|
|
refresh();
|
|
})();
|
|
]]>
|
|
</script>
|
|
</body>
|
|
</html>
|