Source: js/library.constants.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
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;