-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
292 lines (262 loc) · 13.4 KB
/
admin.html
File metadata and controls
292 lines (262 loc) · 13.4 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
if (location.hostname === 'dnoice.github.io') {
location.replace('https://ownership-decision-guide.vercel.app' + location.pathname.replace('/Ownership-Structure-Decision-Guide', '') + location.search + location.hash);
}
</script>
<title>Admin — Decision Scorecard | digiSpace</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=JetBrains+Mono:wght@400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/variables.css">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/layout.css">
<link rel="stylesheet" href="css/components.css">
<link rel="stylesheet" href="css/results.css">
<link rel="stylesheet" href="css/print.css">
<style>
.admin-container { max-width: 800px; margin: 0 auto; padding: 30px 20px; }
.admin-title { font-family: var(--font-display); font-size: 1.8rem; color: var(--navy); text-align: center; margin-bottom: 8px; }
.admin-sub { text-align: center; color: var(--slate); font-size: .9rem; margin-bottom: 24px; }
.code-inputs { display: flex; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.code-group { flex: 1; min-width: 280px; }
.code-group label { display: block; font-family: var(--font-display); font-weight: 700; color: var(--navy); margin-bottom: 6px; font-size: .9rem; }
.code-group input {
width: 100%; padding: 12px 16px; font-family: var(--font-mono); font-size: 1rem;
letter-spacing: 2px; border: 2px solid var(--divider); border-radius: 3px; outline: none;
text-transform: uppercase;
}
.code-group input:focus { border-color: var(--navy); }
.code-error { color: var(--red); font-size: .8rem; margin-top: 4px; min-height: 1.2em; }
.admin-actions { text-align: center; margin-bottom: 30px; }
.admin-lock { text-align: center; margin: 60px 0; }
.admin-lock-title { font-family: var(--font-display); font-size: 1.3rem; color: var(--navy); margin-bottom: 8px; }
.admin-lock-text { color: var(--slate); font-size: .9rem; margin-bottom: 20px; }
.admin-lock input {
padding: 12px 16px; font-family: var(--font-mono); font-size: 1.1rem;
letter-spacing: 1px; text-align: center;
border: 2px solid var(--divider); border-radius: 3px; outline: none; width: 280px;
}
.admin-lock input:focus { border-color: var(--navy); }
.admin-lock .code-error { display: block; margin-top: 8px; }
#admin-content { display: none; }
#admin-results { display: none; }
</style>
</head>
<body>
<header class="site-header">
<div class="header-inner">
<span class="brand">digiSpace</span>
<span class="header-sep">|</span>
<span class="header-ctx">Admin — Combined Scorecard</span>
<span class="header-sep">|</span>
<span class="header-for">Dennis Smaltz</span>
</div>
</header>
<div class="admin-container">
<!-- Admin Access Gate (server-side verification) -->
<div id="admin-gate" class="admin-lock">
<h2 class="admin-lock-title">Admin Access</h2>
<p class="admin-lock-text">Enter the admin code to view the combined scorecard.</p>
<input type="password" id="admin-code" placeholder="Admin code" autocomplete="off">
<p class="code-error" id="admin-gate-error"></p>
<div style="margin-top: 16px;">
<button class="btn btn-primary" id="btn-unlock">Unlock</button>
</div>
</div>
<!-- Admin Content (hidden until unlocked) -->
<div id="admin-content">
<h2 class="admin-title">Combined Decision Scorecard</h2>
<p class="admin-sub">Paste the result codes from each partner's submission email below.</p>
<div class="code-inputs">
<div class="code-group">
<label>Danny Barcelo's Result Code</label>
<input type="text" id="code-danny" placeholder="D...">
<p class="code-error" id="error-danny"></p>
</div>
<div class="code-group">
<label>Benny Rodriguez's Result Code</label>
<input type="text" id="code-benny" placeholder="B...">
<p class="code-error" id="error-benny"></p>
</div>
</div>
<div class="admin-actions">
<button class="btn btn-primary" id="btn-generate">Generate Combined Scorecard</button>
</div>
<div id="admin-results">
<div class="gold-rule"></div>
<div class="score-summary" id="admin-score-summary"></div>
<div id="admin-factor-breakdown"></div>
<div class="verdict-box" id="admin-verdict-box"></div>
<div class="results-actions" style="margin-top: 20px;">
<button class="btn btn-primary" onclick="window.print()">Print / Save PDF</button>
</div>
</div>
</div>
</div>
<footer class="site-footer">
<p class="footer-sig">︻デ═─── ✦ ✦ ✦ | Aim Twice, Shoot Once!</p>
<p class="footer-tag">Precision over Haste • Author: Dennis Smaltz</p>
</footer>
<script type="module">
import { QUESTIONS, FACTORS, FACTOR_INSIGHTS } from './js/config.js';
import { decodeResults, calculateScores, getFactorQuestionIndices, getConviction, getScoreBounds } from './js/scoring.js';
const fqMap = getFactorQuestionIndices();
// Server-side admin verification
document.getElementById("btn-unlock").addEventListener("click", unlockAdmin);
document.getElementById("admin-code").addEventListener("keydown", (e) => {
if (e.key === "Enter") unlockAdmin();
});
function unlockAdmin() {
const input = document.getElementById("admin-code");
const error = document.getElementById("admin-gate-error");
const btn = document.getElementById("btn-unlock");
btn.disabled = true;
btn.textContent = "Verifying…";
fetch("/api/verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ code: input.value.trim() }),
})
.then((r) => r.json())
.then((data) => {
btn.disabled = false;
btn.textContent = "Unlock";
if (data.valid) {
document.getElementById("admin-gate").style.display = "none";
document.getElementById("admin-content").style.display = "block";
} else {
error.textContent = "Incorrect admin code.";
input.value = "";
input.focus();
}
})
.catch(() => {
btn.disabled = false;
btn.textContent = "Unlock";
error.textContent = "Verification failed. Check your connection.";
});
}
// Generate scorecard from pasted result codes
document.getElementById("btn-generate").addEventListener("click", generateScorecard);
function generateScorecard() {
const dannyCode = document.getElementById("code-danny").value.trim().toUpperCase();
const bennyCode = document.getElementById("code-benny").value.trim().toUpperCase();
const errD = document.getElementById("error-danny");
const errB = document.getElementById("error-benny");
errD.textContent = "";
errB.textContent = "";
const dannyData = decodeResults(dannyCode);
const bennyData = decodeResults(bennyCode);
let hasError = false;
if (!dannyData || dannyData.partner !== "danny") {
errD.textContent = dannyCode ? "Invalid code. Must start with 'D' and contain 16 answer digits." : "Please enter Danny's result code.";
hasError = true;
}
if (!bennyData || bennyData.partner !== "benny") {
errB.textContent = bennyCode ? "Invalid code. Must start with 'B' and contain 16 answer digits." : "Please enter Benny's result code.";
hasError = true;
}
if (hasError) return;
const dannyScores = calculateScores(dannyData.answers);
const bennyScores = calculateScores(bennyData.answers);
const combined = { factorScores: new Array(FACTORS.length).fill(0), factorCounts: new Array(FACTORS.length).fill(0), normalized: [] };
FACTORS.forEach((_, i) => {
combined.factorScores[i] = dannyScores.factorScores[i] + bennyScores.factorScores[i];
combined.factorCounts[i] = dannyScores.factorCounts[i] + bennyScores.factorCounts[i];
});
const totalRaw = combined.factorScores.reduce((a, b) => a + b, 0);
combined.normalized = combined.factorScores.map((s, i) => {
return combined.factorCounts[i] === 0 ? 0 : s / (combined.factorCounts[i] * 2);
});
const bounds = getScoreBounds();
const maxPos = bounds.maxPositive * 2;
const maxNeg = Math.abs(bounds.maxNegative) * 2;
const fiftyPct = totalRaw > 0 ? Math.round(((totalRaw / maxPos) * 50) + 50) : totalRaw < 0 ? Math.round(50 - (Math.abs(totalRaw) / maxNeg) * 50) : 50;
const fiftyOnePct = 100 - fiftyPct;
// Score summary
document.getElementById("admin-score-summary").innerHTML = `
<div class="score-block fifty">
<div class="score-label">50/50 Split</div>
<div class="score-value">${fiftyPct}%</div>
<div class="score-unit">alignment</div>
</div>
<div class="score-block fifty-one">
<div class="score-label">51/49 Split</div>
<div class="score-value">${fiftyOnePct}%</div>
<div class="score-unit">alignment</div>
</div>
`;
// Factor breakdown with insights
document.getElementById("admin-factor-breakdown").innerHTML = FACTORS.map((name, i) => {
const norm = combined.normalized[i];
const fiftyW = Math.max(0, norm);
const fiftyOneW = Math.max(0, -norm);
const total = fiftyW + fiftyOneW || 1;
const fiftyBar = (fiftyW / total) * 100;
const fiftyOneBar = (fiftyOneW / total) * 100;
const conviction = getConviction(norm);
const insight = FACTOR_INSIGHTS[i](norm, dannyData.answers, fqMap[i]);
let winnerClass;
if (insight.label.includes("50/50")) winnerClass = "fifty";
else if (insight.label.includes("51/49")) winnerClass = "fifty-one";
else winnerClass = "even";
return `
<div class="factor-card">
<div class="factor-header">
<span class="factor-name">${name}</span>
<div class="factor-tags">
<span class="factor-winner ${winnerClass}">${insight.label}</span>
<span class="factor-conviction ${conviction.css}">${conviction.level}</span>
</div>
</div>
<div class="factor-bar">
<div class="bar-fifty" style="width: ${fiftyBar}%"></div>
<div class="bar-fifty-one" style="width: ${fiftyOneBar}%"></div>
</div>
<p class="factor-note">${insight.detail}</p>
${insight.flag ? `<p class="factor-flag">${insight.flag}</p>` : ""}
</div>
`;
}).join("");
// Verdict (5-tier)
const vBox = document.getElementById("admin-verdict-box");
let verdictClass, verdictTitle, verdictText;
if (fiftyPct >= 65) {
verdictClass = "fifty";
verdictTitle = "Strong alignment toward a 50/50 Split";
verdictText = "Both partners' answers consistently favor equal control, mutual veto power, and shared decision-making. A 50/50 LLC with a robust deadlock-resolution ladder is the natural fit.";
} else if (fiftyPct > 55) {
verdictClass = "fifty";
verdictTitle = "Responses lean toward a 50/50 Split";
verdictText = "The partnership values shared control with some openness to delegated authority. A 50/50 LLC with a managing-member carve-out for routine decisions would be a good fit.";
} else if (fiftyOnePct >= 65) {
verdictClass = "fifty-one";
verdictTitle = "Strong alignment toward a 51/49 Split";
verdictText = "Both partners' answers consistently favor operational efficiency and clear leadership. A 51/49 LLC with robust supermajority protections for the minority partner is the natural fit.";
} else if (fiftyOnePct > 55) {
verdictClass = "fifty-one";
verdictTitle = "Responses lean toward a 51/49 Split";
verdictText = "The partnership values operational efficiency while wanting to preserve shared ownership. A 51/49 LLC with strong minority protections and defined managing-member scope would be a good fit.";
} else {
verdictClass = "even";
verdictTitle = "Balanced — consider a hybrid structure";
verdictText = "Both partners' answers are balanced between structures. Consider the hybrid: 50/50 economic split with 51/49 governance — one partner has tiebreaker on routine decisions, major decisions require unanimity.";
}
vBox.className = `verdict-box ${verdictClass}`;
vBox.innerHTML = `
<h3 class="verdict-heading">${verdictTitle}</h3>
<p class="verdict-text">${verdictText}</p>
<p class="verdict-disclaimer">This is a decision-support tool, not legal advice. Consult with independent legal counsel before finalizing your ownership structure.</p>
`;
document.getElementById("admin-results").style.display = "block";
document.getElementById("admin-results").scrollIntoView({ behavior: "smooth" });
}
</script>
<script defer src="/_vercel/insights/script.js"></script>
</body>
</html>