ZDDC — Zero Day Document Control. A file-naming convention plus five single-file HTML tools (archive, transmittal, classifier, mdedit, landing) and an optional Go HTTP server (zddc-server) with ACL and a virtual archive index. Self-contained, offline-capable, dependency-free. See README.md for an overview, AGENTS.md and ARCHITECTURE.md for the build/release/architecture detail, bootstrap/README.md for the two-level deployment install pattern, and zddc/README.md for the HTTP server.
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
(function (app) {
|
|
'use strict';
|
|
|
|
const json = app.json = app.json || {};
|
|
|
|
const SCRIPT_ID = 'transmittal-data';
|
|
|
|
json.getScriptElement = function getScriptElement() {
|
|
return document.getElementById(SCRIPT_ID);
|
|
};
|
|
|
|
json.getRawText = function getRawText() {
|
|
const el = json.getScriptElement();
|
|
return el && typeof el.textContent === 'string' ? el.textContent : '';
|
|
};
|
|
|
|
json.setData = function setData(obj) {
|
|
const el = json.getScriptElement();
|
|
if (!el) {
|
|
return;
|
|
}
|
|
try {
|
|
el.textContent = JSON.stringify(obj, null, 2);
|
|
} catch (err) {
|
|
console.error('[transmittal] failed to serialize JSON', err);
|
|
}
|
|
};
|
|
|
|
json.parse = function parse() {
|
|
try {
|
|
const raw = json.getRawText();
|
|
if (raw && raw.trim().length) {
|
|
return JSON.parse(raw);
|
|
}
|
|
} catch (err) {
|
|
console.error('[transmittal] failed to parse JSON store', err);
|
|
}
|
|
return app.util.createEmptyData('');
|
|
};
|
|
})(window.transmittalApp);
|