I am not super good with JavaScript. I am trying to write a build config class that can be used to set settings on the fly. The idea is to pass in the environment that it is to be run in and then the variables set up properly. I have the following:
function BuildConfig(){
this.build = 'html5';
this.server = 'http://someurl',
this.nfc = true,
this.barcode = true,
this.scheduler = true,
this.getConfig = function(buildType){
switch(buildType)
{
case "ios":
this.build = 'ios';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = false;
this.scheduler = false;
break;
case "android":
this.build = 'android';
this.server = 'http://someurl';
this.nfc = false;
this.barcode = true;
this.scheduler = false;
break;
case "websiteanonymous":
this.build = 'websiteanonymous';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = false;
this.scheduler = true;
break;
case "website":
this.build = 'website';
this.server = 'http://someurl';
this.nfc = true;
this.barcode = true;
this.scheduler = false;
break;
default:
}
};
};
Does this look OK? Can any improvements be made?
Thanks
Your approach is ok. And the below code is slightly shorter: