Debian Codegraph @

pkg/playground/index.js

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 import '../lib/patternfly/patternfly-6-cockpit.scss';
3 import "../../node_modules/@patternfly/patternfly/components/Button/button.css";
4 import 'cockpit-dark-theme'; // once per page
5 import cockpit from "cockpit";
6 import { page_status } from "notifications";
7
8 import "../lib/page.scss";
9
10 function id(sel) {
11 return document.getElementById(sel);
12 }
13
14 function init() {
15 const entries = cockpit.manifests.playground.playground;
16 cockpit.assert(typeof entries === "object", "Invalid playground manifest");
17 const nav = id("nav");
18
19 for (const p in entries) {
20 const entry = entries[p];
21 const li = document.createElement("li");
22 const a = document.createElement("a");
23 li.appendChild(a);
24 a.appendChild(document.createTextNode(entry.label || p));
25 a.onclick = () => { cockpit.jump("/playground/" + (entry.path || p)) };
26 nav.appendChild(li);
27 }
28
29 id("set-status").onclick = event => {
30 page_status.set_own({ type: id("type").value, title: id("title").value });
31 };
32
33 id("clear-status").onclick = event => {
34 page_status.set_own(null);
35 };
36 }
37
38 document.addEventListener("DOMContentLoaded", () => {
39 cockpit.transport.wait(init);
40 });