In js, load stock data from stock_objs

Daniel Asher Resnick 2 years ago
parent 0e321daa9f
commit 04dbba51f3
  1. 18
      src/public/js/burning-service.js

@ -273,12 +273,12 @@ function BurningDataService($http) {
// // TOTAL: 23 // // TOTAL: 23
// this.totalDataSets = 23; // this.totalDataSets = 23;
// this.onAllDatasetsLoaded = null; // this.onAllDatasetsLoaded = null;
// this.registerOnAllDatasetsLoaded = function(callback){ this.registerOnAllDatasetsLoaded = function(callback){
// if ( this.dataSetsLoaded >= this.totalDataSets ){ if ( this.dataSetsLoaded >= this.totalDataSets ){
// callback(); callback();
// } }
// this.onAllDatasetsLoaded = callback; this.onAllDatasetsLoaded = callback;
// } }
// this.datasetLoaded = function(){ // this.datasetLoaded = function(){
// this.dataSetsLoaded += 1; // this.dataSetsLoaded += 1;
@ -290,21 +290,23 @@ function BurningDataService($http) {
// } // }
// } // }
var myself = this;
var stocks; var stocks;
$http.get("/stock_objs", {'timeout': 3000}). $http.get("/stock_objs", {'timeout': 3000}).
success(function(data,status,headers,config){ 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++) { for (var i = 0; i < stocks.length; i++) {
loadLifepathsForStock(stocks[i]); loadLifepathsForStock(stocks[i]);
loadStartingStatPtsForStock(stocks[i]); loadStartingStatPtsForStock(stocks[i]);
loadResourcesForStock(stocks[i]); loadResourcesForStock(stocks[i]);
} }
console.log("Stocks fetched from server: " + stocks) console.log("Stocks fetched from server: " + stocks)
myself.onAllDatasetsLoaded()
}). }).
error(function(data,status,headers,config){ error(function(data,status,headers,config){
console.log("Error: Getting stocks from server failed: HTTP code " + status + ": " + data); console.log("Error: Getting stocks from server failed: HTTP code " + status + ": " + data);
}); });
var myself = this;
/* Load lifepaths from server */ /* Load lifepaths from server */
var loadLifepathsForStock = function(stock){ var loadLifepathsForStock = function(stock){

Loading…
Cancel
Save