Skip to content

Instantly share code, notes, and snippets.

@MattTheRed
Created June 4, 2013 20:33
Show Gist options
  • Save MattTheRed/5709346 to your computer and use it in GitHub Desktop.
Save MattTheRed/5709346 to your computer and use it in GitHub Desktop.
<div id="linkbait">
<h2>Add a badge to your website</h2>
<p>Copy and paste HTML code below and paste it into your website editor.</p>
<textarea id="html-code" rows="4" cols="60"> </textarea>
<p><strong>Preview:</strong></p>
<div id="preview">
</div>
<p>
<input type="button" onclick="build_seo_badge();" value="Get New Badge Code">
</p>
</div>
<script>
var link = "http://www.mattthered.com";
var logo = "http://25.media.tumblr.com/avatar_94796517506c_64.png";
var prefix = new Array ();
prefix[0] = "Check out this blog about";
prefix[1] = "Great resource for learning about";
prefix[2] = "Worth a read if you're interested in";
prefix[3] = "Interesting set of articles on";
prefix[4] = "Great information about";
prefix[5] = "This blog is the best resource ever for";
var keyword = new Array ();
keyword[0] = "growth hacking";
keyword[1] = "product management";
keyword[2] = "SEO strategy";
keyword[3] = "django development";
keyword[4] = "html & css";
keyword[5] = "building viral products";
var prefix_num = prefix.length;
var keyword_num = keyword.length;
function build_seo_badge(){
var random_prefix = prefix[Math.floor(prefix_num*Math.random())];
var random_keyword = keyword[Math.floor(keyword_num*Math.random())];
link_text = random_prefix + ' <a href="' + link + '">' + random_keyword + '</a>.';
seo_badge_html = '<div style="padding:7px; border: 1px solid #ccc; display: block; border: 1px solid #EEE; background-color:#ffffff; width: 334px; height: 50px;"><a href="' + link + '"><img src="' + logo + '" style="width: 42px; height: 42px; -webkit-border-radius: 6px;-moz-border-radius: 6px;border-radius: 6px;border:0; float: left; margin-right:8px;"></a>' + link_text + '</div>';
document.getElementById("preview").innerHTML = seo_badge_html;
encoded_html = document.getElementById("preview").innerHTML;
document.getElementById("html-code").innerHTML = encoded_html;
}
build_seo_badge();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment