PageSourceSearch

https://www.unionstationdc.com/javascript/pylot.js?v=1.12.55

js unionstationdc.com collected 2026-09-24 19:15:33 UTC 8,593 bytes, 205 lines download raw bytes

1/*******************************************************************************************************
2   Copyright 2021 - Calise Partners LLC d/b/a Imaginuity. All rights are reserved. 
3   Reproduction or transmission in whole or in part, in any form or by any means, electronic, mechanical 
4   or otherwise, is prohibited without the prior written consent of Calise Partners LLC d/b/a Imaginuity.
5********************************************************************************************************
6   Project : 10618 Maverick Platform Development
7   Created By : Joe Bannon
8   Creation Date : August 25, 2021
9   Description : Universal helper functions for Pylot platform available via pylot object.
10   Documentation : Please read the readme.md file for more information.
11********************************************************************************************************
12    UPDATES:
13********************************************************************************************************/
14
15var domain = window.location.hostname.toLowerCase();
16
17this.module = function(names, fn) {
18    var name, space; 
19    names = (typeof names === 'string') ? names.split('.') : names;
20    space = this[name = names.shift()] || (this[name] = {});
21    space.module || (space.module = this.module);
22    return (names.length) ? space.module(names, fn) : fn.call(space);
23}
24 
25this.module('cache', function() {
26    this.fonts = {}; 
27    this.toggled = {};
28    this.dev = domain.includes('dev') ? true : false;
29});
30
31this.module('pylot', function() {
32    this.cache = {
33        layouts: {}
34    };
35    this.attempt = {};
36    this.cookies = {};
37
38    this.module('cookie', function() {
39        this.getall = function() {
40            var cookies = {};
41            var decoded = decodeURIComponent(document.cookie);
42            var array   = decoded.split(';');
43            for (var i = 0; i < array.length; i++) {  
44                var [ key, value ] = array[i].split('=');
45                cookies[key.trim()] = value;
46                pylot.cookies[key.trim()] = value;
47            }
48            return cookies;
49        }
50    });
51
52    this.module('design', function() {
53        this.coloring = function(id, location) {
54            switch (id) {
55                case 'background_color':
56                    return { [location]: cache.settings.design?.colors?.background_color };
57                case 'primary_color':
58                    return { [location]: cache.settings.design?.colors?.primary_color };
59                case 'secondary_color':
60                    return { [location]: cache.settings.design?.colors?.secondary_color };
61                case 'tertiary_color':
62                    return { [location]: cache.settings.design?.colors?.tertiary_color };
63                case 'body_copy_color':
64                    return { [location]: cache.settings.design?.colors?.body_copy_color };
65                case 'white':
66                    return { [location]: '#fff' };
67                default:
68                    return {};
69            }
70        };
71        this.bgColorClass = function(id) {
72            switch (id) {
73                case 'background_color':
74                    return 'background-bg';
75                case 'primary_color':
76                    return 'primary-bg';
77                case 'secondary_color':
78                    return 'secondary-bg';
79                case 'tertiary_color':
80                    return 'tertiary-bg';
81                case 'body_copy_color':
82                    return 'body-copy-bg';
83                case 'none':
84                    return '';
85                default:
86                    return {};
87            }
88        };
89        this.parallax = function(url) {
90            return { backgroundImage:`url(${url})`, backgroundRepeat:'no-repeat', backgroundPosition:'center', backgroundSize:'cover', backgroundAttachment:'fixed' };
91        };
92        this.background = function(url) {
93            return { backgroundImage:`url(${url})`, backgroundRepeat:'no-repeat', backgroundPosition:'center', backgroundSize:'cover' };
94        };
95        this.hexToRGB = function(hex, opacity = 1) {
96            var h = hex?.replace('#', '');
97            h =  h.match(new RegExp('(.{'+h.length/3+'})', 'g'));
98            for (var i=0; i<h.length; i++) {
99                h[i] = parseInt(h[i].length==1? h[i]+h[i]:h[i], 16);
100            }
101            if (typeof opacity != 'undefined') h.push(opacity);
102            return 'rgba('+h.join(',')+')';
103        };
104    });
105
106    this.module('styling', function() {
107        this.inject = function(selector, declaration) {
108            var StyleSheet = document.createElement('style');
109            var StylesString = ` ${selector} { ${declaration}; } `;
110            StyleSheet.innerHTML = StylesString;
111            document.getElementsByTagName('head')[0].appendChild(StyleSheet);
112        };
113    });
114
115    this.module('interface', function() {
116        this.toggle = function(id, classes) {
117            var element = document.getElementById(id);
118        }
119    });
120
121    this.resolve = function(path, obj) {
122        return path.split('.').reduce(function(prev, curr) {
123            return prev ? prev[curr] : null;
124        }, obj || self);
125    };
126
127    this.module('tools', function() {
128        this.module('domain', function() {
129            this.add = function(path = '') {
130                var domain = window.location.hostname;
131                // ALLOWS .DEV TO VIEW .PREFLIGHT IMAGES WHILE WORKING LOCALLY.
132                domain = domain.replace('.dev', '.preflight');
133                return (path.includes('http')) ? path : `https://${domain}${path}`;
134            };
135        });
136    });
137
138    this.module('dates', function() {
139        this.day = function(num) {
140            return ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][num];
141        };
142        this.month = function(num) {
143            return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][num];
144        };
145        this.getOrdinialNum = function(num) {
146            const ordinialIndicators = ['th', 'st', 'nd', 'rd', '']
147
148            if (num <= 0) {
149                selector = 4;
150            } else if ((num > 3 && num < 21) || num % 10 > 3) {
151                selector = 0;
152            } else {
153                selector = num % 10;
154            }
155
156            return num + ordinialIndicators[selector];
157        }
158    });
159
160    this.module('socialShareUrls', function() {
161        this.googleCalendar = function({ // should this go into a /helpers folder instead?
162            startDate, // full new Date(obj)
163            endDate, // full new Date(obj)
164            text,
165            details
166        }) {
167            const formatDates = (date) => `${date.toISOString().replace(new RegExp('\\b(.|:|-)\\b', 'gi'), '').slice(0, -4)}`;
168
169            let googleCalenderStr = 'http://www.google.com/calendar/event?action=TEMPLATE';
170            googleCalenderStr += `&text=${encodeURI(text)}`;
171            googleCalenderStr +=  `&dates=${formatDates(startDate)}/${formatDates(endDate)}`;
172            googleCalenderStr += `&details=${encodeURI(details)}`;
173        
174            return googleCalenderStr;    
175        };
176        this.facebook = function() {
177            return `https://www.facebook.com/sharer/sharer.php?u=${encodeURI(location.href)}&t=${encodeURI(document.title)}`;
178        };
179        this.twitter = function() {
180            return `http://twitter.com/share?text=${encodeURI(document.title)}&url=${location.href}`
181        };
182        this.reddit = function() {
183            return `http://www.reddit.com/submit?url=${encodeURI(location.href)}&title=${encodeURI(document.title)}`
184        };
185        this.tumblr = function() {
186            return `http://tumblr.com/share?s=&v=3&t=${encodeURI(document.title)}&u=${encodeURI(location.href)}`
187        };
188        this.email = function() {
189            return `mailto:?subject=${document.title}&amp;body=Check out this site ${location.href}.`
190        }
191    });
192
193    this.module('validate', function() {
194        this.emailaddress = function(emailaddress) {
195            var filter = /^([+\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/;
196            return (filter.test(emailaddress)) ? true : false;
197        }
198    });
199
200    this.module('cleanse', function() {
201        this.emailaddress = function(emailaddress) {
202            return emailaddress.replace(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/, '');
203        }
204    });
205});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.