@betarena/ad-engine 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/src/App.svelte +17 -7
- package/src/index.js +0 -0
- package/src/index.ts +18 -6
- package/src/lib/Advert-Engine-Widget.svelte +417 -80
- package/src/lib/Advert-InterScroller-Child.svelte +428 -0
- package/src/lib/utils/debug.ts +49 -0
- package/src/lib/utils/device.ts +43 -3
- package/src/lib/Advert-InterScroller.svelte +0 -155
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
3
|
+
│ 📌 High Order Component Overview │
|
|
4
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
5
|
+
│ ➤ Internal Svelte Code Format :|: V.8.0 │
|
|
6
|
+
│ ➤ Status :|: 🔒 LOCKED │
|
|
7
|
+
│ ➤ Author(s) :|: @migbash │
|
|
8
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
9
|
+
│ 📝 Description │
|
|
10
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
11
|
+
│ Betarena Ad-Engine Component - Interscroller │
|
|
12
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
13
|
+
-->
|
|
14
|
+
|
|
15
|
+
<!--
|
|
16
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
17
|
+
│ 🟦 Svelte Component JS/TS │
|
|
18
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
19
|
+
│ ➤ HINT: │ Access snippets for '<script> [..] </script>' those found in │
|
|
20
|
+
│ │ '.vscode/snippets.code-snippets' via intellisense using 'doc' │
|
|
21
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
|
|
26
|
+
// #region ➤ 📦 Package Imports
|
|
27
|
+
|
|
28
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
29
|
+
// │ NOTE: │
|
|
30
|
+
// │ Please add inside 'this' region the 'imports' that are required │
|
|
31
|
+
// │ by 'this' .svelte file is ran. │
|
|
32
|
+
// │ IMPORTANT │
|
|
33
|
+
// │ Please, structure the imports as follows: │
|
|
34
|
+
// │ 1. svelte/sveltekit imports │
|
|
35
|
+
// │ 2. project-internal files and logic │
|
|
36
|
+
// │ 3. component import(s) │
|
|
37
|
+
// │ 4. assets import(s) │
|
|
38
|
+
// │ 5. type(s) imports(s) │
|
|
39
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
40
|
+
|
|
41
|
+
import { onMount } from 'svelte';
|
|
42
|
+
|
|
43
|
+
import { betarenaEndpoint } from './constants/instance.js';
|
|
44
|
+
import { storeAdmin } from './store/admin.js';
|
|
45
|
+
import { postMod } from './utils/fetch.js';
|
|
46
|
+
|
|
47
|
+
import type { AdsCreativeMain } from '@betarena/scores-lib/types/_AUTO-HASURA_.js';
|
|
48
|
+
|
|
49
|
+
// #endregion ➤ 📦 Package Imports
|
|
50
|
+
|
|
51
|
+
// #region ➤ 📌 VARIABLES
|
|
52
|
+
|
|
53
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
54
|
+
// │ NOTE: │
|
|
55
|
+
// │ Please add inside 'this' region the 'variables' that are to be │
|
|
56
|
+
// │ and are expected to be used by 'this' .svelte file / component. │
|
|
57
|
+
// │ IMPORTANT │
|
|
58
|
+
// │ Please, structure the imports as follows: │
|
|
59
|
+
// │ 1. export const / let [..] │
|
|
60
|
+
// │ 2. const [..] │
|
|
61
|
+
// │ 3. let [..] │
|
|
62
|
+
// │ 4. $: [..] │
|
|
63
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
64
|
+
|
|
65
|
+
export let
|
|
66
|
+
/**
|
|
67
|
+
* @description
|
|
68
|
+
* 📝
|
|
69
|
+
*/
|
|
70
|
+
listStrInsertAfter: [number, string] | undefined = [-1, 'p'],
|
|
71
|
+
/**
|
|
72
|
+
* @augments AdsCreativeMain
|
|
73
|
+
*/
|
|
74
|
+
objectAdverData: AdsCreativeMain,
|
|
75
|
+
/**
|
|
76
|
+
* @description
|
|
77
|
+
* 📝
|
|
78
|
+
*/
|
|
79
|
+
instanceNode: Element
|
|
80
|
+
;
|
|
81
|
+
|
|
82
|
+
let
|
|
83
|
+
/**
|
|
84
|
+
* @description
|
|
85
|
+
* 📝
|
|
86
|
+
*/
|
|
87
|
+
instanceAdvertInterscroller: HTMLDivElement
|
|
88
|
+
;
|
|
89
|
+
|
|
90
|
+
// #endregion ➤ 📌 VARIABLES
|
|
91
|
+
|
|
92
|
+
// #region ➤ 🛠️ METHODS
|
|
93
|
+
|
|
94
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
95
|
+
// │ NOTE: │
|
|
96
|
+
// │ Please add inside 'this' region the 'methods' that are to be │
|
|
97
|
+
// │ and are expected to be used by 'this' .svelte file / component. │
|
|
98
|
+
// │ IMPORTANT │
|
|
99
|
+
// │ Please, structure the imports as follows: │
|
|
100
|
+
// │ 1. function (..) │
|
|
101
|
+
// │ 2. async function (..) │
|
|
102
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @author
|
|
106
|
+
* @ivanzob
|
|
107
|
+
* @summary
|
|
108
|
+
* 🟦 HELPER
|
|
109
|
+
* @description
|
|
110
|
+
* 📝 Inject Advert data
|
|
111
|
+
* @return { void }
|
|
112
|
+
*/
|
|
113
|
+
function injectBetarenaInterscrollerAd
|
|
114
|
+
(
|
|
115
|
+
): void
|
|
116
|
+
{
|
|
117
|
+
if (!instanceNode) return;
|
|
118
|
+
|
|
119
|
+
const
|
|
120
|
+
// ╭─────
|
|
121
|
+
// │ NOTE: |:| Destructuring listStrInsertAfter
|
|
122
|
+
// ╰─────
|
|
123
|
+
[
|
|
124
|
+
count,
|
|
125
|
+
n
|
|
126
|
+
] = listStrInsertAfter ?? [-1, 'p'],
|
|
127
|
+
/**
|
|
128
|
+
* @description
|
|
129
|
+
* 📝
|
|
130
|
+
*/
|
|
131
|
+
insertAfterNodes
|
|
132
|
+
= instanceNode.querySelectorAll(n)
|
|
133
|
+
;
|
|
134
|
+
|
|
135
|
+
if (!insertAfterNodes.length)
|
|
136
|
+
return;
|
|
137
|
+
;
|
|
138
|
+
|
|
139
|
+
let
|
|
140
|
+
/**
|
|
141
|
+
* @description
|
|
142
|
+
*/
|
|
143
|
+
afterNode
|
|
144
|
+
;
|
|
145
|
+
|
|
146
|
+
if (count >= 0)
|
|
147
|
+
afterNode = insertAfterNodes[count];
|
|
148
|
+
else if (count === -1)
|
|
149
|
+
if (insertAfterNodes.length > 2)
|
|
150
|
+
afterNode
|
|
151
|
+
= insertAfterNodes
|
|
152
|
+
[
|
|
153
|
+
Math.floor
|
|
154
|
+
(
|
|
155
|
+
Math.random() * (insertAfterNodes.length - 2)
|
|
156
|
+
) + 1
|
|
157
|
+
]
|
|
158
|
+
;
|
|
159
|
+
else
|
|
160
|
+
afterNode = insertAfterNodes[0];
|
|
161
|
+
;
|
|
162
|
+
|
|
163
|
+
if (!afterNode) return;
|
|
164
|
+
|
|
165
|
+
const
|
|
166
|
+
/**
|
|
167
|
+
* @description
|
|
168
|
+
* 📝
|
|
169
|
+
*/
|
|
170
|
+
pos
|
|
171
|
+
= instanceNode.getBoundingClientRect()
|
|
172
|
+
;
|
|
173
|
+
|
|
174
|
+
instanceAdvertInterscroller.style.display = 'flex';
|
|
175
|
+
instanceAdvertInterscroller.style.left = `${-pos.left}px`;
|
|
176
|
+
|
|
177
|
+
afterNode.insertAdjacentElement
|
|
178
|
+
(
|
|
179
|
+
'afterend',
|
|
180
|
+
instanceAdvertInterscroller
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
setTimeout
|
|
184
|
+
(
|
|
185
|
+
() =>
|
|
186
|
+
{
|
|
187
|
+
window.addEventListener('scroll', handleScroll);
|
|
188
|
+
return;
|
|
189
|
+
},
|
|
190
|
+
1000
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @author
|
|
198
|
+
* @ivanzob
|
|
199
|
+
* @summary
|
|
200
|
+
* 🟦 HELPER
|
|
201
|
+
* @description
|
|
202
|
+
* 📝 Handle Scroll Listener
|
|
203
|
+
* @returns { void }
|
|
204
|
+
*/
|
|
205
|
+
function handleScroll
|
|
206
|
+
(
|
|
207
|
+
): void
|
|
208
|
+
{
|
|
209
|
+
if (!instanceAdvertInterscroller) return;
|
|
210
|
+
|
|
211
|
+
if (instanceAdvertInterscroller.getBoundingClientRect().bottom < 0)
|
|
212
|
+
{
|
|
213
|
+
instanceAdvertInterscroller.style.display = 'none';
|
|
214
|
+
window.removeEventListener
|
|
215
|
+
(
|
|
216
|
+
'scroll',
|
|
217
|
+
handleScroll
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// #endregion ➤ 🛠️ METHODS
|
|
225
|
+
|
|
226
|
+
// #region ➤ 🔄 LIFECYCLE [SVELTE]
|
|
227
|
+
|
|
228
|
+
// ╭────────────────────────────────────────────────────────────────────────╮
|
|
229
|
+
// │ NOTE: │
|
|
230
|
+
// │ Please add inside 'this' region the 'logic' that should run │
|
|
231
|
+
// │ immediately and as part of the 'lifecycle' of svelteJs, │
|
|
232
|
+
// │ as soon as 'this' .svelte file is ran. │
|
|
233
|
+
// ╰────────────────────────────────────────────────────────────────────────╯
|
|
234
|
+
|
|
235
|
+
onMount
|
|
236
|
+
(
|
|
237
|
+
() =>
|
|
238
|
+
{
|
|
239
|
+
injectBetarenaInterscrollerAd();
|
|
240
|
+
|
|
241
|
+
storeAdmin.updateData
|
|
242
|
+
(
|
|
243
|
+
[
|
|
244
|
+
['numberOfAdvertsActive', null]
|
|
245
|
+
]
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
// #endregion ➤ 🔄 LIFECYCLE [SVELTE]
|
|
253
|
+
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<!--
|
|
257
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
258
|
+
│ 💠 Svelte Component HTML │
|
|
259
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
260
|
+
│ ➤ HINT: │ Use 'Ctrl + Space' to autocomplete global class=styles, dynamically │
|
|
261
|
+
│ │ imported from './static/app.css' │
|
|
262
|
+
│ ➤ HINT: │ access custom Betarena Scores VScode Snippets by typing emmet-like │
|
|
263
|
+
│ │ abbrev. │
|
|
264
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
265
|
+
-->
|
|
266
|
+
|
|
267
|
+
<div
|
|
268
|
+
id="inter-outer"
|
|
269
|
+
bind:this={instanceAdvertInterscroller}
|
|
270
|
+
class="interscroller-wrapper"
|
|
271
|
+
style=
|
|
272
|
+
"
|
|
273
|
+
display: none;
|
|
274
|
+
height: 100vh;
|
|
275
|
+
right: 0px;
|
|
276
|
+
width: 100vw;
|
|
277
|
+
"
|
|
278
|
+
>
|
|
279
|
+
<h2 class="info-box">
|
|
280
|
+
Advertisement
|
|
281
|
+
</h2>
|
|
282
|
+
|
|
283
|
+
<div
|
|
284
|
+
id="intscdiv"
|
|
285
|
+
class="interscroller-bg-wrapper"
|
|
286
|
+
style="height: 100%; right: 0px; clip: rect(0px 100vw 100vh 0px); width: 100vw;"
|
|
287
|
+
>
|
|
288
|
+
<div
|
|
289
|
+
id="nxtads"
|
|
290
|
+
class=
|
|
291
|
+
"
|
|
292
|
+
interscroller-bg
|
|
293
|
+
"
|
|
294
|
+
style=
|
|
295
|
+
"
|
|
296
|
+
height: 100%;
|
|
297
|
+
width: 100%;
|
|
298
|
+
padding: 0px;
|
|
299
|
+
overflow: hidden;
|
|
300
|
+
text-align: center;
|
|
301
|
+
"
|
|
302
|
+
>
|
|
303
|
+
<div
|
|
304
|
+
style=
|
|
305
|
+
"
|
|
306
|
+
margin: 0px auto;
|
|
307
|
+
width: 100%;
|
|
308
|
+
height: 100%;
|
|
309
|
+
"
|
|
310
|
+
>
|
|
311
|
+
<a
|
|
312
|
+
target="_blank"
|
|
313
|
+
on:click=
|
|
314
|
+
{
|
|
315
|
+
() =>
|
|
316
|
+
{
|
|
317
|
+
postMod
|
|
318
|
+
(
|
|
319
|
+
`${betarenaEndpoint}/ad/update/click`,
|
|
320
|
+
{
|
|
321
|
+
creativeId: objectAdverData.id
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
href={objectAdverData.data?.cta_link}
|
|
327
|
+
>
|
|
328
|
+
<img
|
|
329
|
+
alt="ad_image"
|
|
330
|
+
class="ad_image"
|
|
331
|
+
src={objectAdverData.data?.media}
|
|
332
|
+
width="100%"
|
|
333
|
+
height="100%"
|
|
334
|
+
/>
|
|
335
|
+
</a>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<h2 class="info-box">
|
|
341
|
+
Scroll to continue
|
|
342
|
+
</h2>
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
<!--
|
|
346
|
+
╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
347
|
+
│ 🌊 Svelte Component CSS/SCSS │
|
|
348
|
+
┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
349
|
+
│ ➤ HINT: │ auto-fill/auto-complete iniside <style> for var() │
|
|
350
|
+
│ │ values by typing/CTRL+SPACE │
|
|
351
|
+
│ ➤ HINT: │ access custom Betarena Scores CSS VScode Snippets by typing 'style...' │
|
|
352
|
+
╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
353
|
+
-->
|
|
354
|
+
|
|
355
|
+
<style lang="scss">
|
|
356
|
+
|
|
357
|
+
/*
|
|
358
|
+
╭──────────────────────────────────────────────────────────────────────────────╮
|
|
359
|
+
│ 📲 MOBILE-FIRST │
|
|
360
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
.info-box
|
|
364
|
+
{
|
|
365
|
+
color: var(--colors-text-text-primary-900, #fbfbfb);
|
|
366
|
+
text-align: center;
|
|
367
|
+
font-family: Roboto;
|
|
368
|
+
font-size: 12px !important;
|
|
369
|
+
font-style: normal;
|
|
370
|
+
font-weight: 700 !important;
|
|
371
|
+
line-height: 38px !important; /* 190% */
|
|
372
|
+
text-transform: uppercase;
|
|
373
|
+
width: 100%;
|
|
374
|
+
margin: 0 !important;
|
|
375
|
+
z-index: 1;
|
|
376
|
+
background: var(--colors-background-bg-primary-solid, #313131);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.interscroller-wrapper
|
|
380
|
+
{
|
|
381
|
+
position: relative !important;
|
|
382
|
+
cursor: pointer !important;
|
|
383
|
+
background: #ffffff !important;
|
|
384
|
+
z-index: 10000000 !important;
|
|
385
|
+
flex-direction: column;
|
|
386
|
+
justify-content: space-between;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.interscroller-bg-wrapper
|
|
390
|
+
{
|
|
391
|
+
position: absolute !important;
|
|
392
|
+
width: 100% !important;
|
|
393
|
+
left: 0 !important;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.interscroller-bg
|
|
397
|
+
{
|
|
398
|
+
position: fixed !important;
|
|
399
|
+
height: 100% !important;
|
|
400
|
+
top: 0;
|
|
401
|
+
backface-visibility: hidden !important;
|
|
402
|
+
-webkit-backface-visibility: hidden !important;
|
|
403
|
+
border: 0 !important;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.ad_image
|
|
407
|
+
{
|
|
408
|
+
width: 100% !important;
|
|
409
|
+
height: 100% !important;
|
|
410
|
+
max-width: 100% !important;
|
|
411
|
+
max-height: 100% !important;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/*
|
|
415
|
+
╭──────────────────────────────────────────────────────────────────────────────╮
|
|
416
|
+
│ ⚡️ RESPONSIVNESS │
|
|
417
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
418
|
+
*/
|
|
419
|
+
|
|
420
|
+
@media (min-width: 768px)
|
|
421
|
+
{
|
|
422
|
+
.info-box
|
|
423
|
+
{
|
|
424
|
+
font-size: 20px !important;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// ╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
2
|
+
// │ 📌 High Order Overview │
|
|
3
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
4
|
+
// │ ➤ Code Format // V.8.0 │
|
|
5
|
+
// │ ➤ Status // 🔒 LOCKED │
|
|
6
|
+
// │ ➤ Author(s) // @migbash │
|
|
7
|
+
// │ ➤ Maintainer(s) // @migbash │
|
|
8
|
+
// │ ➤ Created on // 05-12-2024 │
|
|
9
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
10
|
+
// │ 📝 Description │
|
|
11
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
12
|
+
// │ BETARENA (Module)
|
|
13
|
+
// │ |: Debug Logic
|
|
14
|
+
// ╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
15
|
+
|
|
16
|
+
/* eslint-disable new-cap */
|
|
17
|
+
|
|
18
|
+
// #region 📦 Package]
|
|
19
|
+
|
|
20
|
+
import chalk from 'chalk';
|
|
21
|
+
|
|
22
|
+
// #endregion ➤ 📦 Package Imports
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @author
|
|
26
|
+
* @migbash
|
|
27
|
+
* @summary
|
|
28
|
+
* [🐞]
|
|
29
|
+
* @description
|
|
30
|
+
* 📝 Custom `console.log(..)` wrapper for general logging.
|
|
31
|
+
* @param { string[] } listMsg
|
|
32
|
+
* 💠 **[required]** The message.
|
|
33
|
+
* @return { void }
|
|
34
|
+
*/
|
|
35
|
+
export function logger
|
|
36
|
+
(
|
|
37
|
+
listMsg: string[]
|
|
38
|
+
): void
|
|
39
|
+
{
|
|
40
|
+
// [🐞]
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log(chalk.hex('#FF7F50')('📦 [ad-engine] :: ─────────────────────────'));
|
|
43
|
+
for (const message of listMsg)
|
|
44
|
+
// [🐞]
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.log(chalk.hex('#FF7F50')(`📦 [ad-engine] :: ${message}`));
|
|
47
|
+
;
|
|
48
|
+
return;
|
|
49
|
+
}
|
package/src/lib/utils/device.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
// ╭──────────────────────────────────────────────────────────────────────────────────╮
|
|
2
|
+
// │ 📌 High Order Overview │
|
|
3
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
4
|
+
// │ ➤ Code Format // V.8.0 │
|
|
5
|
+
// │ ➤ Status // 🔒 LOCKED │
|
|
6
|
+
// │ ➤ Author(s) // @migbash │
|
|
7
|
+
// │ ➤ Maintainer(s) // @migbash │
|
|
8
|
+
// │ ➤ Created on // <date-created> │
|
|
9
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
10
|
+
// │ 📝 Description │
|
|
11
|
+
// ┣──────────────────────────────────────────────────────────────────────────────────┫
|
|
12
|
+
// │ BETARENA (Module)
|
|
13
|
+
// │ |: Device Logic
|
|
14
|
+
// ╰──────────────────────────────────────────────────────────────────────────────────╯
|
|
15
|
+
|
|
16
|
+
// #region ➤ 📦 Package Imports
|
|
17
|
+
|
|
18
|
+
import { logger } from './debug.js';
|
|
19
|
+
|
|
20
|
+
// #endregion ➤ 📦 Package Imports
|
|
21
|
+
|
|
1
22
|
/**
|
|
2
23
|
* @author
|
|
3
24
|
* @migbash
|
|
@@ -27,11 +48,30 @@ export function detectDeviceType
|
|
|
27
48
|
isUserAgentTablet = /tablet|ipad/.test(userAgentObject)
|
|
28
49
|
;
|
|
29
50
|
|
|
51
|
+
let
|
|
52
|
+
/**
|
|
53
|
+
* @description
|
|
54
|
+
* 📝 Type of device
|
|
55
|
+
*/
|
|
56
|
+
strDeviceType = 'desktop'
|
|
57
|
+
;
|
|
58
|
+
|
|
30
59
|
if (isUserAgentMobile)
|
|
31
|
-
|
|
60
|
+
strDeviceType = 'mobile';
|
|
32
61
|
else if (isUserAgentTablet)
|
|
33
|
-
|
|
62
|
+
strDeviceType = 'tablet';
|
|
34
63
|
else
|
|
35
|
-
|
|
64
|
+
strDeviceType = 'desktop';
|
|
36
65
|
;
|
|
66
|
+
|
|
67
|
+
// [🐞]
|
|
68
|
+
logger
|
|
69
|
+
(
|
|
70
|
+
[
|
|
71
|
+
`🔹 [var] ➤ strDeviceType ${JSON.stringify(strDeviceType)}`,
|
|
72
|
+
'🚏 checkpoint ➤ detectDeviceType(..) // END'
|
|
73
|
+
]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return strDeviceType;
|
|
37
77
|
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { onMount } from "svelte";
|
|
3
|
-
// import { postMod } from "./utils/fetch";
|
|
4
|
-
export let containerSelector = "#content";
|
|
5
|
-
export let insertAfter = ["random", "p"];
|
|
6
|
-
let adData = {
|
|
7
|
-
id: 0,
|
|
8
|
-
image: "",
|
|
9
|
-
link: "",
|
|
10
|
-
};
|
|
11
|
-
let targetNode;
|
|
12
|
-
let adNode: HTMLDivElement;
|
|
13
|
-
|
|
14
|
-
// Fetch ad content
|
|
15
|
-
async function fetchAd() {
|
|
16
|
-
adData = {
|
|
17
|
-
id: 1,
|
|
18
|
-
image:
|
|
19
|
-
"https://firebasestorage.googleapis.com/v0/b/betarena-ios.appspot.com/o/Betarena_Media%2Fads%2F0x1510ea733e1e81f9bcfcc4eabb5a2226d1a9f9ea18da9aea119ba28b8ed6be81%2FBRBet365ADInterscroller.png?alt=media&token=4b1ef015-2643-4834-9081-f2c763531a21",
|
|
20
|
-
link: "http://google.com",
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function trackClick() {
|
|
25
|
-
// postMod(`${betarenaEndpoint}/ad/update/click`, {
|
|
26
|
-
// creativeId: adData.id,
|
|
27
|
-
// });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
onMount(async () => {
|
|
31
|
-
targetNode = document.querySelector(containerSelector);
|
|
32
|
-
await fetchAd();
|
|
33
|
-
injectAdd(targetNode);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
function injectAdd(node: Element | null) {
|
|
37
|
-
if (!node) return;
|
|
38
|
-
const [count, n] = insertAfter;
|
|
39
|
-
const insertAfterNodes = node.querySelectorAll(n);
|
|
40
|
-
if (!insertAfterNodes.length) return;
|
|
41
|
-
let afterNode;
|
|
42
|
-
if (typeof count === "number") {
|
|
43
|
-
afterNode = insertAfterNodes[count];
|
|
44
|
-
}
|
|
45
|
-
if (count === "random") {
|
|
46
|
-
if (insertAfterNodes.length > 2) {
|
|
47
|
-
let randomCount =
|
|
48
|
-
Math.floor(Math.random() * (insertAfterNodes.length - 2)) + 1;
|
|
49
|
-
afterNode = insertAfterNodes[randomCount];
|
|
50
|
-
} else {
|
|
51
|
-
afterNode = insertAfterNodes[0];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (!afterNode) return;
|
|
55
|
-
const pos = node.getBoundingClientRect();
|
|
56
|
-
adNode.style.display = "flex";
|
|
57
|
-
adNode.style.left = `${-pos.left}px`;
|
|
58
|
-
afterNode.insertAdjacentElement("afterend", adNode);
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
window.addEventListener("scroll", handleScroll);
|
|
61
|
-
}, 1000);
|
|
62
|
-
}
|
|
63
|
-
function handleScroll() {
|
|
64
|
-
if (!adNode) return;
|
|
65
|
-
const rect = adNode.getBoundingClientRect();
|
|
66
|
-
if (rect.bottom < 0) {
|
|
67
|
-
adNode.style.display = "none";
|
|
68
|
-
window.removeEventListener("scroll", handleScroll);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
</script>
|
|
72
|
-
|
|
73
|
-
<slot />
|
|
74
|
-
<div
|
|
75
|
-
id="inter-outer"
|
|
76
|
-
bind:this={adNode}
|
|
77
|
-
class="interscroller-wrapper"
|
|
78
|
-
style="display: none; height: 100vh; right: 0px; width: 100vw;"
|
|
79
|
-
>
|
|
80
|
-
<h2 class="info-box">Advertisement</h2>
|
|
81
|
-
<div
|
|
82
|
-
id="intscdiv"
|
|
83
|
-
class="interscroller-bg-wrapper"
|
|
84
|
-
style="height: 100%; right: 0px; clip: rect(0px 100vw 100vh 0px); width: 100vw;"
|
|
85
|
-
>
|
|
86
|
-
<div
|
|
87
|
-
id="nxtads"
|
|
88
|
-
class="interscroller-bg"
|
|
89
|
-
style="height: 100%; width: 100%; padding: 0px; overflow: hidden; text-align: center;"
|
|
90
|
-
>
|
|
91
|
-
<div
|
|
92
|
-
id="smt-130304454"
|
|
93
|
-
style="margin: 0px auto;width: 100%;height: 100%;/* position: absolute; *//* z-index: 1000000000; */"
|
|
94
|
-
>
|
|
95
|
-
<a target="_blank" on:click={trackClick} href={adData.link}>
|
|
96
|
-
<img
|
|
97
|
-
alt="ad_image"
|
|
98
|
-
src={adData.image}
|
|
99
|
-
width="100%"
|
|
100
|
-
height="100%"
|
|
101
|
-
/>
|
|
102
|
-
</a>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
<h2 class="info-box">Scroll to continue</h2>
|
|
107
|
-
</div>
|
|
108
|
-
|
|
109
|
-
<style>
|
|
110
|
-
.info-box {
|
|
111
|
-
color: var(--colors-text-text-primary-900, #fbfbfb);
|
|
112
|
-
text-align: center;
|
|
113
|
-
font-family: Roboto;
|
|
114
|
-
font-size: 12px;
|
|
115
|
-
font-style: normal;
|
|
116
|
-
font-weight: 700;
|
|
117
|
-
line-height: 38px; /* 190% */
|
|
118
|
-
text-transform: uppercase;
|
|
119
|
-
width: 100%;
|
|
120
|
-
margin: 0;
|
|
121
|
-
z-index: 1;
|
|
122
|
-
background: var(--colors-background-bg-primary-solid, #313131);
|
|
123
|
-
}
|
|
124
|
-
.interscroller-wrapper {
|
|
125
|
-
position: relative !important;
|
|
126
|
-
cursor: pointer !important;
|
|
127
|
-
background: #ffffff !important;
|
|
128
|
-
z-index: 10000000 !important;
|
|
129
|
-
flex-direction: column;
|
|
130
|
-
justify-content: space-between;
|
|
131
|
-
/*border-top: 2px solid #cccccc;
|
|
132
|
-
border-bottom: 2px solid #cccccc;*/
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.interscroller-bg-wrapper {
|
|
136
|
-
position: absolute !important;
|
|
137
|
-
width: 100% !important;
|
|
138
|
-
left: 0 !important;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.interscroller-bg {
|
|
142
|
-
position: fixed !important;
|
|
143
|
-
height: 100% !important;
|
|
144
|
-
top: 0;
|
|
145
|
-
backface-visibility: hidden !important;
|
|
146
|
-
-webkit-backface-visibility: hidden !important;
|
|
147
|
-
border: 0 !important;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
@media (min-width: 768px) {
|
|
151
|
-
.info-box {
|
|
152
|
-
font-size: 20px;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
</style>
|