-
Notifications
You must be signed in to change notification settings - Fork 0
/
lineups.html
54 lines (46 loc) · 1.12 KB
/
lineups.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
---
layout: default
permalink: lineup-builder
title: Lineup Builder
nav: lineup-builder
---
<div class="bg-texture-green">
<h1 class="text-white font-bold tracking-wide text-2xl px-8 pb-4 pt-8 text-shadow-green">Lineup Builder</h1>
</div>
<script type="text/javascript">
function validateFields(result) {
var errors = [];
var fields = result.meta.fields;
var requiredFields = [
"player",
"position",
"team",
"salary",
"projection",
"asdf",
];
requiredFields.forEach(function(field) {
if (fields.indexOf(field) === -1) {
errors.push("Could not find required field: " + field);
}
});
return errors;
}
document.addEventListener("DOMContentLoaded", function() {
Papa.parse("/sample.csv", {
header: true,
download: true,
dynamicTyping: true,
trimHeaders: true,
skipEmptyLines: true,
complete: function(result) {
var errors = validateFields(result);
if (errors.length === 0) {
console.log("Success!");
} else {
console.log(errors);
}
}
});
});
</script>