|
@@ -0,0 +1,125 @@
|
|
1
|
+/*
|
|
2
|
+ * encantar.js
|
|
3
|
+ * GPU-accelerated Augmented Reality for the web
|
|
4
|
+ * Copyright (C) 2022-2024 Alexandre Martins <alemartf(at)gmail.com>
|
|
5
|
+ *
|
|
6
|
+ * This program is free software: you can redistribute it and/or modify
|
|
7
|
+ * it under the terms of the GNU Lesser General Public License as published
|
|
8
|
+ * by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+ * (at your option) any later version.
|
|
10
|
+ *
|
|
11
|
+ * This program is distributed in the hope that it will be useful,
|
|
12
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+ * GNU Lesser General Public License for more details.
|
|
15
|
+ *
|
|
16
|
+ * You should have received a copy of the GNU Lesser General Public License
|
|
17
|
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+ *
|
|
19
|
+ * support-widget.ts
|
|
20
|
+ * Support widget
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+/*
|
|
24
|
+
|
|
25
|
+This widget is intended to ask users to support the project
|
|
26
|
+
|
|
27
|
+You are asked to support the project!
|
|
28
|
+
|
|
29
|
+https://encantar.dev/supporter
|
|
30
|
+
|
|
31
|
+*/
|
|
32
|
+
|
|
33
|
+declare const __AR_FLAGS__: number;
|
|
34
|
+
|
|
35
|
+/**
|
|
36
|
+ * Support widget
|
|
37
|
+ */
|
|
38
|
+export class SupportWidget
|
|
39
|
+{
|
|
40
|
+ /** The element of the widget */
|
|
41
|
+ private readonly _element: HTMLElement;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ /**
|
|
46
|
+ * Constructor
|
|
47
|
+ */
|
|
48
|
+ constructor()
|
|
49
|
+ {
|
|
50
|
+ this._element = this._createElement();
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ /**
|
|
54
|
+ * Initialize
|
|
55
|
+ * @param parent parent node
|
|
56
|
+ */
|
|
57
|
+ init(parent: Node): void
|
|
58
|
+ {
|
|
59
|
+ parent.appendChild(this._element);
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ /**
|
|
63
|
+ * Release
|
|
64
|
+ */
|
|
65
|
+ release(): void
|
|
66
|
+ {
|
|
67
|
+ this._element.remove();
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ /**
|
|
71
|
+ * Create the element of the widget
|
|
72
|
+ */
|
|
73
|
+ private _createElement(): HTMLElement
|
|
74
|
+ {
|
|
75
|
+ const button = document.createElement('button');
|
|
76
|
+
|
|
77
|
+ button.innerText = 'Support encantar.js';
|
|
78
|
+ button.style.font = 'bold small-caps 1.25rem sans-serif';
|
|
79
|
+ button.style.color = 'white';
|
|
80
|
+ button.style.padding = '0.5rem';
|
|
81
|
+ button.style.maxWidth = '40%';
|
|
82
|
+
|
|
83
|
+ button.style.position = 'absolute';
|
|
84
|
+ button.style.bottom = '0';
|
|
85
|
+ button.style.right = '50%';
|
|
86
|
+ button.style.transform = 'translateX(50%)';
|
|
87
|
+
|
|
88
|
+ button.style.opacity = '0.75';
|
|
89
|
+ button.style.zIndex = '1000000';
|
|
90
|
+ button.style.cursor = 'pointer';
|
|
91
|
+ button.style.outline = 'none';
|
|
92
|
+ (button.style as any)['-webkit-tap-highlight-color'] = 'transparent';
|
|
93
|
+ button.draggable = false;
|
|
94
|
+ button.hidden = !!(__AR_FLAGS__ & 1);
|
|
95
|
+
|
|
96
|
+ button.style.backgroundColor = 'rgba(0,0,0,0.25)';
|
|
97
|
+ button.style.borderColor = 'white';
|
|
98
|
+ button.style.borderStyle = 'solid';
|
|
99
|
+ button.style.borderWidth = '2px';
|
|
100
|
+ button.style.borderTopLeftRadius = '8px';
|
|
101
|
+ button.style.borderTopRightRadius = '8px';
|
|
102
|
+ button.style.borderBottomStyle = 'none';
|
|
103
|
+
|
|
104
|
+ const highlight = () => {
|
|
105
|
+ button.style.backgroundColor = '#ffd500';
|
|
106
|
+ button.style.borderColor = '#ffd500';
|
|
107
|
+ button.style.opacity = '1.0';
|
|
108
|
+ };
|
|
109
|
+
|
|
110
|
+ const dehighlight = () => {
|
|
111
|
+ button.style.backgroundColor = 'rgba(0,0,0,0.25)';
|
|
112
|
+ button.style.borderColor = 'white';
|
|
113
|
+ button.style.opacity = '0.75';
|
|
114
|
+ };
|
|
115
|
+
|
|
116
|
+ button.addEventListener('pointerdown', highlight);
|
|
117
|
+ button.addEventListener('pointerup', dehighlight);
|
|
118
|
+ button.addEventListener('pointerleave', dehighlight);
|
|
119
|
+ button.addEventListener('click', () => {
|
|
120
|
+ location.href = 'https://encantar.dev/supporter';
|
|
121
|
+ });
|
|
122
|
+
|
|
123
|
+ return button;
|
|
124
|
+ }
|
|
125
|
+}
|