Skip to content

Commit

Permalink
work to textual tree view of FEMA sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
VashJuan committed Sep 29, 2024
1 parent 4d7d2a0 commit 8b0216e
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 121 deletions.
2 changes: 1 addition & 1 deletion content/english/resources2/2024/fema-sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<iframe title="FEMA.gov Sitemap" src="https://share.octopus.do/embed/aq1k7kiqjrs" class="relative border-4 h-[60vh] ml-[calc(50%-45vw)] w-[90vw]"></iframe>
<iframe title="FEMA.gov Sitemap" src="https://share.octopus.do/embed/aq1k7kiqjrs" class="border-4 h-[60vh] ml-[calc(50%-45vw)] w-[90vw]"></iframe>

### FEMA.gov Sitemap Textualized

Expand Down
5 changes: 5 additions & 0 deletions themes/eoconline/layouts/OrgChart/arc-tree.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
</div>
</div>

<label
>Select a JSON file to view:
<input type="file" onChange="fileChange(this.files[0])" />
</label>

<ul id="JSONunorderedList"></ul>

<ul class="tree">
Expand Down
136 changes: 16 additions & 120 deletions themes/eoconline/layouts/OrgChart/arc-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,128 +44,9 @@ function collapseTree() {
console.log("Collapsed all " + checkboxes.length + " nodes.");
}

/*
window.onload = () => {
createList(data);
markupArray.push("</ul>");
$("#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) {
Expand Down Expand Up @@ -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')));
}
131 changes: 131 additions & 0 deletions themes/eoconline/layouts/OrgChart/other.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
window.onload = () => {
createList(data);
markupArray.push("</ul>");
$("#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
20 changes: 20 additions & 0 deletions themes/eoconline/layouts/OrgChart/sample.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 8b0216e

Please sign in to comment.