From 04dbba51f37107a77018d9e3ceef42ae9eef3678 Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Sun, 25 Dec 2022 13:18:40 -0600 Subject: [PATCH] In js, load stock data from stock_objs --- src/public/js/burning-service.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/public/js/burning-service.js b/src/public/js/burning-service.js index b36391f..48301bb 100644 --- a/src/public/js/burning-service.js +++ b/src/public/js/burning-service.js @@ -273,12 +273,12 @@ function BurningDataService($http) { // // TOTAL: 23 // this.totalDataSets = 23; // this.onAllDatasetsLoaded = null; - // this.registerOnAllDatasetsLoaded = function(callback){ - // if ( this.dataSetsLoaded >= this.totalDataSets ){ - // callback(); - // } - // this.onAllDatasetsLoaded = callback; - // } + this.registerOnAllDatasetsLoaded = function(callback){ + if ( this.dataSetsLoaded >= this.totalDataSets ){ + callback(); + } + this.onAllDatasetsLoaded = callback; + } // this.datasetLoaded = function(){ // this.dataSetsLoaded += 1; @@ -290,21 +290,23 @@ function BurningDataService($http) { // } // } + var myself = this; var stocks; $http.get("/stock_objs", {'timeout': 3000}). success(function(data,status,headers,config){ - stocks = data.map(s => s.key); + console.log(data); + stocks = Object.keys(data); for (var i = 0; i < stocks.length; i++) { loadLifepathsForStock(stocks[i]); loadStartingStatPtsForStock(stocks[i]); loadResourcesForStock(stocks[i]); } console.log("Stocks fetched from server: " + stocks) + myself.onAllDatasetsLoaded() }). error(function(data,status,headers,config){ console.log("Error: Getting stocks from server failed: HTTP code " + status + ": " + data); }); - var myself = this; /* Load lifepaths from server */ var loadLifepathsForStock = function(stock){