-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
600 lines (482 loc) · 18 KB
/
index.html
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
<!DOCTYPE html>
<!-- Axel '0vercl0k' Souchet - March 10 2021 -->
<html lang='en-US'>
<head>
<title>📊 teesee calculator</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<meta name='description' content='Visualize, calculate and compare total compensation (TC) packages.'>
<meta name='keywords' content='Total compensation, TC, Total comp calculator' />
<!-- https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started -->
<meta name='twitter:card' content='summary_large_image' />
<meta name='twitter:site' content='@0vercl0k' />
<meta name='twitter:creator' content='@0vercl0k' />
<meta property='og:url' content='https://0vercl0k.github.io/teesee-calc/' />
<meta property='og:title' content='Visualize, calculate and compare total compensation (TC) packages.' />
<meta property='og:description' content='Visualize, calculate and compare total compensation (TC) packages.' />
<meta property='og:image' content='https://0vercl0k.github.io/teesee-calc/pics/teesee.png' />
<link rel='stylesheet' href='./css/bootstrap.min.css'>
<style>
a { text-decoration: none; }
</style>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src='https://www.googletagmanager.com/gtag/js?id=G-EW1KVJFMDM'></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-EW1KVJFMDM');
</script>
<script type='text/javascript' src='./js/bootstrap.min.js'></script>
<script type='text/javascript' src='./js/teesee.js'></script>
<script type='text/javascript' src='./js/Chart.bundle.min.js'></script>
<script type='text/javascript' src='./js/chartjs-plugin-datalabels.min.js'></script>
<script>
//
// The global app instance.
//
let App = null;
//
// Get the value of an element and convert it to a number.
//
function getCleanedNumber(Id) {
return Number(
document.getElementById(Id).value.replace(/\D/g, '')
);
}
//
// Sanitize an array of numbers.
//
function sanitizeNumberArray(Id) {
const A = document.getElementById(Id).value.split('/')
for (let Idx = 0; Idx < A.length; Idx++) {
const Cleaned = A[Idx].replace(/\D/g, '');
if (Cleaned == '') {
A.length = Idx;
break;
}
A[Idx] = Number(Cleaned);
}
return A;
}
//
// Verify that a vesting schedule is properly formed.
//
function verifySchedule(Schedule) {
const Total = Schedule.reduce((Acc, Value) => {
return Acc + Value;
});
if (Total < 99 || Total > 100) {
return false;
}
return true;
}
//
// Create, sanitize a teesee and feed it into the app.
//
function addTeesee() {
//
// Check the validity of the form before going forward.
//
const Form = document.getElementById('form');
if (!Form.reportValidity()) {
return;
}
//
// Grab the various values we need.
//
const Name = document.getElementById('company').value;
const Base = getCleanedNumber('base');
const Benefits = getCleanedNumber('benefits');
const SignOnBonuses = sanitizeNumberArray('signon');
const InitialStocks = getCleanedNumber('initial_stocks');
const InitialStocksSchedule = sanitizeNumberArray('initial_stocks_schedule');
const PerfCash = getCleanedNumber('perf_cash');
const PerfStocks = getCleanedNumber('perf_stocks');
const PerfStocksSchedule = sanitizeNumberArray('perf_stocks_schedule');
//
// Sanitize the base / benefits / stock grant,
// perf cash / perf stocks.
//
if (Base < 0) {
throw `Base is negative`;
}
if (Benefits < 0) {
throw `Benefits is negative`;
}
if (InitialStocks < 0) {
throw `Initial stock grant is negative`;
}
if (PerfCash < 0) {
throw `PerfCash grant is negative`;
}
if (PerfStocks < 0) {
throw `PerfStocks grant is negative`;
}
//
// Assign default values for the stock schedules.
//
if (InitialStocksSchedule.length == 0) {
InitialStocksSchedule.push(25, 25, 25, 25);
}
if (PerfStocksSchedule.length == 0) {
PerfStocksSchedule.push(25, 25, 25, 25);
}
//
// Verify the schedules.
//
if (!verifySchedule(InitialStocksSchedule)) {
alert('The initial stocks grant schedule should total to 100%');
document.getElementById('initial_stocks_schedule').focus();
return;
}
if (!verifySchedule(PerfStocksSchedule)) {
alert('The performance stocks grant schedule should total to 100%');
document.getElementById('perf_stocks_schedule').focus();
return;
}
//
// Create a teesee.
//
const Teesee = new Teesee_t(
Name,
Base,
Benefits,
SignOnBonuses, {
Amount: InitialStocks,
Schedule: InitialStocksSchedule
}, {
Cash: PerfCash,
Stocks: PerfStocks,
Schedule: PerfStocksSchedule
}
);
//
// Feed it to the App.
//
App.addTeesee(Teesee);
}
//
// Format a currency.
//
function formatCurrency(Value) {
//
// Strip any non-digit characters.
//
const Cleaned = Value.replace(/\D/g, '');
if (Cleaned == '') {
return '';
}
//
// Transform the number back to the current locale.
//
return `$${parseInt(Cleaned, 10).toLocaleString()}`;
}
//
// Format a currency element.
//
function formatCurrencyElement(E) {
E.value = formatCurrency(E.value);
}
//
// Format a sign-on bonus.
//
function formatSignon(Value) {
//
// Break up the value in chunks.
//
const Chunks = Value.split('/');
//
// Format each chunks into currency.
//
for(let Idx = 0; Idx < Chunks.length; Idx++) {
//
// Clean up the chunk.
//
Chunks[Idx] = Chunks[Idx].replace(/\D/g, '');
//
// Format the currency.
//
Chunks[Idx] = formatCurrency(Chunks[Idx]);
//
// If the chunk is empty, let's stop here; the only chunk
// that can be empty is the last one.
//
if (Chunks[Idx] == '$') {
//
// Shrink the array.
//
Chunks.length = Idx + 1;
break;
}
}
//
// Assemble the chunks back together.
//
return Chunks.join(' / ');
}
//
// Format a sign-on element.
//
function formatSignonElement(E) {
E.value = formatSignon(E.value);
}
//
// Format a vesting schedule.
//
function formatSchedule(Value) {
//
// Break up the value in chunks.
//
const Chunks = Value.split('/');
//
// Format each chunks.
//
for(let Idx = 0; Idx < Chunks.length; Idx++) {
//
// Clean up the chunk.
//
Chunks[Idx] = Chunks[Idx].replace(/\D/g, '');
//
// If the chunk is empty, let's stop here; the only chunk
// that can be empty is the last one.
//
if (Chunks[Idx] == '') {
//
// Shrink the array.
//
Chunks.length = Idx + 1;
break;
}
//
// Format the percentage.
//
Chunks[Idx] = `${Chunks[Idx]}%`;
}
//
// Assemble the chunks back together.
//
return Chunks.join(' / ');
}
//
// Format a vesting schedule element.
//
function formatScheduleElement(E) {
E.value = formatSchedule(E.value);
}
//
// Copy the URL into the clipboard.
//
function copyUrl() {
document.getElementById('url').select();
document.execCommand('copy');
}
//
// Main.
//
function main() {
//
// Capture the URL first.
//
document.getElementById('url').value = window.location.href;
const Url = new URL(window.location.href);
//
// Instantiate the main app.
//
App = new TeeseeApp_t(getCleanedNumber('years'));
//
// Lookup table mapping short var name to the names of the DOM
// elements that hold those values.
//
const Lookup = new Map([
['na', 'company'],
['ba', 'base'],
['be', 'benefits'],
['si', 'signon'],
['in', 'initial_stocks'],
['sc', 'initial_stocks_schedule'],
['pe', 'perf_cash'],
['ps', 'perf_stocks'],
['pc', 'perf_stocks_schedule'],
]);
//
// All the different fields holding currency values.
//
const Currencies = [
'base', 'benefits', 'initial_stocks',
'perf_cash', 'perf_stocks'
];
//
// Parse the URL to create teesees if we have some.
//
let Cur = 0;
while (1) {
//
// Grab every components of a teesee.
//
let Abort = false;
for (const [K, _] of Lookup.entries()) {
const Param = Url.searchParams.get(`${K}${Cur}`);
if (Param == null) {
Abort = true;
break;
}
//
// Inject the value in the DOM.
//
const Id = Lookup.get(K);
const Dom = document.getElementById(Id);
const Decoded = decodeURI(Param);
if (Id == 'company') {
Dom.value = Decoded;
} else if (Id == 'signon') {
Dom.value = formatSignon(Decoded);
} else if (Currencies.includes(Id)) {
Dom.value = formatCurrency(Decoded);
} else {
Dom.value = formatSchedule(Decoded);
}
}
//
// Abort if we can't find the parameters we expect.
//
if (Abort) {
break;
}
//
// Add teesee!
//
addTeesee();
//
// Bump the counter.
//
Cur += 1;
}
}
</script>
</head>
<body class='bg-dark text-light' onload='main();'>
<nav class='navbar navbar-expand-lg navbar-dark'>
<div class='container-fluid'>
<a class='navbar-brand' href='#'>📊 teesee calculator</a>
<a href='https://github.com/0vercl0k/teesee-calc'><img src='./pics/GitHub-Mark-Light-32px.png'></img></a>
</div>
</nav>
<section class='py-5'>
<div class='container text-center' id='header'>
<h1 class='display-3 my-3'>Visualize and compare compensation packages over time.</h1>
</div>
</section>
<div class='container-fluid'>
<div class='row'>
<div class='col-md-6'>
<form id='form' class='row g-2' onsubmit='return false;' novalidate>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapseCompany' aria-expanded='false' aria-controls='collapseCompany' class='input-group-text bg-dark text-light'>💼 Company</span>
<input type='text' id='company' class='form-control form-control-sm bg-dark text-light' placeholder='Teesee Inc.' required>
<div class='collapse' id='collapseCompany'>
<div class='card card-body bg-dark text-light'>
This is used as the name of the dataset on the chart.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapseBase' aria-expanded='false' aria-controls='collapseBase' class='input-group-text bg-dark text-light'>💰 Base</span>
<input type='text' id='base' class='form-control form-control-sm bg-dark text-light' placeholder='$100,000' onkeyup='formatCurrencyElement(this);' required>
<div class='collapse' id='collapseBase'>
<div class='card card-body bg-dark text-light'>
This is the amount of cash you receive every year.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapseBenefits' aria-expanded='false' aria-controls='collapseBenefits' class='input-group-text bg-dark text-light'>🍧 Benefits</span>
<input type='text' id='benefits' class='form-control form-control-sm bg-dark text-light' placeholder='$10,000' onkeyup='formatCurrencyElement(this);' required>
<div class='collapse' id='collapseBenefits'>
<div class='card card-body bg-dark text-light'>
This is the yearly monetary value of the benefits provided by the company (401k match, health insurance, etc.).
Check-out <a href='https://www.levels.fyi/benefits/'>levels.fyi/benefits</a> for descriptions of what tech companies offer.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapseSignon' aria-expanded='false' aria-controls='collapseSignon' class='input-group-text bg-dark text-light'>👏 Sign-on (yr1/..)</span>
<input type='text' id='signon' class='form-control form-control-sm bg-dark text-light' placeholder='$1,000 / $1,000' onkeyup='formatSignonElement(this);'>
<div class='collapse' id='collapseSignon'>
<div class='card card-body bg-dark text-light'>
This is an amount of cash offered for the first year of employment. It usually is unlocked every month or the whole amount is paid with your first paycheck.
You can enter sign-on bonuses for subsequent years using the '/' separator.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapseInitialStocks' aria-expanded='false' aria-controls='collapseInitialStocks' class='input-group-text bg-dark text-light'>💸 Initial stocks grant</span>
<input type='text' id='initial_stocks' class='form-control form-control-sm bg-dark text-light' placeholder='$50,000' onkeyup='formatCurrencyElement(this);'>
<div class='collapse' id='collapseInitialStocks'>
<div class='card card-body bg-dark text-light'>
This is the value of the amount of stocks offered by the company.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapseInitialStocksSchedule' aria-expanded='false' aria-controls='collapseIniti#collapseInitialStocksSchedule' class='input-group-text bg-dark text-light'>🕐 Schedule</span>
<input type='text' id='initial_stocks_schedule' class='form-control form-control-sm bg-dark text-light' placeholder='25% / 25% / 25% / 25%' onkeyup='formatScheduleElement(this);'>
<div class='collapse' id='collapseInitialStocksSchedule'>
<div class='card card-body bg-dark text-light'>
This is the vesting schedule of the initial stock grant. The regular vesting schedule is 25% over 4 years. It means that in year 4, the total number of stocks awarded is now yours.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapsePerfCash' aria-expanded='false' aria-controls='collapsePerfCash' class='input-group-text bg-dark text-light'>💲 Performance (cash/yr)</span>
<input type='text' id='perf_cash' class='form-control form-control-sm bg-dark text-light' placeholder='$5,000' onkeyup='formatCurrencyElement(this);'>
<div class='collapse' id='collapsePerfCash'>
<div class='card card-body bg-dark text-light'>
This is the amount of cash you receive every year as part of your performance review.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapsePerfStocks' aria-expanded='false' aria-controls='collapsePer#collapsePerfStocks' class='input-group-text bg-dark text-light'>🚀 Performance (stocks/yr)</span>
<input type='text' id='perf_stocks' class='form-control form-control-sm bg-dark text-light' placeholder='$25,000' onkeyup='formatCurrencyElement(this);'>
<div class='collapse' id='collapsePerfStocks'>
<div class='card card-body bg-dark text-light'>
This is the value of an amount of stocks that the company rewards you with as part of the yearly performance review.
It usually is dependent on your past year work as well as the level you were operating at.
</div>
</div>
</div>
<div class='input-group'>
<span data-bs-toggle='collapse' data-bs-target='#collapsePerfStocksSchedule' aria-expanded='false' aria-controls='collapsePerfo#collapsePerfStocksSchedule' class='input-group-text bg-dark text-light'>🕜 Schedule</span>
<input type='text' id='perf_stocks_schedule' class='form-control form-control-sm bg-dark text-light' placeholder='25% / 25% / 25% / 25%' onkeyup='formatScheduleElement(this);'>
<div class='collapse' id='collapsePerfStocksSchedule'>
<div class='card card-body bg-dark text-light'>
This is the vesting schedule of the performance review stock award.
The schedule can be different from the initial stock grant's.
</div>
</div>
</div>
<div class='input-group'>
<input type='range' class='form-range bg-dark text-light' value=5 min=1 max=10 id='years' onload='App.updateYears(this);' onchange='App.updateYears(this);'>
</div>
<input type='submit' class='btn btn-success' value='Model' onclick='addTeesee();'>
<label class='btn btn-danger' onclick='App.reset();'>Reset</label>
<div class='input-group'>
<input id='url' type='text' class='form-control form-control-sm bg-dark text-light'>
<label class='btn btn-light' onclick='copyUrl()'>Copy URL</label>
</div>
</form>
</div>
<div class='col-md-6'>
<canvas id='chart' style='min-height: 500px'></canvas>
</div>
</div>
</div>
<footer class='py-3'>
<div class='container'>
<div class='d-flex justify-content-center mt-2'>
<p class='mb-0 mt-2 small text-muted'>Written with 🍻 by Axel '<a href='https://twitter.com/0vercl0k'>@0vercl0k</a>' Souchet</p>
</div>
</div>
</footer>
</body>
</html>