Some minor changes to make it easier to load a machine in the Node environment
This commit is contained in:
parent
5e2073f3ac
commit
d930b31c53
38 changed files with 4216 additions and 3743 deletions
|
|
@ -971,15 +971,6 @@ class Component {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Component.parmsURL
|
||||
*
|
||||
* Initialized to the set of URL parameters, if any, for the current web page.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
Component.parmsURL = Web.getURLParameters();
|
||||
|
||||
/*
|
||||
* Every component created on the current page is recorded in this array (see Component.add()),
|
||||
* enabling any component to locate another component by ID (see Component.getComponentByID())
|
||||
|
|
|
|||
|
|
@ -110,3 +110,30 @@ var RS232 = {
|
|||
MASK: 0x00400000
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* NODE should be true if we're running under NodeJS (eg, command-line), false if not (eg, web browser)
|
||||
*/
|
||||
var NODE = false;
|
||||
if (typeof module !== 'undefined') {
|
||||
NODE = true;
|
||||
}
|
||||
|
||||
if (NODE) {
|
||||
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
|
||||
global.APPVERSION = APPVERSION;
|
||||
global.XMLVERSION = XMLVERSION;
|
||||
global.COPYRIGHT = COPYRIGHT;
|
||||
global.LICENSE = LICENSE;
|
||||
global.CSSCLASS = CSSCLASS;
|
||||
global.SITEHOST = SITEHOST;
|
||||
global.COMPILED = COMPILED;
|
||||
global.DEBUG = DEBUG;
|
||||
global.MAXDEBUG = MAXDEBUG;
|
||||
global.PRIVATE = PRIVATE;
|
||||
global.RS232 = RS232;
|
||||
global.NODE = NODE;
|
||||
/*
|
||||
* TODO: When we're "required" by Node, should we return anything via module.exports?
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -660,12 +660,26 @@ class Web {
|
|||
}
|
||||
|
||||
/**
|
||||
* getURLParameters(sParms)
|
||||
* getURLParm(sParm)
|
||||
*
|
||||
* @param {string} sParm
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
static getURLParm(sParm)
|
||||
{
|
||||
if (!Web.parmsURL) {
|
||||
Web.parmsURL = Web.parseURLParms();
|
||||
}
|
||||
return Web.parmsURL[sParm];
|
||||
}
|
||||
|
||||
/**
|
||||
* parseURLParms(sParms)
|
||||
*
|
||||
* @param {string} [sParms] containing the parameter portion of a URL (ie, after the '?')
|
||||
* @return {Object} containing properties for each parameter found
|
||||
*/
|
||||
static getURLParameters(sParms)
|
||||
static parseURLParms(sParms)
|
||||
{
|
||||
var aParms = {};
|
||||
if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used
|
||||
|
|
@ -944,6 +958,8 @@ class Web {
|
|||
}
|
||||
}
|
||||
|
||||
Web.parmsURL = null; // initialized on first call to parseURLParms()
|
||||
|
||||
Web.aPageEventHandlers = {
|
||||
'init': [], // list of window 'onload' handlers
|
||||
'show': [], // list of window 'onpageshow' handlers
|
||||
|
|
|
|||
|
|
@ -133,15 +133,6 @@ function Component(type, parms, constructor, bitsMessage)
|
|||
Component.add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component.parmsURL
|
||||
*
|
||||
* Initialized to the set of URL parameters, if any, for the current web page.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
Component.parmsURL = web.getURLParameters();
|
||||
|
||||
/**
|
||||
* Component.inherit(p)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -116,19 +116,19 @@ if (typeof module !== 'undefined') {
|
|||
}
|
||||
|
||||
if (NODE) {
|
||||
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
|
||||
global.APPVERSION = APPVERSION;
|
||||
global.XMLVERSION = XMLVERSION;
|
||||
global.COPYRIGHT = COPYRIGHT;
|
||||
global.LICENSE = LICENSE;
|
||||
global.CSSCLASS = CSSCLASS;
|
||||
global.SITEHOST = SITEHOST;
|
||||
global.COMPILED = COMPILED;
|
||||
global.DEBUG = DEBUG;
|
||||
global.MAXDEBUG = MAXDEBUG;
|
||||
global.PRIVATE = PRIVATE;
|
||||
global.RS232 = RS232;
|
||||
global.NODE = NODE;
|
||||
global.window = false; // provides an alternative "if (typeof window === 'undefined')" (ie, "if (window) ...")
|
||||
global.APPVERSION = APPVERSION;
|
||||
global.XMLVERSION = XMLVERSION;
|
||||
global.COPYRIGHT = COPYRIGHT;
|
||||
global.LICENSE = LICENSE;
|
||||
global.CSSCLASS = CSSCLASS;
|
||||
global.SITEHOST = SITEHOST;
|
||||
global.COMPILED = COMPILED;
|
||||
global.DEBUG = DEBUG;
|
||||
global.MAXDEBUG = MAXDEBUG;
|
||||
global.PRIVATE = PRIVATE;
|
||||
global.RS232 = RS232;
|
||||
global.NODE = NODE;
|
||||
/*
|
||||
* TODO: When we're "required" by Node, should we return anything via module.exports?
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -705,12 +705,26 @@ web.isMobile = function()
|
|||
};
|
||||
|
||||
/**
|
||||
* getURLParameters(sParms)
|
||||
* getURLParm(sParm)
|
||||
*
|
||||
* @param {string} sParm
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
web.getURLParm = function(sParm)
|
||||
{
|
||||
if (!web.parmsURL) {
|
||||
web.parmsURL = web.parseURLParms();
|
||||
}
|
||||
return web.parmsURL[sParm];
|
||||
};
|
||||
|
||||
/**
|
||||
* parseURLParms(sParms)
|
||||
*
|
||||
* @param {string} [sParms] containing the parameter portion of a URL (ie, after the '?')
|
||||
* @return {Object} containing properties for each parameter found
|
||||
*/
|
||||
web.getURLParameters = function(sParms)
|
||||
web.parseURLParms = function(sParms)
|
||||
{
|
||||
var aParms = {};
|
||||
if (window) { // an alternative to "if (typeof module === 'undefined')" if require("defines") was used
|
||||
|
|
@ -855,6 +869,8 @@ web.onClickRepeat = function(e, msDelay, msRepeat, fn)
|
|||
};
|
||||
};
|
||||
|
||||
web.parmsURL = null; // initialized on first call to parseURLParms()
|
||||
|
||||
web.aPageEventHandlers = {
|
||||
'init': [], // list of window 'onload' handlers
|
||||
'show': [], // list of window 'onpageshow' handlers
|
||||
|
|
|
|||
Loading…
Reference in a new issue