Daniel Asher Resnick 2 years ago
parent dd5cf6dcdc
commit aae021437a
  1. 72
      src/public/js/burning-service.js

@ -263,32 +263,32 @@ function BurningDataService($http) {
// A hash of StartingStatPoints objects keyed by stock. // A hash of StartingStatPoints objects keyed by stock.
this.startingStatPts = {}; this.startingStatPts = {};
this.dataSetsLoaded = 0; // this.dataSetsLoaded = 0;
// Total data sets: // // Total data sets:
// lifepaths: 7 (man, dwarf, elf, orc, roden, wolf, troll) // // lifepaths: 7 (man, dwarf, elf, orc, roden, wolf, troll)
// stat points: 7 (man, dwarf, elf, orc, roden, wolf, troll) // // stat points: 7 (man, dwarf, elf, orc, roden, wolf, troll)
// skills // // skills
// traits // // traits
// resources: 7 (man, dwarf, elf, orc, roden, wolf. troll) // // resources: 7 (man, dwarf, elf, orc, roden, wolf. troll)
// 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;
if ( this.onAllDatasetsLoaded && (this.dataSetsLoaded >= this.totalDataSets) ){ // if ( this.onAllDatasetsLoaded && (this.dataSetsLoaded >= this.totalDataSets) ){
this.onAllDatasetsLoaded(); // this.onAllDatasetsLoaded();
} // }
if ( this.dataSetsLoaded > this.totalDataSets){ // if ( this.dataSetsLoaded > this.totalDataSets){
console.log("Error: the totalDataSets setting in BurningDataService is too low! This will cause wierd errors. Please adjust it"); // console.log("Error: the totalDataSets setting in BurningDataService is too low! This will cause wierd errors. Please adjust it");
} // }
} // }
var stocks; var stocks;
$http.get("/stock_objs", {'timeout': 3000}). $http.get("/stock_objs", {'timeout': 3000}).
@ -316,11 +316,11 @@ function BurningDataService($http) {
$http.get("/lifepaths/" + stock, {'timeout': 3000} ). $http.get("/lifepaths/" + stock, {'timeout': 3000} ).
success(function(data,status,headers,config){ success(function(data,status,headers,config){
myself.lifepaths[stock] = data; myself.lifepaths[stock] = data;
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Loaded "+stock+" lifepaths. " + Object.keys(myself.lifepaths).length + " settings"); console.log("Loaded "+stock+" lifepaths. " + Object.keys(myself.lifepaths).length + " settings");
}). }).
error(function(data,status,headers,config){ error(function(data,status,headers,config){
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Error: Getting "+stock+" lifepaths from server failed: HTTP code " + status + ": " + data); console.log("Error: Getting "+stock+" lifepaths from server failed: HTTP code " + status + ": " + data);
}); });
} }
@ -335,11 +335,11 @@ function BurningDataService($http) {
$http.get("/starting_stat_pts/" + stock, {'timeout': 3000} ). $http.get("/starting_stat_pts/" + stock, {'timeout': 3000} ).
success(function(data,status,headers,config){ success(function(data,status,headers,config){
myself.startingStatPts[stock] = new StartingStatPoints(data); myself.startingStatPts[stock] = new StartingStatPoints(data);
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Loaded "+stock+" starting stat points. "); console.log("Loaded "+stock+" starting stat points. ");
}). }).
error(function(data,status,headers,config){ error(function(data,status,headers,config){
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Error: Getting "+stock+" stat points from server failed: HTTP code " + status + ": " + data); console.log("Error: Getting "+stock+" stat points from server failed: HTTP code " + status + ": " + data);
}); });
} }
@ -354,11 +354,11 @@ function BurningDataService($http) {
$http.get("/resources/" + stock, {'timeout': 3000} ). $http.get("/resources/" + stock, {'timeout': 3000} ).
success(function(data,status,headers,config){ success(function(data,status,headers,config){
myself.resources[stock] = data; myself.resources[stock] = data;
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Loaded "+stock+" resources. "); console.log("Loaded "+stock+" resources. ");
}). }).
error(function(data,status,headers,config){ error(function(data,status,headers,config){
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Error: Getting "+stock+" stat points from server failed: HTTP code " + status + ": " + data); console.log("Error: Getting "+stock+" stat points from server failed: HTTP code " + status + ": " + data);
}); });
} }
@ -368,11 +368,11 @@ function BurningDataService($http) {
$http.get("/skills", {'timeout': 3000} ). $http.get("/skills", {'timeout': 3000} ).
success(function(data,status,headers,config){ success(function(data,status,headers,config){
myself.skills = data; myself.skills = data;
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Loaded skills. "); console.log("Loaded skills. ");
}). }).
error(function(data,status,headers,config){ error(function(data,status,headers,config){
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Error: Getting skills from server failed: HTTP code " + status + ": " + data); console.log("Error: Getting skills from server failed: HTTP code " + status + ": " + data);
}); });
@ -380,11 +380,11 @@ function BurningDataService($http) {
$http.get("/traits", {'timeout': 3000} ). $http.get("/traits", {'timeout': 3000} ).
success(function(data,status,headers,config){ success(function(data,status,headers,config){
myself.traits = data; myself.traits = data;
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Loaded traits. "); console.log("Loaded traits. ");
}). }).
error(function(data,status,headers,config){ error(function(data,status,headers,config){
myself.datasetLoaded(); // myself.datasetLoaded();
console.log("Error: Getting traits from server failed: HTTP code " + status + ": " + data); console.log("Error: Getting traits from server failed: HTTP code " + status + ": " + data);
}); });
} }

Loading…
Cancel
Save