From 15c5ae9f73814427ecfcfc2cff31c1e1713c807d Mon Sep 17 00:00:00 2001 From: Jason Dekarske Date: Tue, 5 Apr 2022 12:59:09 -0700 Subject: [PATCH] I think I got it --- apps/golfview/custom.html | 14 +++++++++----- apps/golfview/golfview.js | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/golfview/custom.html b/apps/golfview/custom.html index b619251cb..e71332212 100644 --- a/apps/golfview/custom.html +++ b/apps/golfview/custom.html @@ -78,7 +78,7 @@ return course_processed; } - function preprocessCoords(course_input) { + function preprocessCoords(course_input) { // first do the high-level way for (var hole in course_input.holes) { course_input.holes[hole].nodesXY = arraytoXY(course_input.holes[hole].nodes, course_input.holes[hole].nodes[0]) @@ -98,15 +98,16 @@ return course_input; } - var courses = []; + var course = {}; + var course_name = "Davis"; $("#upload").click(function () { sendCustomizedApp({ - storage: courses + storage: course }); }); $("#download").click(function () { - downloadObjectAsJSON(courses, "courses"); + downloadObjectAsJSON(course, "golfcourse-" + course_name); }); // download info from the course @@ -116,7 +117,10 @@ out = processFeatures(course_input.elements); out = preprocessCoords(out); console.log(out); - courses.push(JSON.parse(JSON.stringify(out))); // deep copy + course = { + name: "golfcourse-" + course_name + ".json", + content: JSON.parse(JSON.stringify(out)) // deep copy + }; $('#status').text("Course retrieved!"); $('#upload').attr("disabled", false); $('#download').attr("disabled", false); diff --git a/apps/golfview/golfview.js b/apps/golfview/golfview.js index 74feb7c63..2cf394375 100644 --- a/apps/golfview/golfview.js +++ b/apps/golfview/golfview.js @@ -1,4 +1,4 @@ -let course = require("Storage").readJSON("courses.json")[0].holes; +let course = require("Storage").readJSON("golfcourse-Davis.json").holes;//TODO use the course ID let current_hole = 1; let hole = course[current_hole.toString()];