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.
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
(function (app) {
|
|
'use strict';
|
|
|
|
const dom = app.dom;
|
|
const json = app.json;
|
|
const state = app.state;
|
|
|
|
function computePublishedState() {
|
|
const data = json.parse();
|
|
const digest = (data.envelope && data.envelope.digest) || '';
|
|
state.published = !!digest;
|
|
return state.published;
|
|
}
|
|
|
|
function setMode(mode) {
|
|
if (mode !== 'edit' && mode !== 'view') {
|
|
return;
|
|
}
|
|
if (state.published && mode === 'edit') {
|
|
mode = 'view';
|
|
}
|
|
state.mode = mode;
|
|
}
|
|
|
|
var _previousMode = state.mode;
|
|
|
|
function refresh() {
|
|
const wasPublished = state.published;
|
|
const nowPublished = computePublishedState();
|
|
if (nowPublished && !wasPublished) {
|
|
state.mode = 'view';
|
|
}
|
|
// Re-render file table only when mode actually changes (edit↔view)
|
|
if (state.mode !== _previousMode) {
|
|
_previousMode = state.mode;
|
|
if (app.modules.files && typeof app.modules.files.render === 'function') {
|
|
app.modules.files.render();
|
|
}
|
|
}
|
|
if (app.modules.files && app.modules.files.updateToolbars) {
|
|
app.modules.files.updateToolbars();
|
|
}
|
|
}
|
|
|
|
app.modules.mode = {
|
|
setMode,
|
|
refresh
|
|
};
|
|
|
|
app.registerInit(function () {
|
|
computePublishedState();
|
|
if (state.published) {
|
|
state.mode = 'view';
|
|
} else {
|
|
state.mode = 'edit';
|
|
}
|
|
});
|
|
})(window.transmittalApp);
|