Source: js/library.constants.js

window.check = function (thing, feature)
{
    return !!thing || !!(feature && console.warn('Feature not available: ' + feature));
};

/* environment */

var // mode
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether code is running in the Star2Star Application Framework.
    */
    ISORION = !!window.OrionSystem,
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether Framework is running in developer mode.
    */
    DEVELOPER = OrionFramework.developerMode,
    
    // server
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether resources are to be loaded from Production server.
        @see      {@link TEST}
    */
    PRODUCTION = !!~OrionFramework.apiURL.indexOf('.com'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether resources are to be loaded from Test server.
        @see      {@link PRODUCTION}
    */
    TEST = !PRODUCTION,
    
    // platform
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether Framework is running on the Mac platform.
        @see      {@link WIN}
    */
    MAC = OrionFramework.platform === 'mac',
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether Framework is running on the Windows platform.
        @see      {@link MAC}
    */
    WIN = !MAC,
    
    /** @enum     {Number}
        @readonly
        @desc     Values identifying browser platform.
        @see      {@link BrowserArchitecture}
    */
    BrowserPlatform =
    {
        'Unknown': 0,
        'Mac'    : 1,
        'Windows': 2,
        'Linux'  : 3,
        'iOS'    : 4,
        'Android': 5
    },
    
    /** @enum     {Number}
        @readonly
        @desc     Values identifying browser architecture.
        @see      {@link BrowserPlatform}
    */
    BrowserArchitecture =
    {
        'Unknown': 0,
        'x86'    : 1,
        'x86_64' : 2,
        'ARM'    : 3,
        'PPC'    : 4,
        'ia64'   : 5
    },
    
    // location
    
    /** @const    {String}
        @readonly
        @desc     Hostname of current location.
    */
    HOST = window.location.hostname,
    
    /** @const    {String}
        @readonly
        @desc     Protocol + hostname of current location.
    */
    ORIGIN = window.location.origin,
    
    /** @const    {String}
        @readonly
        @desc     Full path of current location including filename.
    */
    PATH = window.location.pathname,
    
    /** @const    {String}
        @readonly
        @desc     Base path of current location.
    */
    ROOT = PATH.substring(0, PATH.lastIndexOf('/')),
    
    /** @const    {String}
        @readonly
        @desc     Fragment of current location.
    */
    HASH = window.location.hash.substring(1),

    // features
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether HTML imports are supported.
                  Even if true, a <link>'s 'import' property will be null if:
                  The <link> doesn't have rel="import".
                  The <link> has not been added to the DOM.
                  The <link> has been removed from the DOM.
                  The resource is not CORS-enabled.
    */
    F_IMPORT = check('import' in document.createElement('link'), 'HTML Imports'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether HTML templates are supported.
    */
    F_TEMPLATE = check('content' in document.createElement('template'), 'HTML Templates'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether Shadow DOM is supported.
    */
    F_SHADOW = check(document.createElement('div').createShadowRoot, 'Shadow DOM'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether custom elements are supported.
    */
    F_CUSTOM = check(document.registerElement, 'Custom Elements'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether the features comprising components are supported.
    */
    F_COMPONENT = check(F_IMPORT && F_TEMPLATE && F_SHADOW && F_CUSTOM, 'Components'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether Objects are observable.
    */
    F_OBSERVE = check(Object.observe, 'Observables'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether WebSockets are supported.
    */
    F_SOCKET = check(window.WebSocket, 'WebSockets'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether WebWorkers are supported.
    */
    F_WORKER = check(window.Worker, 'WebWorkers'),
    
    /** @const    {Boolean}
        @readonly
        @desc     Indicates whether ServiceWorkers are supported.
    */
    F_SERVICE = check(navigator.serviceWorker, 'ServiceWorkers');
    
/* precomputed */

var // time
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1/100th of 1 second.
    */
    T_HUNDREDTH = 10,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1/10th of 1 second.
    */
    T_TENTH = 100,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1/4th of 1 second.
    */
    T_QUARTER = 250,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1/3rd of 1 second.
    */
    T_THIRD = 333,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1/2 of 1 second.
    */
    T_HALF = 500,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 second.
    */
    T_SECOND = 1000,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 minute.
    */
    T_MINUTE = T_SECOND * 60,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 hour.
    */
    T_HOUR = T_MINUTE * 60,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 day.
    */
    T_DAY = T_HOUR * 24,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 week.
    */
    T_WEEK = T_DAY * 7,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 month (30 days).
    */
    T_MONTH = T_DAY * 30,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 year (365 days).
    */
    T_YEAR = T_DAY * 365,
    
    /** @const    {Number}
        @readonly
        @desc     Time: Precomputed ms value of 1 leap year (366 days).
    */
    T_LEAPYEAR = T_DAY * 366;

/* levels */

var // logging
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Silence, only for setting display level.
    */
    L_OFF = 0,                                                                           // • off (display)
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Show regardless of display level (avoid).
    */
    L_ALWAYS = 0,                                                                        // • general/prominent/severe
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Something's gone wrong.
    */
    L_ERROR = 1,                                                                         // ↓ 
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Potential problem or something to avoid.
    */
    L_WARN = 2,                                                                          // ↓ 
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Primary occurrences only, e.g. foundational happenings.
    */
    L_MAIN = 3,                                                                          // ↓ 
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Noting a function ran, stepping stone on a path.
    */
    L_FUNC = 4,                                                                          // ↓ 
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Processing details.
    */
    L_INFO = 5,                                                                          // ↓ 
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Arguments and presence are {@link deval}ed.
    */
    L_DEBUG = 6,                                                                          // • specific/detailed
    
    /** @const    {Number}
        @readonly
        @desc     Log level: Silence, only for setting squelch display level.
    */
    L_NEVER = 7,                                                                          // • off (arguments, presence)
    
    // starlets
    
    /** @const    {Number}
        @readonly
        @desc     Starlet state: Starlet not loaded.
    */
    S_CLOSED = 0,
    
    /** @const    {Number}
        @readonly
        @desc     Starlet state: Starlet's WebView instantiated, location set.
    */
    S_OPENED = 1,
    
    /** @const    {Number}
        @readonly
        @desc     Starlet state: Starlet initialized and responsive.
    */
    S_REGISTERED = 2,
    
    /** @const    {Number}
        @readonly
        @desc     Starlet state: Starlet's onRun has fired and UI initialized.
    */
    S_READY = 3;

/* groupings */

var // starlets
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of accepted Starlet types.
    */
    S_TYPES = ['connection', 'navigation', 'shoebox', 'notification', 'trusted_starlet', 'untrusted_starlet'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of Starlet types within main application window.
    */
    S_TYPES_MAIN = ['navigation', 'shoebox', 'trusted_starlet', 'untrusted_starlet'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of crucial Starlet properties.
    */
    S_PROPERTIES = ['type', 'url', 'name', 'identifier', 'title', 'width', 'height', 'order', 'state'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of possible Starlet modes.
    */
    S_MODES = ['main', 'overlay', 'lightbox', 'tearoff', 'minitearoff'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of application window states.
    */
    S_STATES = ['visible', 'active', 'focused', 'minimized', 'hidden', 'mouse'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of Starlet overlay types.
    */
    S_NAMES_OVERLAYS = ['shoebox', 'navigation', 'notification'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Starlet details: List of recognized lightbox names.
    */
    S_NAMES_LIGHTBOXES = ['help', 'whatsnew', 'feedback'],
    
    // methods
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Minishoebox: List of possible modes.
    */
    MINISHOEBOX_MODES = ['starchat', 'starvideo', 'starfax', 'shoebox'],
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Popovers: List of accepted placement strings.
    */
    POPOVER_PLACEMENTS = ['left', 'top', 'right', 'bottom'],
    
    // analytics
    
    /** @const    {Array.<String>}
        @readonly
        @desc     Analytics: List of query selectors outlining elements to track.
    */
    TRACKABLES =
    [
        '[data-ga-title]',
        'button:not(.ga-notrack)',
        'input[type=button]:not(.ga-notrack)',
        'input[type=submit]:not(.ga-notrack)',
        'input[type=reset]:not(.ga-notrack)',
        'a:not(.ga-notrack)',
        '.button:not(.ga-notrack)',
        '.btn:not(.ga-notrack)',
        '[class*=btn-]:not(.btn-group):not(.ga-notrack)',
        '.ga-trackable'
    ];

/* input */

var // modifiers
    
    /** @const    {Number}
        @readonly
        @desc     Modifiers: OR-able value for Alt.
        @see {@link M_CONTROL}
        @see {@link M_COMMAND}
        @see {@link M_SHIFT}
        @see {@link Modifiers}
    */
    M_ALT = 1,
    
    /** @const    {Number}
        @readonly
        @desc     Modifiers: OR-able value for Control.
        @see {@link M_ALT}
        @see {@link M_COMMAND}
        @see {@link M_SHIFT}
        @see {@link Modifiers}
    */
    M_CONTROL = 2,
    
    /** @const    {Number}
        @readonly
        @desc     Modifiers: OR-able value for Command.
        @see {@link M_ALT}
        @see {@link M_CONTROL}
        @see {@link M_SHIFT}
        @see {@link Modifiers}
    */
    M_COMMAND = 4,
    
    /** @const    {Number}
        @readonly
        @desc     Modifiers: OR-able value for Shift.
        @see {@link M_ALT}
        @see {@link M_CONTROL}
        @see {@link M_COMMAND}
        @see {@link Modifiers}
    */
    M_SHIFT = 8,
    
    /** @enum     {Number}
        @readonly
        @desc     Modifiers: OR-able values representing cross-platform keys.
        @see {@link M_ALT}
        @see {@link M_CONTROL}
        @see {@link M_COMMAND}
        @see {@link M_SHIFT}
    */
    Modifiers =
    {
        Alt    : 1,
        Crtl   : 2,
        Command: 4,
        Shift  : 8
    },
    
    /* key mapping*/
    
    /** @enum     {Number}
        @readonly
        @desc     Hashlike index of keycodes and corresponding values.
    */
    KEYCODES =
    {
        '\t': 9,
        
        '0': 48, ')': 48,
        '1': 49, '!': 49,
        '2': 50, '@': 50,
        '3': 51, '#': 51,
        '4': 52, '$': 52,
        '5': 53, '%': 53,
        '6': 54, '^': 54,
        '7': 55, '&': 55,
        '8': 56, '*': 56,
        '9': 57, '(': 57,
        
        'a': 65, 'b': 66, 'c': 67, 'd': 68, 'e': 69,
        'f': 70, 'g': 71, 'h': 72, 'i': 73, 'j': 74,
        'k': 75, 'l': 76, 'm': 77, 'n': 78, 'o': 79,
        'p': 80, 'q': 81, 'r': 82, 's': 83, 't': 84,
        'u': 85, 'v': 86, 'w': 87, 'x': 88, 'y': 89,
        'z': 90,
        
        ';' : 186, ':': 186,
        '=' : 187, '+': 187,
        ',' : 188, '<': 188,
        '-' : 189, '_': 189,
        '.' : 190, '>': 190,
        '/' : 191, '?': 191,
        '`' : 192, '~': 192,
        '[' : 219, '{': 219,
        '\\': 220, '|': 220,
        ']' : 221, '}': 221,
        '\'': 222, '"': 222
    };

/* config */

    /** @const    {Number}
        @readonly
        @desc     Maximum number of concurrent chat sessions.
    */
var CHATSESSIONS_LIMIT = 50;

delete window.check;