-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (45 loc) · 2.4 KB
/
script.js
File metadata and controls
53 lines (45 loc) · 2.4 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
let overlay = document.querySelector('.overlay');
let share_modal = document.querySelector('.share-modal');
function openModal(){
overlay.classList.add('overlay_on');
share_modal.classList.add('share-modal_on');
}
function closeModal(){
overlay.classList.remove('overlay_on');
share_modal.classList.remove('share-modal_on');
}
// Profile URL to share
const profileUrl = 'https://www.linkedin.com/in/bhupinder-singh-8616b432b/';
const profileTitle = "Check out Bhupinder's profile";
const profileDescription = "I'm a Full Stack Web Developer with a passion for creating dynamic and user-friendly websites. With expertise in HTML, CSS, JavaScript, React, and Node.js, I build responsive and visually appealing web applications. Let's collaborate and turn your ideas into reality!";
// Function to share profile on various platforms
function shareProfile(platform) {
const encodedUrl = encodeURIComponent(profileUrl);
const encodedTitle = encodeURIComponent(profileTitle);
const encodedDescription = encodeURIComponent(profileDescription);
let shareUrl = '';
switch(platform) {
case 'twitter':
shareUrl = `https://twitter.com/intent/tweet?url=${encodedUrl}&text=${encodedTitle}&description=${encodedDescription}`;
break;
case 'linkedin':
// LinkedIn doesn't directly support description in the URL, but we can add it to the summary parameter
shareUrl = `https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl}&summary=${encodedDescription}`;
break;
case 'facebook':
// Facebook allows description via Open Graph meta tags, but for direct sharing we can only use URL
shareUrl = `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}"e=${encodedDescription}`;
break;
case 'reddit':
// Reddit supports title and URL, we can combine title with description
shareUrl = `https://www.reddit.com/submit?url=${encodedUrl}&title=${encodedTitle} - ${encodedDescription}`;
break;
case 'whatsapp':
// WhatsApp allows free-form text
shareUrl = `https://api.whatsapp.com/send?text=${encodedTitle}: ${encodedUrl} ${encodedDescription} `;
break;
default:
shareUrl = profileUrl;
}
window.open(shareUrl, '_blank');
}