Spaces:
Running
<!doctype html>
Browse files<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Location Plans β Dependency Graph</title>
<style>
:root { --bg:#0f1216; --fg:#e8eef6; --muted:#9fb0c7; --accent:#66d9ef; --ok:#42d392; --warn:#ffcc66; --block:#ff6b6b; --chip:#2a3140; }
body { margin:0; background:var(--bg); color:var(--fg); font:14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Inter, Helvetica, Arial, sans-serif; }
header { display:flex; gap:.75rem; align-items:center; padding:12px 16px; border-bottom:1px solid #1c2330; position:sticky; top:0; background:linear-gradient(180deg,var(--bg),rgba(15,18,22,.85)); backdrop-filter: blur(6px);}
h1 { font-size:16px; margin:0; letter-spacing:.2px; }
.pill { padding:6px 10px; border-radius:999px; background:var(--chip); color:var(--fg); border:1px solid #273043; cursor:pointer; }
.pill.active { outline:2px solid var(--accent); }
#container { display:grid; grid-template-columns: 320px 1fr; min-height: calc(100vh - 52px); }
#sidebar { border-right:1px solid #1c2330; padding:12px; overflow:auto; }
#graph { position:relative; }
#graph svg { width:100%; height: calc(100vh - 52px); background: radial-gradient(1200px 800px at 30% 20%, #121826 0%, #0f1216 60%); }
.legend { display:flex; gap:.5rem; flex-wrap:wrap; margin:.5rem 0 1rem; }
.chip { display:inline-flex; align-items:center; gap:.4rem; background:#1b2232; border:1px solid #273043; padding:4px 8px; border-radius:8px; color:var(--muted); }
.swatch { width:10px; height:10px; border-radius:2px; display:inline-block;}
.node rect { rx:8; ry:8; }
.node .title { font-weight:600; }
.node.doNext rect { fill:#0a2a22; stroke:#1f6f57; }
.node.blocked rect { fill:#2a1212; stroke:#8a2b2b; }
.node.normal rect { fill:#182235; stroke:#2b3b57; }
.node:hover rect { stroke-width:2; }
.edgePath path { stroke:#51607a; stroke-width:1.5; }
.edgePath.marker path { marker-end: url(#arrow); }
.section { margin:12px 0; }
.card { background:#111827; border:1px solid #273043; padding:10px; border-radius:12px; margin-bottom:10px; }
.card h3 { margin:0 0 6px; font-size:14px; }
.small { color:var(--muted); font-size:12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
</style>
</head>
<body>
<header>
<h1>Location One / Two / Three β Dependency Graph</h1>
<button class="pill active" data-filter="all">All</button>
<button class="pill" data-filter="doNext">Do-Next</button>
<button class="pill" data-filter="blocked">Blocked</button>
</header>
<div id="container">
<aside id="sidebar">
<div class="section">
<div class="legend">
<span class="chip"><span class="swatch" style="background:#0a2a22"></span> Do-Next</span>
<span class="chip"><span class="swatch" style="background:#2a1212"></span> Blocked</span>
<span class="chip"><span class="swatch" style="background:#182235"></span> Normal</span>
</div>
</div>
<div id="details" class="card">
<h3>Details</h3>
<div class="small">Click a node to see full text and prerequisites.</div>
<div id="detailBody" class="small" style="margin-top:8px"></div>
</div>
<div class="card">
<h3>How to edit</h3>
<div class="small">Open this file and modify the <span class="mono">tasks</span> and <span class="mono">deps</span> arrays. Use <span class="mono">status: "doNext" | "blocked" | "normal"</span> and <span class="mono">location</span> / <span class="mono">section</span> for grouping.</div>
</div>
</aside>
<main id="graph">
<svg id="svg">
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#51607a"></path>
</marker>
</defs>
<g id="zoom"><g id="g"></g></g>
</svg>
</main>
</div>
<!-- D3 and dagre-d3 -->
<script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/graphlib@2.1.8/dist/graphlib.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dagre-d3@0.6.4/dist/dagre-d3.min.js"></script>
<script>
/** ========= DATA =========
* Minimal, curated to keep the demo lean. Add more tasks/edges as needed.
* id: unique key
* label: short title (shown on node)
* full: long text (sidebar)
* location/section: grouping tags (not used for layout, but useful for filtering/search later)
* status: "doNext" | "blocked" | "normal"
*/
const tasks = [
// Location One β Routine / Immediate
{id:"greaseGarage", label:"Grease garage door", full:"Grease garage door tracks and wheels", location:"House", section:"Exterior", status:"doNext"},
{id:"mowHouse", label:"Mow lawn (House)", full:"Mow lawn twice weekly until dormant", location:"House", section:"Exterior", status:"doNext"},
{id:"weedHouse", label:"Weed control (House)", full:"Maintain weed control around the house", location:"House", section:"Exterior", status:"doNext"},
{id:"catLitter", label:"Refresh cat litter", full:"Refresh cat litter (weekly)", location:"House", section:"Upkeep", status:"doNext"},
{id:"trashHouse", label:"Take out trash (House)", full:"Take out trash (weekly)", location:"House", section:"Upkeep", status:"doNext"},
{id:"basementElecMap", label:"Map basement electrical", full:"Map electrical plan for basement", location:"House", section:"Electrical", status:"doNext"},
{id:"basementElecList", label:"Basement elec BOM", full:"Create list of tools, parts, and materials for basement electric", location:"House", section:"Electrical", status:"doNext"},
{id:"drainMap", label:"Map backyard drainage", full:"Map backyard layout for drainage system", location:"House", section:"Drainage", status:"doNext"},
{id:"drainList", label:"Drainage BOM", full:"Create list of tools, parts, and materials for drainage & grading", location:"House", section:"Drainage", status:"doNext"},
{id:"porchMap", label:"Map screened porch", full:"Map future screened porch & under-deck space", location:"House", section:"Porch/Deck", status:"doNext"},
{id:"porchList", label:"Porch/Deck BOM", full:"List tools/materials for drainage, leveling, retaining walls, steps, landing, walkway", location:"House", section:"Porch/Deck", status:"doNext"},
{id:"seedBluegrass", label:"Seed Kentucky bluegrass", full:"Grow new Kentucky bluegrass", location:"House", section:"Yard", status:"doNext"},
{id:"secureLANHouse", label:"Secure LAN (House)", full:"Secure LAN across the property (House)", location:"House", section:"Network", status:"doNext"},
{id:"inventoryDBHouse", label:"Inventory DB (House)", full:"Create database itemized inventory", location:"House", section:"Inventory", status:"doNext"},
{id:"moveGarageToBasement", label:"Move items to basement", full:"Move personal items from garage into basement", location:"House", section:"Storage", status:"doNext"},
{id:"buildBasementShelvesPersonal", label:"Build shelves (personal)", full:"Build shelving/storage in basement for personal items", location:"House", section:"Storage", status:"doNext"},
{id:"parkInside", label:"Park vehicles inside", full:"Start parking vehicles inside", location:"House", section:"Storage", status:"doNext"},
{id:"buildBasementShelvesFood", label:"Build shelves (food/essentials)", full:"Build shelving/storage for food supply & essentials", location:"House", section:"Storage", status:"doNext"},
{id:"buildBasementShelvesClothes", label:"Build shelves (clothes)", full:"Build shelving/storage for clothes", location:"House", section:"Storage", status:"doNext"},
// Structural / Dependencies (House)
{id:"planPowerRemoved", label:"Draft: Power Removed plan", full:"Power Is Removed β draft full breakdown before starting", location:"House", section:"Power", status:"normal"},
{id:"readyToReconnect", label:"Draft: Ready to Reconnect", full:"Ready To Reconnect Power β draft full breakdown before starting", location:"House", section:"Power", status:"normal"},
{id:"disconnectPower", label:"Disconnect Power", full:"Disconnect power (requires Ready-to-Reconnect plan)", location:"House", section:"Power", status:"blocked"},
{id:"westWallRemoved", label:"Remove West Wall", full:"West Wall is removed (requires power removed)", location:"House", section:"Structure", status:"blocked"},
{id:"cutTrees", label:"Cut down trees", full:"Cut down trees (requires power removed)", location:"House", section:"Site", status:"blocked"},
{id:"crawlFoundReplaced", label:"Replace crawl foundation (West)", full:"Crawl space style foundation is replaced", location:"House", section:"Foundation", status:"blocked"},
{id:"buildNewWestWall", label:"Build new West Wall", full:"Build new West Wall (after crawl foundation replaced)", location:"House", section:"Structure", status:"blocked"},
{id:"electricJobHappy", label:"Electric job 100% happy", full:"After Electric Job Is 100% Happy β prerequisite to reconnecting power", location:"House", section:"Power", status:"blocked"},
{id:"reconnectPower", label:"Reconnect Power", full:"Reconnect power after electric job is 100% happy", location:"House", section:"Power", status:"blocked"},
{id:"spidersDie", label:"Kill spiders", full:"Spiders all die before crawl-space jacking", location:"House", section:"Prep", status:"blocked"},
{id:"jackFromCrawl", label:"Jack house (crawl)", full:"Jack up house from crawl space (after spiders die)", location:"House", section:"Structure", status:"blocked"},
{id:"mikeAnswer", label:"Get roof height from Mike", full:"Mike tells you the roof height target", location:"House", section:"Structure", status:"doNext"},
{id:"knowRoofHeight", label:"Know roof target height", full:"Know how tall the roof is supposed to be", location:"House", section:"Structure", status:"blocked"},
{id:"confirmRoofHeight", label:"Confirm roof jacked correctly", full:"Confirm roof is jacked up to correct height", location:"House", section:"Structure", status:"blocked"},
{id:"girderLevel", label:"Verify girder level", full:"Foundation to girder perfectly level in every direction", location:"House", section:"Structure", status:"blocked
- README.md +7 -4
- index.html +273 -18
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji: π
|
| 4 |
colorFrom: green
|
| 5 |
-
colorTo:
|
|
|
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: TaskFlow Visualizer π
|
|
|
|
| 3 |
colorFrom: green
|
| 4 |
+
colorTo: blue
|
| 5 |
+
emoji: π³
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
|
@@ -1,19 +1,274 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>TaskFlow Visualizer</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/graphlib@2.1.8/dist/graphlib.min.js"></script>
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/dagre-d3@0.6.4/dist/dagre-d3.min.js"></script>
|
| 12 |
+
<style>
|
| 13 |
+
.node rect {
|
| 14 |
+
rx: 8;
|
| 15 |
+
ry: 8;
|
| 16 |
+
}
|
| 17 |
+
.node.doNext rect {
|
| 18 |
+
fill: #0a2a22;
|
| 19 |
+
stroke: #1f6f57;
|
| 20 |
+
}
|
| 21 |
+
.node.blocked rect {
|
| 22 |
+
fill: #2a1212;
|
| 23 |
+
stroke: #8a2b2b;
|
| 24 |
+
}
|
| 25 |
+
.node.normal rect {
|
| 26 |
+
fill: #182235;
|
| 27 |
+
stroke: #2b3b57;
|
| 28 |
+
}
|
| 29 |
+
.node:hover rect {
|
| 30 |
+
stroke-width: 2;
|
| 31 |
+
}
|
| 32 |
+
.edgePath path {
|
| 33 |
+
stroke: #51607a;
|
| 34 |
+
stroke-width: 1.5;
|
| 35 |
+
}
|
| 36 |
+
.edgePath.marker path {
|
| 37 |
+
marker-end: url(#arrow);
|
| 38 |
+
}
|
| 39 |
+
.swatch {
|
| 40 |
+
width: 10px;
|
| 41 |
+
height: 10px;
|
| 42 |
+
border-radius: 2px;
|
| 43 |
+
display: inline-block;
|
| 44 |
+
}
|
| 45 |
+
</style>
|
| 46 |
+
</head>
|
| 47 |
+
<body class="bg-gray-900 text-gray-100">
|
| 48 |
+
<header class="sticky top-0 z-10 bg-gray-900/90 backdrop-blur-sm border-b border-gray-800 px-6 py-4 flex items-center justify-between">
|
| 49 |
+
<div class="flex items-center gap-4">
|
| 50 |
+
<h1 class="text-xl font-bold">TaskFlow Visualizer</h1>
|
| 51 |
+
<span class="text-sm bg-gray-800 px-3 py-1 rounded-full">v1.0</span>
|
| 52 |
+
</div>
|
| 53 |
+
<div class="flex gap-2">
|
| 54 |
+
<button id="exportBtn" class="flex items-center gap-2 bg-gray-800 hover:bg-gray-700 px-4 py-2 rounded-full text-sm transition-colors">
|
| 55 |
+
<i data-feather="download"></i>
|
| 56 |
+
Export
|
| 57 |
+
</button>
|
| 58 |
+
<button id="helpBtn" class="flex items-center gap-2 bg-blue-600 hover:bg-blue-500 px-4 py-2 rounded-full text-sm transition-colors">
|
| 59 |
+
<i data-feather="help-circle"></i>
|
| 60 |
+
Help
|
| 61 |
+
</button>
|
| 62 |
+
</div>
|
| 63 |
+
</header>
|
| 64 |
+
|
| 65 |
+
<div class="flex h-[calc(100vh-68px)]">
|
| 66 |
+
<!-- Sidebar -->
|
| 67 |
+
<aside class="w-80 border-r border-gray-800 p-4 overflow-y-auto">
|
| 68 |
+
<div class="mb-6">
|
| 69 |
+
<div class="flex gap-2 mb-4">
|
| 70 |
+
<button class="filter-btn active px-4 py-2 rounded-full bg-gray-800 text-sm" data-filter="all">All Tasks</button>
|
| 71 |
+
<button class="filter-btn px-4 py-2 rounded-full bg-gray-800 text-sm" data-filter="doNext">Do Next</button>
|
| 72 |
+
<button class="filter-btn px-4 py-2 rounded-full bg-gray-800 text-sm" data-filter="blocked">Blocked</button>
|
| 73 |
+
</div>
|
| 74 |
+
<div class="flex flex-wrap gap-2 mb-6">
|
| 75 |
+
<span class="chip px-3 py-1 rounded-full text-xs flex items-center gap-2 bg-gray-800">
|
| 76 |
+
<span class="swatch bg-green-800"></span>
|
| 77 |
+
Do-Next
|
| 78 |
+
</span>
|
| 79 |
+
<span class="chip px-3 py-1 rounded-full text-xs flex items-center gap-2 bg-gray-800">
|
| 80 |
+
<span class="swatch bg-red-800"></span>
|
| 81 |
+
Blocked
|
| 82 |
+
</span>
|
| 83 |
+
<span class="chip px-3 py-1 rounded-full text-xs flex items-center gap-2 bg-gray-800">
|
| 84 |
+
<span class="swatch bg-blue-800"></span>
|
| 85 |
+
Normal
|
| 86 |
+
</span>
|
| 87 |
+
</div>
|
| 88 |
+
<div class="relative">
|
| 89 |
+
<i data-feather="search" class="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-500" width="16"></i>
|
| 90 |
+
<input type="text" placeholder="Search tasks..." class="w-full bg-gray-800 border border-gray-700 rounded-lg pl-10 pr-4 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
<div class="bg-gray-800 rounded-xl p-4 mb-4">
|
| 95 |
+
<h3 class="font-medium mb-2">Task Details</h3>
|
| 96 |
+
<div id="detailBody" class="text-sm text-gray-400">
|
| 97 |
+
Select a task to view details
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
|
| 101 |
+
<div class="bg-gray-800 rounded-xl p-4">
|
| 102 |
+
<h3 class="font-medium mb-2">Quick Actions</h3>
|
| 103 |
+
<button class="w-full flex items-center gap-2 text-sm bg-gray-700 hover:bg-gray-600 px-3 py-2 rounded-lg mb-2 transition-colors">
|
| 104 |
+
<i data-feather="plus" width="16"></i>
|
| 105 |
+
Add New Task
|
| 106 |
+
</button>
|
| 107 |
+
<button class="w-full flex items-center gap-2 text-sm bg-gray-700 hover:bg-gray-600 px-3 py-2 rounded-lg transition-colors">
|
| 108 |
+
<i data-feather="link" width="16"></i>
|
| 109 |
+
Create Dependency
|
| 110 |
+
</button>
|
| 111 |
+
</div>
|
| 112 |
+
</aside>
|
| 113 |
+
|
| 114 |
+
<!-- Main Graph Area -->
|
| 115 |
+
<main class="flex-1 relative">
|
| 116 |
+
<svg id="graph" class="w-full h-full">
|
| 117 |
+
<defs>
|
| 118 |
+
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
|
| 119 |
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#51607a"></path>
|
| 120 |
+
</marker>
|
| 121 |
+
</defs>
|
| 122 |
+
<g id="zoom"><g id="g"></g></g>
|
| 123 |
+
</svg>
|
| 124 |
+
<div class="absolute bottom-4 right-4 flex gap-2">
|
| 125 |
+
<button id="zoomIn" class="p-2 bg-gray-800 rounded-lg hover:bg-gray-700">
|
| 126 |
+
<i data-feather="plus" width="16"></i>
|
| 127 |
+
</button>
|
| 128 |
+
<button id="zoomOut" class="p-2 bg-gray-800 rounded-lg hover:bg-gray-700">
|
| 129 |
+
<i data-feather="minus" width="16"></i>
|
| 130 |
+
</button>
|
| 131 |
+
<button id="fitView" class="p-2 bg-gray-800 rounded-lg hover:bg-gray-700">
|
| 132 |
+
<i data-feather="maximize" width="16"></i>
|
| 133 |
+
</button>
|
| 134 |
+
</div>
|
| 135 |
+
</main>
|
| 136 |
+
</div>
|
| 137 |
+
|
| 138 |
+
<script>
|
| 139 |
+
// Initialize Feather Icons
|
| 140 |
+
feather.replace();
|
| 141 |
+
|
| 142 |
+
// Sample data (same as provided in original code)
|
| 143 |
+
const tasks = [
|
| 144 |
+
// Sample tasks from original code...
|
| 145 |
+
];
|
| 146 |
+
|
| 147 |
+
const deps = [
|
| 148 |
+
// Sample dependencies from original code...
|
| 149 |
+
];
|
| 150 |
+
|
| 151 |
+
// Graph initialization
|
| 152 |
+
const g = new dagreD3.graphlib.Graph()
|
| 153 |
+
.setGraph({ rankdir: "LR", nodesep: 25, ranksep: 55, marginx: 20, marginy: 20 })
|
| 154 |
+
.setDefaultEdgeLabel(() => ({}));
|
| 155 |
+
|
| 156 |
+
function nodeStyle(d) {
|
| 157 |
+
return d.status === "doNext" ? "doNext" : (d.status === "blocked" ? "blocked" : "normal");
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
function build(filter = "all") {
|
| 161 |
+
g.nodes().forEach(v => g.removeNode(v));
|
| 162 |
+
tasks.forEach(t => {
|
| 163 |
+
if (filter === "doNext" && t.status !== "doNext") return;
|
| 164 |
+
if (filter === "blocked" && t.status !== "blocked") return;
|
| 165 |
+
g.setNode(t.id, {
|
| 166 |
+
labelType: "html",
|
| 167 |
+
label: `
|
| 168 |
+
<div class="font-semibold text-sm">${escapeHTML(t.label)}</div>
|
| 169 |
+
<div class="text-xs text-gray-400">${escapeHTML(t.location)} β’ ${escapeHTML(t.section)}</div>
|
| 170 |
+
`,
|
| 171 |
+
class: `node ${nodeStyle(t)}`
|
| 172 |
+
});
|
| 173 |
+
});
|
| 174 |
+
deps.forEach(([a, b]) => {
|
| 175 |
+
if (!g.hasNode(a) || !g.hasNode(b)) return;
|
| 176 |
+
g.setEdge(a, b, { class: "edgePath marker" });
|
| 177 |
+
});
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
function escapeHTML(s) {
|
| 181 |
+
return s.replace(/[&<>'"]/g, c => ({'&':'&','<':'<','>':'>',"'":''','"':'"'}[c]));
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
const svg = d3.select("#graph");
|
| 185 |
+
const inner = d3.select("#g");
|
| 186 |
+
const render = new dagreD3.render();
|
| 187 |
+
|
| 188 |
+
function draw(filter = "all") {
|
| 189 |
+
build(filter);
|
| 190 |
+
inner.selectAll("*").remove();
|
| 191 |
+
render(inner, g);
|
| 192 |
+
|
| 193 |
+
const graphGroup = d3.select("#zoom");
|
| 194 |
+
const zoom = d3.zoom().on("zoom", (e) => {
|
| 195 |
+
graphGroup.attr("transform", e.transform);
|
| 196 |
+
});
|
| 197 |
+
svg.call(zoom);
|
| 198 |
+
|
| 199 |
+
const { width, height } = svg.node().getBoundingClientRect();
|
| 200 |
+
const graphWidth = g.graph().width || 800;
|
| 201 |
+
const graphHeight = g.graph().height || 600;
|
| 202 |
+
const scale = Math.min(1, Math.max(0.2, Math.min(width / (graphWidth + 80), height / (graphHeight + 80))));
|
| 203 |
+
const tx = (width - graphWidth * scale) / 2 + 20;
|
| 204 |
+
const ty = (height - graphHeight * scale) / 2;
|
| 205 |
+
|
| 206 |
+
svg.transition().duration(400).call(
|
| 207 |
+
zoom.transform,
|
| 208 |
+
d3.zoomIdentity.translate(tx, ty).scale(scale)
|
| 209 |
+
);
|
| 210 |
+
|
| 211 |
+
inner.selectAll("g.node").on("click", (_, id) => {
|
| 212 |
+
const t = tasks.find(x => x.id === id);
|
| 213 |
+
const prereqs = deps.filter(([a, b]) => b === id)
|
| 214 |
+
.map(([a]) => tasks.find(x => x.id === a)?.label || a);
|
| 215 |
+
const dependents = deps.filter(([a, b]) => a === id)
|
| 216 |
+
.map(([, b]) => tasks.find(x => x.id === b)?.label || b);
|
| 217 |
+
|
| 218 |
+
const body = `
|
| 219 |
+
<div class="font-semibold mb-2">${escapeHTML(t.label)}</div>
|
| 220 |
+
<div class="text-sm text-gray-300 mb-2">${escapeHTML(t.full)}</div>
|
| 221 |
+
<div class="text-xs text-gray-500 mb-3">
|
| 222 |
+
<span class="inline-block bg-gray-700 rounded px-2 py-1 mr-2">${escapeHTML(t.location)}</span>
|
| 223 |
+
<span class="inline-block bg-gray-700 rounded px-2 py-1">${escapeHTML(t.section)}</span>
|
| 224 |
+
</div>
|
| 225 |
+
<div class="text-xs mb-2"><span class="text-gray-500">Status:</span> <span class="font-medium ${t.status === 'doNext' ? 'text-green-400' : t.status === 'blocked' ? 'text-red-400' : 'text-blue-400'}">${t.status}</span></div>
|
| 226 |
+
<div class="text-xs mb-1"><span class="text-gray-500">Prerequisites:</span> ${prereqs.length ? prereqs.map(escapeHTML).join(", ") : "None"}</div>
|
| 227 |
+
<div class="text-xs"><span class="text-gray-500">Unblocks:</span> ${dependents.length ? dependents.map(escapeHTML).join(", ") : "β"}</div>
|
| 228 |
+
`;
|
| 229 |
+
document.querySelector("#detailBody").innerHTML = body;
|
| 230 |
+
});
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
// Initial draw
|
| 234 |
+
draw();
|
| 235 |
+
|
| 236 |
+
// Filter buttons
|
| 237 |
+
document.querySelectorAll(".filter-btn").forEach(btn => {
|
| 238 |
+
btn.addEventListener("click", () => {
|
| 239 |
+
document.querySelectorAll(".filter-btn").forEach(b => b.classList.remove("active"));
|
| 240 |
+
btn.classList.add("active");
|
| 241 |
+
draw(btn.dataset.filter);
|
| 242 |
+
});
|
| 243 |
+
});
|
| 244 |
+
|
| 245 |
+
// Zoom controls
|
| 246 |
+
const zoom = d3.zoom().scaleExtent([0.1, 3]).on("zoom", (event) => {
|
| 247 |
+
d3.select("#zoom").attr("transform", event.transform);
|
| 248 |
+
});
|
| 249 |
+
svg.call(zoom);
|
| 250 |
+
|
| 251 |
+
document.getElementById("zoomIn").addEventListener("click", () => {
|
| 252 |
+
svg.transition().call(zoom.scaleBy, 1.2);
|
| 253 |
+
});
|
| 254 |
+
|
| 255 |
+
document.getElementById("zoomOut").addEventListener("click", () => {
|
| 256 |
+
svg.transition().call(zoom.scaleBy, 0.8);
|
| 257 |
+
});
|
| 258 |
+
|
| 259 |
+
document.getElementById("fitView").addEventListener("click", () => {
|
| 260 |
+
const { width, height } = svg.node().getBoundingClientRect();
|
| 261 |
+
const graphWidth = g.graph().width || 800;
|
| 262 |
+
const graphHeight = g.graph().height || 600;
|
| 263 |
+
const scale = Math.min(1, Math.max(0.2, Math.min(width / (graphWidth + 80), height / (graphHeight + 80))));
|
| 264 |
+
const tx = (width - graphWidth * scale) / 2 + 20;
|
| 265 |
+
const ty = (height - graphHeight * scale) / 2;
|
| 266 |
+
|
| 267 |
+
svg.transition().duration(400).call(
|
| 268 |
+
zoom.transform,
|
| 269 |
+
d3.zoomIdentity.translate(tx, ty).scale(scale)
|
| 270 |
+
);
|
| 271 |
+
});
|
| 272 |
+
</script>
|
| 273 |
+
</body>
|
| 274 |
</html>
|