-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupernav.js
More file actions
140 lines (127 loc) · 5.1 KB
/
Copy pathsupernav.js
File metadata and controls
140 lines (127 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* AgentTrust super-navigation — injected into all agentrust-io.com properties */
(function () {
'use strict';
var SITES = [
{ id: 'home', label: 'agentrust-io', url: 'https://agentrust-io.com', dot: '#B91C1C', ext: false },
{ id: 'trace', label: 'TRACE', url: 'https://trace.agentrust-io.com', dot: '#1B5EA0', ext: false },
{ id: 'manifest', label: 'Manifest', url: 'https://manifest.agentrust-io.com', dot: '#1B7A4A', ext: false },
{ id: 'cmcp', label: 'cMCP', url: 'https://cmcp.agentrust-io.com', dot: '#6D28D9', ext: false },
{ id: 'governance', label: 'Governance', url: 'https://governance.agentrust-io.com', dot: '#EA580C', ext: false },
{ id: 'agt', label: 'AGT', url: 'https://github.com/microsoft/agent-governance-toolkit', dot: '#6B7F94', ext: true },
{ id: 'github', label: 'GitHub', url: 'https://github.com/agentrust-io', dot: '#8B949E', ext: true }
];
var HOST = location.hostname;
var CURRENT_ID = HOST === 'agentrust-io.com' ? 'home'
: HOST.indexOf('trace.') === 0 ? 'trace'
: HOST.indexOf('manifest.') === 0 ? 'manifest'
: HOST.indexOf('cmcp.') === 0 ? 'cmcp'
: HOST.indexOf('governance.') === 0 ? 'governance'
: HOST.indexOf('tests.') === 0 ? 'trace'
: 'home';
var NAV_ID = 'agt-supernav';
var STYLE_ID = 'agt-supernav-style';
var CSS = [
'#' + NAV_ID + '{',
' background:#15294B;',
' border-bottom:2px solid #B91C1C;',
' height:36px;',
' display:flex;',
' align-items:center;',
' padding:0 12px;',
' overflow-x:auto;',
' overflow-y:hidden;',
' white-space:nowrap;',
' position:relative;',
' z-index:10000;',
' font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;',
' font-size:11.5px;',
' gap:0;',
' scrollbar-width:none;',
'}',
'#' + NAV_ID + '::-webkit-scrollbar{display:none}',
'#' + NAV_ID + ' a{',
' display:inline-flex;',
' align-items:center;',
' gap:5px;',
' padding:0 11px;',
' height:36px;',
' color:rgba(255,255,255,0.58);',
' text-decoration:none;',
' font-weight:400;',
' letter-spacing:0.01em;',
' border-bottom:2px solid transparent;',
' transition:color .12s,border-color .12s;',
' flex-shrink:0;',
'}',
'#' + NAV_ID + ' a:hover{color:#fff}',
'#' + NAV_ID + ' a.active{color:#fff;font-weight:600;border-bottom-color:#B91C1C}',
'#' + NAV_ID + ' .dot{',
' width:6px;height:6px;border-radius:50%;flex-shrink:0;display:inline-block;',
'}',
'#' + NAV_ID + ' .sep{',
' width:1px;height:16px;background:rgba(255,255,255,0.1);flex-shrink:0;',
'}',
'#' + NAV_ID + ' .ext-icon{',
' opacity:.45;font-size:9px;line-height:1;',
'}'
].join('\n');
function buildNav() {
var div = document.createElement('div');
div.id = NAV_ID;
var html = '';
SITES.forEach(function (s, i) {
if (i === SITES.length - 2) {
html += '<span class="sep"></span>';
}
var active = s.id === CURRENT_ID ? ' class="active"' : '';
var target = s.ext ? ' target="_blank" rel="noopener noreferrer"' : '';
var extIcon = s.ext ? '<span class="ext-icon">↗</span>' : '';
html += '<a href="' + s.url + '"' + active + target + '>'
+ '<span class="dot" style="background:' + s.dot + '"></span>'
+ s.label
+ extIcon
+ '</a>';
});
div.innerHTML = html;
return div;
}
function injectStyles() {
if (document.getElementById(STYLE_ID)) return;
var style = document.createElement('style');
style.id = STYLE_ID;
style.textContent = CSS;
document.head.appendChild(style);
}
function injectNav() {
if (document.getElementById(NAV_ID)) return;
injectStyles();
var nav = buildNav();
// Insert at very top of body, before everything
document.body.insertBefore(nav, document.body.firstChild);
}
// Initial injection
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', injectNav);
} else {
injectNav();
}
// Material for MkDocs instant navigation — document$ fires on every page swap
// Guard: only subscribe if the observable exists (it's set synchronously in Material's bundle)
function subscribeMaterial() {
if (typeof window.document$ !== 'undefined' && typeof window.document$.subscribe === 'function') {
window.document$.subscribe(function () {
// After a content swap the nav div is still in DOM (header/body persists),
// but guard in case Material ever removes it.
if (!document.getElementById(NAV_ID)) {
injectNav();
}
});
}
}
// document$ may not be defined yet when this script runs; defer to after DOMContentLoaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', subscribeMaterial);
} else {
subscribeMaterial();
}
})();