Conversion Function Simplification
Working on simplifying the header conversion function by comparing the output from each one
by WizKid81
JavaScript
//Takes in a Header name and then returns the Javascript Object Path that can be used
//in the getObjectPropertyByPath function. This is the default conversion function
function termConverter(header) {
var shortName = header.toString().toLowerCase();
switch(shortName) {
case "name":
shortName = "nameKey";
break;
case "shards to unlock":
shortName = "shardsToUnlock";
break;
case "base id":
shortName = "baseId";
break;
case "max power":
shortName = "power";
break;
case "url":
shortName = "url";
break;
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "10":
case "11":
case "12":
var arrayIndex = shortName - 1;
shortName = 'unitTierList[' + arrayIndex + '].equipmentSetList';
break;
case 'recipe':
shortName = 'recipe.ingredientsList';
break;
case 'lookup location':
shortName = 'firstFarmLocation.shortName';
break;
case 'light side farm':
shortName = 'lightSideFarmable';
break;
case 'dark side farm':
shortName = 'darkSideFarmable';
break;
case 'ship farm':
shortName = 'shipFarmable';
break;
case 'cantina farm':
shortName = 'cantinaFarmable';
break;
}
return shortName;
}
//Takes in a header name and returns the JSON path to the item in the collection for that term.
//This conversion function is used on data related to the myCollection object which is specific
//for the given ally code
function myCollectionTermConversion(header) {
var shortName = header.toString().toLowerCase();
switch(shortName) {
case "character name":
shortName = "name";
break;
case "stars":
shortName = "rarity";
break;
case "level":
shortName = "level";
break;
case "gear":
shortName = "gear";
break;
case "zetas":
...