@snippyly/plugin 1.0.0
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/firebase.js +51 -0
- package/package.json +12 -0
- package/plugin-ui.js +332 -0
- package/snippyly.js +29 -0
package/firebase.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// import { initializeApp } from "firebase/app";
|
|
2
|
+
import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.8.3/firebase-app.js';
|
|
3
|
+
// import { getAuth, GoogleAuthProvider } from "firebase/auth";
|
|
4
|
+
import { getAuth, GoogleAuthProvider, signInWithPopup, onAuthStateChanged } from 'https://www.gstatic.com/firebasejs/9.8.3/firebase-auth.js';
|
|
5
|
+
|
|
6
|
+
// TODO: Replace the following with your app's Firebase project configuration
|
|
7
|
+
// See: https://firebase.google.com/docs/web/learn-more#config-object
|
|
8
|
+
const firebaseConfig = {
|
|
9
|
+
apiKey: "AIzaSyAzcW2n1JhY_zhkXmuFcwe550AkwmYeJ0w",
|
|
10
|
+
authDomain: "snipply-sdk-staging.firebaseapp.com",
|
|
11
|
+
// databaseURL: "https://snipply-sdk-staging-default-rtdb.firebaseio.com",
|
|
12
|
+
projectId: "snipply-sdk-staging",
|
|
13
|
+
storageBucket: "snipply-sdk-staging.appspot.com",
|
|
14
|
+
messagingSenderId: "877538579326",
|
|
15
|
+
appId: "1:877538579326:web:f793f73f2b7dc770c4992f"
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Initialize Firebase
|
|
19
|
+
const app = initializeApp(firebaseConfig);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// Initialize Firebase Authentication and get a reference to the service
|
|
23
|
+
const auth = getAuth(app);
|
|
24
|
+
const provider = new GoogleAuthProvider();
|
|
25
|
+
|
|
26
|
+
export const loginWithGoogle = () => {
|
|
27
|
+
return signInWithPopup(auth, provider)
|
|
28
|
+
.then((result) => {
|
|
29
|
+
// This gives you a Google Access Token. You can use it to access the Google API.
|
|
30
|
+
const credential = GoogleAuthProvider.credentialFromResult(result);
|
|
31
|
+
const token = credential.accessToken;
|
|
32
|
+
// The signed-in user info.
|
|
33
|
+
const user = result.user;
|
|
34
|
+
console.log('user', user);
|
|
35
|
+
return user;
|
|
36
|
+
// ...
|
|
37
|
+
}).catch((error) => {
|
|
38
|
+
// Handle Errors here.
|
|
39
|
+
const errorCode = error.code;
|
|
40
|
+
const errorMessage = error.message;
|
|
41
|
+
// The email of the user's account used.
|
|
42
|
+
const email = error.customData.email;
|
|
43
|
+
// The AuthCredential type that was used.
|
|
44
|
+
const credential = GoogleAuthProvider.credentialFromError(error);
|
|
45
|
+
// ...
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const getUser = (callback) => {
|
|
50
|
+
onAuthStateChanged(auth, callback);
|
|
51
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@snippyly/plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "snippyly.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"publish:sdk": "npm version patch && npm publish --access public"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC"
|
|
12
|
+
}
|
package/plugin-ui.js
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import * as firebase from './firebase.js';
|
|
2
|
+
|
|
3
|
+
let snippylyUser;
|
|
4
|
+
let commentBtnTool, shareBtn, loginBtn, closeBtn, snippylyBtn;
|
|
5
|
+
|
|
6
|
+
export const initializeSnippyly = async () => {
|
|
7
|
+
if (window.SNIPPYLY_API_KEY) {
|
|
8
|
+
await Snippyly.init(window.SNIPPYLY_API_KEY);
|
|
9
|
+
getUser();
|
|
10
|
+
addPluginUI();
|
|
11
|
+
} else {
|
|
12
|
+
console.warn('Snippyly api key is not added.');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const addPluginUI = () => {
|
|
17
|
+
const snippylyPlugin = document.createElement('snippyly-plugin');
|
|
18
|
+
snippylyPlugin.attachShadow({ mode: 'open' })
|
|
19
|
+
const shadowRoot = snippylyPlugin.shadowRoot;
|
|
20
|
+
|
|
21
|
+
const snippylyPluginContainer = document.createElement('div');
|
|
22
|
+
snippylyPluginContainer.id = 'snippylyPlugin';
|
|
23
|
+
snippylyPluginContainer.classList.add(...['snippyly-plugin-container', 'show']);
|
|
24
|
+
|
|
25
|
+
// Add comment btn
|
|
26
|
+
commentBtnTool = document.createElement('snippyly-comment-tool');
|
|
27
|
+
commentBtnTool.innerHTML = `
|
|
28
|
+
<div class="snippyly-feature-block comment-btn">
|
|
29
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-geo-alt-fill" viewBox="0 0 16 16">
|
|
30
|
+
<path d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10zm0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"></path>
|
|
31
|
+
</svg>
|
|
32
|
+
</div>
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
// Add share btn
|
|
36
|
+
shareBtn = document.createElement('div');
|
|
37
|
+
shareBtn.classList.add(...['snippyly-feature-block', 'share-btn']);
|
|
38
|
+
shareBtn.addEventListener('click', () => {
|
|
39
|
+
navigator.clipboard.writeText(window.location.href);
|
|
40
|
+
});
|
|
41
|
+
shareBtn.innerHTML = `
|
|
42
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
|
43
|
+
class="bi bi-share-fill" viewBox="0 0 16 16">
|
|
44
|
+
<path
|
|
45
|
+
d="M11 2.5a2.5 2.5 0 1 1 .603 1.628l-6.718 3.12a2.499 2.499 0 0 1 0 1.504l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.256l6.718-3.12A2.5 2.5 0 0 1 11 2.5z" />
|
|
46
|
+
</svg>
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
// Add login btn
|
|
50
|
+
loginBtn = document.createElement('div');
|
|
51
|
+
loginBtn.classList.add(...['snippyly-feature-block']);
|
|
52
|
+
loginBtn.addEventListener('click', () => {
|
|
53
|
+
loginWithGoogle();
|
|
54
|
+
});
|
|
55
|
+
loginBtn.innerHTML = `
|
|
56
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
|
|
57
|
+
<g transform="matrix(1, 0, 0, 1, 27.009001, -39.238998)">
|
|
58
|
+
<path fill="#4285F4" d="M -3.264 51.509 C -3.264 50.719 -3.334 49.969 -3.454 49.239 L -14.754 49.239 L -14.754 53.749 L -8.284 53.749 C -8.574 55.229 -9.424 56.479 -10.684 57.329 L -10.684 60.329 L -6.824 60.329 C -4.564 58.239 -3.264 55.159 -3.264 51.509 Z"/>
|
|
59
|
+
<path fill="#34A853" d="M -14.754 63.239 C -11.514 63.239 -8.804 62.159 -6.824 60.329 L -10.684 57.329 C -11.764 58.049 -13.134 58.489 -14.754 58.489 C -17.884 58.489 -20.534 56.379 -21.484 53.529 L -25.464 53.529 L -25.464 56.619 C -23.494 60.539 -19.444 63.239 -14.754 63.239 Z"/>
|
|
60
|
+
<path fill="#FBBC05" d="M -21.484 53.529 C -21.734 52.809 -21.864 52.039 -21.864 51.239 C -21.864 50.439 -21.724 49.669 -21.484 48.949 L -21.484 45.859 L -25.464 45.859 C -26.284 47.479 -26.754 49.299 -26.754 51.239 C -26.754 53.179 -26.284 54.999 -25.464 56.619 L -21.484 53.529 Z"/>
|
|
61
|
+
<path fill="#EA4335" d="M -14.754 43.989 C -12.984 43.989 -11.404 44.599 -10.154 45.789 L -6.734 42.369 C -8.804 40.429 -11.514 39.239 -14.754 39.239 C -19.444 39.239 -23.494 41.939 -25.464 45.859 L -21.484 48.949 C -20.534 46.099 -17.884 43.989 -14.754 43.989 Z"/>
|
|
62
|
+
</g>
|
|
63
|
+
</svg>
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
// Add close btn
|
|
67
|
+
closeBtn = document.createElement('div');
|
|
68
|
+
closeBtn.classList.add(...['snippyly-feature-block', 'close-btn']);
|
|
69
|
+
closeBtn.addEventListener('click', () => {
|
|
70
|
+
const plugin = shadowRoot.getElementById('snippylyPlugin');
|
|
71
|
+
if (plugin) {
|
|
72
|
+
if (plugin.classList.contains('show')) {
|
|
73
|
+
plugin.classList.remove('show');
|
|
74
|
+
plugin.classList.add('hide');
|
|
75
|
+
} else {
|
|
76
|
+
plugin.classList.remove('hide');
|
|
77
|
+
plugin.classList.add('show');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
closeBtn.innerHTML = `
|
|
82
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
|
|
83
|
+
<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>
|
|
84
|
+
</svg>
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
// Add snippyly btn
|
|
88
|
+
snippylyBtn = document.createElement('div');
|
|
89
|
+
snippylyBtn.classList.add(...['snippyly-feature-block', 'snippyly-toggle-btn']);
|
|
90
|
+
snippylyBtn.addEventListener('click', () => {
|
|
91
|
+
const plugin = shadowRoot.getElementById('snippylyPlugin');
|
|
92
|
+
if (plugin) {
|
|
93
|
+
if (plugin.classList.contains('show')) {
|
|
94
|
+
plugin.classList.remove('show');
|
|
95
|
+
plugin.classList.add('hide');
|
|
96
|
+
} else {
|
|
97
|
+
plugin.classList.remove('hide');
|
|
98
|
+
plugin.classList.add('show');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
snippylyBtn.innerHTML = `
|
|
103
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="150" height="150" viewBox="0 0 165 150" fill="none">
|
|
104
|
+
<path d="M64.1815 1.85957C59.9002 0.028852 55.1655 -0.464714 50.5987 0.443652C46.0319 1.35202 41.8464 3.61987 38.5915 6.94957C35.2666 10.2075 33.002 14.3928 32.0939 18.9584C31.1858 23.5239 31.6764 28.2573 33.5015 32.5396C35.2405 36.8543 38.2411 40.5439 42.111 43.1256C45.9809 45.7073 50.5398 47.061 55.1915 47.0096H78.6715V23.5496C78.7227 18.8952 77.3666 14.334 74.781 10.4636C72.1954 6.59321 68.5008 3.59419 64.1815 1.85957V1.85957Z" fill="#FFCB00"/>
|
|
105
|
+
<path d="M149.732 31.0096C144.239 25.5215 137.243 21.784 129.627 20.2691C122.012 18.7541 114.118 19.5296 106.943 22.4977C99.7679 25.4657 93.6332 30.4932 89.3133 36.9453C84.9935 43.3974 82.6823 50.9849 82.6715 58.7496V98.0096H122.012C129.799 98.0918 137.43 95.8208 143.905 91.4939C150.38 87.167 155.398 80.9859 158.301 73.7596C161.337 66.5983 162.143 58.6883 160.614 51.062C159.085 43.4358 155.293 36.4476 149.732 31.0096V31.0096Z" fill="#FF7162"/>
|
|
106
|
+
<path d="M127.852 116.53C126.113 112.21 123.112 108.515 119.241 105.928C115.369 103.341 110.807 101.983 106.152 102.03H82.6715V125.51C82.6225 130.165 83.9806 134.726 86.5679 138.596C89.1552 142.467 92.8511 145.465 97.1715 147.2C100.062 148.415 103.166 149.044 106.302 149.05C110.151 149.01 113.931 148.029 117.313 146.191C120.695 144.353 123.575 141.714 125.702 138.505C127.828 135.296 129.136 131.616 129.51 127.785C129.885 123.954 129.316 120.089 127.852 116.53V116.53Z" fill="#0DCF82"/>
|
|
107
|
+
<path d="M3.10152 75.2796C0.0453598 82.4433 -0.776403 90.363 0.743827 98.0016C2.26406 105.64 6.05543 112.642 11.6215 118.09C15.2126 121.748 19.4944 124.658 24.2185 126.649C28.9425 128.64 34.0149 129.674 39.1415 129.69C44.3888 129.678 49.5819 128.628 54.4215 126.6C61.6486 123.697 67.8306 118.68 72.1576 112.204C76.4847 105.729 78.7551 98.0973 78.6715 90.3096V51.0096H39.3915C31.6018 50.9289 23.9694 53.2029 17.4939 57.5335C11.0185 61.8641 6.002 68.0496 3.10152 75.2796V75.2796Z" fill="#A259FE"/>
|
|
108
|
+
</svg>
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
snippylyPluginContainer.appendChild(commentBtnTool);
|
|
112
|
+
snippylyPluginContainer.appendChild(shareBtn);
|
|
113
|
+
snippylyPluginContainer.appendChild(loginBtn);
|
|
114
|
+
snippylyPluginContainer.appendChild(closeBtn);
|
|
115
|
+
snippylyPluginContainer.appendChild(snippylyBtn);
|
|
116
|
+
|
|
117
|
+
window.document.body.appendChild(snippylyPlugin);
|
|
118
|
+
|
|
119
|
+
const styles = document.createElement('style');
|
|
120
|
+
styles.innerHTML = `
|
|
121
|
+
.snippyly-plugin-container {
|
|
122
|
+
display: flex;
|
|
123
|
+
border: 1px solid lightgrey;
|
|
124
|
+
border-radius: 8px;
|
|
125
|
+
position: fixed;
|
|
126
|
+
bottom: 0;
|
|
127
|
+
right: 0;
|
|
128
|
+
margin: 24px;
|
|
129
|
+
min-height: 48px;
|
|
130
|
+
align-items: center;
|
|
131
|
+
z-index: 999999999;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.snippyly-feature-block {
|
|
135
|
+
padding: 8px;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
#snippylyPlugin .snippyly-feature-block.snippyly-toggle-btn {
|
|
140
|
+
display: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#snippylyPlugin.show .snippyly-feature-block {
|
|
144
|
+
display: block;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#snippylyPlugin.show .snippyly-feature-block.snippyly-toggle-btn {
|
|
148
|
+
display: none;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
#snippylyPlugin.hide .snippyly-feature-block {
|
|
152
|
+
display: none;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#snippylyPlugin.hide .snippyly-feature-block.snippyly-toggle-btn {
|
|
156
|
+
display: block;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.snippyly-feature-block.comment-btn:hover svg {
|
|
160
|
+
fill: #a259fe;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.snippyly-feature-block.share-btn:hover svg {
|
|
164
|
+
fill: rgb(13, 207, 130);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.snippyly-feature-block.close-btn:hover svg {
|
|
168
|
+
fill: rgb(255, 113, 98);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.snippyly-feature-block svg {
|
|
172
|
+
height: 24px;
|
|
173
|
+
width: 24px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.snippyly-feature-block img {
|
|
177
|
+
height: 28px;
|
|
178
|
+
width: 28px;
|
|
179
|
+
border-radius: 100px;
|
|
180
|
+
}
|
|
181
|
+
`;
|
|
182
|
+
|
|
183
|
+
shadowRoot.appendChild(styles);
|
|
184
|
+
shadowRoot.appendChild(snippylyPluginContainer);
|
|
185
|
+
|
|
186
|
+
// add snippyly elements
|
|
187
|
+
const snippylyComments = document.createElement('snippyly-comments');
|
|
188
|
+
document.body.appendChild(snippylyComments);
|
|
189
|
+
|
|
190
|
+
const snippylyCursor = document.createElement('snippyly-cursor');
|
|
191
|
+
document.body.appendChild(snippylyCursor);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const addSnippylyCdn = () => {
|
|
195
|
+
const existingScript = document.getElementById('snippylyScript');
|
|
196
|
+
if (!existingScript) {
|
|
197
|
+
const script = document.createElement('script');
|
|
198
|
+
script.src = 'https://cdn.jsdelivr.net/npm/@snippyly/sdk@1.0.39/snippyly.js';
|
|
199
|
+
script.id = 'snippylyScript';
|
|
200
|
+
script.type = 'module';
|
|
201
|
+
document.body.appendChild(script);
|
|
202
|
+
script.onload = () => {
|
|
203
|
+
if (initializeSnippyly) {
|
|
204
|
+
initializeSnippyly();
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
} else {
|
|
208
|
+
if (initializeSnippyly) {
|
|
209
|
+
initializeSnippyly();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const users = [
|
|
215
|
+
{
|
|
216
|
+
userId: '1',
|
|
217
|
+
name: 'James Smith',
|
|
218
|
+
photoUrl: '',
|
|
219
|
+
email: 'james.smith@gmail.com',
|
|
220
|
+
plan: 'free',
|
|
221
|
+
groupId: '',
|
|
222
|
+
contacts: [
|
|
223
|
+
{
|
|
224
|
+
userId: '2',
|
|
225
|
+
name: 'Maria Garcia',
|
|
226
|
+
email: 'maria.garcia@gmail.com',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
userId: '3',
|
|
230
|
+
name: 'Sarah Wilson',
|
|
231
|
+
email: 'sarah.wilson@gmail.com',
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
userId: 'maria.garcia@gmail.com',
|
|
237
|
+
name: 'Maria Garcia',
|
|
238
|
+
photoUrl: '',
|
|
239
|
+
email: 'maria.garcia@gmail.com',
|
|
240
|
+
plan: 'paid',
|
|
241
|
+
groupId: '',
|
|
242
|
+
isReadOnly: true,
|
|
243
|
+
contacts: [
|
|
244
|
+
{
|
|
245
|
+
userId: '1',
|
|
246
|
+
name: 'James Smith',
|
|
247
|
+
email: 'james.smith@gmail.com',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
userId: '3',
|
|
251
|
+
name: 'Sarah Wilson',
|
|
252
|
+
email: 'sarah.wilson@gmail.com',
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
userId: '3',
|
|
258
|
+
name: 'Sarah Wilson',
|
|
259
|
+
photoUrl: '',
|
|
260
|
+
email: 'sarah.wilson@gmail.com',
|
|
261
|
+
plan: 'trial',
|
|
262
|
+
groupId: '',
|
|
263
|
+
isAdmin: true,
|
|
264
|
+
contacts: [
|
|
265
|
+
{
|
|
266
|
+
userId: '1',
|
|
267
|
+
name: 'James Smith',
|
|
268
|
+
email: 'james.smith@gmail.com',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
userId: '2',
|
|
272
|
+
name: 'Maria Garcia',
|
|
273
|
+
email: 'maria.garcia@gmail.com',
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
];
|
|
278
|
+
|
|
279
|
+
const getUser = () => {
|
|
280
|
+
firebase.getUser((user) => {
|
|
281
|
+
console.log('user', user);
|
|
282
|
+
if (user) {
|
|
283
|
+
snippylyUser = {};
|
|
284
|
+
snippylyUser.userId = user.uid;
|
|
285
|
+
snippylyUser.name = user.displayName;
|
|
286
|
+
snippylyUser.email = user.email;
|
|
287
|
+
snippylyUser.photoUrl = user?.photoURL;
|
|
288
|
+
identifyUser();
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const loginWithGoogle = () => {
|
|
294
|
+
firebase.loginWithGoogle();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const identifyUser = async () => {
|
|
298
|
+
// let user;
|
|
299
|
+
// if (!localStorage.getItem('user')) {
|
|
300
|
+
// const userIndex = Math.floor(Math.random() * 3);
|
|
301
|
+
// user = users[userIndex];
|
|
302
|
+
// localStorage.setItem('user', JSON.stringify(user));
|
|
303
|
+
// } else {
|
|
304
|
+
// user = JSON.parse(localStorage.getItem('user'));
|
|
305
|
+
// }
|
|
306
|
+
|
|
307
|
+
// firebase.loginWithGoogle().then(async (user) => {
|
|
308
|
+
// if (user) {
|
|
309
|
+
// snippylyUser = {};
|
|
310
|
+
// snippylyUser.userId = user.uid;
|
|
311
|
+
// snippylyUser.name = user.displayName;
|
|
312
|
+
// snippylyUser.email = user.email;
|
|
313
|
+
// snippylyUser.photoUrl = user?.photoURL;
|
|
314
|
+
// await Snippyly.identify(snippylyUser);
|
|
315
|
+
// showUser(snippylyUser);
|
|
316
|
+
// }
|
|
317
|
+
// console.log('snippyly user', user);
|
|
318
|
+
// })
|
|
319
|
+
|
|
320
|
+
if(snippylyUser?.userId) {
|
|
321
|
+
await Snippyly.identify(snippylyUser);
|
|
322
|
+
showUser();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const showUser = () => {
|
|
327
|
+
if (snippylyUser) {
|
|
328
|
+
loginBtn.innerHTML = `
|
|
329
|
+
<img src="${snippylyUser?.photoUrl}" title="${snippylyUser?.name}" class="user-profile-img" />
|
|
330
|
+
`
|
|
331
|
+
}
|
|
332
|
+
}
|
package/snippyly.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as ui from './plugin-ui.js';
|
|
2
|
+
|
|
3
|
+
const loadPluginUI = () => {
|
|
4
|
+
const pluginElement = document.querySelector('snippyly-plugin');
|
|
5
|
+
if (!pluginElement) {
|
|
6
|
+
ui.addSnippylyCdn();
|
|
7
|
+
// ui.initializeSnippyly();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
(() => {
|
|
12
|
+
const url = window.location.href;
|
|
13
|
+
if (url.includes('#review-mode')) {
|
|
14
|
+
loadPluginUI();
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
|
|
18
|
+
window.addEventListener('hashchange', () => {
|
|
19
|
+
const url = window.location.href;
|
|
20
|
+
if (url.includes('#review-mode')) {
|
|
21
|
+
loadPluginUI();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// setTimeout(() => {
|
|
26
|
+
// if (!window.location.href.includes('#review-mode')) {
|
|
27
|
+
// window.location.href = window.location.href + '#review-mode'
|
|
28
|
+
// }
|
|
29
|
+
// }, 3000);
|