Skip to content

Commit

Permalink
stats are loaded from script tag instead of xhr
Browse files Browse the repository at this point in the history
added a script to generate a js file from csv
Chrome won't load xhr to file protocols.  This will allow running it locally with a script tag.
run the script after the csv changes
  • Loading branch information
queler committed Jun 1, 2019
1 parent e7f022b commit 60825d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src="trackables.js"></script>
<script src="moment.js"></script>
<script src="timer.js"></script>
<script src="stats_standard_random.js"></script>
<script src="stats.js"></script>
</head>

Expand Down
6 changes: 6 additions & 0 deletions makestatsjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# generate stats_standard_random.js from the csv file
# run after changing the csv
# https://www.freeformatter.com/javascript-escape.html works for this as well
echo -n 'var strStats = "'>stats_standard_random.js
perl -p -e "s#\\\#\\\\\\\#g;s#'#\\\'#g;s#\n#\\\n#g;s#\r##g;"'s#\"#\\"#g;s#\t#\\t#g' stats_standard_random.csv>>stats_standard_random.js
echo '";'>>stats_standard_random.js
12 changes: 2 additions & 10 deletions stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,8 @@ stats = {
list = list.filter(Boolean);
return list;
},
fetch: function () {
$.ajax({
type: "GET",
url: "stats_standard_random.csv",
dataType: "text",
success: function (data) {

fetch: function () {
data=strStats;
//convert the CSV into a javascript object
data = data.split(/\r\n|\n/);
$.each(data, function (row, values) {
Expand Down Expand Up @@ -322,9 +317,6 @@ stats = {
stats.find("boss10");


}
});

},
find: function (elem) {

Expand Down
1 change: 1 addition & 0 deletions stats_standard_random.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 60825d2

Please sign in to comment.