Skip to content

Instantly share code, notes, and snippets.

@t-ashula
Created February 18, 2014 11:58
Show Gist options
  • Save t-ashula/9069616 to your computer and use it in GitHub Desktop.
Save t-ashula/9069616 to your computer and use it in GitHub Desktop.
function socialbutton_hatena(target, options, defaults, index, max_index)
{
var layout = options.layout || options.button || defaults.button;
var url = options.url || defaults.url;
var title = options.title || defaults.title;
url = htmlspecialchars(url);
title = htmlspecialchars(title);
var attr = merge_attributes({
'href': 'http://b.hatena.ne.jp/entry/' + url,
'class': 'hatena-bookmark-button',
'data-hatena-bookmark-title': title,
'data-hatena-bookmark-layout': layout,
'title': '\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0'
});
var tag = '<a' + attr + '><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30\
c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0" width="20" height="20" style="border: none;" /></a>' + '<script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.j\
s" charset="utf-8" async="async"></script>';
$(target).html(tag);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment