@lchase/kiln 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/serve.js CHANGED
@@ -1011,8 +1011,9 @@
1011
1011
  document.addEventListener("click", function (event) {
1012
1012
  var target = event.target;
1013
1013
  if (!target || !target.closest) return;
1014
- if (target.closest("#open-settings")) {
1015
- openSettings();
1014
+ var settingsControl = target.closest("#open-settings");
1015
+ if (settingsControl) {
1016
+ if (settingsControl.tagName !== "A") openSettings();
1016
1017
  return;
1017
1018
  }
1018
1019
  if (target.closest("#add-job")) {
@@ -1169,7 +1170,7 @@
1169
1170
  return;
1170
1171
  }
1171
1172
  el.className = "status";
1172
- var jobs = document.querySelectorAll(".board .card").length;
1173
+ var jobs = document.querySelectorAll(".job").length;
1173
1174
  el.textContent = jobs + (jobs === 1 ? " job · " : " jobs · ") + new Date().toLocaleTimeString();
1174
1175
  localizeTimes(document);
1175
1176
  }
@@ -1194,11 +1195,20 @@
1194
1195
  toggle.textContent = data.paused ? "Resume" : "Pause";
1195
1196
  toggle.setAttribute("aria-pressed", data.paused ? "true" : "false");
1196
1197
  form.setAttribute("action", data.paused ? "/api/resume" : "/api/pause");
1198
+ var label = document.getElementById("run-label");
1199
+ var dot = document.getElementById("run-dot");
1200
+ if (label) label.textContent = data.paused ? "Paused" : "Running";
1201
+ if (dot) dot.classList.toggle("paused", data.paused);
1197
1202
  }
1198
1203
  var spend = document.getElementById("spend");
1199
1204
  if (spend && data && data.spend) {
1200
1205
  var capText = data.spend.cap == null ? "no cap" : "$" + Number(data.spend.cap).toFixed(2);
1201
1206
  spend.textContent = "today " + data.spend.day + " $" + Number(data.spend.usd).toFixed(2) + " / " + capText;
1207
+ var capNote = document.getElementById("cap-note");
1208
+ if (capNote) {
1209
+ var blocked = data.spend.blocked === true || (data.spend.cap != null && Number(data.spend.usd) >= Number(data.spend.cap));
1210
+ capNote.hidden = !blocked;
1211
+ }
1202
1212
  }
1203
1213
  stamp(true);
1204
1214
  })
@@ -1237,11 +1247,70 @@
1237
1247
  }
1238
1248
  var previewBtn = document.getElementById("preview-job");
1239
1249
  if (previewBtn) previewBtn.addEventListener("click", function () { submitIntake(true); });
1250
+ function readSeen() {
1251
+ try {
1252
+ var raw = localStorage.getItem("kiln-seen");
1253
+ var parsed = raw ? JSON.parse(raw) : {};
1254
+ return parsed && typeof parsed === "object" ? parsed : {};
1255
+ } catch (err) {
1256
+ return {};
1257
+ }
1258
+ }
1259
+
1260
+ function writeSeen(map) {
1261
+ try { localStorage.setItem("kiln-seen", JSON.stringify(map)); } catch (err) { /* private mode */ }
1262
+ }
1263
+
1264
+ function paintCount(node, count) {
1265
+ if (!node) return;
1266
+ if (!count) {
1267
+ node.hidden = true;
1268
+ node.textContent = "";
1269
+ return;
1270
+ }
1271
+ node.hidden = false;
1272
+ node.textContent = count === 1 ? "1 change since you last looked" : count + " changes since you last looked";
1273
+ }
1274
+
1275
+ function paintUnseen() {
1276
+ var seen = readSeen();
1277
+ var params = [];
1278
+ for (var id in seen) {
1279
+ if (!Object.prototype.hasOwnProperty.call(seen, id)) continue;
1280
+ if (typeof seen[id] !== "string" || !seen[id]) continue;
1281
+ params.push("seen=" + encodeURIComponent(id + "|" + seen[id]));
1282
+ }
1283
+ fetch("/api/unseen" + (params.length ? "?" + params.join("&") : ""), { cache: "no-store", headers: { Accept: "application/json" } })
1284
+ .then(function (response) { return response.ok ? response.json() : null; })
1285
+ .then(function (data) {
1286
+ if (!data) return;
1287
+ var counts = {};
1288
+ var jobs = data.jobs || [];
1289
+ for (var i = 0; i < jobs.length; i++) counts[jobs[i].jobId] = jobs[i].count;
1290
+ var nodes = document.querySelectorAll("[data-unseen-for]");
1291
+ for (var n = 0; n < nodes.length; n++) paintCount(nodes[n], counts[nodes[n].getAttribute("data-unseen-for")] || 0);
1292
+ paintCount(document.getElementById("inbox-unseen"), data.inbox || 0);
1293
+ })
1294
+ .catch(function () { /* the list still works without the badge */ });
1295
+ }
1296
+
1297
+ function markLooking() {
1298
+ var id = body.getAttribute("data-job");
1299
+ var latest = body.getAttribute("data-latest");
1300
+ if (!id || !latest) return;
1301
+ var seen = readSeen();
1302
+ seen[id] = latest;
1303
+ writeSeen(seen);
1304
+ }
1305
+
1240
1306
  showFresh();
1241
1307
  renderCompact();
1242
1308
  notifyLabel();
1243
1309
  applyRepo();
1244
1310
  stamp(true);
1311
+ paintUnseen();
1312
+ markLooking();
1313
+ if (document.getElementById("settings-form")) loadSettings();
1245
1314
  try {
1246
1315
  var open = localStorage.getItem("kiln-drawer");
1247
1316
  if (open) openJob(open);