forked from ubiquity-os/ubiquity-os-plugin-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-manifest.js
80 lines (67 loc) · 2.79 KB
/
render-manifest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const manifestGui = document.querySelector(`#manifest-gui`);
const manifestGuiBody = document.querySelector(`#manifest-gui-body`);
(function renderManifest() {
manifestGui?.classList.add("rendering");
const decodedManifest = window.decodedManifest;
const dfg = document.createDocumentFragment();
const _div = document.createElement("DIV");
const _nestedObject = document.createElement("pre");
// const _h3 = document.createElement("h3");
/**
* name": "Start | Stop",
description": "Assign or un-assign yourself from an issue.",
ubiquity:listeners": [
commands": {
*/
console.trace(decodedManifest)
const decodedManifestKeys = Object.keys(decodedManifest);
let x = -1;
const limit = decodedManifestKeys.length;
// const buffer = [];
const _tableRow = document.createElement("tr");
const _tableDataHeader = document.createElement("td");
_tableDataHeader.className = "table-data-header";
const _tableDataValue = document.createElement("td");
_tableDataValue.className = "table-data-value";
_tableRow.appendChild(_tableDataHeader);
_tableRow.appendChild(_tableDataValue);
console.trace(_tableRow);
while (++x < limit) {
const tableRow = _tableRow.cloneNode(true);
const key = decodedManifestKeys[x];
tableRow.id = key;
let rawValue = decodedManifest[key];
let isString = true;
if (typeof rawValue != "string") {
const prettified = JSON.stringify(decodedManifest[key], null, 2);
let humanize = prettified.replace(/\{|\}|\[|\]/igm, ``);
humanize = humanize.replace(/ubiquity:/igm, ``);
humanize = humanize.replace(/": "/igm, ` ➡️ `);
humanize = humanize.replace(/",?$/igm, ``);
humanize = humanize.replace(/^\s\s\s\s"/igm, ` `);
humanize = humanize.replace(/^\s\s"/igm, ` `);
humanize = humanize.replace(/":/igm, ``);
humanize = humanize.replace(/^\s\s,/igm, ``);
rawValue = humanize;
isString = false;
}
const valueParsed = rawValue;
const keyDiv = _div.cloneNode();
keyDiv.textContent = key.replace("ubiquity:", "");;
// h3.id = `key-${key}`;
const valueDiv = _div.cloneNode();
if (isString) {
valueDiv.textContent = valueParsed;
} else {
const nestedObject = _nestedObject.cloneNode();
nestedObject.textContent = valueParsed;
valueDiv.appendChild(nestedObject);
}
// div.id = `value-${key}`;
tableRow.children[0].appendChild(keyDiv);
tableRow.children[1].appendChild(valueDiv);
dfg.appendChild(tableRow);
}
manifestGuiBody.appendChild(dfg);
manifestGui?.classList.add("rendered");
})();