Step 1: Create following function in your js file:
(function (exports) {
"use strict";
var apiConfig = {
// Properties
IsProduction: isProduction(),
// Functions
Test: function(){
return "";
}
};
// Constants for Cookies Names
var cookiesConstants = {
CompanyUID: "companyUUID",
DivisionUID: "divisionUUID"
};
//Private functions
function isProduction() {
if (window.location.host == "prod.com") {
return true;
}
return false;
}
exports.apiConfig = apiConfig;
exports.cookiesConstants = cookiesConstants;
})(this);
Step 2: Usage:
<script>
var companyConstant = cookiesConstants.CompanyUID; //Get property value
apiConfig.Test(); // Execute function
</script>
(function (exports) {
"use strict";
var apiConfig = {
// Properties
IsProduction: isProduction(),
// Functions
Test: function(){
return "";
}
};
// Constants for Cookies Names
var cookiesConstants = {
CompanyUID: "companyUUID",
DivisionUID: "divisionUUID"
};
//Private functions
function isProduction() {
if (window.location.host == "prod.com") {
return true;
}
return false;
}
exports.apiConfig = apiConfig;
exports.cookiesConstants = cookiesConstants;
})(this);
Step 2: Usage:
<script>
var companyConstant = cookiesConstants.CompanyUID; //Get property value
apiConfig.Test(); // Execute function
</script>
No comments:
Post a Comment