Skip to content

Instantly share code, notes, and snippets.

@pentamania
Last active June 21, 2017 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pentamania/21c28081271b4f855f977b70f5a4f543 to your computer and use it in GitHub Desktop.
Save pentamania/21c28081271b4f855f977b70f5a4f543 to your computer and use it in GitHub Desktop.
phina.js twitterシェアボタンの実装例
var params = {
score: 200,
hashtags: ["phina.js", "myCoolGame"]
};
var shareButton = phina.ui.Button({
text: "シェアする",
fontSize: 30,
width: 256,
height: 54,
}).addChildTo(this);
// onpushではダメ
shareButton.onclick = function(){
var text = 'Score: {0}\n{1}'.format(params.score, message);
var url = phina.social.Twitter.createURL({
text: text,
hashtags: params.hashtags,
url: params.url, // 指定がない場合はlocation.hrefが代入される (ローカル(files://...)の場合は上手くいかないっぽい)
});
// 新規ウィンドウで開く場合(OS・端末によっては制限があってダメかも?)
window.open(url, 'share window', 'width=480, height=320');
// 新規タブで開く場合
var childWindow = window.open('about:blank');
childWindow.location.href = url;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment