2015-11-26 05:31:31 +00:00
|
|
|
/// <reference path="typings/tsd.d.ts" />
|
2015-11-30 14:04:04 +00:00
|
|
|
/// <reference path="classes.ts" />
|
2015-11-26 05:31:31 +00:00
|
|
|
var beautylog = require("beautylog")("os");
|
|
|
|
var smartenv:any = {}; //create smartenv object
|
|
|
|
smartenv.items = {}; // create the items object to store items to.
|
2015-11-30 14:04:04 +00:00
|
|
|
|
|
|
|
/* ----------------------------------------- *
|
|
|
|
* ----- Environment ----------------------- *
|
|
|
|
* ----------------------------------------- */
|
|
|
|
var environment:Environment;
|
|
|
|
var setEnvironment = function() {
|
|
|
|
var localRunTimeEnv = "undefined";
|
|
|
|
var localUserAgent = "undefined";
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
localRunTimeEnv = 'browser';
|
|
|
|
localUserAgent = navigator.userAgent;
|
|
|
|
} else if (typeof process !== 'undefined') {
|
|
|
|
localRunTimeEnv = 'node';
|
|
|
|
}
|
|
|
|
environment = new Environment(localRunTimeEnv,localUserAgent);
|
2015-11-26 05:31:31 +00:00
|
|
|
};
|
2015-11-30 14:04:04 +00:00
|
|
|
setEnvironment();
|
|
|
|
|
|
|
|
|
|
|
|
smartenv.getEnv = function() {
|
|
|
|
return environment;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------------------------------------- *
|
|
|
|
* ----- Info vars ------------------------- *
|
|
|
|
* ----------------------------------------- */
|
2015-11-26 05:31:31 +00:00
|
|
|
|
|
|
|
|
2015-11-30 14:04:04 +00:00
|
|
|
smartenv.printEnv = function() {
|
|
|
|
if (environment.isNode) {
|
|
|
|
var smartenvVersion = require("./package.json").version;
|
|
|
|
beautylog.log("node version is " + environment.nodeVersion + " and smartenv version is " + smartenvVersion);
|
|
|
|
} else {
|
|
|
|
beautylog.log("browser is " + environment.userAgent)
|
|
|
|
}
|
|
|
|
beautylog.log("the smartenv registration store currently holds the following properties:");
|
2015-11-26 05:31:31 +00:00
|
|
|
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
|
|
|
|
};
|
|
|
|
|
|
|
|
smartenv.register = function(objectArg,paramName = "undefined") {
|
|
|
|
if (paramName == "undefined"){
|
|
|
|
beautylog.error("paramName is undefined");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
smartenv.items[paramName] = objectArg;
|
|
|
|
};
|
|
|
|
smartenv.get = function(keyName) {
|
|
|
|
return smartenv.items[keyName];
|
2015-11-28 13:49:44 +00:00
|
|
|
};
|
|
|
|
|
2015-11-26 05:31:31 +00:00
|
|
|
module.exports = smartenv;
|