Skip to content

Instantly share code, notes, and snippets.

@ano
Last active April 23, 2023 22:20
Show Gist options
  • Save ano/da399600c23eab58bbabc0581546e8f1 to your computer and use it in GitHub Desktop.
Save ano/da399600c23eab58bbabc0581546e8f1 to your computer and use it in GitHub Desktop.
Code to share referral code in Govcrate
$(document).ready(function() {
const referral = `
<p>Copy & Share your referral link below to move up the waitlist:<br /><br />
<a id='referral-button' title="Copy Referral Code" class="referral-button bb_button bb_green" href='#' color="#fff">
Referral Code
</a> |
<a id="linkedin-button" title="Share to LinkedIn" class="linkedin-button bb_button bb_blue" href="#" color="#fff">
<span class="icon-fb"> </span>Share to LinkedIn
</a> |
<a id="facebook-button" title="Share to Facebook" class="facebook-button bb_button bb_blue" href="#" color="#fff">
<span class="icon-fb"> </span>Share to Facebook
</a> |
<a id="twitter-button" title="Share to Twitter" class="twitter-button bb_button bb_blue" href="#" color="#fff">
<span class="icon-fb"> </span>Share to Twitter
</a>
|
<a id="email-button" title="Share via Email" class="email-button bb_button bb_blue" href="#" color="#fff">
<span class="icon-fb"> </span>Share via Email
</a>
</p>
<p>Click here to get back to <a href="https://www.landify.com/">https://www.landify.com/</a></p>
`;
$('div.form_success h2').after(referral);
const referralCode = $('#referral_code').text();
console.log(referralCode);
$('#referral_code').hide();// Outputs the referral code to the console
// Function to share on Facebook
function shareOnFacebook() {
const message = "Hey Guys, I found an awesome new tool for finding properties at scale, join the waitlist to get early access to check it out";
const title = "Landify: A Platform to Find, Analyse and Assess NZ properties - ";
const url = `https://www.facebook.com/dialog/feed?app_id=624508949106580&display=popup&link=${encodeURIComponent(referralCode)}&quote=${encodeURIComponent(title + message)}`;
window.open(url, '_blank');
}
// Function to share on Twitter
function shareOnTwitter() {
const message = "Hey Guys, I found an awesome new tool for finding properties at scale, join the waitlist to get early access to check it out";
const title = "Landify: A Platform to Find, Analyse and Assess NZ properties ";
const url = `https://twitter.com/intent/tweet?text=${encodeURIComponent(title + message)}&url=${encodeURIComponent(referralCode)}`;
window.open(url, '_blank');
}
// Function to share on LinkedIn
function shareOnLinkedIn() {
const message = "Hey Guys, I found an awesome new tool for finding properties at scale, join the waitlist to get early access to check it out";
const title = "Landify: A Platform to Find, Analyse and Assess NZ properties";
const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(referralCode)}&title={encodeURIComponent(referralCode)}&summary=${encodeURIComponent(message)}`;
window.open(url, '_blank');
}
// Function to share via email
function shareViaEmail() {
const subject = "Landify: A Platform to Find, Analyse and Assess NZ properties";
const body = `Hey,\n\nI wanted to share this awesome new tool I found for finding properties at scale. Just click this link to check it out: ${referralCode}\n\nEnjoy!`;
const url = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
window.location.href = url;
}
// Bind click event to buttons
$('#facebook-button').click(shareOnFacebook);
$('#twitter-button').click(shareOnTwitter);
$('#linkedin-button').click(shareOnLinkedIn);
$('#email-button').click(shareViaEmail);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment