1/// determine the environment 2const isPlayground = location.hostname.match('localhost'); 3const isDev = location.hostname.match('orric.app'); 4const isProd = location.hostname.match('brightful.me'); 5 6function getCookie(cname) { 7 var name = cname + '='; 8 var decodedCookie = decodeURIComponent(document.cookie); 9 var ca = decodedCookie.split(';'); 10 for (var i = 0; i < ca.length; i++) { 11 var c = ca[i]; 12 while (c.charAt(0) == ' ') { 13 c = c.substring(1); 14 } 15 if (c.indexOf(name) == 0) { 16 return c.substring(name.length, c.length); 17 } 18 } 19 return ''; 20} 21 22function setCookie(cname, cvalue, daysToExpire) { 23 let domain; 24 const d = new Date(); 25 d.setTime(d.getTime() + daysToExpire * 24 * 60 * 60 * 1000); 26 const expires = 'expires=' + d.toUTCString(); 27 if (isPlayground) { 28 domain = 'localhost'; 29 } else if (isDev) { 30 domain = 'orric.app'; 31 } else if (isProd) { 32 domain = 'brightful.me'; 33 } 34 document.cookie = 35 cname + 36 '=' + 37 cvalue + 38 ';' + 39 `domain=${domain};` + 40 expires + 41 ';path=/' + 42 ';secure'; 43} 44 45function initAmplitude() { 46 try { 47 let key; 48 if (isPlayground) key = '9279bd321ccc4cf647dd62531ea3d4ad'; 49 else if (isDev) key = 'e3b11f33776ddf256ef5a0755cd80a67'; 50 else key = 'e0bddb97e8d2c849bc94e4a9af95958c'; 51 const visitorCache = getCookie('visitorCache'); 52 if (visitorCache === '') { 53 amplitude.getInstance().init(key, undefined, { 54 includeReferrer: true, 55 includeUtm: true, 56 saveParamsReferrerOncePerSession: true, 57 }); 58 } else { 59 const visitorId = JSON.parse(visitorCache)['visitorId']; 60 setCookie('visitorCache', JSON.stringify({ visitorId: visitorId }), 365); 61 amplitude.getInstance().init(key, visitorId, { 62 includeReferrer: true, 63 includeUtm: true, 64 saveParamsReferrerOncePerSession: true, 65 }); 66 } 67 } catch (err) { 68 console.log(err); 69 } 70} 71 72function amplitudeEvent(eventName, properties) { 73 try { 74 const urlParams = new URLSearchParams(window.location.search); 75 if (urlParams.has('source')) { 76 properties['source'] = urlParams.get('source'); 77 amplitude.getInstance().logEvent(eventName, properties); 78 } else amplitude.getInstance().logEvent(eventName, properties); 79 console.log(`${eventName} logged`); 80 return; 81 } catch (err) { 82 console.log(err); 83 } 84} 85 86function identifyAmplitude(mode, propertyName, propertyValue) { 87 try { 88 let identify; 89 switch (mode) { 90 case 'add': { 91 identify = new amplitude.Identify().add(propertyName, propertyValue); 92 break; 93 } 94 case 'append': { 95 identify = new amplitude.Identify().append(propertyName, propertyValue); 96 break; 97 } 98 case 'prepend': { 99 identify = new amplitude.Identify().prepend( 100 propertyName, 101 propertyValue 102 ); 103 break; 104 } 105 case 'set': { 106 identify = new amplitude.Identify().set(propertyName, propertyValue); 107 break; 108 } 109 case 'setOnce': { 110 identify = new amplitude.Identify().setOnce( 111 propertyName, 112 propertyValue 113 ); 114 break; 115 } 116 case 'unset': { 117 identify = new amplitude.Identify().unset(propertyName); 118 break; 119 } 120 } 121 amplitude.getInstance().identify(identify); 122 console.log(`identify logged`); 123 } catch (err) { 124 console.log(err); 125 } 126} 127 128function getParameterByName(name, url) { 129 if (!url) url = window.location.href; 130 name = name.replace(/[\[\]]/g, '\\$&'); 131 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 132 results = regex.exec(url); 133 if (!results) return null; 134 if (!results[2]) return ''; 135 return decodeURIComponent(results[2].replace(/\+/g, ' ')); 136} 137 138function getEndpoint(endpoint) { 139 const playground = 'https://upcentral-prototype.appspot.com'; 140 const dev = 'https://api.orric.app'; 141 const prod = 'https://api.brightful.me'; 142 let apiUrl; 143 const prefix = '/api/whiteboard/'; 144 if (isPlayground) { 145 apiUrl = playground + prefix + endpoint; 146 } else if (isDev) { 147 apiUrl = dev + prefix + endpoint; 148 } else if (isProd) { 149 apiUrl = prod + prefix + endpoint; 150 } 151 return apiUrl; 152} 153const isValidElement = (element) => { 154 return element.name && element.value; 155}; 156 157const isValidValue = (element) => { 158 return !['checkbox', 'radio'].includes(element.type) || element.checked; 159}; 160 161const isCheckbox = (element) => element.type === 'checkbox'; 162 163const isMultiSelect = (element) => element.options && element.multiple; 164 165const getSelectValues = (options) => 166 [].reduce.call( 167 options, 168 (values, option) => { 169 return option.selected ? values.concat(option.value) : values; 170 }, 171 [] 172 ); 173 174const generateGamesList = () => { 175 /* This is the fucntion show all games list to Carousels */
176 $('.our-game-carousel').owlCarousel({ 177 loop: false, 178 margin: 0, 179 nav: true, 180 dots: false, 181 182 responsive: { 183 0: { 184 items: 3, 185 touchDrag: true, 186 autoWidth: true, 187 margin: 12, 188 nav: false, 189 }, 190 768: { 191 items: 2, 192 mouseDrag: false, 193 touchDrag: false, 194 margin: 20, 195 slideBy: 2 196 }, 197 992: { 198 items: 3, 199 margin: 6, 200 mouseDrag: false, 201 touchDrag: false, 202 slideBy: 3 203 }, 204 1280: { 205 items: 4, 206 margin: 6, 207 mouseDrag: false, 208 touchDrag: false, 209 slideBy: 4 210 } 211 } 212 }); 213}; 214 215const formToJSON = (elements) => 216 [].reduce.call( 217 elements, 218 (data, element) => { 219 if (isValidElement(element) && isValidValue(element)) { 220 if (isCheckbox(element)) { 221 data[element.name] = (data[element.name] || []).concat(element.value); 222 } else if (isMultiSelect(element)) { 223 data[element.name] = getSelectValues(element); 224 } else { 225 data[element.name] = element.value; 226 } 227 } 228 229 return data; 230 }, 231 {} 232 );
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.