-
Notifications
You must be signed in to change notification settings - Fork 7
/
backpayCalc.js
1874 lines (1669 loc) · 81.9 KB
/
backpayCalc.js
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
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* To-do:
* * Fix anniversary problem - Fixed
* * Deal with anniversary dates == contract dates - Done
* * OT not showing up in the right pay period - Fixed.
* * Make sure promotions, actings, overtimes, lwops, and lump sums use querySelectorAll - Done....I think
* * Contractual increases not taking place during acting periods - Done
* * Anniversaries not being honoured during actings/lwops. - Done
* * Start after beginning of contract
* * Being on acting at beginning of contract
* * Being on lwop at beginning of contract
*
*/
var dbug = true;
let data = {};
let i18n = {};
let lang = "en";
var version = "3.0";
var updateHash = true;
var saveValues = null;
var showExtraCols = true;
var level = -1;
var step = -1;
var mainForm = null;
var startingSalary = 0;
var resultsDiv = null;
var startDateTxt = null;
var classification = null;
var chosenCA = null;
var classSel = null;
var CASel = null;
var levelSel = null;
var stepSelect = null;
var numPromotions = null;
var addPromotionBtn = null;
var addActingBtn = null;
var addOvertimeBtn = null;
var addLwopBtn = null;
var addLumpSumBtn = null;
var resultStatus = null;
var calcStartDate = null;
var endDateTxt = "2024-04-15";
var TABegin = new Date("2021", "11", "22"); // Remember months: 0 == Janaury, 1 == Feb, etc.
var EndDate = new Date("2024", "02", "17"); // This is the day after this should stop calculating; same as endDateTxt.value in the HTML
var day = (1000 * 60 * 60 * 24);
var parts = [];
var resultsBody = null;
var resultsFoot = null;
var resultsTheadTR = null;
var periods = [];
var initPeriods = [];
var lumpSumPeriods = {};
var overtimePeriods = {};
var promotions = 0;
var actings = 0;
var lumpSums = 0;
var overtimes = 0;
var lwops = 0;
var lastModified = new Date("2023", "09", "22");
var lastModTime = null;
var salaries = [];
var daily = [];
var hourly = [];
// taken from http://www.tbs-sct.gc.ca/agreements-conventions/view-visualiser-eng.aspx?id=1#toc377133772
/*
var salaries = [
[56907, 59011, 61111, 63200, 65288, 67375, 69461, 73333],
[70439, 72694, 74947, 77199, 79455, 81706, 83960, 86213],
[83147, 86010, 88874, 91740, 94602, 97462, 100325, 103304],
[95201, 98485, 101766, 105050, 108331, 111613, 114896, 118499],
[108528, 112574, 116618, 120665, 124712, 128759, 132807, 136852, 141426]
];
var daily = [
[218.13, 226.20, 234.25, 242.26, 250.26, 258.26, 266.26, 281.10],
[270.01, 278.65, 287.29, 295.92, 304.57, 313.19, 321.83, 330.47],
[318.72, 329.69, 340.67, 351.66, 362.63, 373.59, 384.56, 395.98],
[364.92, 377.51, 390.09, 402.68, 415.25, 427.83, 440.42, 454.23],
[416.01, 431.52, 447.02, 462.53, 478.04, 493.56, 509.07, 524.58, 542.11]
];
var hourly = [
[29.08, 30.16, 31.23, 32.30, 33.37, 34.43, 35.50, 37.48],
[36.00, 37.15, 38.30, 39.46, 40.61, 41.76, 42.91, 44.06],
[42.50, 43.96, 45.42, 46.89, 48.35, 49.81, 51.28, 52.80],
[48.66, 50.33, 52.01, 53.69, 55.37, 57.04, 58.72, 60.56],
[55.47, 57.54, 59.60, 61.67, 63.74, 65.81, 67.88, 69.94, 72.28]
];
*/
//var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
//var days = [31, 29, 31
function init() {
lang = document.documentElement.lang;
console.log ("Got lang " + lang + ".");
mainForm = document.getElementById("mainForm");
createClassificationSelect ();
} // End of init
function oldinit () {
if (dbug) console.log ("Initting");
//saveValues = new Map();
var calcBtn = document.getElementById("calcBtn");
levelSel = document.getElementById("levelSelect");
//if (updateHash) levelSel.addEventListener("change", saveValue, false);
stepSelect = document.getElementById("stepSelect");
//if (updateHash) stepSelect.addEventListener("change", saveValue, false);
resultsDiv = document.getElementById("resultsDiv");
startDateTxt = document.getElementById("startDateTxt");
//if (updateHash) startDateTxt.addEventListener("change", saveValue, false);
endDateTxt = document.getElementById("endDateTxt");
//if (updateHash) startDateTxt.addEventListener("change", saveValue, false);
calcStartDate = document.getElementById("calcStartDate");
addPromotionBtn = document.getElementById("addPromotionBtn");
addActingBtn = document.getElementById("addActingBtn");
addOvertimeBtn = document.getElementById("addOvertimeBtn");
addLwopBtn = document.getElementById("addLwopBtn");
addLumpSumBtn = document.getElementById("addLumpSumBtn");
resultsBody = document.getElementById("resultsBody");
resultsFoot = document.getElementById("resultsFoot");
resultsTheadTR = document.getElementById("resultsTheadTR");
resultStatus = document.getElementById("resultStatus");
lastModTime = document.getElementById("lastModTime");
if (lastModTime) {
lastModTime.setAttribute("datetime", lastModified.toISOString().substr(0,10));
lastModTime.innerHTML = lastModified.toLocaleString("en-CA", { year: 'numeric', month: 'long', day: 'numeric' });
}
if (dbug || showExtraCols) {
var ths = resultsTheadTR.getElementsByTagName("th");
if (ths.length == 4) {
createHTMLElement("th", {"parentNode":resultsTheadTR, "scope":"col", "textNode":"Level"});
createHTMLElement("th", {"parentNode":resultsTheadTR, "scope":"col", "textNode":"Step"});
createHTMLElement("th", {"parentNode":resultsTheadTR, "scope":"col", "textNode":"There?"});
createHTMLElement("th", {"parentNode":resultsTheadTR, "scope":"col", "textNode":"Salary"});
createHTMLElement("th", {"parentNode":resultsTheadTR, "scope":"col", "textNode":"Working Days"});
}
}
/*for (var r in results) {
results[r] = document.getElementById(r);
}*/
if (dbug) console.log("init::MainForm is " + mainForm + ".");
if (levelSel && stepSelect && mainForm && startDateTxt && calcBtn && addActingBtn && addPromotionBtn) {
if (dbug) console.log ("Adding change event to calcBtn.");
levelSel.addEventListener("change", populateSalary, false);
if (levelSel.value.match(/[1-5]/)) populateSalary();
startDateTxt.addEventListener("change", selectSalary, false);
if (startDateTxt.value.replace(/[^-\d]/, "").match(/YYYY-MM-DD/)) populateSalary();
calcBtn.addEventListener("click", startProcess, false);
addActingBtn.addEventListener("click", addActingHandler, false);
addLwopBtn.addEventListener("click", addLWoPHandler, false);
addOvertimeBtn.addEventListener("click", addOvertimeHandler, false);
addLumpSumBtn.addEventListener("click", addLumpSumHandler, false);
addPromotionBtn.addEventListener("click", addPromotionHandler, false);
} else {
if (dbug) console.error ("Couldn't get levelSelect.");
}
handleHash ();
} // End of oldinit
function createClassificationSelect () {
if (!document.getElementById("classSel")) {
let div = createHTMLElement ("div", {"parentNode":mainForm, "class":"fieldHolder"});
let lbl = createHTMLElement ("label", {"parentNode":div, "for":"classSel", "textNode":i18n["selectClass"][lang]});
classSel = createHTMLElement ("select", {"parentNode":div, "id":"classSel"});
let opt1 = createHTMLElement ("option", {"parentNode":classSel, "textNode":" -- " + i18n["selectClass"][lang] + " --"});
for (var classifications in data) {
let opt = createHTMLElement("option", {"parentNode":classSel, "textNode" : classifications});
// Add something for the bookmarks
}
// Add a change handler for this to add the next thing
classSel.addEventListener("change", function () {
classification = classSel.value;
createCASelect();
}, false);
}
} // End of createClassificationSelect
function createCASelect () {
if (!document.getElementById("CASel")) {
let div = createHTMLElement ("div", {"parentNode":mainForm, "class":"fieldHolder"});
let lbl = createHTMLElement ("label", {"parentNode":div, "for":"CASel", "textNode":i18n["selectCALbl"][lang]});
CASel = createHTMLElement ("select", {"parentNode":div, "id":"CASel"});
console.log ("Dealing with classification: " + classification + ".");
let opt = createHTMLElement("option", {"parentNode":CASel, "textNode" : i18n["selectCALbl"][lang]});
for (var CA in data[classification]) {
opt = createHTMLElement("option", {"parentNode":CASel, "textNode" : CA});
// Add something for the bookmarks
}
// Add a change handler for this to add the next thing
// What's next?
// Now we know what CA, we now need to determine a Start Date
CASel.addEventListener("change", function () {
chosenCA = CASel.value;
askStartDate();
}, false);
}
} // End of createCASelect
function askStartDate () {
if (!document.getElementById("askStartDateFS")) {
let askStartDateFS = createHTMLElement("fieldset", {"parentNode": mainForm, "id":"askStartDateFS"});
let askStartDateLgndTxt = i18n["startDateLgnd"][lang].replace("{{classification}}", classification).replace("{{startDate}}", data[classification][chosenCA]["TABegin"]);
let askStartDateLgnd = createHTMLElement("legend", {"parentNode": askStartDateFS, "textNode" : askStartDateLgndTxt});
let yesHolderDiv = createHTMLElement("div", {"parentNode" : askStartDateFS});
let noHolderDiv = createHTMLElement("div", {"parentNode" : askStartDateFS});
let yesRB = createHTMLElement("input", {"parentNode" : yesHolderDiv, "id" : "yesRB", "type" : "radio", "name" : "startDateRBs"});
let yesRBLbl = createHTMLElement("label", {"parentNode" : yesHolderDiv, "for" : "yesRB", "textNode" : i18n["yesTxt"][lang]});
let noRB = createHTMLElement("input", {"parentNode" : noHolderDiv, "id" : "noRB", "type" : "radio", "name" : "startDateRBs"});
let noRBLbl = createHTMLElement("label", {"parentNode" : noHolderDiv, "for" : "noRB", "textNode" : i18n["noTxt"][lang]});
yesRB.addEventListener("change", function () {}, false);
}
} // End of askStartDate
// Check the document location for saved things
function handleHash () {
let hasHash = false;
let thisURL = new URL(document.location);
let params = thisURL.searchParams;
//let hash = thisURL.hash;
let toCalculate = 0;
if (params.has("dbug")) {
if (params.get("dbug") == "true") dbug= true;
}
if (params.has("lvl")) {
let lvl = params.get("lvl").replace(/\D/g, "");
levelSel.selectedIndex = lvl;
toCalculate = toCalculate + 1;
populateSalary();
hasHash = true;
}
if (params.has("strtdt")) {
let sd = params.get("strtdt");
if (sd.match(/\d\d\d\d-\d\d-\d\d/)) {
startDateTxt.value = sd;
toCalculate = toCalculate | 2;
}
hasHash = true;
}
if (params.has("stp")) {
let stp = params.get("stp").replace(/\D/g, "");
stepSelect.selectedIndex = stp;
toCalculate = toCalculate | 4;
hasHash = true;
}
/*
setTimeout (function () {
console.log ("Gonna try and set step now");
if (params.get("stp")) {
let stp = params.get("stp").replace(/\D/g, "");
console.log ("And gonna set it now to " + stp + ".");
stepSelect.selectedIndex = stp;
toCalculate = toCalculate | 4;
}}, 0);
*/
if (params.get("enddt")) {
let ed = params.get("enddt");
if (ed.match(/\d\d\d\d-\d\d-\d\d/)) {
endDateTxt.value = ed;
toCalculate = toCalculate | 8;
}
hasHash = true;
}
// Promotions
let looking = true;
for (i = 0; i<5 && looking; i++) {
if (params.has("pdate" + i) && params.has("plvl"+i)) {
addPromotionHandler(null, {"date" : params.get("pdate" + i), "level" : params.get("plvl" + i), "toFocus" : false});
hasHash = true;
} else {
looking = false;
}
}
// Actings
looking = true;
let acl = 0;
while (looking) {
// afrom0=2020-01-05&ato0=2020-02-06&alvl0=3&afrom1=2020-04-04&ato1=2020-05-06&alvl1=3
if (params.has("afrom" + acl) || params.has("ato"+acl) || params.has("alvl"+acl)) {
if (params.has("afrom" + acl) && params.has("ato"+acl) && params.has("alvl"+acl)) {
addActingHandler(null, {"from" : params.get("afrom" + acl), "to" : params.get("ato" + acl), "level" : params.get("alvl" + acl), "toFocus" : false});
hasHash = true;
}
} else {
looking = false;
}
acl++;
}
// LWoPs
looking = true;
let ls = 0;
while (looking) {
if (params.has("lfrom" + ls) || params.has("lto"+ls)) {
if (params.has("lfrom" + ls) && params.has("lto"+ls)) {
addLWoPHandler(null, {"from" : params.get("lfrom" + ls), "to" : params.get("lto" + ls), "toFocus" : false});
hasHash = true;
}
} else {
looking = false;
}
ls++;
}
// Overtimes/Standbys
looking = true;
let ots = 0;
while (looking) {
if (params.has("otdate" + ots) || params.has("otamt"+ots) || params.has("otrt"+ots)) {
if (params.has("otdate" + ots) && params.has("otamt"+ots) && params.has("otrt"+ots)) {
addOvertimeHandler(null, {"date" : params.get("otdate" + ots), "hours" : params.get("otamt" + ots), "rate" : params.get("otrt" + ots), "toFocus" : false});
hasHash = true;
}
} else {
looking = false;
}
ots++;
}
// Lump Sum Payments
looking = true;
let lss = 0;
while (looking) {
if (params.has("lsdate" + lss) || params.has("lsamt"+lss) || params.has("lsrt"+lss)) {
if (params.has("lsdate" + lss) && params.has("lsamt"+lss)) {
addLumpSumHandler(null, {"date" : params.get("lsdate" + lss), "hours" : params.get("lsamt" + lss), "toFocus" : false});
hasHash = true;
}
} else {
looking = false;
}
lss++;
}
if (dbug) console.log ("toCalculate: " + toCalculate + ": " + toCalculate.toString(2) + ".");
if (hasHash) {
//calcBtn.focus();
let clickEv = new Event("click");
calcBtn.dispatchEvent(clickEv);
}
} // End of handleHash
function saveValue (e) {
let ot = e.originalTarget;
let key = ot.id;
let value = (ot.toString().match(/HTMLSelect/) ? ot.selectedIndex : ot.value);
//saveValues[key] = value;
//saveValues.set(key, value);
if (updateHash) setURL();
} // End of saveValue
// set the URL
function setURL () {
let url = new URL(document.location);
let newURL = url.toString().replace(/#.*$/, "");
newURL = newURL.replace(/\?.*$/, "");
//let params = [];
/*for (let id in filters) {
if (!filters[id].checked) {
params.push(id.replace("Chk", ""));
if (id.match(/levelA/)) {
params[params.length-1] += "$";
}
}
}*/
/*
if (levelSel) saveValues["lvl"] = levelSel.selectedIndex);
if (startDateTxt.value) ("strtdt=" + startDateTxt.value);
if (stepSelect) params.push("stp=" + stepSelect.selectedIndex);
if (endDateTxt.value) params.push("enddt=" + endDateTxt.value);
newURL += "?" + params.join("&");
*/
newURL += "?";
/*saveValues.forEach(function (val, key, saveValues) {
console.log ("adding " + key + "=" + val);
newURL += key + "=" + val + "&";
});
newURL = newURL.substring(0, newURL.length - 1);
*/
newURL += saveValues.join("&");
/*
if (params.length > 0) {
newURL += "?filters=" + params.join(sep) + (selectedTab != "" ? "&" + selectedTab : "") + url.hash;
} else {
newURL += (selectedTab != "" ? "?" + selectedTab : "") + url.hash;
}
*/
history.pushState({}, document.title, newURL);
} // End of setURL
/*
Populates the Salary Select basedon the CS-0x level selected
*/
function populateSalary () {
removeChildren(stepSelect);
if (levelSel.value >0 && levelSel.value <= 5) {
createHTMLElement("option", {"parentNode":stepSelect, "value":"-1", "textNode":"Select Salary"});
for (var i = 0; i < salaries[(levelSel.value-1)].length; i++) {
createHTMLElement("option", {"parentNode":stepSelect, "value":i, "textNode":"$" + salaries[levelSel.value-1][i].toLocaleString()});
}
}
if (startDateTxt.value.replace(/[^-\d]/, "").match(/(\d\d\d\d)-(\d\d)-(\d\d)/)) selectSalary();
} // End of populateSalary
// Once a CS-level and startDate have been selected, select the most likely salary from the dropdown
// Called from init when startDateTxt has changed, and from populateSalary if startDateTxt is a date (####-##-##)
// I don't get it. What's the difference btween selectSalary and getSalary?
// They both start the same way: get the startDateText date, check for leapyear, set the startDateTxt value, figure out your step, select the step
function selectSalary () {
//if (!(levelSelect.value > 0 && levelSelect.value <= 5))
if (parts && levelSel.value >0 && levelSel.value <= 5) { // if you have a start date, and a CS-0x level
let startDate = getStartDate();
startDateTxt.value = startDate.toISOString().substr(0,10)
let timeDiff = (TABegin - startDate) / day;
let years = Math.floor(timeDiff/365);
if (dbug) console.log ("TimeDiff between " + TABegin.toString() + " and " + startDate.toString() + ": " + timeDiff + ".");
if (timeDiff < 0) {
// You started after the CA started
calcStartDate.setAttribute("datetime", startDate.toISOString().substr(0,10));
calcStartDate.innerHTML = startDate.toLocaleString("en-CA", { year: 'numeric', month: 'long', day: 'numeric' });
step = 1;
} else {
// You started after the CA started
calcStartDate.setAttribute("datetime", TABegin.toISOString().substr(0,10));
calcStartDate.innerHTML = TABegin.toLocaleString("en-CA", { year: 'numeric', month: 'long', day: 'numeric' });
var step = Math.ceil(years, salaries[levelSel.value].length-1) + 1;
}
if (dbug) console.log ("Your step would be " + step + ".");
if (step > salaries[levelSel.value].length) step = salaries[levelSel.value].length;
if (dbug) console.log ("But there ain't that many steps. so you're step " + step +".");
stepSelect.selectedIndex=step;
//step = Math.min(years, salaries[levelSel.value].length);
/*
var opts = stepSelect.getElementsByTagName("option");
for (var i = 0; i < opts.length; i++) {
if (opts[i].hasAttribute("selected")) opts[i].removeAttribute("selected");
if (i == step) opts[i].setAttribute("selected", "selected");
}
*/
}
} // End of selectSalary
function getStartDate () {
let dparts = null;
startDateTxt.value = startDateTxt.value.replace(/[^-\d]/, "");
dparts = startDateTxt.value.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
if (dbug) console.log ("Got startDateTxt " + startDateTxt.value + ".");
if (dbug) console.log ("Got dparts " + dparts + ".");
// Leap years
if (dparts[2] == "02" && dparts[3] > "28") {
if (parseInt(dparts[1]) % 4 === 0 && dparts[3] == "29") {
// Do nothing right now
} else {
dparts[3]=(parseInt(dparts[1]) % 4 === 0? "29" : "28");
}
}
return new Date(dparts[1], dparts[2]-1, dparts[3]);
} // End of getStartDate
function startProcess () {
resetPeriods();
saveValues = [];
lumpSumPeriods = {};
overtimePeriods = {};
if (resultsBody) {
removeChildren (resultsBody);
} else {
var resultsTable = document.getElementById("resultsTable");
resultsBody = createHTMLElement("tbody", {"parentNode":resultsTable, "id":"resultsBody"});
}
if (resultsFoot) {
removeChildren (resultsFoot);
} else {
var resultsTable = document.getElementById("resultsTable");
resultsFoot = createHTMLElement("tfoot", {"parentNode":resultsTable, "id":"resultsFoot"});
}
var errorDivs = document.querySelectorAll(".error");
if (dbug && errorDivs.length > 0) console.log ("Found " + errorDivs.length + " errorDivs.");
for (var i = 0; i < errorDivs.length; i++) {
if (errorDivs[i].hasAttribute("id")) {
var id = errorDivs[i].getAttribute("id");
var referrers = document.querySelectorAll("[aria-describedby="+id+"]");
for (var j = 0; j<referrers.length; j++) {
if (referrers[j].getAttribute("aria-describedby") == id) {
referrers[j].removeAttribute("aria-describedby");
} else {
referrers[j].setAttribute("aria-describedby", referrers[j].getAttribute("aria-describedby").replace(id, "").replace(/\s+/, " "));
}
}
}
errorDivs[i].parentNode.removeChild(errorDivs[i]);
}
// get salary?
//dbug = true;
getSalary();
// Add promotions
addPromotions();
//dbug = false;
// Add actings
getActings ();
// Add lwops
getLWoPs ();
// Add Overtimes
getOvertimes();
// Add Lump Sums
getLumpSums ();
setURL();
calculate();
} // End of startProcess
function resetPeriods () {
periods = [];
periods = initPeriods;
if (dbug) console.log ("resetPeriods::initPeriods: " + initPeriods + ".");
if (dbug) console.log ("resetPeriods::periods: " + periods + ".");
} // End of resetPeriods
// getSalary called during startProcess. "guess" isn't really a good word for this, so I changed it to "get"
// I don't get it. What's the difference btween selectSalary and getSalary?
// This ones starts: get the CS-0level, get the startDateText date, check for leapyear, set the startDateTxt value, figure out your step, select the step
function getSalary () {
var levelSelect = document.getElementById("levelSelect");
var lvl = levelSelect.value.replace(/\D/, "");
if (dbug) console.log ("Got level " + lvl + "."); // and start date of " + startDate + ".");
if (lvl < 1 || lvl > 5) { // Should only happen if someone messes with the querystring
if (dbug) console.log ("getSalary::Error: lvl is -1.");
var errDiv = createHTMLElement("div", {"parentNode":levelSelect.parentNode, "id":"levelSelectError", "class":"error"});
createHTMLElement("span", {"parentNode":errDiv, "nodeText":"Please select a level"});
levelSelect.setAttribute("aria-describedby", "levelSelectError");
levelSelect.focus();
//return;
} else {
saveValues.push("lvl="+lvl);
}
level = ((lvl > 0 && lvl < salaries.length+1) ? lvl : null);
let startDate = getStartDate();
if (level && startDate) {
level -= 1;
if (dbug) console.log("getSalary::Got valid data (" + startDate.toISOString().substr(0,10) + ")....now trying to figure out salary.");
let timeDiff = (TABegin - startDate) / day;
if (stepSelect.value && stepSelect.value >= 0 && stepSelect.value < salaries[level].length) {
step = stepSelect.value;
if (dbug) console.log ("getSalary::Got step from the stepSelect. And it's " + step + ".");
} else {
if (dbug) console.log ("getSalary::Couldn't get step from the stepSelect. Gotta guess. stepSelect.value: " + stepSelect.value + ".");
if (dbug) console.log ("getSalary::TimeDiff: " + timeDiff + ".");
let years = Math.floor(timeDiff/365);
step = Math.min(years, salaries[level].length-1);
if (dbug) console.log ("getSalary::Your step would be " + step + ".");
}
var stp = step;
saveValues.push("stp="+stp);
saveValues.push("strtdt="+startDateTxt.value);
saveValues.push("enddt="+endDateTxt.value);
let dparts = null;
dparts = endDateTxt.value.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
if (dparts) {
EndDate = new Date(dparts[1], (dparts[2]-1), dparts[3]);
EndDate.setDate(EndDate.getDate() + parseInt(1));
if (dbug) console.log ("getSalary::Got EndDateTxt as " + endDateTxt.value + ".");
//if (dbug) console.log ("Got EndDate as " + EndDate.toISOString().substr(0, 10) + ".");
}
//This used to be below adding anniversaries, but some anniversaries were being missed
if (dbug) console.log ("getSalary::About to set EndDate to " + EndDate.toISOString().substr(0, 10) + ".");
addPeriod ({"startDate" : EndDate.toISOString().substr(0, 10), "increase":0, "reason":"end", "multiplier" : 1});
//add anniversarys
//dbug = true;
let startYear = Math.max(2018, startDate.getFullYear());
if (dbug) console.log ("getSalary::Going to set anniversary dates betwixt: " + startYear + " and " + EndDate.getFullYear() + ".");
for (var i = startYear; i <=EndDate.getFullYear(); i++) {
if (stp < salaries[level].length) {
let dateToAdd = i + "-" + ((startDate.getMonth()+1) > 9 ? "" : "0") + (startDate.getMonth()+1) + "-" + (startDate.getDate() > 9 ? "" : "0") + startDate.getDate();
if (dbug) console.log ("getSalary::Going to set anniversary date " + dateToAdd + ".");
if (dateToAdd > startDate.toISOString().substr(0,10)) {
if (dbug) console.log ("getSalary::Going to add anniversary on " + dateToAdd + " because it's past " + startDate.toISOString().substr(0,10) + ".");
addPeriod ({"startDate": dateToAdd, "increase":0, "reason":"Anniversary Increase", "multiplier":1});
stp++;
} else {
if (dbug) console.log ("getSalary::Not going to add anniversary on " + dateToAdd + " because it's too early.");
}
}
}
//dbug = false;
if (timeDiff < 0) {
if (dbug) console.log ("getSalary::You weren't even there then.");
// remove all older periods?? Maybe? Or just somehow make them 0s?
// This one makes the mulitpliers 0.
addPeriod ({"startDate" : startDate.toISOString().substr(0,10), "increase":0, "reason":"Starting", "multiplier":1});
for (var i = 0; i < periods.length; i++) {
if (startDate.toISOString().substr(0,10) > periods[i]["startDate"]) periods[i]["multiplier"] = 0;
}
// This one removes the ones before start date.
// This _sounds_ good, but it totally messes up the compounding raises later.
/*
addPeriod ({"startDate" : startDate.toISOString().substr(0,10), "increase":0, "reason":"Starting", "multiplier":1});
do {
periods.shift();
} while (periods[0]["startDate"] <= startDate.toISOString().substr(0,10) && periods[0]["reason"] != "Starting");
*/
//for (var i = periods.length-1; i >=0; i--)
/*
if (dbug) console.log ("getSalary::From step " + step + ".");
step = step - startYear - EndDate.getFullYear();
if (dbug) console.log ("getSalary::to step " + step + ".");
*/
} else {
//var salary = salaries[level][step];
//if (dbug) console.log ("You were there at that point, and your salary would be $" + salary.toFixed(2) + ".");
}
if (dbug) {
console.log("getSalary::pre-calc checks:");
for (var i = 0; i < periods.length; i++) {
console.log ("getSalary::" + periods[i]["reason"] + ": " + periods[i]["startDate"] + ".");
}
}
} else {
if (dbug) console.log ("getSalary::Something's not valid. Lvl: " + level + ", startDate: " + startDate + ".");
addStartDateErrorMessage();
}
} // End of getSalary
function addPromotions () {
// Add promotions
var promotions = document.querySelectorAll(".promotions");
var numOfPromotions = promotions.length;
if (dbug) console.log("addPromotions::Checking for " + numOfPromotions + " promotions.");
for (var i = 0; i < promotions.length; i++) {
var promoLevel = promotions[i].getElementsByTagName("select")[0].value;
if (dbug) console.log("addPromotions::promoLevel " + i + ": " + promoLevel + ".");
var promoDate = promotions[i].getElementsByTagName("input")[0].value.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
if (dbug) console.log("addPromotions::promoDate " + i + ": " + promoDate[0] + ".");
if (promoDate) {
if (promoDate[0] > TABegin.toISOString().substr(0,10) && promoDate[0] < EndDate.toISOString().substr(0, 10) && promoLevel > 0 && promoLevel <=5) {
if (dbug) console.log ("addPromotions::Adding a promotion on " + promoDate[0] + " at level " + promoLevel +".");
// add the promo period
var j = addPeriod ({"startDate":promoDate[0],"increase":0, "reason":"promotion", "multiplier":1, "level":(promoLevel-1)});
// remove future anniversaries
for (var k = j; k < periods.length; k++) {
if (periods[k]["reason"] == "Anniversary Increase") {
periods.splice(k, 1);
}
}
// add anniversaries
var k = parseInt(promoDate[1])+1;
if (dbug) console.log ("addPromotions::Starting with promo anniversaries k: " + k + ", and make sure it's <= " + EndDate.getFullYear() + ".");
for (k; k <= EndDate.getFullYear(); k++) {
if (dbug) console.log ("addPromotions::Adding anniversary date " + k + "-" + promoDate[2] + "-" + promoDate[3] + ".");
addPeriod ({"startDate": k + "-" + promoDate[2] + "-" + promoDate[3], "increase":0, "reason":"Anniversary Increase", "multiplier":1});
}
saveValues.push("pdate" + i + "=" + promoDate[0]);
saveValues.push("plvl" + i + "=" + promoLevel);
} else {
if (dbug) {
if (promoDate[0] > TABegin.toISOString().substr(0,10)) console.log ("addPromotions::It's after the beginning.");
if (promoDate[0] < EndDate.toISOString().substr(0, 10)) console.log ("addPromotions::It's before the end.");
if (promoLevel > 0) console.log ("addPromotions::It's greater than 0.");
if (promoLevel < 5) console.log ("addPromotions::It's less than or equal to 5.");
}
}
} else {
if (dbug) console.log("addPromotions::Didn't get promoDate.");
}
}
} // End of addPromotions
function getActings () {
// Add actings
var actingStints = document.querySelectorAll(".actingStints");
if (dbug) console.log ("getActings::Dealing with " + actingStints.length + " acting stints.");
for (var i =0; i < actings; i++) {
var actingLvl = actingStints[i].getElementsByTagName("select")[0].value;
var dates = actingStints[i].getElementsByTagName("input");
var actingFromDate = dates[0].value;
var actingToDate = dates[1].value;
if (dbug) console.log("getActings::Checking acting at " + actingLvl + " from " + actingFromDate + " to " + actingToDate + ".");
if (actingLvl >=0 && actingLvl <5 && actingFromDate.match(/\d\d\d\d-\d\d-\d\d/) && actingToDate.match(/\d\d\d\d-\d\d-\d\d/)) {
if (dbug) console.log ("getActings::Passed the initial tests.");
if (actingFromDate <= EndDate.toISOString().substr(0, 10) && actingToDate >= TABegin.toISOString().substr(0,10) && actingToDate > actingFromDate) {
if (actingFromDate < TABegin.toISOString().substr(0,10) && actingToDate >= TABegin.toISOString().substr(0,10)) actingFromDate = TABegin.toISOString().substr(0,10);
if (dbug) console.log ("getActings::And the dates are in the right range.");
// add a period for starting
var from = addPeriod({"startDate":actingFromDate, "increase":0, "reason":"Acting Start", "multiplier":1, "level":(actingLvl-1)});
// add a period for returning
var toParts = actingToDate.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
actingToDate = new Date(toParts[1], (toParts[2]-1), toParts[3]);
actingToDate.setDate(actingToDate.getDate() + parseInt(1));
var to = addPeriod({"startDate":actingToDate.toISOString().substr(0, 10), "increase":0, "reason":"Acting Finished", "multiplier":1});
var fromParts = actingFromDate.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
actingFromDate = new Date(fromParts[1], (fromParts[2]-1), fromParts[3]);
for (var j = parseInt(fromParts[1])+1; j < toParts[1]; j++) {
if (j + "-" + fromParts[2] + "-" + fromParts[3] < actingToDate.toISOString().substr(0, 10)) {
addPeriod({"startDate":j + "-" + fromParts[2] + "-" + fromParts[3], "increase":0, "reason":"Acting Anniversary", "multiplier":1});
}
}
saveValues.push("afrom" + i + "=" + actingFromDate.toISOString().substr(0, 10));
saveValues.push("ato" + i + "=" + actingToDate.toISOString().substr(0, 10));
saveValues.push("alvl" + i + "=" + actingLvl);
} else {
if (dbug) {
if (actingFromDate <= EndDate.toISOString().substr(0, 10)) console.log ("getActings::actingFrom is before EndDate");
if (actingToDate >= TABegin.toISOString().substr(0,10)) console.log ("getActings::actingTo is after startDate");
if (actingToDate <= EndDate.toISOString().substr(0, 10)) console.log ("getActings::actingTo is before EndDate");
if (actingToDate > actingFromDate) console.log ("getActings::actingTo is after actingFrom");
}
}
} else {
if (dbug) {
if (actingLvl >=0) console.log ("getActings::actingLvl >= 0");
if (actingLvl <5) console.log ("getActings::actingLvl < 5");
if (actingFromDate.match(/\d\d\d\d-\d\d-\d\d/)) console.log ("getActings::actingFrom is right format.");
if (actingToDate.match(/\d\d\d\d-\d\d-\d\d/)) console.log ("getActings::actingTo is right format.");
}
}
}
} // End of getActings
function getLWoPs () {
// Add lwops
var lwopStints = document.querySelectorAll(".lwopStints");
if (dbug) console.log ("Dealing with " + lwopStints.length + " lwops.");
for (var i =0; i < lwopStints.length; i++) {
var dates = lwopStints[i].getElementsByTagName("input");
var lwopFromDate = dates[0].value;
var lwopToDate = dates[1].value;
if (lwopFromDate.match(/\d\d\d\d-\d\d-\d\d/) && lwopToDate.match(/\d\d\d\d-\d\d-\d\d/)) {
if (dbug) console.log ("getLWoPs::Passed the initial tests for " + lwopFromDate + " to " + lwopToDate + ".");
if (lwopFromDate <= EndDate.toISOString().substr(0, 10) &&
lwopToDate >= TABegin.toISOString().substr(0,10) &&
lwopToDate > lwopFromDate) {
if (lwopFromDate <= TABegin.toISOString().substr(0, 10) && lwopToDate >= TABegin.toISOString().substr(0,10)) lwopFromDate = TABegin.toISOString().substr(0, 10);
if (lwopFromDate <= EndDate.toISOString().substr(0, 10) && lwopToDate > EndDate.toISOString().substr(0, 10)) lwopToDate = EndDate.toISOString().substr(0, 10);
if (dbug) console.log ("getLWoPs::And the dates are in the right range.");
// add a period for starting
var from = addPeriod({"startDate":lwopFromDate, "increase":0, "reason":"LWoP Start", "multiplier":0});
// add a period for returning
var toParts = lwopToDate.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
lwopToDate = new Date(toParts[1], (toParts[2]-1), toParts[3]);
lwopToDate.setDate(lwopToDate.getDate() + parseInt(1));
var to = addPeriod({"startDate":lwopToDate.toISOString().substr(0, 10), "increase":0, "reason":"LWoP Finished", "multiplier":1});
for (var j = from; j < to; j++) {
periods[j]["multiplier"] = 0;
}
saveValues.push("lfrom" + i + "=" + lwopFromDate); //.toISOString().substr(0, 10));
saveValues.push("lto" + i + "=" + lwopToDate.toISOString().substr(0, 10));
//var fromParts = lwopFromDate.match(/(\d\d\d\d)-(\d\d)-(\d\d)/);
//lwopFromDate = new Date(fromParts[1], (fromParts[2]-1), fromParts[3]);
} else {
if (dbug) {
if (lwopFromDate <= EndDate.toISOString().substr(0, 10)) console.log ("lwopFrom is before EndDate");
if (lwopToDate >= TABegin.toISOString().substr(0,10)) console.log ("lwopTo is after startDate");
if (lwopToDate > lwopFromDate) console.log ("lwopTo is after lwopFrom");
}
}
} else {
if (dbug) {
if (lwopFromDate.match(/\d\d\d\d-\d\d-\d\d/)) console.log ("getLWoPs::lwopFrom is right format.");
if (lwopToDate.match(/\d\d\d\d-\d\d-\d\d/)) console.log ("getLWoPs::lwopTo is right format.");
}
}
}
} // End of getLWoPs
function getOvertimes () {
// Add Overtimes
var overtimeStints = document.querySelectorAll(".overtimes");
if (dbug) console.log ("overtimes::Dealing with " + overtimeStints.length + " overtimes.");
for (var i =0; i < overtimeStints.length; i++) {
var overtimeDate = overtimeStints[i].querySelector("input[type=date]").value;
var overtimeAmount = overtimeStints[i].querySelector("input[type=text]").value.replace(/[^\d\.]/, "");
var overtimeRate = overtimeStints[i].querySelector("select").value;
if (overtimeDate.match(/\d\d\d\d-\d\d-\d\d/)) {
if (dbug) console.log ("Passed the initial tests.");
if (overtimeDate >= TABegin.toISOString().substr(0,10) && overtimeDate <= EndDate.toISOString().substr(0, 10) && overtimeAmount > 0) {
if (dbug) console.log ("overtimes::And the dates are in the right range.");
// add a period for starting
var from = addPeriod({"startDate":overtimeDate, "increase":0, "reason":"Overtime", "multiplier":0, "hours":overtimeAmount, "rate":overtimeRate});
saveValues.push("otdate" + i + "=" + overtimeDate);
saveValues.push("otamt" + i + "=" + overtimeAmount);
saveValues.push("otrt" + i + "=" + overtimeRate);
} else {
if (dbug) {
if (overtimeDate >= TABegin.toISOString().substr(0,10)) console.log ("overtimeDate is after startDate");
if (overtimeDate <= EndDate.toISOString().substr(0, 10)) console.log ("overtimeDate is before EndDate");
if (overtimeAmount > 0) console.log ("overtimeAmount > 0");
}
}
} else {
if (dbug) {
if (overtimeDate.match(/\d\d\d\d-\d\d-\d\d/)) console.log ("overtimeDate is right format.");
}
}
}
} // End of getOvertimes
function getLumpSums () {
// Add LumpSums
var lumpsums = document.querySelectorAll(".lumpSums");
if (dbug) console.log ("Dealing with " + lumpsums.length + " lumpsums.");
for (var i =0; i < lumpsums.length; i++) {
var lumpSumDate = lumpsums[i].querySelector("input[type=date]").value;
var lumpSumAmount = lumpsums[i].querySelector("input[type=text]").value.replace(/[^\d\.]/, "");
if (lumpSumDate.match(/\d\d\d\d-\d\d-\d\d/)) {
if (dbug) console.log ("Passed the initial tests.");
if (lumpSumDate >= TABegin.toISOString().substr(0,10) && lumpSumDate <= EndDate.toISOString().substr(0, 10) && lumpSumAmount > 0) {
if (dbug) console.log ("And the dates are in the right range.");
// add a period for starting
var from = addPeriod({"startDate":lumpSumDate, "increase":0, "reason":"Lump Sum", "multiplier":0, "hours":lumpSumAmount});
saveValues.push("lsdate" + i + "=" + lumpSumDate);
saveValues.push("lsamt" + i + "=" + lumpSumAmount);
} else {
if (dbug) {
if (lumpSumDate >= TABegin.toISOString().substr(0,10)) console.log ("lumpSumDate is after startDate");
if (lumpSumDate <= EndDate.toISOString().substr(0, 10)) console.log ("lumpSumDate is before EndDate");
if (lumpSumAmount > 0) console.log ("lumpSumAmount > 0");
}
}
} else {
if (dbug) {
if (lumpSumDate.match(/\d\d\d\d-\d\d-\d\d/)) console.log ("lumpSumDate is right format.");
}
}
}
} // End of getLumpSums
/*
Defunct:
function handlePromotions () {
//var lvl = parseInt(document.getElementById("levelSelect").value.replace(/\D/, ""));
var promotionsDiv = document.getElementById("promotionsDiv");
var numOfPromotions = numPromotions.value;
for (var i = 0; i < 4; i++) {
var newPromotionDiv = null;
newPromotionDiv = document.getElementById("promo" + i);
if (newPromotionDiv) {
// It's there.
if (i>=numOfPromotions) {
promotionsDiv.removeChild(newPromotionDiv);
}
} else {
// It's not there.
if (i < numOfPromotions) {
newPromotionDiv = createHTMLElement("div", {"parentNode":promotionsDiv, "class":"fieldHolder promotions", "id":"promo"+i});
var newPromoLbl = createHTMLElement("label", {"parentNode":newPromotionDiv, "for":"promoDate" + i, "nodeText":"Date of promotion: "});
var newPromoDate = createHTMLElement("input", {"parentNode":newPromotionDiv, "type":"date", "id":"promoDate" + i, "aria-describedby":"dateFormat"});
var newLevelLbl = createHTMLElement("label", {"parentNode":newPromotionDiv, "for":"promoLevel" + i, "nodeText":"Level promotion: "});
var newPromoSel = createHTMLElement("select", {"parentNode":newPromotionDiv, "id":"promoLevel" + i});
for (var j = 0; j < 6; j++) {
var newPromoOpt = createHTMLElement("option", {"parentNode":newPromoSel, "value": j, "nodeText":(j == 0 ? "Select Level" : "CS-0" + j)});
}
}
}
}
resultStatus.innerHTML="New promotions section added.";
} // End of handlePromotions
*/
function addPromotionHandler (e, o) {
let toFocus = true;
let pdate = null;
let plvl = null;
if (arguments.length > 1) {
let args = arguments[1];
if (dbug) console.log ("addPromotionHandler::arguments: " + arguments.length);
if (args.hasOwnProperty("toFocus")) toFocus = args["toFocus"];
if (args.hasOwnProperty("date")) {
pdate = (isValidDate(args["date"]) ? args["date"] : null);
}
if (args.hasOwnProperty("level")) {
plvl = args["level"].replaceAll(/\D/g, "");
plvl = (plvl >0 && plvl <6 ? plvl : null);
}
if (dbug) console.log (`addPromotionHandler::toFocus: ${toFocus}, pdate: ${pdate}, plvl: ${plvl}.`);
}
let promotionsDiv = document.getElementById("promotionsDiv");
let id = promotions;
let looking = true;
while (looking) {
if (document.getElementById("promotion" + id)) {
id++;
} else {
looking = false;
}
}
let newPromotionFS = createHTMLElement("fieldset", {"parentNode":promotionsDiv, "class":"fieldHolder promotions", "id" :"promo" + id});
let newPromotionLegend = createHTMLElement("legend", {"parentNode":newPromotionFS, "textNode":"Promotion " + (id+1)});
var newPromoLbl = createHTMLElement("label", {"parentNode":newPromotionFS, "for":"promoDate" + id, "nodeText":"Date of promotion: "});
var newPromoDate = createHTMLElement("input", {"parentNode":newPromotionFS, "type":"date", "id":"promoDate" + id, "aria-describedby":"dateFormat", "value":(pdate ? pdate : null)});
if (toFocus) newPromoDate.focus();
//newPromoDate.addEventListener("change", saveValue, false);
let newLevelLbl = createHTMLElement("label", {"parentNode":newPromotionFS, "for":"promotionLevel" + id, "nodeText":"Promoted to level: "});
var newPromotionSel = createHTMLElement("select", {"parentNode":newPromotionFS, "id":"promotionLevel" + id});
for (var j = 0; j < 6; j++) {
var newPromoOpt = createHTMLElement("option", {"parentNode":newPromotionSel, "value": j, "nodeText":(j == 0 ? "Select Level" : "CS-0" + j)});
if (plvl) {
if (plvl == j) newPromoOpt.setAttribute("selected", "selected");
} else {
if (parseInt(levelSel.value)+1 == j) newPromoOpt.setAttribute("selected", "selected");
}
}
//newPromotionSel.addEventListener("change", saveValue, false);
let promoButtonsDiv = null;
if (id == 0) {
promoButtonsDiv = createHTMLElement("div", {"parentNode":newPromotionFS, "id":"promoButtonsDiv"});
var newDelPromotionBtn = createHTMLElement("input", {"parentNode":promoButtonsDiv, "type":"button", "value":"Remove", "id": "removePromotionBtn" + promotions});
var newAddPromotionBtn = createHTMLElement("input", {"parentNode":promoButtonsDiv, "type":"button", "value":"Add another promotion", "class":"promotionsBtn", "id": "addPromotionsBtn" + id});
newAddPromotionBtn.addEventListener("click", addPromotionHandler, false);
newDelPromotionBtn.addEventListener("click", removePromotionDiv, false);
} else {
promoButtonsDiv = document.getElementById("promoButtonsDiv");
newPromotionFS.appendChild(promoButtonsDiv);
}
promotions++;
resultStatus.innerHTML="New Acting section added.";
} // End of addPromotionHandler
function addActingHandler () {
let toFocus = true;
let afdate = null;
let atdate = null;
let alvl = null;
if (arguments.length > 1) {
let args = arguments[1];