From 8b0216e8406832e131e700806993b8598a4a83b6 Mon Sep 17 00:00:00 2001 From: JCornelison Date: Sun, 29 Sep 2024 09:32:06 -0700 Subject: [PATCH] work to textual tree view of FEMA sitemap --- .../english/resources2/2024/fema-sitemap.md | 2 +- .../eoconline/layouts/OrgChart/arc-tree.html | 5 + themes/eoconline/layouts/OrgChart/arc-tree.js | 136 +++--------------- themes/eoconline/layouts/OrgChart/other.json | 131 +++++++++++++++++ themes/eoconline/layouts/OrgChart/sample.json | 20 +++ 5 files changed, 173 insertions(+), 121 deletions(-) create mode 100644 themes/eoconline/layouts/OrgChart/other.json create mode 100644 themes/eoconline/layouts/OrgChart/sample.json diff --git a/content/english/resources2/2024/fema-sitemap.md b/content/english/resources2/2024/fema-sitemap.md index a790a55..2c72c8d 100644 --- a/content/english/resources2/2024/fema-sitemap.md +++ b/content/english/resources2/2024/fema-sitemap.md @@ -42,7 +42,7 @@ The FEMA site is mammoth, and like eating an elephant its best to proceed a bit - Zoom using the controls at the upper right, or using a scroll mouse wheel with the CTRL key held - Click on the arrow icon at the upper right of each block to go to that page - + ### FEMA.gov Sitemap Textualized diff --git a/themes/eoconline/layouts/OrgChart/arc-tree.html b/themes/eoconline/layouts/OrgChart/arc-tree.html index 5a64ae8..ffb88ab 100644 --- a/themes/eoconline/layouts/OrgChart/arc-tree.html +++ b/themes/eoconline/layouts/OrgChart/arc-tree.html @@ -36,6 +36,11 @@ + + "); - $("#list").html(markupArray.join("")); -}; -*/ +// {{ now.UnixNano }} to create a unique ID -/* - -https://ajv.js.org/guide/getting-started.html#basic-data-validation -https://www.npmjs.com/package/ajv - -// or ESM/TypeScript import -import Ajv from "ajv" -// Node.js require: -const Ajv = require("ajv") - -const ajv = new Ajv() // options can be passed, e.g. {allErrors: true} - -const schema = { - type: "object", - properties: { - foo: { type: "integer" }, - bar: { type: "string" }, - }, - required: ["foo"], - additionalProperties: false, -} - -const data = { - foo: 1, - bar: "abc", -} - -const validate = ajv.compile(schema) -const valid = validate(data) -if (!valid) console.log(validate.errors) - - -*/ - -dataSource = { - title: "", - url: "emergency-managers", - summary: "Emergency Managers", - children: [ - { title: "Tools for Practitioners", url: "emergency-managers/practitioners" }, - - ] -}; - -/* -Parent Page ID; -Page ID; -Page title; -Block title; -Block content; -Page link; -SEO title; -SEO slug; -SEO description; -SEO H1; -SEO additional -*/ - - - - -dataSource3 = { - id: 1, - name: "Lao Lao", - title: "general manager", - children: [ - { id: 2, name: "Bo Miao", title: "department manager" }, - { - id: 3, - name: "Su Miao", - title: "department manager", - children: [ - { id: 4, name: "Tie Hua", title: "senior engineer" }, - { - id: 5, - name: "Hei Hei", - title: "senior engineer", - children: [ - { id: 6, name: "Pang Pang", title: "engineer" }, - { id: 7, name: "Xiang Xiang", title: "UE engineer" }, - ], - }, - ], - }, - { id: 8, name: "Yu Jie", title: "department manager" }, - { id: 9, name: "Yu Li", title: "department manager" }, - { id: 10, name: "Hong Miao", title: "department manager" }, - { id: 11, name: "Yu Wei", title: "department manager" }, - { id: 12, name: "Yu Tie", title: "department manager" }, - ], -}; - -// See https://jsonlint.com/ for JSON formatting rules. - -// https://stackoverflow.com/questions/6692538/generate-unordered-list-from-json-data - -var jsonObj = { - "labels": [ - { - "labelFont": "35pt Calibri", - "labelLocation": { "x": 0.1483, "y": 0.75 }, - "labelText": "fluffer" - }, - { - "labelFont": "35pt Calibri", - "labelLocation": { "x": 0.666, "y": 0.666 }, - "labelText": "nutter" - } - ] -}; //some json to display - -var listEl = document.getElementById('JSONunorderedList'); -makeList(jsonObj, listEl); function makeList(jsonObject, listElement) { for (var i in jsonObject) { @@ -196,3 +77,18 @@ function makeList(jsonObject, listElement) { } } } + +async function readJSONFile(file) { + return new Promise((resolve, reject) => { + let fileReader = new FileReader(); + fileReader.onload = event => { + resolve(JSON.parse(event.target.result)) + }; + fileReader.onerror = (error => reject(error)); + fileReader.readAsText(file); + }); +} + +async function fileChange(file) { + readJSONFile(file).then(json => makeList(json, document.getElementById('JSONunorderedList'))); +} diff --git a/themes/eoconline/layouts/OrgChart/other.json b/themes/eoconline/layouts/OrgChart/other.json new file mode 100644 index 0000000..cb3ffab --- /dev/null +++ b/themes/eoconline/layouts/OrgChart/other.json @@ -0,0 +1,131 @@ +/* +window.onload = () => { + createList(data); + markupArray.push(""); + $("#list").html(markupArray.join("")); +}; +*/ +/* + +https://ajv.js.org/guide/getting-started.html#basic-data-validation +https://www.npmjs.com/package/ajv + +// or ESM/TypeScript import +import Ajv from "ajv" +// Node.js require: +const Ajv = require("ajv") + +const ajv = new Ajv() // options can be passed, e.g. {allErrors: true} + +const schema = { + type: "object", + properties: { + foo: { type: "integer" }, + bar: { type: "string" }, + }, + required: ["foo"], + additionalProperties: false, +} + +const data = { + foo: 1, + bar: "abc", +} + +const validate = ajv.compile(schema) +const valid = validate(data) +if (!valid) console.log(validate.errors) + + +*/ + +dataSource = { + title: "", + url: "emergency-managers", + summary: "Emergency Managers", + children: [ + { title: "Tools for Practitioners", url: "emergency-managers/practitioners" + }, + ] +}; + +/* +Parent Page ID; +Page ID; +Page title; +Block title; +Block content; +Page link; +SEO title; +SEO slug; +SEO description; +SEO H1; +SEO additional +*/ + + + + +dataSource3 = { + id: 1, + name: "Lao Lao", + title: "general manager", + children: [ + { id: 2, name: "Bo Miao", title: "department manager" + }, + { + id: 3, + name: "Su Miao", + title: "department manager", + children: [ + { id: 4, name: "Tie Hua", title: "senior engineer" + }, + { + id: 5, + name: "Hei Hei", + title: "senior engineer", + children: [ + { id: 6, name: "Pang Pang", title: "engineer" + }, + { id: 7, name: "Xiang Xiang", title: "UE engineer" + }, + ], + }, + ], + }, + { id: 8, name: "Yu Jie", title: "department manager" + }, + { id: 9, name: "Yu Li", title: "department manager" + }, + { id: 10, name: "Hong Miao", title: "department manager" + }, + { id: 11, name: "Yu Wei", title: "department manager" + }, + { id: 12, name: "Yu Tie", title: "department manager" + }, + ], +}; + +// See https://jsonlint.com/ for JSON formatting rules. +// https://stackoverflow.com/questions/6692538/generate-unordered-list-from-json-data + +var jsonObj = { + "labels": [ + { + "labelFont": "35pt Calibri", + "labelLocation": { + "x": 0.1483, + "y": 0.75 + }, + "labelText": "fluffer" + }, + { + "labelFont": "35pt Calibri", + "labelLocation": { + "x": 0.666, + "y": 0.666 + }, + "labelText": "nutter" + } + ] +}; //some json to display diff --git a/themes/eoconline/layouts/OrgChart/sample.json b/themes/eoconline/layouts/OrgChart/sample.json new file mode 100644 index 0000000..63c21e0 --- /dev/null +++ b/themes/eoconline/layouts/OrgChart/sample.json @@ -0,0 +1,20 @@ +{ + "labels": [ + { + "labelFont": "35pt Calibri", + "labelLocation": { + "x": 0.1483, + "y": 0.75 + }, + "labelText": "fluffer" + }, + { + "labelFont": "35pt Calibri", + "labelLocation": { + "x": 0.666, + "y": 0.666 + }, + "labelText": "nutter" + } + ] +} \ No newline at end of file