-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (48 loc) · 1.67 KB
/
index.js
File metadata and controls
58 lines (48 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import '../scss/index.scss'
import { initializeApp } from "firebase/app";
import { getAnalytics, logEvent } from "firebase/analytics";
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
apiKey: "AIzaSyDJMVkse8Mla3rqrVak1qkfXYxlh2AmUd8",
authDomain: "bvarga-fe600.firebaseapp.com",
projectId: "bvarga-fe600",
storageBucket: "bvarga-fe600.appspot.com",
messagingSenderId: "443364341536",
appId: "1:443364341536:web:d7b91d4ecfa7618f594945",
measurementId: "G-PB70YSPDG1"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// Initialize Analytics and get a reference to the service
const analytics = getAnalytics(app);
function trackButtonClick(obj) {
const event = obj.innerText || obj.textContent;
logEvent(analytics, "click", { name: event });
}
function trackSocialButtonClick(obj) {
const event = obj.getAttribute('aria-label');
logEvent(analytics, "click-social", { name: event });
}
function copyLink(url) {
window.navigator.clipboard.writeText(url);
confirm("Page URL copied to the clipboard.")
}
// Attach Event Handlers
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.clazz-button-container a').forEach(a => {
a.addEventListener('click', (e) => {
trackButtonClick(a);
});
});
document.querySelectorAll('.clazz-social-links a').forEach(a => {
a.addEventListener('click', (e) => {
trackSocialButtonClick(a);
});
});
document.querySelectorAll('.clazz-copy-link').forEach(a => {
a.addEventListener('click', (e) => {
e.preventDefault();
copyLink(window.location.href);
});
});
});