-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBigfoot-Bib-Report-Initial.html
1207 lines (1009 loc) · 54.1 KB
/
Bigfoot-Bib-Report-Initial.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="author" content="Greg KG6SJT" />
<meta name="author" content="Jon K7RMZ" />
<meta
name="description"
content="Race Tracker Form for Winlink Express created by KG6SJT, modified by K7RMZ for Bigfoot ultra marathon comms-support events."
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="" />
<title>Bigfoot Bib Tracker</title>
<script language="javascript" type="text/javascript">
// get data in TheCsvData and clean it up and set the count of entries
function cleanAndCountCsvData() {
let csvData = GetElementById('TheCsvData').value;
let csvDataArray = csvData.split('\n');
let nonEmptyLinesCount = 0;
let cleanCsvDataArray = csvDataArray.map(item => {
if (item !== undefined && item.length > 0) {
nonEmptyLinesCount++;
return item.replace(/ *\, */g, ', ');
}
});
let rejoinedCsvData = cleanCsvDataArray.join('\n');
GetElementById('TheCsvData').value = rejoinedCsvData;
GetElementById('entryCount').value = nonEmptyLinesCount;
}
// converts bib records from csv-delimited and returns tab-delimited version
function convertCsvRecordsToTabbed() {
let csvData = GetElementById('TheCsvData').value;
return csvData.replace(/, /g, '\t');
}
// updates both csv and tabbed bib records into their respective elements
function updateCsvAndTabRecordsElement(riderNum, bibAction, time, dayOfMonth, shortLoc){
let previousRecordsComma = GetElementById('TheCsvData').value;
let previousRecordsTab = convertCsvRecordsToTabbed();
GetElementById('TheCsvData').value = formatBibRecord(previousRecordsComma, riderNum, bibAction, time, dayOfMonth, shortLoc, ', ');
GetElementById('TheData').value = formatBibRecord(previousRecordsTab, riderNum, bibAction, time, dayOfMonth, shortLoc, '\t');
}
// pluck the top record from the csv data and return to the caller
function getTopRecordFromCsvData() {
let csvData = GetElementById('TheCsvData').value;
let csvDataArray = csvData.split('\n');
let topRecord = csvDataArray[0];
return topRecord;
}
// copy csv data and convert it to tabbed then set tabbed data to tabbed data element
function handleCsvDataEdited() {
let csvData = GetElementById('TheCsvData').value;
let tabbedData = convertCsvRecordsToTabbed();
GetElementById('TheData').value = tabbedData;
let lastEnteredBibRecord = getTopRecordFromCsvData();
// force a comma-space delimiter for readability
let lastEnteredBibRecordParts = lastEnteredBibRecord.split(', ');
storePreviousRecord(lastEnteredBibRecordParts[0], lastEnteredBibRecordParts[1], lastEnteredBibRecordParts[2], lastEnteredBibRecordParts[3], lastEnteredBibRecordParts[4]);
}
// gets an element by id
function GetElementById(id) {
return document.getElementById(id);
}
// calculate most likely hours characters returning a best-effort hours value
function getHoursFromTimeString(timeString) {
var ghColonIndex = timeString.indexOf(':');
var ghHoursResult = "00";
// if there is a colon, take character(s) just before it
if (ghColonIndex > -1) {
if (ghColonIndex > 2) {
var ghHourIndex = ghColonIndex - 2;
ghHoursResult = timeString.slice(ghHourIndex, ghColonIndex);
}
if (ghColonIndex > 0 && ghColonIndex <= 2) {
ghHoursResult = timeString.slice(0, ghColonIndex);
}
}
else {
// if there is no colon take up to 2 leftmost characters depending on timeString size
if (timeString.length >= 4) {
ghHoursResult = timeString.slice(timeString.length - 4, timeString.length - 2);
}
if (timeString.length === 3) {
ghHoursResult = timeString.slice(0, 1);
}
if (timeString.length <= 2) {
console.log('Info: TIME value character cound is less than 3. No action required.');
}
}
return ghHoursResult;
}
// calculate most likely minutes characters returning a best-effort minutes value
function getMinutesFromTimeString(gmTimeString) {
var gmColonIndex = gmTimeString.indexOf(':');
var gmMinutesResult = "00";
// if there is a colon, take up to 2 characters after it, adding zero(s) to get 2 characters total
if (gmColonIndex > -1) {
if (gmColonIndex < gmTimeString.length - 1) {
// if input :01 then result 01, if input :001 then result 00, etc
gmMinutesResult = gmTimeString.slice(gmColonIndex + 1, gmColonIndex + 3);
}
while (gmMinutesResult.length < 2) {
// if input was : then result 00, if :1 then result 10, if :2 then result 20, etc
gmMinutesResult = gmMinutesResult + '0';
}
}
else {
// there is no colon in the input so best-effort to find minutes characters
if (gmTimeString.length == 2) {
// 11 is 11, 22 is 22 etc
gmMinutesResult = gmTimeString;
}
if (gmTimeString.length > 2) {
// just take the last two characters there is no way to tell user intent anymore
gmMinutesResult = gmTimeString.slice(gmTimeString.length - 2, gmTimeString.length);
}
if (gmTimeString.length == 1) {
// if no colon then 1 is 01 minutes, 2 is 02 minutes, etc
gmMinutesResult = "0" + gmTimeString;
}
}
return gmMinutesResult;
}
// return a valid value for hours or minutes based on maxValue
function sanitizeTimeUnits(stuTimeString, maxValue) {
var stuTimeNum = Number.parseInt(stuTimeString, 10);
if (stuTimeNum === undefined || Number.isNaN(stuTimeNum) || stuTimeNum < 0) {
stuTimeNum == '00';
}
if (stuTimeNum > maxValue) {
stuTimeNum = maxValue;
}
var stuResult = stuTimeNum.toString();
while (stuResult.length < 2) {
stuResult = '0' + stuResult;
}
return stuResult;
}
// take a string and attempt to format it as HHMM using helper methods
function formatTimeValue(ftvTimeString) {
// eliminate common non-time characters from the string maintaining only numbers and colon character
var ftvHoursMins = ftvTimeString.replaceAll(/(?:[a-zA-Z]|[,;\!\@\#\$\%\^\&\*\(\)\-\_])/gm, '');
// get hours and minutes, sanitize the numbers, then concatenate and return
var ftvHours = getHoursFromTimeString(ftvHoursMins);
var ftvMinutes = getMinutesFromTimeString(ftvHoursMins);
var ftvSanitizedHours = sanitizeTimeUnits(ftvHours, 23);
var ftvSanitizedMinutes = sanitizeTimeUnits(ftvMinutes, 59);
return ftvSanitizedHours + ftvSanitizedMinutes;
}
function getDayOfMonth(date) {
var today = date.getDate();
var day = GetElementById('yesterday').checked ? (today === 1 ? 31 : today - 1) : today;
var result = day.toString();
if (result.length < 2) {
result = "0" + result;
}
return result;
}
function ResetForm() {
['RiderNum', 'TimeField'].forEach(id => GetElementById(id).value = '');
GetElementById('yesterday').checked = false;
GetElementById('RiderNum').focus();
}
// validate bib number and time then add bib record to csv and tab record elements
function handleAddBib(bibAction) {
const riderNum = GetElementById('RiderNum').value;
if (riderNum && bibAction != undefined && bibAction.length > 0) {
// let time = formatCurrentTime(GetElementById('TimeField').value);
var time = formatTimeValue(GetElementById('TimeField').value);
let dayOfMonth = getDayOfMonth(new Date());
let locationVal = GetElementById('Location').value;
let shortLoc = shortenLocation(locationVal);
storePreviousRecord(riderNum, bibAction, time, dayOfMonth, shortLoc);
updateCsvAndTabRecordsElement(riderNum, bibAction, time, dayOfMonth, shortLoc);
ResetForm();
cleanAndCountCsvData();
} else {
alert('Enter Runner/Bib number');
GetElementById('RiderNum').focus();
}
}
function elementValuesToLocalStorage() {
let addressFormatted = GetElementById('address');
localStorage.setItem('RTrackeradd', addressFormatted.value);
let locationFormatted= GetElementById('Location');
localStorage.setItem('RTrackerloc', locationFormatted.value);
let eventTitleFormatted = GetElementById('EventTitle');
localStorage.setItem('RTrackertitle', eventTitleFormatted.value);
let msgNumFormatted = GetElementById('MessageNumber');
localStorage.setItem('MessageNumber', msgNumFormatted.value);
let locationLong = lengthenLocation(locationFormatted.value);
let regulartitle = GetElementById('EventTitle').value + ' ' + locationLong + ' Message #' + msgNumFormatted.value;
GetElementById('msgsubject').value = regulartitle;
}
function shortenLocation(locationVal) {
let underscoreIdx = locationVal.indexOf('_');
return locationVal.slice(0, underscoreIdx);
}
function lengthenLocation(locationVal) {
if (!locationVal) {
return ' ';
}
let underscoreIdx = locationVal.indexOf('_') + 1;
return locationVal.slice(underscoreIdx);
}
// set form elements with the values stored in local storage
function setFormElementsWithLsValues() {
let storedAddress = localStorage.getItem('RTrackeradd');
GetElementById('address').value = storedAddress;
let storedLocation = localStorage.getItem('RTrackerloc');
if (storedLocation !== '') {
GetElementById('Location').value = storedLocation;
} else {
GetElementById('Location').value = '--Choose a station--';
}
let storedTitle = localStorage.getItem('RTrackertitle');
GetElementById('EventTitle').value = storedTitle;
let storedMsgNumber = localStorage.getItem('MessageNumber');
GetElementById('MessageNumber').value = storedMsgNumber;
let locationLong = lengthenLocation(storedLocation);
let regulartitle = '' + storedTitle + ' ' + locationLong + ' Message #' + storedMsgNumber;
GetElementById('msgsubject').value = regulartitle;
GetElementById('MessageNumber').value = storedMsgNumber;
GetElementById('FormatNote').value = '* The entries in the message will be TAB delimited, allowing copy/paste into a spreadsheet.';
copyPreviousRecordFromLsToElement();
}
function copyPreviousRecordFromLsToElement() {
// if previous record key exists in local storage populate the element with string formatted value
if (localStorage.getItem('previousRecord')) {
const previousItem = JSON.parse(localStorage.getItem('previousRecord'));
const prevRunner = previousItem.runner || 'none';
const prevAction = previousItem.action || 'none';
const prevTime = previousItem.time || 'none';
const prevDOM = previousItem.dayOfMonth || 'none';
const prevMsgNum = previousItem.messageNumber || 'none';
console.log('previous Runner, Action, Time, DOM, MsgNum', prevRunner, prevAction, prevTime, prevDOM, prevMsgNum);
const previousRecordString = '#' + previousItem.runner + ', ' + previousItem.action + ', ' + prevTime + ', D:' + previousItem.dayOfMonth + ', M#' + previousItem.messageNumber;
GetElementById('endOfPriorBatch').value = previousRecordString;
}
}
function clearParticipantData() {
if (confirm('Clear all participant data?')) {
GetElementById('TheData').value = '';
GetElementById('TheCsvData').value = '';
GetElementById('Inbtn').disabled = false;
GetElementById('Outbtn').disabled = false;
GetElementById('Dropbtn').disabled = false;
GetElementById('entryCount').disabled = false;
GetElementById('entryCount').value = '0';
let formatNoteText =
'* Entries in the email will be tab-delimited, allowing copy/paste into a spreadsheet.';
GetElementById('FormatNote').value = formatNoteText;
ResetForm();
}
}
// gets, formats, and returns the current clock time in HHMM format
function getCurrentTime() {
var currentDateResult = new Date();
var dateResultHoursOnly = currentDateResult.getHours();
var dateResultMinutesOnly = currentDateResult.getMinutes();
var currentHour = dateResultHoursOnly.toString();
while (currentHour.length < 2) {
currentHour = "0" + currentHour;
}
var currentMinute = dateResultMinutesOnly.toString();
while (currentMinute.length < 2) {
currentMinute = "0" + currentMinute;
}
var resultGctTime = currentHour + ':' + currentMinute;
return resultGctTime;
}
function addIn() {
handleAddBib('IN');
}
function addOut() {
handleAddBib('OUT');
}
function addDrop() {
handleAddBib('DROP');
}
function storePreviousRecord(bibNumber, action, timestamp, dayOfMonth, location) {
// capture the current message number to store with the previous record
const messageNumber = GetElementById('MessageNumber').value;
// initialize a new object and store bibNumber, action, timestamp, dayOfMonth, and location variables as properties
let previousRecord = {
runner: bibNumber,
action: action,
time: timestamp,
dayOfMonth: dayOfMonth,
location: location,
messageNumber: messageNumber,
};
// store this object into localStorage
localStorage.setItem('previousRecord', JSON.stringify(previousRecord));
}
// separator is either '\t' or ', ' depending on format needed
function formatBibRecord(pTime, tRunner, action, tTime, doM, loc, separator) {
if (separator !== '\t' && separator !== ', ') {
separator = '\t';
}
storePreviousRecord(tRunner, action, tTime, doM, loc);
newTime = String(tTime);
if (tTime.indexOf(':') > -1) {
newTime = tTime.replace(':', '');
}
return (
tRunner +
separator +
action +
separator +
newTime +
separator +
doM +
separator +
loc +
'\n' +
pTime
);
}
function autoGrowTextArea(textField) {
if (textField.clientHeight < textField.scrollHeight) {
textField.style.height =
textField.scrollHeight * 2 - textField.clientHeight + 'px';
}
}
// converts bib records in TheData element from tab-separated to comma-separated values
function convertRawBibRecordsToArray() {
let bibRecordsRaw = GetElementById('TheData').value;
const bibRecordsArray = bibRecordsRaw.split('\n');
const cleanBibRecordsArray = [];
bibRecordsArray.forEach(record => {
if (record.length > 0) {
let csvRecord = record.replace(/\t/g, ', ');
cleanBibRecordsArray.push(csvRecord);
}
});
return cleanBibRecordsArray;
}
function createJsonObjectFromFormElements(cleanBibRecordsArray) {
const jsonObject = {
FormVersion: GetElementById('FormVersion').value,
EventTitle: GetElementById('EventTitle').value,
MessageNumber: GetElementById('MessageNumber').value,
address: GetElementById('address').value,
Location: GetElementById('Location').value,
msgsubject: GetElementById('msgsubject').value,
entryCount: GetElementById('entryCount').value,
Comment: GetElementById('Comment').value,
TheCsvData: cleanBibRecordsArray
};
return jsonObject;
}
function saveTextAsFile() {
let fileNameToSaveAs = 'Bigfoot Bib Data ' + dateStampForFile() + '.txt';
fileNameToSaveAs = prompt('', fileNameToSaveAs);
const cleanBibRecords = convertRawBibRecordsToArray();
let formElementsAsJson = createJsonObjectFromFormElements(cleanBibRecords);
let textToWrite = JSON.stringify(formElementsAsJson, null, 2);
let textFileAsBlob = new Blob([textToWrite], {
type: 'application/json',
});
if (navigator.msSaveBlob) {
navigator.msSaveBlob(textFileAsBlob, fileNameToSaveAs);
} else {
let downloadLink = document.createElement('a');
downloadLink.download = fileNameToSaveAs;
downloadLink.href = URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = function (e) {
document.body.removeChild(e.target);
};
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
downloadLink.click();
}
}
function dateStampForFile() {
let d = new Date();
let thisyear = d.getFullYear();
let thismonth = d.getMonth() + 1;
let thisday = d.getDate();
let h = (d.getHours() < 10 ? '0' : '') + d.getHours();
let m = (d.getMinutes() < 10 ? '0' : '') + d.getMinutes();
if (thismonth < 10) {
thismonth = '0' + thismonth;
}
if (thisday < 10) {
thisday = '0' + thisday;
}
return '' + thisyear + '-' + thismonth + '-' + thisday + ' ' + h + '_' + m;
}
// captures each form element value in a JSON object and stores it in hidden element 'parseme'
function storeFormValuesToHiddenElement() {
const FormVersion = GetElementById('FormVersion').value;
const EventTitle = GetElementById('EventTitle').value;
const MessageNumber = GetElementById('MessageNumber').value;
const address = GetElementById('address').value;
const Location = GetElementById('Location').value;
const msgsubject = GetElementById('msgsubject').value;
const entryCount = GetElementById('entryCount').value;
const TheData = GetElementById('TheData').value;
const Comment = GetElementById('Comment').value;
const previousRecord = JSON.parse(localStorage.getItem('previousRecord'));
const formObject = JSON.stringify({
FormVersion,
EventTitle,
MessageNumber,
address,
Location,
msgsubject,
entryCount,
TheData,
Comment,
previousRecord,
});
GetElementById('parseme').value = formObject;
}
// takes values stored in parseme hidden element, iterates through form elements and populates them with values
function populateForm(jsonStringData) {
if (jsonStringData === undefined || jsonStringData.length < 1) {
console.log('jsonStringData is empty. Exiting function.');
} else {
GetElementById('EventTitle').value = jsonStringData.EventTitle;
GetElementById('MessageNumber').value = jsonStringData.MessageNumber ? jsonStringData.MessageNumber : 1;
GetElementById('address').value = jsonStringData.address ? jsonStringData.address : '';
GetElementById('Location').value = jsonStringData.Location ? jsonStringData.Location : '';
GetElementById('msgsubject').value = jsonStringData.msgsubject ? jsonStringData.msgsubject : '';
GetElementById('entryCount').value = jsonStringData.entryCount ? jsonStringData.entryCount : 0;
GetElementById('Comment').value = jsonStringData.Comment ? jsonStringData.Comment : '';
GetElementById('endOfPriorBatch').value = jsonStringData.previousRecord ? jsonStringData.previousRecord : '';
const theCsvDataRaw = jsonStringData.TheCsvData;
let csvData = theCsvDataRaw.join('\n');
GetElementById('TheCsvData').value = csvData;
let tabbedData = theCsvDataRaw.map(item => {
if (item !== undefined && item.length > 0) {
return item.replace(/, /g, '\t');
}
}).join('\n');
GetElementById('TheData').value = tabbedData;
copyPreviousRecordFromLsToElement();
}
}
function SaveData() {
storeFormValuesToHiddenElement();
elementValuesToLocalStorage(); // update localstorage values
saveTextAsFile();
}
function incrementMsgNum() {
const formMsgNum = Number.parseInt(GetElementById('MessageNumber').value, 10);
const lsMsgNum = Number.parseInt(localStorage.getItem('MessageNumber'), 10);
const incrMsgNum = formMsgNum ? formMsgNum + 1 : 1;
GetElementById('MessageNumber').value = incrMsgNum;
elementValuesToLocalStorage();
}
window.addEventListener('load', function () {
const formVersion = '2.3.5';
document.getElementById('thisVersion').innerText = 'Version ' + formVersion;
document.getElementById('FormVersion').value = formVersion;
localStorage.setItem('Form Version', formVersion);
// Check the support for the File API
if (window.File && window.FileReader && window.FileList && window.Blob) {
let fileSelected = GetElementById('txtfiletoread');
// begin fileSelected Change Event Listener
fileSelected.addEventListener('change', function (e) {
// Set the extension for the file
let fileExtension = /text.*/;
// Get the file object
let fileTobeRead = fileSelected.files[0];
// Check if the extension matches
if (fileTobeRead.type.match(fileExtension)) {
// Initialize the FileReader object to read the file data
let fileReader = new FileReader();
fileReader.onload = function (e) {
document.getElementById('parseme').value = fileReader.result;
try {
let jsonData = JSON.parse(document.getElementById('parseme').value);
// console.log('filereader.onload json parse of parseme element value: ', jsonData);
populateForm(jsonData);
} catch (err) {
console.error('An error occurred while parsing the JSON data: ', err);
}
};
fileReader.readAsText(fileTobeRead);
} else {
alert('Please select a text file');
}
});
// end fileSelected Change Event Listener
} else {
alert('Files are not supported');
}
setFormElementsWithLsValues();
autoGrowTextArea(GetElementById('TheCsvData'));
});
</script>
<style type="text/css">
body {
font-family:Arial, Helvetica, sans-serif;
font-size: 18px;
background-color: rgb(220, 220, 220);
}
@media screen and (width < 650px) {
label, input, textarea, select, button {
font-size: .7em;
}
input {
margin: 0.2em 0.2em;
}
input[type="checkbox"] {
width: 1em;
height: 1em;
}
.formTitleHeader {
font-size: 2em;
}
.bibEntries {
min-height: 3em;
max-height: 6em;
}
.msgHeaderTitle {
font-size: 0.7em;
}
.addressInput {
min-width: 70%;
}
.block-line-div {
display: block;
}
.readOnlyText {
font-size: 0.6em;
}
}
@media screen and (width >= 650px) {
label, input, textarea, select, button {
font-size: 1em;
}
input {
margin: 0.3em 0.3em;
}
input[type="checkbox"] {
width: 1.2em;
height: 1.2em;
}
.formTitleHeader {
font-size: 3em;
}
.bibEntries {
min-height: 4em;
max-height: 10em;
}
.msgHeaderTitle {
font-size: 1.1em;
}
.addressInput {
max-width: 55%;
}
.block-line-div {
display: inline;
}
}
hr {
height: 0.1em;
width: 90%;
}
textarea {
width: 96%;
}
ul {
list-style-type: none;
}
li {
padding: 0.2rem;
}
.screen-reader {
/* only screen readers see this element */
position: absolute;
left: -500px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
}
.div-across-auto-align {
width:100%;
margin:auto;
text-align:center;
}
.formTitleHeader {
text-align: center;
color:rgb(0,0,255);
font-style: italic;
}
.msgHeaderTitle {
color: rgb(0,0,255);
text-align: center;
}
.maxSizeInputWidth {
min-width: 75%;
}
.readOnlyText {
color: rgb(84, 84, 84) !important;
outline: none !important;
cursor: default !important;
opacity: unset !important;
}
/* Pop-up content shifted off-screen when not in view. Still readable by screen-reader software. When targeted it fills the browser window. */
.pop-up {
position: absolute;
top: 0em;
left: -500em;
}
.pop-up:target {
position: static;
left: 0em;
}
/* The pop-up itself */
.popBox {
background: rgb(255, 255, 255);
/* alternatively fixed width / height and negative margins from 50% */
position: absolute;
left: 2em;
right: 2em;
top: 2em;
bottom: 2em;
z-index: 10;
border: 3px solid rgb(0, 0, 150);
/* CSS3 where available: rounded corners, drop-shadow, and fade in. */
border-radius: 1rem;
box-shadow: 0rem 0.5rem 0.5rem rgb(255, 255, 255);
opacity: 0;
transition: opacity 0.8s ease-out;
}
:target .popBox {
position: fixed;
opacity: 1;
}
/* The pop-ups close link, moved via CSS to the top right of the pop-up */
.close:link,
.close:visited {
position: absolute;
top: -2rem;
right: -0.75em;
display: block;
line-height: 1.8;
padding-left: 0.4rem;
padding-right: 0.4rem;
padding-top: 0.2rem;
padding-bottom: 0.2rem;
text-align: center;
text-decoration: none;
background-color: rgb(0,0,0);
border: 2px solid rgb(255,255,255);
color: rgb(255,255,255);
border-radius: 1em;
box-shadow: 0rem 0rem 0.5rem 0.5rem;
}
.close:hover,
.close:active,
.close:focus {
box-shadow: 0rem 0rem 0.5rem 0.5rem;
background-color: rgb(192, 192, 192);
color: rgb(0,0,0);
}
.close span {
text-indent: -200em;
display: block;
}
/* The pop-up content div will scroll if it has too much content */
.popScroll {
position: absolute;
top: 1rem;
left: 1rem;
right: 1rem;
bottom: 1rem;
overflow-y: auto;
padding-right: 0.5em;
}
input {
padding: 0.2em 0.2em;
border-radius: 0.5rem;
}
input[type='submit'] {
color: rgb(0, 0, 0);
font-weight: bold;
background-color: rgb(113, 169, 253);
padding-left: 0.8em;
padding-right: 0.8em;
}
.clearDataButton {
color: black;
background-color: rgb(255, 153, 0);
font-weight: bold;
}
input[type='button'] {
color: black;
padding-left: 0.8em;
padding-right: 0.8em;
}
textarea, select {
padding: 0.3em 0.3em;
border: rgb(0,0,0) solid 0.15em;
border-radius: 0.5rem;
}
input:hover, textarea:hover, select:hover {
cursor: pointer;
opacity: 0.8;
}
input:focus, textarea:focus, select:focus {
outline: rgb(255, 153, 0) solid 3px;
}
</style>
</head>
<body>
<section id="close">
<form
onsubmit="return confirm('To complete your form submission, click OK and close the browser tab. You will return to the new message window so you can post your message to the outbox.');"
method="post" id="myform" enctype="multipart/form-data" action="http://{FormServer}:{FormPort}">
<div style="text-align: center;">
<label class="formTitleHeader">Bigfoot Bib Report</label>
</div>
<div style="text-align: center;">
<input type="button" value="Form Information - READ" onclick="location.href='#pop1'" />
<label id="thisVersion"></label>
</div>
<hr />
<div class="msgHeaderTitle">Message Header</div>
<div class="div-across-auto-align">
<div class="block-line-div">
<label for="EventTitle">Event Name:</label>
<input name="EventTitle" type="text" id="EventTitle" maxlength="40" onchange="elementValuesToLocalStorage();" placeholder="Race or Event Name" required />
</div>
<div class="block-line-div">
<label for="MessageNumber">Message #</label>
<input name="MessageNumber" type="text" id="MessageNumber" maxlength="3" style="max-width: 3em;" onchange="elementValuesToLocalStorage();" />
<input name="incrMsgNum" type="button" id="incrMsgNum" value="increment" onclick="incrementMsgNum();" />
<!-- invisible label that screen readers can still use -->
<label for="incrMsgNum" class="screen-reader">Increment</label>
</div>
</div>
<div class="div-across-auto-align">
<div class="block-line-div">
<label for="address">Send to:</label>
<input name="address" type="text" id="address" class="addressInput" maxlength="40" onchange="elementValuesToLocalStorage();"
title="Separate multiple calls or addresses with a semicolon;" placeholder="Winlink Radio Call or Email"
required />
</div>
<div class="aidStnSpan block-line-div">
<label for="Location">Aid Station:</label>
<select name="Location" id="Location" onchange="elementValuesToLocalStorage();" required>
<option value="MM_Marble Mountain SnoPark">Marble Mountain SnoPark</option>
<option value="BL_Blue Lake">Blue Lake</option>
<option value="AC_Ape Canyon">Ape Canyon</option>
<option value="WR_Windy Ridge">Windy Ridge</option>
<option value="JR_Johnston Ridge">Johnston Ridge</option>
<option value="CW_Coldwater Lake">Coldwater Lake</option>
<option value="NP_Norway Pass">Norway Pass</option>
<option value="EP_Elk Pass">Elk Pass</option>
<option value="WM_Wright Meadow (Rd.9327)">Wright Meadow (Rd.9327)</option>
<option value="SB_Spencer Butte">Spencer Butte</option>
<option value="LR_Lewis River">Lewis River</option>
<option value="QR_Quartz Ridge">Quartz Ridge</option>
<option value="CB_Council Bluff">Council Bluff</option>
<option value="CH_Chain of Lakes">Chain of Lakes</option>
<option value="KT_Klickitat">Klickitat</option>
<option value="TS_Twin Sisters">Twin Sisters</option>
<option value="OC_Owens Creek">Owen´s Creek</option>
<option value="RS_Randle Skandle">Randle Skandle</option>
<option value="FN_Finish Line">Finish (Bigfoot Base)</option>
</select>
</div>
</div>
<!-- hidden elements -->
<input name="FormVersion" type="hidden" id="FormVersion" />
<input name="FormatNote" type="hidden" id="FormatNote"
value="* Entries in the email will be tab-delimited, allowing copy/paste into a spreadsheet." />
<input type="file" id="txtfiletoread" accept=".txt" style="display: none" />
<input name="sendto" type="hidden" id="sendto" />
<textarea name="parseme" id="parseme" style="display: none"></textarea>
<!-- end hidden elements -->
<div class="div-across-auto-align">
<label for="msgsubject">Subject:</label>
<input name="msgsubject" type="text" id="msgsubject" readonly="readonly" maxlength="40" class="maxSizeInputWidth readOnlyText" />
</div>
<hr />
<div class="msgHeaderTitle">Bib Data Entry</div>
<div class="div-across-auto-align">
<div class="block-line-div">
<label for="RiderNum">Bib Number:</label>
<input name="RiderNum" type="text" id="RiderNum" maxlength="15" style="max-width: 6em;" required />
</div>
<div class="block-line-div">
<label for="TimeField">Time:</label>
<input name="TimeField" type="text" id="TimeField" maxlength="6" style="max-width: 6em;" required />
<input type="checkbox" id="yesterday" name="yesterday" value="Yesterday" />
<label for="yesterday">Yesterday</label>
</div>
</div>
<div id="inOutDropBtns" class="div-across-auto-align">
<div class="block-line-div">
<label>Click an Action button to create a record:</label>
</div>
<div class="block-line-div">
<input name="Inbtn" type="button" id="Inbtn" onclick="addIn();" value="In"
title="Participant arrived at this station." />
<input name="Outbtn" type="button" id="Outbtn" onclick="addOut();" value="Out"
title="Participant departed from this station." />
<input name="Dropbtn" type="button" id="Dropbtn" onclick="addDrop()" value="Drop"
title="Participant dropped from race." />
</div>
</div>
<hr />
<div class="div-across-auto-align">
<label for="entryCount">Entry Count:</label>
<input name="entryCount" type="text" id="entryCount" size="3" class="readOnlyText" readonly title="Number of bib entries submitted." />
<label for="endOfPriorBatch">End Of Prior:</label>
<input name="endOfPriorBatch" type="text" id="endOfPriorBatch" size="25" class="readOnlyText" readonly title="The last saved bib record."></input>
</div>
<div class="div-across-auto-align">
<textarea name="TheCsvData" placeholder="Limit to a sensible number of entries." id="TheCsvData" class="bibEntries" maxlength="1200"></textarea> <!-- visible, put csv items here -->
<textarea name="TheData" id="TheData" class="bibEntries" maxlength="1200" style="display:none"></textarea> <!-- style display:none, put tab delim data here -->
</div>
<div class="div-across-auto-align">
<label for="Comment">Comment:</label>
<textarea name="Comment" id="Comment" maxlength="340" placeholder="Enter a short comment, space is very limited!"></textarea>
</div>
<div class="div-across-auto-align">
<div class="block-line-div">
<input title="After submitting, close browser, then address message for posting" class="SubmitBtn"
enctype="multipart/form-data" id="Submit" method="Post" name="Submit" value="SUBMIT" type="submit" />
<input name="savebtn" type="button" class="saveDataButton" id="savebtn" onclick="SaveData()"
value="Save Race data" title="Save data to a file." />
</div>
<div class="block-line-div">
<input name="loadbtn" type="button" class="loadDataButton" id="loadbtn"
onclick="document.getElementById('txtfiletoread').click();" value="Load Race data"
title="Load data from a file." />
<input name="doclear" type="button" id="doclear" onclick="clearParticipantData()" value="Clear Entries"
title="Clear all runner entries." class="clearDataButton" />
</div>
</div>
</form>
</section>
<section>
<div id="pop1" class="pop-up">
<!-- The pop-up block -->
<div class="popBox">
<!-- If the content becomes larger than the pop-up this div will scroll the content -->
<a href="#close" class="close">Click to close this help</a>
<div class="popScroll">
<h1>Winlink Operator Instructions</h1>
<h2>About This Form</h2>
<p>This form has been coded using technologies available to desktop browsers all the way back to March of 2010. Chrome, Firefox, IE 11, Opera, and Safari are supported. You can also use Edge (released in 2015), although the later versions that include the Chromium Engine will be most reliably compatible.</p>
<p>Mobile device-based web browsers are also supported! This includes Chrome, Samsung Internet, Opera Mobile, and Android Firefox. You can rotate your device to change the view and the form will adjust its layout to accommodate the new screen dimensions (try it now!)</p>
<p>Some mobile device browsers have quirks:</p>
<ul>
<li>The on-screen keyboard will definitely get in your way. Use a compatible external keyboard if you have one.</li>
<li>Tab-order is not always correct. Just tap the field you want to change/fill-in to work around the problem.</li>
</ul>
<p>NEW FEATURE for 2024: Users now have the ability to edit Bib Data in the Entries Field after entering them using the IN, OUT, or DROP buttons. <em>Using the form to enter data is a better choice than entering or editing the data manually</em>, so use this feature with care and precision.</p>
<h2>Topics</h2>
<p>The form is broken up into three sections:</p>
<ul>
<li>Top: Form header with event, location, and message information.</li>
<li>Middle: Entering and viewing bib data.</li>
<li>Bottom: A Comments field and buttons for saving, restoring, and clearing bib data, and submitting data for posting a new Winlink Express message.</li>
</ul>